Пример #1
0
        private string consumeText(EngageToken tokenType)
        {
            string ret = _lookAhead.text;

            match(tokenType);
            return(ret);
        }
Пример #2
0
 private void match(EngageToken tokenType)
 {
     if (!eof() && _lookAhead.id == (int)tokenType)
     {
         ++_pos;
         if (!eof())
         {
             _lookAhead = _tokens[_pos];
         }
     }
     else
     {
         string tokType = tokenName(_lookAhead.id);
         throw new Exception($"Expected: {tokenName((int) tokenType)}, got {tokType} @line {_lookAhead.line}");
     }
 }
Пример #3
0
 // Check the token *after* the current lookAhead
 private bool LookAhead2(EngageToken t)
 => _pos + 1 < _tokens.Count && _tokens[_pos + 1].id == (int)t;
Пример #4
0
 private bool LookAhead(EngageToken t1, EngageToken t2)
 => _pos + 1 < _tokens.Count && _lookAhead.id == (int)t1 && _tokens[_pos + 1].id == (int)t2;
Пример #5
0
 private bool LookAhead(EngageToken tokenType)
 => !eof() && _lookAhead.id == (int)tokenType;