//lax/parse/assemble inputfile, and write flat binary out to outputFile public byte[] Assemble(ICharStream input) { try { //Antlr boilerplate AtlasLexer lexer = new AtlasLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); AtlasParser parser = new AtlasParser(tokens); parser.RemoveErrorListeners(); parser.AddErrorListener(this); AtlasParser.RootContext root = parser.root(); ParseTreeWalker walker = new ParseTreeWalker(); //reset assembler state m_currentPass = AssemblerSemanticAnalysisPass.RecordLabels; m_fileSize = 0; m_labels.Clear(); m_wordBuffer.Clear(); //perform all passes while (m_currentPass != AssemblerSemanticAnalysisPass.Done) { //parse the input file //this will trigger listeners for the current pass //TODO fix it so we dont lex/parse on every single pass walker.Walk(this, root); } return(m_wordBuffer.SelectMany(x => AtlasCPU.BytesFromInt(x)).ToArray()); } catch (AssemblerException e) { m_outStream.WriteLine("Assembly Failed: " + e.Message); return(null); } }
public void EvaluateAtlas(string path) { offsetDictionary = AtlasParser.GetOffsets(path); }