src/jdk/nashorn/internal/parser/Parser.java

Print this page




1683         // Container block needed to act as target for labeled break statements
1684         final int startLine = line;
1685         Block outer = newBlock();
1686 
1687         // Create try.
1688 
1689         try {
1690             final Block       tryBody     = getBlock(true);
1691             final List<Block> catchBlocks = new ArrayList<>();
1692 
1693             while (type == CATCH) {
1694                 final int  catchLine  = line;
1695                 final long catchToken = token;
1696                 next();
1697                 expect(LPAREN);
1698                 final IdentNode exception = getIdent();
1699 
1700                 // ECMA 12.4.1 strict mode restrictions
1701                 verifyStrictIdent(exception, "catch argument");
1702 
1703                 // Check for conditional catch.


1704                 final Expression ifExpression;
1705                 if (type == IF) {
1706                     next();
1707                     // Get the exception condition.
1708                     ifExpression = expression();
1709                 } else {
1710                     ifExpression = null;
1711                 }
1712 
1713                 expect(RPAREN);
1714 
1715                 Block catchBlock = newBlock();
1716                 try {
1717                     // Get CATCH body.
1718                     final Block catchBody = getBlock(true);
1719                     final CatchNode catchNode = new CatchNode(catchLine, catchToken, finish, exception, ifExpression, catchBody, 0);
1720                     appendStatement(catchNode);
1721                 } finally {
1722                     catchBlock = restoreBlock(catchBlock);
1723                     catchBlocks.add(catchBlock);
1724                 }
1725 




1683         // Container block needed to act as target for labeled break statements
1684         final int startLine = line;
1685         Block outer = newBlock();
1686 
1687         // Create try.
1688 
1689         try {
1690             final Block       tryBody     = getBlock(true);
1691             final List<Block> catchBlocks = new ArrayList<>();
1692 
1693             while (type == CATCH) {
1694                 final int  catchLine  = line;
1695                 final long catchToken = token;
1696                 next();
1697                 expect(LPAREN);
1698                 final IdentNode exception = getIdent();
1699 
1700                 // ECMA 12.4.1 strict mode restrictions
1701                 verifyStrictIdent(exception, "catch argument");
1702 
1703                 // Nashorn extension: catch clause can have optional
1704                 // condition. So, a single try can have more than one
1705                 // catch clause each with it's own condition.
1706                 final Expression ifExpression;
1707                 if (!env._no_syntax_extensions && type == IF) {
1708                     next();
1709                     // Get the exception condition.
1710                     ifExpression = expression();
1711                 } else {
1712                     ifExpression = null;
1713                 }
1714 
1715                 expect(RPAREN);
1716 
1717                 Block catchBlock = newBlock();
1718                 try {
1719                     // Get CATCH body.
1720                     final Block catchBody = getBlock(true);
1721                     final CatchNode catchNode = new CatchNode(catchLine, catchToken, finish, exception, ifExpression, catchBody, 0);
1722                     appendStatement(catchNode);
1723                 } finally {
1724                     catchBlock = restoreBlock(catchBlock);
1725                     catchBlocks.add(catchBlock);
1726                 }
1727