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); }
public override bool Match(Parser p) { int pos = p.GetPos(); if (mRule.Match(p)) { p.SetPos(pos); return false; } Trace.Assert(p.GetPos() == pos); return true; }
public override bool Match(Parser p) { return p.AtEnd(); }
public override bool Match(Parser p) { if (!mRule.Match(p)) return false; while (mRule.Match(p)) { } return true; }
public override bool Match(Parser p) { while (mRule.Match(p)) { } return true; }
public override bool Match(Parser p) { if (p.AtEnd()) return false; if (p.GetChar() >= mFirst && p.GetChar() <= mLast) { p.GotoNext(); return true; } return false; }
public override bool Match(Parser p) { if (!p.AtEnd()) { p.GotoNext(); return true; } return false; }
public override bool Match(Parser p) { // TODO: make a more descriptive error message. if (!mRule.Match(p)) throw new Exception(msMsg); return true; }
public override bool Match(Parser p) { return mDeleg().Match(p); }
public override bool Match(Parser p) { p.CreateNode(mLabel); bool result = mRule.Match(p); if (result) { p.CompleteNode(); } else { p.AbandonNode(); } return result; }
public abstract bool Match(Parser p);
public void Complete(Parser p) { mnCount = p.GetPos() - mnBegin; }
public PegAstNode Add(Parser p, Object label) { PegAstNode ret = new PegAstNode(p.GetPos(), msText, this, label); mChildren.Add(ret); return ret; }
public override bool Match(Parser p) { if (p.AtEnd()) return false; if (p.GetChar() == mData) { p.GotoNext(); return true; } return false; }
public override bool Match(Parser p) { if (p.AtEnd()) return false; int pos = p.GetPos(); foreach (char c in mData) { if (p.GetChar() != c) { p.SetPos(pos); return false; } p.GotoNext(); } return true; }
public override bool Match(Parser p) { int iter = p.GetPos(); foreach (Rule r in mRules) { if (!r.Match(p)) { p.SetPos(iter); return false; } } return true; }
public override bool Match(Parser p) { if (p.AtEnd()) return false; foreach (char c in mData) { if (c == p.GetChar()) { p.GotoNext(); return true; } } return false; }
public override bool Match(Parser p) { foreach (Rule r in mRules) { if (r.Match(p)) return true; } return false; }
public override bool Match(Parser p) { int pos = p.GetPos(); while (!mTerm.Match(p)) { if (!mElem.Match(p)) { p.SetPos(pos); return false; } } return true; }
public override bool Match(Parser p) { mRule.Match(p); return true; }