using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using NS_XCmplr;
using NM_DirectedGraphLibrary;
using NM_GraphCommon;
using NM_DirectedGraphLibrary.NM_DirectedGraphLibraryInternals;
using NS_Compiler;
namespace NS_XCmplr
{
class COptions
{
static public string SrcFile
{
get
{
return "C:\\tem\\CTests\\ex01.c";
}
}
static public bool DumpLexer
{
get
{
return true;
}
}
static public bool DumpSyntaxParser
{
get
{
return true;
}
}
static public bool DumpIrAfterSyntaxParser
{
get
{
return true;
}
}
static public bool DelayAfterCompile
{
get
{
return true;
}
}
static public int AlignStaticData
{
get
{
return 1;
}
}
static public int AlignStackData
{
get
{
return 1;
}
}
static public int AlignStructField
{
get
{
return 1;
}
}
static public int AlignArrayItem
{
get
{
return 1;
}
}
static public int AlignCode
{
get
{
return 1;
}
}
}
class XCmplrMain
{
class COptionParser
{
static public COptions Parse(string[] args)
{
return new COptions();
}
static public string ErrorMsg
{
get
{
return "";
}
}
}
static void Main(string[] args)
{
Console.WriteLine("X compiler version 0.1\nCopyright (C) BMSTU 2014\n");
COptions opts = COptionParser.Parse(args);
Compiler cmplr = new Compiler(opts);
cmplr.CompileIt();
try {
using (StreamReader sr = new StreamReader("C:\\tem\\CTests\\TestFile.txt")) {
int m, n, i;
var g = new CBiDirAdjMtrxGraph<TestEdge, TestVertex>(20);
n = Convert.ToInt32(sr.ReadLine());
m = Convert.ToInt32(sr.ReadLine());
Dictionary<String, CVDescr<TestVertex>> vertexes = new Dictionary<string, CVDescr<TestVertex>>();
CEDescr<TestVertex, TestEdge>[] edges = new CEDescr<TestVertex, TestEdge>[m];
for (i = 0; i < n; i++) {
var name = sr.ReadLine();
vertexes.Add(name, g.AddVertex(new TestVertex(name)));
}
for (i = 0; i < m; i++) {
string[] edgeInfo = sr.ReadLine().Split(default(string[]), StringSplitOptions.RemoveEmptyEntries);
CVDescr<TestVertex> begin, end;
vertexes.TryGetValue(edgeInfo[0], out begin);
vertexes.TryGetValue(edgeInfo[1], out end);
edges[i] = g.AddEdge(begin, end, new TestEdge());
}
CGraphVisualization.EmitGraphVizFormat(g);
foreach (CVDescr<TestVertex> v in g.BFS) {
Console.WriteLine("BFS VERTEX -- " + v.props.ToString());
}
if (COptions.DelayAfterCompile) {
Console.WriteLine("Delay after compilation. Press any key");
Console.ReadLine();
}
}
} catch (FileNotFoundException e) {
Console.WriteLine(Environment.CurrentDirectory);
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
Console.ReadLine();
}
if (COptions.DelayAfterCompile)
{
Console.WriteLine("Delay after compilation. Press any key");
Console.ReadLine();
}
}
}
public class CBiDirAdjMtrxGraph<
EProperties,
VProperties>
: CDirGraph<EProperties, VProperties> {
public CBiDirAdjMtrxGraph(int num)
: base(new CBiDirectedAdjMatrixStorage<EProperties, VProperties>(num)) { }
}
public class TestVertex {
string s;
public TestVertex(string s) {
this.s = s;
}
public override string ToString() {
return s;
}
}
public class TestEdge {
}
}