private string consumeText(EngageToken tokenType) { string ret = _lookAhead.text; match(tokenType); return(ret); }
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}"); } }
// Check the token *after* the current lookAhead private bool LookAhead2(EngageToken t) => _pos + 1 < _tokens.Count && _tokens[_pos + 1].id == (int)t;
private bool LookAhead(EngageToken t1, EngageToken t2) => _pos + 1 < _tokens.Count && _lookAhead.id == (int)t1 && _tokens[_pos + 1].id == (int)t2;
private bool LookAhead(EngageToken tokenType) => !eof() && _lookAhead.id == (int)tokenType;