-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
34 lines (28 loc) · 1020 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
using System;
using System.IO;
using Antlr4.Runtime;
namespace Vectrasm
{
class MainClass
{
public static void Main(string[] args)
{
string code = File.ReadAllText("/Volumes/exFat/Vectrex/hello2.asm");
AntlrInputStream stream = new AntlrInputStream(code);
AsmLexer lexer = new AsmLexer(stream);
//lexer.AddErrorListener(new LexerErrorListener());
CommonTokenStream tokens = new CommonTokenStream(lexer);
AsmParser parser = new AsmParser(tokens);
//parser.AddErrorListener(new ParserErrorListener());
AsmParser.ProgContext tree;
tree = parser.prog();
AsmVisitor visitor = new AsmVisitor();
visitor.Visit(tree);
foreach (byte b in visitor.m_objectCode)
{
Console.Write("{0:X2} ", b);
}
File.WriteAllBytes("/Volumes/exFat/Vectrex/hello2.bin", visitor.m_objectCode.ToArray());
}
}
}