// ReSharper disable once UnusedMember.Local private bool ExpectNextToken(IPeekableEnumerator <Token> tokens, Token.Tokens ident) { if (tokens.PeekNext?.Type != ident) { AddError(string.Format("expected {0}, got {1} instead", ident, tokens.PeekNext?.ToString() ?? "<EOF>")); return(false); } return(true); }
private Token ExpectTokenAndAdvance(IPeekableEnumerator <Token> tokens, Token.Tokens ident) { var currentToken = tokens.Current; if (currentToken?.Type != ident) { AddError(string.Format("expected {0}, got {1} instead", ident, currentToken?.ToString() ?? "<EOF>")); return(null); } tokens.MoveNext(); return(currentToken); }
// ReSharper disable once UnusedMember.Local private void RegisterInfixParserFn(Token.Tokens tokens, InfixParserFn fn) { _infixParserFns[tokens] = fn; }
private void RegisterPrefixParserFn(Token.Tokens tokens, PrefixParserFn fn) { _prefixParserFns[tokens] = fn; }