-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
35 lines (28 loc) · 939 Bytes
/
Program.cs
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
using System;
using System.IO;
using Antlr4.Runtime;
using Antlr4.Runtime.Tree;
namespace MiniC {
class Program {
static void Main(string[] args) {
var aStream = new StreamReader(args[0]);
var antlrInputStream = new AntlrInputStream(aStream);
var lexer = new MiniCLexer(antlrInputStream);
var tokens = new CommonTokenStream(lexer);
var parser = new MiniCParser(tokens);
IParseTree tree = parser.compileUnit();
//Console.WriteLine(tree.ToStringTree());
var stPrinter = new STPrinter();
stPrinter.Visit(tree);
var ast = new ASTGenerator();
ast.Visit(tree);
var astPrinter = new ASTPrinter();
astPrinter.Visit(ast.Root);
var code = new CodeGenerator();
code.Visit(ast.Root);
var codePrinter = new CodePrinter();
codePrinter.Visit(code.TranslatedFile);
code.EmitToStdout();
}
}
}