Exemple #1
0
        // 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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 // ReSharper disable once UnusedMember.Local
 private void RegisterInfixParserFn(Token.Tokens tokens, InfixParserFn fn)
 {
     _infixParserFns[tokens] = fn;
 }
Exemple #4
0
 private void RegisterPrefixParserFn(Token.Tokens tokens, PrefixParserFn fn)
 {
     _prefixParserFns[tokens] = fn;
 }