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 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); } }