public static List <CatAstNode> Parse(string s) { Peg.Parser parser = new Peg.Parser(s); try { bool bResult = parser.Parse(CatGrammar.CatProgram()); if (!bResult) { throw new Exception("failed to parse input"); } } catch (Exception e) { Output.WriteLine("Parsing error occured with message: " + e.Message); Output.WriteLine(parser.ParserPosition); throw e; } AstProgram tmp = new AstProgram(parser.GetAst()); return(tmp.mStatements); }
public static List<CatAstNode> Parse(string s) { Peg.Parser parser = new Peg.Parser(s); try { bool bResult = parser.Parse(CatGrammar.CatProgram()); if (!bResult) throw new Exception("failed to parse input"); } catch (Exception e) { Output.WriteLine("Parsing error occured with message: " + e.Message); Output.WriteLine(parser.ParserPosition); throw e; } AstProgram tmp = new AstProgram(parser.GetAst()); return tmp.mStatements; }