/** * Parses the Java block contained in a {@link String} and returns a * {@link BlockStmt} that represents it. * * @param blockStatement * {@link String} containing Java block code * @return BlockStmt representing the Java block * @throws ParseException * if the source code has parser errors * @throws IOException */ public static BlockStmt parseBlock(final String blockStatement) throws ParseException { StringReader sr = new StringReader(blockStatement); BlockStmt result = new ASTParser(sr).Block(); sr.close(); return result; }
final public SynchronizedStmt SynchronizedStatement() throws ParseException { Expression expr; BlockStmt block; int line; int column; jj_consume_token(SYNCHRONIZED); line=token.beginLine; column=token.beginColumn; jj_consume_token(LPAREN); expr = Expression(); jj_consume_token(RPAREN); block = Block(); {if (true) return new SynchronizedStmt(line, column, token.endLine, token.endColumn,expr, block);} throw new Error("Missing return statement in function"); }
final public SynchronizedStmt SynchronizedStatement() throws ParseException { Expression expr; BlockStmt block; int line; int column; jj_consume_token(SYNCHRONIZED); line=token.beginLine; column=token.beginColumn; jj_consume_token(LPAREN); expr = Expression(); jj_consume_token(RPAREN); block = Block(); SynchronizedStmt tmp = new SynchronizedStmt(line, column, token.endLine, token.endColumn,expr, block); {if (true) return tmp;} throw new Error("Missing return statement in function"); }
final public InitializerDeclaration InitializerDeclaration() throws ParseException { BlockStmt block; int line = -1; int column = 0; boolean isStatic = false; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STATIC: jj_consume_token(STATIC); isStatic = true; line=token.beginLine; column=token.beginColumn; break; default: jj_la1[49] = jj_gen; ; } block = Block(); if(line==-1){line=block.getBeginLine(); column=block.getBeginColumn();} InitializerDeclaration tmp = new InitializerDeclaration(line, column, token.endLine, token.endColumn, isStatic, block); {if (true) return tmp;} throw new Error("Missing return statement in function"); }
jj_consume_token(TRY); line=token.beginLine; column=token.beginColumn; tryBlock = Block(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CATCH: except = FormalParameter(); jj_consume_token(RPAREN); catchBlock = Block(); catchs = add(catchs, new CatchClause(cLine, cColumn, token.endLine, token.endColumn, except, catchBlock)); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FINALLY: jj_consume_token(FINALLY); finallyBlock = Block(); break; default: case FINALLY: jj_consume_token(FINALLY); finallyBlock = Block(); break; default:
final public InitializerDeclaration InitializerDeclaration() throws ParseException { BlockStmt block; int line = -1; int column = 0; boolean isStatic = false; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STATIC: jj_consume_token(STATIC); isStatic = true; line=token.beginLine; column=token.beginColumn; break; default: jj_la1[49] = jj_gen; ; } block = Block(); if(line==-1){line=block.getBeginLine(); column=block.getBeginColumn();} {if (true) return new InitializerDeclaration(line, column, token.endLine, token.endColumn,popJavadoc(), isStatic, block);} throw new Error("Missing return statement in function"); }
tryBlock = Block(); label_44: while (true) { catchBlock = Block(); catchs = add(catchs, new CatchClause(cLine, cColumn, token.endLine, token.endColumn, exceptModifier.modifiers, exceptModifier.annotations, exceptTypes, exceptId, catchBlock)); exceptTypes = new LinkedList(); case FINALLY: jj_consume_token(FINALLY); finallyBlock = Block(); break; default:
block = Block(); break; case SEMICOLON:
block = Block(); break; case SEMICOLON:
break; case LBRACE: ret = Block(); break; case SEMICOLON:
break; case LBRACE: ret = Block(); break; case SEMICOLON: