private static void Main(string[] args) { try { string filename = ProcessOptions(args); if (filename == null) { return; } Parser parser = new Parser(); Grammar grammar = parser.Parse(filename); LALRGenerator generator = new LALRGenerator(grammar); List <State> states = generator.BuildStates(); generator.ComputeLookAhead(); generator.BuildParseTable(); if (!grammar.CheckGrammar()) { throw new Exception("Non-terminating grammar"); } if (REPORT) { generator.Report(); } else { CodeGenerator code = new CodeGenerator(); code.Generate(states, grammar); } } catch (Scanner.ParseException e) { Console.Error.WriteLine("Parse error (line {0}, column {1}): {2}", e.line, e.column, e.Message); } catch (System.Exception e) { Console.Error.WriteLine("Unexpected Error {0}", e.Message); } }
private static void Main(string[] args) { try { string filename; string text; string log; if (GPCG.ProcessOptions(args, out filename, out text, out log)) { using (TextWriter textWriter = (text != null) ? File.CreateText(text) : Console.Out) { Parser parser = new Parser(); Grammar grammar = parser.Parse(filename); LALRGenerator lALRGenerator = new LALRGenerator(grammar); List<State> states = lALRGenerator.BuildStates(); lALRGenerator.ComputeLookAhead(); lALRGenerator.BuildParseTable(); if (GPCG.REPORT) { lALRGenerator.Report(log); } CodeGenerator codeGenerator = new CodeGenerator(textWriter); codeGenerator.Generate(states, grammar); } } } catch (Scanner.ParseException ex) { Console.Error.WriteLine("Parse error (line {0}, column {1}): {2}", ex.line, ex.column, ex.Message); } catch (Exception ex2) { Console.Error.WriteLine("Unexpected Error {0}", ex2.Message); Console.Error.WriteLine("Please report to [email protected]"); } }
private static void Main(string[] args) { try { string filename; string text; string log; if (GPCG.ProcessOptions(args, out filename, out text, out log)) { using (TextWriter textWriter = (text != null) ? File.CreateText(text) : Console.Out) { Parser parser = new Parser(); Grammar grammar = parser.Parse(filename); LALRGenerator lALRGenerator = new LALRGenerator(grammar); List <State> states = lALRGenerator.BuildStates(); lALRGenerator.ComputeLookAhead(); lALRGenerator.BuildParseTable(); if (GPCG.REPORT) { lALRGenerator.Report(log); } CodeGenerator codeGenerator = new CodeGenerator(textWriter); codeGenerator.Generate(states, grammar); } } } catch (Scanner.ParseException ex) { Console.Error.WriteLine("Parse error (line {0}, column {1}): {2}", ex.line, ex.column, ex.Message); } catch (Exception ex2) { Console.Error.WriteLine("Unexpected Error {0}", ex2.Message); Console.Error.WriteLine("Please report to [email protected]"); } }
private static void Main(string[] args) { try { string filename = ProcessOptions(args); if (filename == null) return; Parser parser = new Parser(); Grammar grammar = parser.Parse(filename); LALRGenerator generator = new LALRGenerator(grammar); List<State> states = generator.BuildStates(); generator.ComputeLookAhead(); generator.BuildParseTable(); if (!grammar.CheckGrammar()) throw new Exception("Non-terminating grammar"); if (REPORT) generator.Report(); else { CodeGenerator code = new CodeGenerator(); code.Generate(states, grammar); } } catch (Scanner.ParseException e) { Console.Error.WriteLine("Parse error (line {0}, column {1}): {2}", e.line, e.column, e.Message); } catch (System.Exception e) { Console.Error.WriteLine("Unexpected Error {0}", e.Message); } }
private static void Main(string[] args) { try { string filename = ProcessOptions(args); if (filename == null) return; Assembly assm = Assembly.GetExecutingAssembly(); object info = Attribute.GetCustomAttribute(assm, typeof(AssemblyInformationalVersionAttribute)); versionInfo = ((AssemblyInformationalVersionAttribute)info).InformationalVersion; Parser parser = new Parser(); Grammar grammar = parser.Parse(filename); LALRGenerator generator = new LALRGenerator(grammar); List<State> states = generator.BuildStates(); generator.ComputeLookAhead(); generator.BuildParseTable(); if (!grammar.CheckGrammar()) throw new Exception("Non-terminating grammar"); if (REPORT) generator.Report(); else { CodeGenerator code = new CodeGenerator(); code.Generate(states, grammar); } } catch (Scanner.ParseException e) { Console.Error.WriteLine("Parse error (line {0}, column {1}): {2}", e.line, e.column, e.Message); } catch (System.Exception e) { Console.Error.WriteLine("Unexpected Error {0}", e.Message); } }
private static int Main(string[] args) { try { string outfile = null; string filename = ProcessOptions(args, ref outfile); if (filename == null) { return(1); } if (outfile != null) { if (File.Exists(outfile)) { if (File.GetLastWriteTime(typeof(GPCG).Assembly.Location) > File.GetLastWriteTime(outfile)) { } else if (File.Exists(outfile) && new FileInfo(outfile).Length > 0) { if (File.GetLastWriteTime(filename) < File.GetLastWriteTime(outfile)) { return(0); } } } Console.SetOut(output = File.CreateText(outfile)); } Console.Error.WriteLine("gppg {0}", System.IO.Path.GetFileName(filename)); Console.WriteLine("#pragma warning disable 3001,3002,3003,3004,3005,3006,3007,3008,3009"); Parser parser = new Parser(); Grammar grammar = parser.Parse(filename); LALRGenerator generator = new LALRGenerator(grammar); List <State> states = generator.BuildStates(); generator.ComputeLookAhead(); generator.BuildParseTable(); if (REPORT) { generator.Report(filename); } CodeGenerator code = new CodeGenerator(); code.Generate(states, grammar); return(0); } catch (Scanner.ParseException e) { Console.Error.WriteLine("Parse error (line {0}, column {1}): {2}", e.line, e.column, e.Message); } finally { Console.Out.Flush(); if (output != null) { output.Close(); } } return(1); /* * catch (System.Exception e) * { * Console.Error.WriteLine("Unexpected Error {0}", e.Message); * Console.Error.WriteLine(e.StackTrace); * Console.Error.WriteLine("Please report to [email protected]"); * } */ }