use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseBitwiseXOR.
// 11.10 Bitwise XOR
private ParseTree parseBitwiseXOR(Expression expressionIn) {
SourcePosition start = getTreeStartLocation();
ParseTree left = parseBitwiseAND(expressionIn);
while (peek(TokenType.CARET)) {
Token operator = eat(TokenType.CARET);
ParseTree right = parseBitwiseAND(expressionIn);
left = new BinaryOperatorTree(getTreeLocation(start), left, operator, right);
}
return left;
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseNewDotSomething.
private ParseTree parseNewDotSomething() {
// currently only "target" is valid after "new."
SourcePosition start = getTreeStartLocation();
eat(TokenType.NEW);
eat(TokenType.PERIOD);
eatPredefinedString("target");
return new NewTargetExpressionTree(getTreeLocation(start));
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseSwitchStatement.
// 12.11 The switch Statement
private ParseTree parseSwitchStatement() {
SourcePosition start = getTreeStartLocation();
eat(TokenType.SWITCH);
eat(TokenType.OPEN_PAREN);
ParseTree expression = parseExpression();
eat(TokenType.CLOSE_PAREN);
eat(TokenType.OPEN_CURLY);
ImmutableList<ParseTree> caseClauses = parseCaseClauses();
eat(TokenType.CLOSE_CURLY);
return new SwitchStatementTree(getTreeLocation(start), expression, caseClauses);
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseArrayPattern.
// Pattern ::= ... | "[" Element? ("," Element?)* "]"
private ParseTree parseArrayPattern(PatternKind kind) {
SourcePosition start = getTreeStartLocation();
ImmutableList.Builder<ParseTree> elements = ImmutableList.builder();
eat(TokenType.OPEN_SQUARE);
while (peek(TokenType.COMMA) || peekArrayPatternElement()) {
if (peek(TokenType.COMMA)) {
SourcePosition nullStart = getTreeStartLocation();
eat(TokenType.COMMA);
elements.add(new NullTree(getTreeLocation(nullStart)));
} else {
elements.add(parsePatternAssignmentTarget(kind));
if (peek(TokenType.COMMA)) {
// Consume the comma separator
eat(TokenType.COMMA);
} else {
// Otherwise we must be done
break;
}
}
}
if (peek(TokenType.ELLIPSIS)) {
recordFeatureUsed(Feature.ARRAY_PATTERN_REST);
elements.add(parseIterRest(kind));
}
if (eat(TokenType.CLOSE_SQUARE) == null) {
// source has syntactic errors.
return new MissingPrimaryExpressionTree(getTreeLocation(getTreeStartLocation()));
}
return new ArrayPatternTree(getTreeLocation(start), elements.build());
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseObjectLiteral.
// 11.1.4 Object Literal Expression
private ParseTree parseObjectLiteral() {
SourcePosition start = getTreeStartLocation();
ImmutableList.Builder<ParseTree> result = ImmutableList.builder();
eat(TokenType.OPEN_CURLY);
Token commaToken = null;
while (peek(TokenType.ELLIPSIS) || peekPropertyNameOrComputedProp(0) || peek(TokenType.STAR)) {
result.add(parsePropertyAssignment());
commaToken = eatOpt(TokenType.COMMA);
if (commaToken == null) {
break;
}
}
eat(TokenType.CLOSE_CURLY);
maybeReportTrailingComma(commaToken);
return new ObjectLiteralExpressionTree(getTreeLocation(start), result.build(), commaToken != null);
}
Aggregations