use of com.google.javascript.jscomp.parsing.parser.trees.MemberExpressionTree in project closure-compiler by google.
the class Parser method parseLeftHandSideExpression.
// 11.2 Left hand side expression
//
// Also inlines the call expression productions
@SuppressWarnings("incomplete-switch")
private ParseTree parseLeftHandSideExpression() {
SourcePosition start = getTreeStartLocation();
ParseTree operand = parseNewExpression();
// this test is equivalent to is member expression
if (!(operand instanceof NewExpressionTree) || ((NewExpressionTree) operand).arguments != null) {
// The Call expression productions
while (peekCallSuffix()) {
switch(peekType()) {
case OPEN_PAREN:
ArgumentListTree arguments = parseArguments();
operand = new CallExpressionTree(getTreeLocation(start), operand, arguments);
break;
case OPEN_SQUARE:
eat(TokenType.OPEN_SQUARE);
ParseTree member = parseExpression();
eat(TokenType.CLOSE_SQUARE);
operand = new MemberLookupExpressionTree(getTreeLocation(start), operand, member);
break;
case PERIOD:
eat(TokenType.PERIOD);
IdentifierToken id = eatIdOrKeywordAsId();
operand = new MemberExpressionTree(getTreeLocation(start), operand, id);
break;
case NO_SUBSTITUTION_TEMPLATE:
case TEMPLATE_HEAD:
operand = parseTemplateLiteral(operand);
break;
default:
throw new AssertionError("unexpected case: " + peekType());
}
}
}
return operand;
}
use of com.google.javascript.jscomp.parsing.parser.trees.MemberExpressionTree in project closure-compiler by google.
the class Parser method parseMemberExpressionNoNew.
// 11.2 Member Expression without the new production
private ParseTree parseMemberExpressionNoNew() {
SourcePosition start = getTreeStartLocation();
ParseTree operand;
if (peekAsyncFunctionStart()) {
operand = parseAsyncFunctionExpression();
} else if (peekFunction()) {
operand = parseFunctionExpression();
} else {
operand = parsePrimaryExpression();
}
while (peekMemberExpressionSuffix()) {
switch(peekType()) {
case OPEN_SQUARE:
eat(TokenType.OPEN_SQUARE);
ParseTree member = parseExpression();
eat(TokenType.CLOSE_SQUARE);
operand = new MemberLookupExpressionTree(getTreeLocation(start), operand, member);
break;
case PERIOD:
eat(TokenType.PERIOD);
IdentifierToken id = eatIdOrKeywordAsId();
operand = new MemberExpressionTree(getTreeLocation(start), operand, id);
break;
case NO_SUBSTITUTION_TEMPLATE:
case TEMPLATE_HEAD:
operand = parseTemplateLiteral(operand);
break;
default:
throw new RuntimeException("unreachable");
}
}
return operand;
}
Aggregations