using System using System Collections Generic using System Linq using

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
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 {
}
}