private static void Main(string[] args) { if (!args.Any()) { Console.WriteLine("There is no file to compile."); return; } var fileName = args.First(); if (!File.Exists(fileName)) { Console.WriteLine("There is no file to compile."); return; } string program; using (var fr = new StreamReader(File.Open(fileName, FileMode.Open))) { program = fr.ReadToEnd(); } var reader = new Reader("input.txt"); var grammar = reader.ReadGrammar(); var lexical = new LexicalAnalyzer(grammar, "LA.xml"); var tokens = lexical.Convert(program); var syntax = new SyntaxAnalyzer(tokens); var tree = syntax.Analyze(); if (ReportError(syntax.Errors)) return; var semantics = new SemanticAnalyzer(tree); semantics.DecorateAndValidateTree(); if (ReportError(semantics.Errors)) return; var gen = new CodeGenerator(tree); gen.Generate(Path.GetFileNameWithoutExtension(fileName) + ".exe"); }
private void RunAction() { var tree = Compile(); if (tree == null) return; var gen = new CodeGenerator(tree); gen.Generate(Path.GetFileNameWithoutExtension(_lastUsedFileName) + ".exe"); using (var proc = Process.Start(Path.GetFileNameWithoutExtension(_lastUsedFileName) + ".exe")) { proc.WaitForExit(); } }
private void CompileAction() { var tree = Compile(); if (tree == null) return; var gen = new CodeGenerator(tree); gen.Generate(Path.GetFileNameWithoutExtension(_lastUsedFileName) + ".exe"); }
public void Test1() { var g = new CodeGenerator(null); g.Generate(""); }