public static void CompileDec(ParsedCommandOptions opts) { var Dec = new DecFile(@"C:\Users\yveem\source\repos\Redmond\TestDec.dec"); CompileSettings.InitSettings(Dec.SettingsLines); var gram = new DecGrammar(Dec); Console.WriteLine("Generating parsing table..."); ParseFile parseFile = new ParseFile(@"C:\Users\yveem\source\repos\Redmond\TestParse.parse"); parseFile.SetLexLines(Dec.LexLines); parseFile.SetParseTableLines(gram.SerializeParsingTable()); parseFile.SetTokenIdLines(ProductionEntry.Register.Serialize()); parseFile.Save(); Console.WriteLine("Done!"); Console.Beep(); var parser = gram.GetParser(); var input = new MultiFileInputStream(new List <string>(new string[] { @"C:\Users\yveem\source\repos\Redmond\TestInput.txt" })); //var input = GetAllCSFiles(@"C:\Users\yveem\source\repos\CompileTestProject"); TokenStream Input = new TokenStream(input, Dec.LexLines, new string(Enumerable.Range('\x1', 127).Select(i => (char)i).ToArray())); parser.Parse(Input); var tree = SyntaxTreeNode.CurrentNode; Console.WriteLine(tree.ToTreeString()); Console.WriteLine("============\n"); new IntermediateGenerator(new ConsoleStream()).Start(tree); Console.WriteLine("============\n"); }
public static void Compile(ParsedCommandOptions opts) { Console.WriteLine("Reading parse file.."); var output = GetSelectedOutput(opts); var input = new MultiFileInputStream(new List <string>(new string[] { @"C:\Users\yveem\source\repos\Redmond\TestInput.txt" })); //var input = GetAllCSFiles(@"C:\Users\yveem\source\repos\CompileTestProject"); //var input = GetAllCSFiles(@"C:\Users\yveem\source\repos\Redmond"); ParseFile parseFile = new ParseFile(@"C:\Users\yveem\source\repos\Redmond\TestParse.parse").Read(); string inputFile = opts.FindOption("input", "i")?.Argument ?? @"C:\Users\yveem\source\repos\Redmond\TestInput.txt"; var context = new CompilationContext(parseFile, input, output); context.Compile(); }