MCPcopy Create free account
hub / github.com/mozilla/rhino / parenExpr

Method parenExpr

rhino/src/main/java/org/mozilla/javascript/Parser.java:3699–3738  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3697 }
3698
3699 private AstNode parenExpr() throws IOException {
3700 boolean wasInForInit = inForInit;
3701 inForInit = false;
3702 try {
3703 Comment jsdocNode = getAndResetJsDoc();
3704 int lineno = lineNumber(), column = columnNumber();
3705 int begin = ts.tokenBeg;
3706 AstNode e = (peekToken() == Token.RP ? new EmptyExpression(begin) : expr(true));
3707 if (peekToken() == Token.FOR) {
3708 return generatorExpression(e, begin);
3709 }
3710 mustMatchToken(Token.RP, "msg.no.paren", true);
3711
3712 int length = ts.tokenEnd - begin;
3713
3714 boolean hasObjectLiteralDestructuring =
3715 e.getIntProp(Node.OBJECT_LITERAL_DESTRUCTURING, 0) == 1;
3716 boolean hasTrailingComma = e.getIntProp(Node.TRAILING_COMMA, 0) == 1;
3717 if ((hasTrailingComma || hasObjectLiteralDestructuring || e.getType() == Token.EMPTY)
3718 && peekToken() != Token.ARROW) {
3719 reportError("msg.syntax");
3720 return makeErrorNode();
3721 }
3722
3723 ParenthesizedExpression pn = new ParenthesizedExpression(begin, length, e);
3724 pn.setLineColumnNumber(lineno, column);
3725 if (jsdocNode == null) {
3726 jsdocNode = getAndResetJsDoc();
3727 }
3728 if (jsdocNode != null) {
3729 pn.setJsDocNode(jsdocNode);
3730 }
3731 if (hasTrailingComma) {
3732 pn.putIntProp(Node.TRAILING_COMMA, 1);
3733 }
3734 return pn;
3735 } finally {
3736 inForInit = wasInForInit;
3737 }
3738 }
3739
3740 private AstNode name(int ttFlagged, int tt) throws IOException {
3741 String nameString = ts.getString();

Callers 1

primaryExprMethod · 0.95

Calls 14

getAndResetJsDocMethod · 0.95
lineNumberMethod · 0.95
columnNumberMethod · 0.95
peekTokenMethod · 0.95
exprMethod · 0.95
generatorExpressionMethod · 0.95
mustMatchTokenMethod · 0.95
reportErrorMethod · 0.95
makeErrorNodeMethod · 0.95
setLineColumnNumberMethod · 0.80
setJsDocNodeMethod · 0.80
putIntPropMethod · 0.80

Tested by

no test coverage detected