2163 List<JCCase> switchBlockStatementGroups() { |
2163 List<JCCase> switchBlockStatementGroups() { |
2164 ListBuffer<JCCase> cases = new ListBuffer<JCCase>(); |
2164 ListBuffer<JCCase> cases = new ListBuffer<JCCase>(); |
2165 while (true) { |
2165 while (true) { |
2166 int pos = token.pos; |
2166 int pos = token.pos; |
2167 switch (token.kind) { |
2167 switch (token.kind) { |
2168 case CASE: { |
2168 case CASE: |
2169 nextToken(); |
2169 case DEFAULT: |
2170 JCExpression pat = parseExpression(); |
2170 cases.append(switchBlockStatementGroup()); |
2171 accept(COLON); |
|
2172 List<JCStatement> stats = blockStatements(); |
|
2173 JCCase c = F.at(pos).Case(pat, stats); |
|
2174 if (stats.isEmpty()) |
|
2175 storeEnd(c, S.prevToken().endPos); |
|
2176 cases.append(c); |
|
2177 break; |
2171 break; |
2178 } |
|
2179 case DEFAULT: { |
|
2180 nextToken(); |
|
2181 accept(COLON); |
|
2182 List<JCStatement> stats = blockStatements(); |
|
2183 JCCase c = F.at(pos).Case(null, stats); |
|
2184 if (stats.isEmpty()) |
|
2185 storeEnd(c, S.prevToken().endPos); |
|
2186 cases.append(c); |
|
2187 break; |
|
2188 } |
|
2189 case RBRACE: case EOF: |
2172 case RBRACE: case EOF: |
2190 return cases.toList(); |
2173 return cases.toList(); |
2191 default: |
2174 default: |
2192 nextToken(); // to ensure progress |
2175 nextToken(); // to ensure progress |
2193 syntaxError(pos, "expected3", |
2176 syntaxError(pos, "expected3", |
2194 CASE, DEFAULT, RBRACE); |
2177 CASE, DEFAULT, RBRACE); |
2195 } |
2178 } |
2196 } |
2179 } |
|
2180 } |
|
2181 |
|
2182 protected JCCase switchBlockStatementGroup() { |
|
2183 int pos = token.pos; |
|
2184 List<JCStatement> stats; |
|
2185 JCCase c; |
|
2186 switch (token.kind) { |
|
2187 case CASE: |
|
2188 nextToken(); |
|
2189 JCExpression pat = parseExpression(); |
|
2190 accept(COLON); |
|
2191 stats = blockStatements(); |
|
2192 c = F.at(pos).Case(pat, stats); |
|
2193 if (stats.isEmpty()) |
|
2194 storeEnd(c, S.prevToken().endPos); |
|
2195 return c; |
|
2196 case DEFAULT: |
|
2197 nextToken(); |
|
2198 accept(COLON); |
|
2199 stats = blockStatements(); |
|
2200 c = F.at(pos).Case(null, stats); |
|
2201 if (stats.isEmpty()) |
|
2202 storeEnd(c, S.prevToken().endPos); |
|
2203 return c; |
|
2204 } |
|
2205 throw new AssertionError("should not reach here"); |
2197 } |
2206 } |
2198 |
2207 |
2199 /** MoreStatementExpressions = { COMMA StatementExpression } |
2208 /** MoreStatementExpressions = { COMMA StatementExpression } |
2200 */ |
2209 */ |
2201 <T extends ListBuffer<? super JCExpressionStatement>> T moreStatementExpressions(int pos, |
2210 <T extends ListBuffer<? super JCExpressionStatement>> T moreStatementExpressions(int pos, |