private void match(TokenType token) { if (lookahead.Type == token) { lookahead = enumerator.MoveNext() ? enumerator.Current : new Token(TokenType.Empty); } else throw new InvalidOperationException(String.Format("Failed to match on {0}", token)); }
public string Parse(IEnumerable<Token> tokens) { enumerator = tokens.GetEnumerator(); result = new StringBuilder(); if (enumerator.MoveNext()) { lookahead = enumerator.Current; expr(); } return result.ToString(); }
private void output(Token token) { result.Append(token.Value.ToString()); }
private static bool isDigit(Token lookahead) { return lookahead.Type == TokenType.Digit; }