/** BlockStatements = { BlockStatement } * BlockStatement = LocalVariableDeclarationStatement * | ClassOrInterfaceOrEnumDeclaration * | [Ident ":"] Statement * LocalVariableDeclarationStatement * = { FINAL | '@' Annotation } Type VariableDeclarators ";" */ @SuppressWarnings("fallthrough") List<JCStatement> blockStatements() { //todo: skip to anchor on error(?) ListBuffer<JCStatement> stats = new ListBuffer<JCStatement>(); while (true) { List<JCStatement> stat = blockStatement(); if (stat.isEmpty()) { return stats.toList(); } else { if (token.pos <= endPosTable.errorEndPos) { skip(false, true, true, true); } stats.addAll(stat); } } }
/** BlockStatements = { BlockStatement } * BlockStatement = LocalVariableDeclarationStatement * | ClassOrInterfaceOrEnumDeclaration * | [Ident ":"] Statement * LocalVariableDeclarationStatement * = { FINAL | '@' Annotation } Type VariableDeclarators ";" */ @SuppressWarnings("fallthrough") List<JCStatement> blockStatements() { //todo: skip to anchor on error(?) ListBuffer<JCStatement> stats = new ListBuffer<JCStatement>(); while (true) { List<JCStatement> stat = blockStatement(); if (stat.isEmpty()) { return stats.toList(); } else { if (token.pos <= endPosTable.errorEndPos) { skip(false, true, true, true); } stats.addAll(stat); } } }
JCStatement parseStatementAsBlock() { int pos = token.pos; List<JCStatement> stats = blockStatement(); if (stats.isEmpty()) { JCErroneous e = F.at(pos).Erroneous(); error(e, "illegal.start.of.stmt"); return F.at(pos).Exec(e); } else { JCStatement first = stats.head; String error = null; switch (first.getTag()) { case CLASSDEF: error = "class.not.allowed"; break; case VARDEF: error = "variable.not.allowed"; break; } if (error != null) { error(first, error); List<JCBlock> blist = List.of(F.at(first.pos).Block(0, stats)); return toP(F.at(pos).Exec(F.at(first.pos).Erroneous(blist))); } return first; } }
JCStatement parseStatementAsBlock() { int pos = token.pos; List<JCStatement> stats = blockStatement(); if (stats.isEmpty()) { JCErroneous e = F.at(pos).Erroneous(); error(e, "illegal.start.of.stmt"); return F.at(pos).Exec(e); } else { JCStatement first = stats.head; String error = null; switch (first.getTag()) { case CLASSDEF: error = "class.not.allowed"; break; case VARDEF: error = "variable.not.allowed"; break; } if (error != null) { error(first, error); List<JCBlock> blist = List.of(F.at(first.pos).Block(0, stats)); return toP(F.at(pos).Exec(F.at(first.pos).Erroneous(blist))); } return first; } }