Token Consume(TokenType tokenType) { var old = currentToken; currentToken = lexer.Next(); if (old.TokenType != tokenType) { // Special case for missing bibtex key - we'll just create one. (Also deals with no tags) if (tokenType == TokenType.Text && old.TokenType == TokenType.Comma && (currentToken.TokenType == TokenType.Text || currentToken.TokenType == TokenType.ClosingBrace)) { old = new Token(TokenType.Text, "_Unknown_" + (++unknownCounter), old.Line, old.Column, old.Position); return old; } throw new TemplateParseException("Unexpected token: " + old.TokenType + ". Was expecting: " + tokenType, currentToken.Line, currentToken.Column); } return old; }
Token Consume() { var oldToken = currentToken; currentToken = lexer.Next(); return oldToken; }