use of com.google.javascript.jscomp.parsing.parser.trees.ParseTree in project closure-compiler by google.
the class Parser method parseComprehension.
private ParseTree parseComprehension(ComprehensionTree.ComprehensionType type, TokenType startToken, TokenType endToken) {
SourcePosition start = getTreeStartLocation();
eat(startToken);
ImmutableList.Builder<ParseTree> children = ImmutableList.builder();
while (peek(TokenType.FOR) || peek(TokenType.IF)) {
if (peek(TokenType.FOR)) {
children.add(parseComprehensionFor());
} else {
children.add(parseComprehensionIf());
}
}
ParseTree tailExpression = parseAssignmentExpression();
eat(endToken);
return new ComprehensionTree(getTreeLocation(start), type, children.build(), tailExpression);
}
use of com.google.javascript.jscomp.parsing.parser.trees.ParseTree in project closure-compiler by google.
the class Parser method parseForOfStatement.
// The for-of Statement
// for ( { let | var }? identifier of expression ) statement
private ParseTree parseForOfStatement(SourcePosition start, ParseTree initializer) {
eatPredefinedString(PredefinedName.OF);
ParseTree collection = parseExpression();
eat(TokenType.CLOSE_PAREN);
ParseTree body = parseStatement();
return new ForOfStatementTree(getTreeLocation(start), initializer, collection, body);
}
use of com.google.javascript.jscomp.parsing.parser.trees.ParseTree in project closure-compiler by google.
the class Parser method parseShiftExpression.
// 11.7 Shift Expression
private ParseTree parseShiftExpression() {
SourcePosition start = getTreeStartLocation();
ParseTree left = parseAdditiveExpression();
while (peekShiftOperator()) {
Token operator = nextToken();
ParseTree right = parseAdditiveExpression();
left = new BinaryOperatorTree(getTreeLocation(start), left, operator, right);
}
return left;
}
use of com.google.javascript.jscomp.parsing.parser.trees.ParseTree in project closure-compiler by google.
the class Parser method parseThrowStatement.
// 12.13 Throw Statement
private ParseTree parseThrowStatement() {
SourcePosition start = getTreeStartLocation();
eat(TokenType.THROW);
ParseTree value = null;
if (peekImplicitSemiColon()) {
reportError("semicolon/newline not allowed after 'throw'");
} else {
value = parseExpression();
}
eatPossiblyImplicitSemiColon();
return new ThrowStatementTree(getTreeLocation(start), value);
}
use of com.google.javascript.jscomp.parsing.parser.trees.ParseTree in project closure-compiler by google.
the class Parser method parseEnumDeclaration.
private ParseTree parseEnumDeclaration() {
SourcePosition start = getTreeStartLocation();
eat(TokenType.ENUM);
IdentifierToken name = eatId();
eat(TokenType.OPEN_CURLY);
ImmutableList<ParseTree> members = parseEnumMembers();
eat(TokenType.CLOSE_CURLY);
return new EnumDeclarationTree(getTreeLocation(start), name, members);
}
Aggregations