use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition 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();
}
eatPossibleImplicitSemiColon();
return new ThrowStatementTree(getTreeLocation(start), value);
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseMissingPrimaryExpression.
private ParseTree parseMissingPrimaryExpression() {
SourcePosition start = getTreeStartLocation();
nextToken();
reportError("primary expression expected");
return new MissingPrimaryExpressionTree(getTreeLocation(start));
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseSpreadExpression.
private SpreadExpressionTree parseSpreadExpression() {
SourcePosition start = getTreeStartLocation();
eat(TokenType.SPREAD);
ParseTree operand = parseAssignmentExpression();
return new SpreadExpressionTree(getTreeLocation(start), operand);
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseCaseClauses.
private ImmutableList<ParseTree> parseCaseClauses() {
boolean foundDefaultClause = false;
ImmutableList.Builder<ParseTree> result = ImmutableList.builder();
while (true) {
SourcePosition start = getTreeStartLocation();
switch(peekType()) {
case CASE:
eat(TokenType.CASE);
ParseTree expression = parseExpression();
eat(TokenType.COLON);
ImmutableList<ParseTree> statements = parseCaseStatementsOpt();
result.add(new CaseClauseTree(getTreeLocation(start), expression, statements));
break;
case DEFAULT:
if (foundDefaultClause) {
reportError("Switch statements may have at most one default clause");
} else {
foundDefaultClause = true;
}
eat(TokenType.DEFAULT);
eat(TokenType.COLON);
result.add(new DefaultClauseTree(getTreeLocation(start), parseCaseStatementsOpt()));
break;
default:
return result.build();
}
}
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseArguments.
private ArgumentListTree parseArguments() {
// ArgumentList :
// AssignmentOrSpreadExpression
// ArgumentList , AssignmentOrSpreadExpression
//
// AssignmentOrSpreadExpression :
// ... AssignmentExpression
// AssignmentExpression
SourcePosition start = getTreeStartLocation();
ImmutableList.Builder<ParseTree> arguments = ImmutableList.builder();
eat(TokenType.OPEN_PAREN);
while (peekAssignmentOrSpread()) {
arguments.add(parseAssignmentOrSpread());
if (!peek(TokenType.CLOSE_PAREN)) {
Token comma = eat(TokenType.COMMA);
if (peek(TokenType.CLOSE_PAREN)) {
features = features.with(Feature.TRAILING_COMMA_IN_PARAM_LIST);
if (!config.atLeast8) {
reportError(comma, "Invalid trailing comma in arguments list");
}
}
}
}
eat(TokenType.CLOSE_PAREN);
return new ArgumentListTree(getTreeLocation(start), arguments.build());
}
Aggregations