示例#1
0
文件: Parser.cs 项目: wimh/monkey-cs
        // 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);
        }
示例#2
0
文件: Parser.cs 项目: wimh/monkey-cs
        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);
        }
示例#3
0
 // ReSharper disable once UnusedMember.Local
 private void RegisterInfixParserFn(Token.Tokens tokens, InfixParserFn fn)
 {
     _infixParserFns[tokens] = fn;
 }
示例#4
0
 private void RegisterPrefixParserFn(Token.Tokens tokens, PrefixParserFn fn)
 {
     _prefixParserFns[tokens] = fn;
 }