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

Method statement

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

Source from the content-addressed store, hash-verified

1387 }
1388
1389 private AstNode statement() throws IOException {
1390 int pos = ts.tokenBeg;
1391 try {
1392 AstNode pn = statementHelper();
1393 if (pn != null) {
1394 if (compilerEnv.isStrictMode() && !pn.hasSideEffects()) {
1395 int beg = pn.getPosition();
1396 beg = Math.max(beg, lineBeginningFor(beg));
1397 addStrictWarning(
1398 pn instanceof EmptyStatement
1399 ? "msg.extra.trailing.semi"
1400 : "msg.no.side.effects",
1401 "",
1402 beg,
1403 nodeEnd(pn) - beg);
1404 }
1405 int ntt = peekToken();
1406 if (ntt == Token.COMMENT
1407 && pn.getLineno()
1408 == scannedComments.get(scannedComments.size() - 1).getLineno()) {
1409 pn.setInlineComment(scannedComments.get(scannedComments.size() - 1));
1410 consumeToken();
1411 }
1412 return pn;
1413 }
1414 } catch (ParserException e) {
1415 // an ErrorNode was added to the ErrorReporter
1416 }
1417
1418 // error: skip ahead to a probable statement boundary
1419 guessingStatementEnd:
1420 for (; ; ) {
1421 int tt = peekTokenOrEOL();
1422 consumeToken();
1423 switch (tt) {
1424 case Token.ERROR:
1425 case Token.EOF:
1426 case Token.EOL:
1427 case Token.SEMI:
1428 break guessingStatementEnd;
1429 }
1430 }
1431 // We don't make error nodes explicitly part of the tree;
1432 // they get added to the ErrorReporter. May need to do
1433 // something different here.
1434 return new EmptyStatement(pos, ts.tokenBeg - pos);
1435 }
1436
1437 private AstNode statementHelper() throws IOException {
1438 // If the statement is set, then it's been told its label by now.

Callers 7

parseMethod · 0.95
parseFunctionBodyMethod · 0.95
statementsMethod · 0.95
ifStatementMethod · 0.95
switchStatementMethod · 0.95
tryStatementMethod · 0.95

Calls 15

statementHelperMethod · 0.95
hasSideEffectsMethod · 0.95
getPositionMethod · 0.95
lineBeginningForMethod · 0.95
addStrictWarningMethod · 0.95
nodeEndMethod · 0.95
peekTokenMethod · 0.95
getLinenoMethod · 0.95
setInlineCommentMethod · 0.95
consumeTokenMethod · 0.95
peekTokenOrEOLMethod · 0.95
maxMethod · 0.80

Tested by

no test coverage detected