public virtual void Compile(StreamReader input, BytecodeStream output) { Scanner scanner = new Scanner(input); var builder = new ProgramNodeBuilder(); Parser parser = new Parser(); parser.Parse(scanner, builder); RISCCodeGenerator generator = new RISCCodeGenerator(output); ProgramNode parseTree = builder.GetRootNode(); parseTree.Traverse(generator); }
public void Compile(InputStream input, BytecodeStream output) { // creating scanner from InputStream Scanner scanner = new Scanner(input); // creating builder for abstract syntax tree ProgramNodeBuilder builder = new ProgramNodeBuilder(); // creating Parser Parser parser = new Parser(); // parsing using scanner and builder, hence creating AST parser.Parse(scanner, builder); // creating target code generator RISCCodeGenerator generator = new RISCCodeGenerator(output); // retrieving abstract syntax tree from builder ProgramNode parseTree = builder.GetRootNode(); // generating target code from AST and generator parseTree.Traverse(generator); Console.WriteLine("compilation complete"); }
public void Traverse(RISCCodeGenerator generator) { }
public void Traverse(RISCCodeGenerator generator) { generator.Visit(this); }