/** * Consumes an identifier token that may be a reserved word, i.e. * an IdentifierName, not necessarily an Identifier. * @see "http://www.ecma-international.org/ecma-262/5.1/#sec-7.6" */ private IdentifierToken eatIdOrKeywordAsId() { Token token = nextToken(); if (token.type == TokenType.IDENTIFIER) { return (IdentifierToken) token; } else if (Keywords.isKeyword(token.type)) { return new IdentifierToken( token.location, Keywords.get(token.type).toString()); } else { reportExpectedError(token, TokenType.IDENTIFIER); } return null; }
private void maybeWarnReservedKeyword(IdentifierToken token) { String identifier = token.toString(); boolean isIdentifier = false; if (TokenStream.isKeyword(identifier)) { features = features.require(Feature.ES3_KEYWORDS_AS_IDENTIFIERS); isIdentifier = config.languageMode == LanguageMode.ECMASCRIPT3; } if (reservedKeywords != null && reservedKeywords.contains(identifier)) { isIdentifier = true; } if (isIdentifier) { errorReporter.error( "identifier is a reserved word", sourceName, lineno(token.location.start), charno(token.location.start)); } }
return builder.build(getTreeLocation(name.getStart())); } else {
/** * Consumes an identifier token that may be a reserved word, i.e. * an IdentifierName, not necessarily an Identifier. * @see "http://www.ecma-international.org/ecma-262/5.1/#sec-7.6" */ private IdentifierToken eatIdOrKeywordAsId() { Token token = nextToken(); if (token.type == TokenType.IDENTIFIER) { return (IdentifierToken) token; } else if (Keywords.isKeyword(token.type)) { return new IdentifierToken( token.location, Keywords.get(token.type).toString()); } else { reportExpectedError(token, TokenType.IDENTIFIER); } return null; }
case IDENTIFIER_EXPRESSION: requiredParams.put( param.asIdentifierExpression().identifierToken.toString(), type); break; optionalParams.put( param.asOptionalParameter().param.asIdentifierExpression() .identifierToken.toString(), type); break; case REST_PARAMETER: restName = param.asRestParameter().identifier.toString(); restType = type; break;
return new IdentifierToken(getTokenRange(beginToken), value.intern());
Node processNameWithInlineJSDoc(IdentifierToken identifierToken) { JSDocInfo info = handleInlineJsDoc(identifierToken); maybeWarnReservedKeyword(identifierToken); Node node = newStringNode(Token.NAME, identifierToken.toString()); if (info != null) { node.setJSDocInfo(info); } setSourceInfo(node, identifierToken); return node; }
return new IdentifierToken(getTokenRange(beginToken), value);