/** Block = "{" BlockStatements "}" */ JCBlock block(int pos, long flags) { accept(LBRACE); List<JCStatement> stats = blockStatements(); JCBlock t = F.at(pos).Block(flags, stats); while (token.kind == CASE || token.kind == DEFAULT) { syntaxError("orphaned", token.kind); switchBlockStatementGroups(); } // the Block node has a field "endpos" for first char of last token, which is // usually but not necessarily the last char of the last token. t.endpos = token.pos; accept(RBRACE); return toP(t); }
/** Block = "{" BlockStatements "}" */ JCBlock block(int pos, long flags) { accept(LBRACE); List<JCStatement> stats = blockStatements(); JCBlock t = F.at(pos).Block(flags, stats); while (token.kind == CASE || token.kind == DEFAULT) { syntaxError("orphaned", token.kind); switchBlockStatementGroups(); } // the Block node has a field "endpos" for first char of last token, which is // usually but not necessarily the last char of the last token. t.endpos = token.pos; accept(RBRACE); return toP(t); }
protected JCCase switchBlockStatementGroup() { int pos = token.pos; List<JCStatement> stats; JCCase c; switch (token.kind) { case CASE: nextToken(); JCExpression pat = parseExpression(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(pat, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; case DEFAULT: nextToken(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(null, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; } throw new AssertionError("should not reach here"); }
protected JCCase switchBlockStatementGroup() { int pos = token.pos; List<JCStatement> stats; JCCase c; switch (token.kind) { case CASE: nextToken(); JCExpression pat = parseExpression(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(pat, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; case DEFAULT: nextToken(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(null, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; } throw new AssertionError("should not reach here"); }