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

Method condExpr

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

Source from the content-addressed store, hash-verified

2737 }
2738
2739 private AstNode condExpr() throws IOException {
2740 AstNode pn = nullishCoalescingExpr();
2741 if (matchToken(Token.HOOK, true)) {
2742 int qmarkPos = ts.tokenBeg, colonPos = -1;
2743 /*
2744 * Always accept the 'in' operator in the middle clause of a ternary,
2745 * where it's unambiguous, even if we might be parsing the init of a
2746 * for statement.
2747 */
2748 boolean wasInForInit = inForInit;
2749 inForInit = false;
2750 AstNode ifTrue;
2751 try {
2752 ifTrue = assignExpr();
2753 } finally {
2754 inForInit = wasInForInit;
2755 }
2756 if (mustMatchToken(Token.COLON, "msg.no.colon.cond", true)) colonPos = ts.tokenBeg;
2757 AstNode ifFalse = assignExpr();
2758 int beg = pn.getPosition(), len = getNodeEnd(ifFalse) - beg;
2759 ConditionalExpression ce = new ConditionalExpression(beg, len);
2760 ce.setLineColumnNumber(pn.getLineno(), pn.getColumn());
2761 ce.setTestExpression(pn);
2762 ce.setTrueExpression(ifTrue);
2763 ce.setFalseExpression(ifFalse);
2764 ce.setQuestionMarkPosition(qmarkPos - beg);
2765 ce.setColonPosition(colonPos - beg);
2766 pn = ce;
2767 }
2768 return pn;
2769 }
2770
2771 private AstNode nullishCoalescingExpr() throws IOException {
2772 AstNode pn = orExpr();

Callers 1

assignExprMethod · 0.95

Calls 14

nullishCoalescingExprMethod · 0.95
matchTokenMethod · 0.95
assignExprMethod · 0.95
mustMatchTokenMethod · 0.95
getPositionMethod · 0.95
getNodeEndMethod · 0.95
getLinenoMethod · 0.95
setTestExpressionMethod · 0.95
setTrueExpressionMethod · 0.95
setFalseExpressionMethod · 0.95
setColonPositionMethod · 0.95

Tested by

no test coverage detected