/// <summary> /// Accept the specified token and value. /// </summary> /// <param name="token">Token.</param> /// <param name="strval">Strval.</param> public bool Accept(LoreToken token, string strval) { var match = Match(token) && Match(strval); Skip(match ? 1 : 0); return(match); }
/// <summary> /// Accept the specified token. /// </summary> /// <param name="token">Token.</param> public bool Accept(LoreToken token) { var match = Match(token); Skip(match ? 1 : 0); return(match); }
/// <summary> /// Expect the specified token and string. /// </summary> /// <param name="token">Token.</param> /// <param name="strval">Strval.</param> public Lexeme <LoreToken> Expect(LoreToken token, string strval) { var current = Current; if (Accept(token, strval)) { return(current); } if (!See()) { throw LoreException.Create(Location).Describe("Unexpected end of file."); } var next = Read(); throw LoreException.Create(Location).Describe($"Unexpected token: '{next.Value}' ({next.Token})"); }
public bool Match(LoreToken token, string strval) => Current != null && Match(token) && Match(strval);
public bool Match(LoreToken token) => Current != null && Current.Token == token;