public static void Fatal(string message, IParser parser, TokenStream toks, IParseStack stk) { throw new ParseException($"{message}\n" + $"parser: {parser.ToString()}\n" + $"rest: {toks.ToString()}\n" + $"stack trace: {stk.ToSExp().ToPrettyString()}"); }
public ParseResult Parse(TokenStream toks, IParseStack stk) { if (stk.Has(this, toks)) { this.Fatal("left-recursion detected", this, toks, stk); } var result = _parse(toks, stk.Extend(this, toks)); result.ParserName = _name; return(result); }
public ParseResult Parse(TokenStream toks, IParseStack stk) { var offset = toks.Car().Start.Offset; if (!_memo.TryGetValue(offset, out ParseResult r)) { r = _parser.Parse(toks, stk); _memo[offset] = r; } return(r); }
private ParseStack(IParser parser, TokenStream toks, IParseStack prev) { _parser = parser; _toks = toks; _prev = prev; }