private bool ConsumeToken(Token.Symbol symbol, bool force) { if (tokens.Count == 0) { if (force) { throw new ParseError(String.Format( "end of input while expecting token \"{0}\"", symbol)); } else { return(false); } } if (tokens.Peek().Name == symbol) { tokens.Dequeue(); return(true); } else if (force) { throw new ParseError(String.Format( "expected \"{0}\" found \"{1}\"", symbol, tokens.Peek().ToString())); } else { return(false); } }
private bool CanConsumeToken(Token.Symbol symbol) { if (tokens.Count == 0) { return(false); } if (tokens.Peek().Name == symbol) { return(true); } return(false); }
private bool ConsumeToken(Token.Symbol symbol) { return(ConsumeToken(symbol, false)); }