Clover coverage report - DynamicJava Test Coverage (dynamicjava-20120526-r5436)
Coverage timestamp: Sat May 26 2012 03:02:18 CDT
file stats: LOC: 7,853   Methods: 521
NCLOC: 6,967   Classes: 30
 
 Source file Conditionals Statements Methods TOTAL
Parser.java 50.6% 52.7% 77.2% 53.9%
coverage coverage
 1    /* Generated By:JavaCC: Do not edit this line. Parser.java */
 2    package koala.dynamicjava.parser.impl;
 3   
 4    import java.util.*;
 5    import java.io.File;
 6   
 7    import edu.rice.cs.plt.tuple.Option;
 8    import edu.rice.cs.plt.tuple.Pair;
 9    import edu.rice.cs.plt.collect.ConsList;
 10    import edu.rice.cs.plt.collect.CollectUtil;
 11   
 12    import koala.dynamicjava.parser.wrapper.*;
 13    import koala.dynamicjava.tree.*;
 14    import koala.dynamicjava.tree.ModifierSet.Modifier;
 15    import koala.dynamicjava.tree.visitor.*;
 16    import koala.dynamicjava.util.*;
 17    import koala.dynamicjava.tree.tiger.*;
 18    import edu.rice.cs.dynamicjava.Options;
 19   
 20    /**
 21    * This class represents a (interpreted) Java 1.1 language parser
 22    * adapted for 1.5 language extensions.
 23    */
 24   
 25    public class Parser implements ParserConstants {
 26    /** The name of the file currently interpreted; null by default */
 27    private File file = null;
 28   
 29    /** DynamicJava options */
 30    private Options opt = Options.DEFAULT;
 31   
 32    /**
 33    * A flag to use in semantic lookaheads. Declared here as a workaround because
 34    * lookahead can't access local variables or production parameters.
 35    */
 36    private boolean lookaheadFlag;
 37   
 38    /** Hack to pass the fact that a formal parameter was varargs back to the method/constructor production. */
 39    boolean lastFormalParameterIsVarArgs = false;
 40   
 41    /**
 42    * The message reader
 43    */
 44    private LocalizedMessageReader reader =
 45    new LocalizedMessageReader("koala.dynamicjava.parser.resources.messages");
 46   
 47    /** Sets the current file */
 48  0 public void setFile(File f) { file = f; }
 49   
 50  732 public void setOptions(Options o) { opt = o; }
 51   
 52  4966 private SourceInfo _range(Token first, Token last) {
 53  4966 return SourceInfo.range(file, first.beginLine, first.beginColumn, last.endLine, last.endColumn);
 54    }
 55   
 56  1074 private SourceInfo _range(Token first, SourceInfo.Wrapper last) {
 57  1074 return SourceInfo.prepend(first.beginLine, first.beginColumn, last);
 58    }
 59   
 60  4733 private SourceInfo _range(SourceInfo.Wrapper first, Token last) {
 61  4733 return SourceInfo.extend(first, last.beginLine, last.beginColumn);
 62    }
 63   
 64  0 private SourceInfo _range(Token first, SourceInfo last) {
 65  0 return SourceInfo.prepend(first.beginLine, first.beginColumn, last);
 66    }
 67   
 68  0 private SourceInfo _range(SourceInfo first, Token last) {
 69  0 return SourceInfo.extend(first, last.beginLine, last.beginColumn);
 70    }
 71   
 72  1346 private SourceInfo _range(SourceInfo.Wrapper first, SourceInfo.Wrapper last) {
 73  1346 return SourceInfo.span(first, last);
 74    }
 75   
 76  4 private SourceInfo _range(SourceInfo first, SourceInfo last) {
 77  4 return SourceInfo.span(first, last);
 78    }
 79   
 80    /**
 81    * Throws a parse exception with the given message at the current (last consumed) token
 82    * @param message - the message to be thrown
 83    */
 84   
 85  0 private <T> T _throwParseException(String message) throws ParseException {
 86  0 ParseException pe = new ParseException(message);
 87  0 pe.currentToken = token;
 88  0 throw pe;
 89    }
 90   
 91    /**
 92    * Throws a parse exception with the given message at the current token, if the given
 93    * parse exception was one auto generated by the parser (not one of ours), but not if the
 94    * message is an <EOF> message, which is passed up to allow continuation of typing
 95    * @param pe - the previous parse exception thrown
 96    * @param message - the message to be thrown
 97    */
 98  0 private <T> T _throwParseException(ParseException pe, String message) throws ParseException {
 99  0 if (pe.expectedTokenSequences == null) { // has custom message
 100  0 message = pe.getMessage();
 101    }
 102    else {
 103  0 edu.rice.cs.plt.debug.DebugUtil.debug.log("Raw parse exception", pe);
 104    }
 105  0 if(pe.getMessage().indexOf("<EOF>\"") != -1) {
 106  0 message = "Encountered Unexpected \"<EOF>\"";
 107    }
 108  0 return this.<T>_throwParseException(message);
 109    }
 110   
 111    public static enum DeclType { TOP, CLASS_MEMBER, INTERFACE_MEMBER, LOCAL, REPL };
 112   
 113    /**
 114    * Creates a field declaration
 115    */
 116  23 private FieldDeclaration createFieldDeclaration(ModifierSet mods,
 117    TypeName typ,
 118    Token name,
 119    Expression exp,
 120    int dim) {
 121  23 SourceInfo si = (exp == null) ? _range(mods, name) : _range(mods, exp);
 122   
 123    // If the field is an array, create an array type node
 124  23 if (dim > 0) {
 125  0 typ = new ArrayTypeName(typ, dim, false, typ.getSourceInfo());
 126    }
 127   
 128  23 return new FieldDeclaration(mods, typ, name.image, exp, si);
 129    }
 130   
 131    /**
 132    * Creates a variable declaration
 133    */
 134  671 private VariableDeclaration createVariableDeclaration(ModifierSet mods,
 135    TypeName typ,
 136    Token name,
 137    Expression exp,
 138    int dim) {
 139  671 SourceInfo si = (exp == null) ? _range(mods, name) : _range(mods, exp);
 140   
 141    // If the variable contains an array, create an array type node
 142  671 if (dim > 0) {
 143  0 typ = new ArrayTypeName(typ, dim, false, typ.getSourceInfo());
 144    }
 145   
 146  671 return new VariableDeclaration(mods, typ, name.image, exp, si);
 147    }
 148   
 149   
 150  1623 private void checkModifiers(ModifierSet mods, ModifierSet.Modifier... allowed) throws ParseException {
 151  1623 Set<ModifierSet.Modifier> copy = EnumSet.copyOf(mods.getFlags());
 152  4074 for (ModifierSet.Modifier m : allowed) { copy.remove(m); }
 153  1623 if (!copy.isEmpty()) {
 154  0 ModifierSet.Modifier badMod = copy.iterator().next();
 155  0 _throwParseException("Modifier " + badMod.getName() + " is not allowed here");
 156    }
 157    }
 158   
 159   
 160    /** A hierarchy of helper classes for building primary expressions. */
 161    abstract class Primary implements SourceInfo.Wrapper {
 162    private final SourceInfo _si;
 163  4652 protected Primary(SourceInfo si) { _si = si; }
 164  3308 public SourceInfo getSourceInfo() { return _si; }
 165   
 166  0 public Expression asExpression() throws ParseException {
 167  0 return _throwParseException("Incomplete expression");
 168    }
 169  0 public Primary dotId(Option<List<TypeName>> targs, Token id) throws ParseException {
 170  0 if (targs.isNone()) { return _throwParseException("Unexpected identifier"); }
 171  0 else { return _throwParseException("Unexpected type arguments and identifier"); }
 172    }
 173  0 public Primary dotThis(Option<List<TypeName>> targs, Token t) throws ParseException {
 174  0 if (targs.isNone()) { return _throwParseException("Unexpected 'this' keyword"); }
 175  0 else { return _throwParseException("Unexpected type arguments and 'this' keyword"); }
 176    }
 177  0 public Primary dotSuper(Option<List<TypeName>> targs, Token t) throws ParseException {
 178  0 if (targs.isNone()) { return _throwParseException("Unexpected 'super' keyword"); }
 179  0 else { return _throwParseException("Unexpected type arguments and 'super' keyword"); }
 180    }
 181  0 public Primary dotClass(Token t) throws ParseException {
 182  0 return _throwParseException("Illegal class literal");
 183    }
 184  0 public Primary dotNew(Option<List<TypeName>> targs, Token id) throws ParseException {
 185  0 if (targs.isNone()) { return _throwParseException("Unexpected 'new' keyword"); }
 186  0 else { return _throwParseException("Unexpected 'new' keyword and type arguments"); }
 187    }
 188  0 public Primary withArrayDim(Token last) throws ParseException {
 189  0 return _throwParseException("Unexpected empty array brackets");
 190    }
 191  0 public Primary withArrayAccess(Expression exp, Token last) throws ParseException {
 192  0 return _throwParseException("Unexpected array access");
 193    }
 194  0 public Primary withTypeArgs(List<TypeName> targs, Token last) throws ParseException {
 195  0 return _throwParseException("Unexpected type arguments");
 196    }
 197  0 public Primary withArgs(List<Expression> args, Token last) throws ParseException {
 198  0 return _throwParseException("Unexpected argument list");
 199    }
 200  0 public Primary withClassBody(List<Node> members, Token last) throws ParseException {
 201  0 return _throwParseException("Unexpected class body");
 202    }
 203    }
 204   
 205    /** A primary that can be parsed as a complete expression and act as a method receiver, etc. */
 206    abstract class CompletedPrimary extends Primary {
 207  4051 protected CompletedPrimary(SourceInfo si) { super(si); }
 208   
 209    @Override public abstract Expression asExpression() throws ParseException;
 210   
 211  23 @Override public Primary dotId(Option<List<TypeName>> targs, Token id) throws ParseException {
 212  23 if (targs.isNone()) { return new ObjectFieldAccessPrimary(asExpression(), id); }
 213  0 else { return new PartialObjectMethodCallPrimary(asExpression(), targs, id); }
 214    }
 215   
 216  0 @Override public Primary dotSuper(Option<List<TypeName>> targs, Token t) throws ParseException {
 217  0 return new PartialSuperConstructorCallPrimary(asExpression(), targs, t);
 218    }
 219   
 220  1 @Override public Primary dotNew(Option<List<TypeName>> targs, Token id) throws ParseException {
 221  1 return new PartialInnerAllocationPrimary(asExpression(), targs, id);
 222    }
 223   
 224  109 @Override public Primary withArrayAccess(Expression exp, Token last) throws ParseException {
 225  109 return new ExpressionPrimary(new ArrayAccess(asExpression(), exp, _range(this, last)));
 226    }
 227    }
 228   
 229    /** A primary that can *only* be parsed as the given expression, regardless of what follows. */
 230    class ExpressionPrimary extends CompletedPrimary {
 231    private Expression _exp;
 232  1413 public ExpressionPrimary(Expression exp) { super(exp.getSourceInfo()); _exp = exp; }
 233  1413 public Expression asExpression() { return _exp; }
 234    }
 235   
 236    /** Like an ExpressionPrimary, but constructor calls can't be followed by additional dots, etc. */
 237    class ConstructorCallPrimary extends Primary {
 238    private ConstructorCall _call;
 239  46 public ConstructorCallPrimary(ConstructorCall call) { super(call.getSourceInfo()); _call = call; }
 240  46 @Override public Expression asExpression() { return _call; }
 241    }
 242   
 243    /** An ExpressionPrimary, but doesn't allow array accesses. */
 244    class ArrayAllocationPrimary extends ExpressionPrimary {
 245  14 public ArrayAllocationPrimary(ArrayAllocation alloc) { super(alloc); }
 246  0 public Primary withArrayAccess(Expression exp, Token last) throws ParseException {
 247  0 return _throwParseException("Unexpected array access");
 248    }
 249    }
 250   
 251   
 252    /** A dotted sequence of names. */
 253    class AmbiguousNamePrimary extends CompletedPrimary {
 254    private final ConsList.Nonempty<IdentifierToken> _reversed;
 255  1856 public AmbiguousNamePrimary(Token id) {
 256  1856 this(ConsList.<IdentifierToken>singleton(new TreeToken(id, file)), _range(id, id));
 257    }
 258  2118 private AmbiguousNamePrimary(ConsList.Nonempty<IdentifierToken> reversed, SourceInfo si) {
 259  2118 super(si);
 260  2118 _reversed = reversed;
 261    }
 262  1610 private LinkedList<IdentifierToken> ids() { return CollectUtil.makeLinkedList(ConsList.reverse(_reversed)); }
 263   
 264  1602 public Expression asExpression() {
 265  1602 return new AmbiguousName(ids(), getSourceInfo());
 266    }
 267   
 268  262 @Override public Primary dotId(Option<List<TypeName>> targs, Token id) {
 269  262 if (targs.isNone()) {
 270  262 return new AmbiguousNamePrimary(ConsList.cons(new TreeToken(id, file), _reversed), _range(this, id));
 271    }
 272  0 else { return new PartialObjectMethodCallPrimary(asExpression(), targs, id); }
 273    }
 274   
 275  1 @Override public Primary dotThis(Option<List<TypeName>> targs, Token t) throws ParseException {
 276  1 if (targs.isNone()) {
 277  1 Option<String> cn = Option.some(TreeUtilities.listToName(ids()));
 278  1 return new ExpressionPrimary(new ThisExpression(cn, _range(this, t)));
 279    }
 280  0 else { return _throwParseException("Unexpected type arguments"); }
 281    }
 282   
 283  0 @Override public Primary dotSuper(Option<List<TypeName>> targs, Token t) throws ParseException {
 284  0 if (targs.isNone()) { return new PartialSuperPrimary(ids(), t); }
 285  0 else { return super.dotSuper(targs, t); }
 286    }
 287   
 288  6 @Override public Primary dotClass(Token t) {
 289  6 return new ExpressionPrimary(new TypeExpression(new ReferenceTypeName(ids(), getSourceInfo()), _range(this, t)));
 290    }
 291   
 292  1 @Override public Primary withArrayDim(Token last) {
 293  1 TypeName elt = new ReferenceTypeName(ids(), getSourceInfo());
 294  1 return new ArrayTypeNamePrimary(new ArrayTypeName(elt, 1, false, _range(this, last)));
 295    }
 296   
 297  0 @Override public Primary withTypeArgs(List<TypeName> targs, Token last) {
 298  0 return new GenericReferenceTypeNamePrimary(_reversed, targs, _range(this, last));
 299    }
 300   
 301  246 @Override public Primary withArgs(List<Expression> args, Token last) {
 302  246 SourceInfo si = _range(this, last);
 303  246 ConsList<? extends IdentifierToken> revObjIds = _reversed.rest();
 304  246 if (revObjIds.isEmpty()) {
 305  110 return new ExpressionPrimary(new SimpleMethodCall(_reversed.first().image(), args, si));
 306    }
 307    else {
 308  136 LinkedList<IdentifierToken> objIds = CollectUtil.makeLinkedList(ConsList.reverse(revObjIds));
 309  136 AmbiguousName obj = new AmbiguousName(objIds, _range(objIds.getFirst(), objIds.getLast()));
 310  136 return new ExpressionPrimary(new ObjectMethodCall(obj, _reversed.first().image(), args, si));
 311    }
 312    }
 313    }
 314   
 315    /** A dotted name with at least one type argument. Can be followed by additional identifiers and type arguments. */
 316    class GenericReferenceTypeNamePrimary extends Primary {
 317    protected final ConsList.Nonempty<IdentifierToken> _reversed;
 318    protected final ConsList.Nonempty<List<TypeName>> _targsReversed;
 319  0 public GenericReferenceTypeNamePrimary(ConsList.Nonempty<IdentifierToken> reversed, List<TypeName> targs,
 320    SourceInfo si) {
 321  0 super(si);
 322  0 _reversed = reversed;
 323  0 ConsList<List<TypeName>> noArgs = ConsList.empty();
 324  0 int noArgCount = _reversed.size() - 1;
 325  0 for (int i = 0; i < noArgCount; i++) { noArgs = ConsList.cons(new LinkedList<TypeName>(), noArgs); }
 326  0 _targsReversed = ConsList.cons(targs, noArgs);
 327    }
 328  0 private GenericReferenceTypeNamePrimary(ConsList.Nonempty<IdentifierToken> reversed,
 329    ConsList.Nonempty<List<TypeName>> targsReversed, SourceInfo si) {
 330  0 super(si);
 331  0 _reversed = reversed;
 332  0 _targsReversed = targsReversed;
 333    }
 334   
 335  0 protected GenericReferenceTypeName asTypeName() {
 336  0 List<IdentifierToken> ids = CollectUtil.makeLinkedList(ConsList.reverse(_reversed));
 337  0 List<List<? extends TypeName>> targs =
 338    CollectUtil.<List<? extends TypeName>>makeLinkedList(ConsList.reverse(_targsReversed));
 339  0 return new GenericReferenceTypeName(ids, targs, getSourceInfo());
 340    }
 341   
 342  0 @Override public Primary dotId(Option<List<TypeName>> targs, Token id) {
 343  0 if (targs.isNone()) { return new IdGenericReferenceTypeNamePrimary(this, id); }
 344  0 else { return new PartialStaticMethodCallPrimary(asTypeName(), targs, id); }
 345    }
 346   
 347  0 @Override public Primary dotClass(Token t) {
 348  0 return new ExpressionPrimary(new TypeExpression(asTypeName(), _range(this, t)));
 349    }
 350   
 351  0 @Override public Primary withArrayDim(Token last) {
 352  0 return new ArrayTypeNamePrimary(new ArrayTypeName(asTypeName(), 1, false, _range(this, last)));
 353    }
 354   
 355    }
 356   
 357    /** A GenericReferenceTypeNamePrimary that ends with an id. */
 358    class IdGenericReferenceTypeNamePrimary extends GenericReferenceTypeNamePrimary {
 359    private final GenericReferenceTypeNamePrimary _prev;
 360  0 public IdGenericReferenceTypeNamePrimary(GenericReferenceTypeNamePrimary prev, Token id) {
 361  0 super(ConsList.cons(new TreeToken(id, file), prev._reversed),
 362    ConsList.cons(new LinkedList<TypeName>(), prev._targsReversed),
 363    _range(prev, id));
 364  0 _prev = prev;
 365    }
 366  0 @Override public Primary withTypeArgs(List<TypeName> targs, Token last) {
 367  0 ConsList.Nonempty<List<TypeName>> newTargs = ConsList.cons(targs, _targsReversed.rest());
 368  0 return new GenericReferenceTypeNamePrimary(_reversed, newTargs, _range(this, last));
 369    }
 370  0 @Override public Primary withArgs(List<Expression> args, Token last) {
 371  0 return new ExpressionPrimary(new StaticMethodCall(_prev.asTypeName(), _reversed.first().image(),
 372    args, _range(this, last)));
 373    }
 374    }
 375   
 376    /** An array type name. */
 377    class ArrayTypeNamePrimary extends Primary {
 378    private final ArrayTypeName _type;
 379  3 public ArrayTypeNamePrimary(ArrayTypeName type) { super(type.getSourceInfo()); _type = type; }
 380  2 @Override public Primary dotClass(Token t) {
 381  2 return new ExpressionPrimary(new TypeExpression(_type, _range(this, t)));
 382    }
 383  1 @Override public Primary withArrayDim(Token last) {
 384  1 return new ArrayTypeNamePrimary(new ArrayTypeName(_type, 1, false, _range(this, last)));
 385    }
 386    }
 387   
 388    /** A primitive type, which may be part of a class literal or an array type. */
 389    class PrimitiveTypeNamePrimary extends Primary {
 390    private final PrimitiveTypeName _type;
 391  8 public PrimitiveTypeNamePrimary(PrimitiveTypeName type) { super(type.getSourceInfo()); _type = type; }
 392  7 @Override public Primary dotClass(Token t) {
 393  7 return new ExpressionPrimary(new TypeExpression(_type, _range(this, t)));
 394    }
 395  1 @Override public Primary withArrayDim(Token last) {
 396  1 return new ArrayTypeNamePrimary(new ArrayTypeName(_type, 1, false, _range(this, last)));
 397    }
 398    }
 399   
 400    /** A "void" keyword, which may be part of a class literal. */
 401    class VoidTypeNamePrimary extends Primary {
 402    private final VoidTypeName _type;
 403  1 public VoidTypeNamePrimary(VoidTypeName type) { super(type.getSourceInfo()); _type = type; }
 404  1 @Override public Primary dotClass(Token t) {
 405  1 return new ExpressionPrimary(new TypeExpression(_type, _range(this, t)));
 406    }
 407    }
 408   
 409   
 410    /** Optional type arguments followed by a method name. */
 411    class PartialSimpleMethodCallPrimary extends Primary {
 412    private final Option<List<TypeName>> _targs;
 413    private final String _name;
 414  0 public PartialSimpleMethodCallPrimary(Option<List<TypeName>> targs, Token id, SourceInfo si) {
 415  0 super(si);
 416  0 _targs = targs;
 417  0 _name = id.image;
 418    }
 419  0 @Override public Primary withArgs(List<Expression> args, Token last) throws ParseException {
 420  0 SourceInfo si = _range(this, last);
 421  0 return new ExpressionPrimary(new SimpleMethodCall(_targs, _name, args, si));
 422    }
 423    }
 424   
 425    /** An expression followed by a dot and a name. May be followed by method arguments. */
 426    class ObjectFieldAccessPrimary extends CompletedPrimary {
 427    private final Expression _obj;
 428    private final String _name;
 429  23 public ObjectFieldAccessPrimary(Expression obj, Token id) {
 430  23 super(_range(obj, id));
 431  23 _obj = obj;
 432  23 _name = id.image;
 433    }
 434  0 public Expression asExpression() { return new ObjectFieldAccess(_obj, _name, getSourceInfo()); }
 435  23 @Override public Primary withArgs(List<Expression> args, Token last) {
 436  23 return new ExpressionPrimary(new ObjectMethodCall(_obj, _name, args, _range(this, last)));
 437    }
 438    }
 439   
 440    /** An expression followed by a dot, optional type arguments, and a method name. */
 441    class PartialObjectMethodCallPrimary extends Primary {
 442    private final Expression _obj;
 443    private final Option<List<TypeName>> _targs;
 444    private final String _name;
 445  0 public PartialObjectMethodCallPrimary(Expression obj, Option<List<TypeName>> targs, Token id) {
 446  0 super(_range(obj, id));
 447  0 _obj = obj;
 448  0 _targs = targs;
 449  0 _name = id.image;
 450    }
 451  0 @Override public Primary withArgs(List<Expression> args, Token last) {
 452  0 SourceInfo si = _range(this, last);
 453  0 return new ExpressionPrimary(new ObjectMethodCall(_obj, _targs, _name, args, si));
 454    }
 455    }
 456   
 457    /** A type followed by a dot, optional type arguments, and a method name. */
 458    class PartialStaticMethodCallPrimary extends Primary {
 459    private final TypeName _type;
 460    private final Option<List<TypeName>> _targs;
 461    private final String _name;
 462  0 PartialStaticMethodCallPrimary(TypeName type, Option<List<TypeName>> targs, Token id) {
 463  0 super(_range(type, id));
 464  0 _type = type;
 465  0 _targs = targs;
 466  0 _name = id.image;
 467    }
 468  0 @Override public Primary withArgs(List<Expression> args, Token last) {
 469  0 SourceInfo si = _range(this, last);
 470  0 return new ExpressionPrimary(new StaticMethodCall(_type, _targs, _name, args, si));
 471    }
 472    }
 473   
 474    /** The "this" keyword. May be a constructor call. */
 475    class ThisExpressionPrimary extends CompletedPrimary {
 476  0 public ThisExpressionPrimary(Token t) { super(_range(t, t)); }
 477  0 public Expression asExpression() {
 478  0 return new ThisExpression(Option.<String>none(), getSourceInfo());
 479    }
 480  0 @Override public Primary withArgs(List<Expression> args, Token last) {
 481  0 return new ConstructorCallPrimary(new ConstructorCall(null, args, false, _range(this, last)));
 482    }
 483    }
 484   
 485    /** A "this" keyword prefixed by optional type arguments. */
 486    class PartialThisConstructorCallPrimary extends Primary {
 487    private final Option<List<TypeName>> _targs;
 488  0 public PartialThisConstructorCallPrimary(Option<List<TypeName>> targs, SourceInfo si) {
 489  0 super(si);
 490  0 _targs = targs;
 491    }
 492  0 @Override public Primary withArgs(List<Expression> args, Token last) throws ParseException {
 493  0 if (_targs.isSome()) {
 494  0 return _throwParseException("Parameterized this constructor calls are not yet supported");
 495    }
 496  0 return new ConstructorCallPrimary(new ConstructorCall(null, args, false, _range(this, last)));
 497    }
 498    }
 499   
 500    /** The "super" keyword, optionally prefixed by a dotted name. May be a constructor call or a field/method access. */
 501    class PartialSuperPrimary extends Primary {
 502    private final LinkedList<IdentifierToken> _ids; // may be null
 503  47 public PartialSuperPrimary(Token t) { super(_range(t, t)); _ids = null; }
 504  0 public PartialSuperPrimary(LinkedList<IdentifierToken> ids, Token t) {
 505  0 super(_range(ids.getFirst(), t));
 506  0 _ids = ids;
 507    }
 508  1 @Override public Primary dotId(Option<List<TypeName>> targs, Token id) {
 509  1 Option<String> cn = (_ids == null) ? Option.<String>none() : Option.some(TreeUtilities.listToName(_ids));
 510  1 if (targs.isNone()) { return new SuperFieldAccessPrimary(cn, id, _range(this, id)); }
 511  0 else { return new PartialSuperMethodCallPrimary(cn, targs, id, _range(this, id)); }
 512    }
 513  46 @Override public Primary withArgs(List<Expression> args, Token last) {
 514  46 Expression outer = null;
 515  0 if (_ids != null) { outer = new AmbiguousName(_ids, _range(_ids.getFirst(), _ids.getLast())); }
 516  46 return new ConstructorCallPrimary(new ConstructorCall(outer, args, true, _range(this, last)));
 517    }
 518    }
 519   
 520    /** A "super" keyword prefixed by optional type arguments. Optionally prefixed by an outer expression. */
 521    class PartialSuperConstructorCallPrimary extends Primary {
 522    private final Expression _outer; // may be null
 523    private final Option<List<TypeName>> _targs;
 524  0 public PartialSuperConstructorCallPrimary(Option<List<TypeName>> targs, SourceInfo si) {
 525  0 super(si);
 526  0 _outer = null;
 527  0 _targs = targs;
 528    }
 529  0 public PartialSuperConstructorCallPrimary(Expression outer, Option<List<TypeName>> targs, Token last) {
 530  0 super(_range(outer, last));
 531  0 _outer = outer;
 532  0 _targs = targs;
 533    }
 534  0 @Override public Primary withArgs(List<Expression> args, Token last) throws ParseException {
 535  0 if (_targs.isSome()) {
 536  0 return _throwParseException("Parameterized super constructor calls are not yet supported");
 537    }
 538  0 return new ConstructorCallPrimary(new ConstructorCall(_outer, args, true, _range(this, last)));
 539    }
 540    }
 541   
 542    /**
 543    * A "super" keyword (optionally prefixed by a name), followed by a dot and a name. May be followed by
 544    * method arguments.
 545    */
 546    class SuperFieldAccessPrimary extends CompletedPrimary {
 547    private final Option<String> _className;
 548    private final String _name;
 549  1 public SuperFieldAccessPrimary(Option<String> className, Token id, SourceInfo si) {
 550  1 super(si);
 551  1 _className = className;
 552  1 _name = id.image;
 553    }
 554  1 public Expression asExpression() throws ParseException {
 555  1 return new SuperFieldAccess(_className, _name, getSourceInfo());
 556    }
 557  0 @Override public Primary withArgs(List<Expression> args, Token last) throws ParseException {
 558  0 return new ExpressionPrimary(new SuperMethodCall(_className, _name, args, _range(this, last)));
 559    }
 560    }
 561   
 562    /**
 563    * A "super" keyword (optionally prefixed by a name), followed by a dot, optional type arguments, and
 564    * a method name.
 565    */
 566    class PartialSuperMethodCallPrimary extends Primary {
 567    private final Option<String> _className;
 568    private final Option<List<TypeName>> _targs;
 569    private final String _name;
 570  0 PartialSuperMethodCallPrimary(Option<String> className, Option<List<TypeName>> targs, Token id,
 571    SourceInfo si) {
 572  0 super(si);
 573  0 _className = className;
 574  0 _targs = targs;
 575  0 _name = id.image;
 576    }
 577  0 @Override public Primary withArgs(List<Expression> args, Token last) throws ParseException {
 578  0 SourceInfo si = _range(this, last);
 579  0 return new ExpressionPrimary(new SuperMethodCall(_className, _targs, _name, args, si));
 580    }
 581    }
 582   
 583    /** A "new" keyword followed by optional type arguments and a type. */
 584    class PartialSimpleAllocationPrimary extends Primary {
 585    private final Option<List<TypeName>> _targs;
 586    private final ReferenceTypeName _type;
 587  495 public PartialSimpleAllocationPrimary(Option<List<TypeName>> targs, ReferenceTypeName type, SourceInfo si) {
 588  495 super(si);
 589  495 _targs = targs;
 590  495 _type = type;
 591    }
 592  495 @Override public Primary withArgs(List<Expression> args, Token last) {
 593  495 return new SimpleAllocationPrimary(_targs, _type, args, _range(this, last));
 594    }
 595    }
 596   
 597    /**
 598    * A "new" keyword followed by optional type arguments, a type, and constructor arguments. May
 599    * be an anonymous allocation if followed by a class body.
 600    */
 601    class SimpleAllocationPrimary extends CompletedPrimary {
 602    private final Option<List<TypeName>> _targs;
 603    private final ReferenceTypeName _type;
 604    private final List<Expression> _args;
 605  495 public SimpleAllocationPrimary(Option<List<TypeName>> targs, ReferenceTypeName type, List<Expression> args,
 606    SourceInfo si) {
 607  495 super(si);
 608  495 _targs = targs;
 609  495 _type = type;
 610  495 _args = args;
 611    }
 612  494 public Expression asExpression() {
 613  494 return new SimpleAllocation(_targs, _type, _args, getSourceInfo());
 614    }
 615  1 @Override public Primary withClassBody(List<Node> members, Token last) {
 616  1 SourceInfo si = _range(this, last);
 617  1 return new ExpressionPrimary(new AnonymousAllocation(_targs, _type, _args, members, si));
 618    }
 619    }
 620   
 621    /** An expression followed by a dot, "new", optional type arguments, and a class name. */
 622    class PartialInnerAllocationPrimary extends Primary {
 623    private final Expression _outer;
 624    private final Option<List<TypeName>> _targs;
 625    private final String _name;
 626  1 public PartialInnerAllocationPrimary(Expression outer, Option<List<TypeName>> targs, Token id) {
 627  1 super(_range(outer, id));
 628  1 _outer = outer;
 629  1 _targs = targs;
 630  1 _name = id.image;
 631    }
 632  0 @Override public Primary withTypeArgs(List<TypeName> args, Token last) {
 633  0 return new PartialGenericInnerAllocationPrimary(_outer, _targs, _name, args, last);
 634    }
 635  1 @Override public Primary withArgs(List<Expression> args, Token last) {
 636  1 return new InnerAllocationPrimary(_outer, _targs, _name, Option.<List<TypeName>>none(), args, last);
 637    }
 638    }
 639   
 640    /** An expression followed by a dot, "new", optional type arguments, a class name, and class type arguments. */
 641    class PartialGenericInnerAllocationPrimary extends Primary {
 642    private final Expression _outer;
 643    private final Option<List<TypeName>> _targs;
 644    private final String _name;
 645    private final List<TypeName> _ctargs;
 646  0 public PartialGenericInnerAllocationPrimary(Expression outer, Option<List<TypeName>> targs, String name,
 647    List<TypeName> ctargs, Token last) {
 648  0 super(_range(outer, last));
 649  0 _outer = outer;
 650  0 _targs = targs;
 651  0 _name = name;
 652  0 _ctargs = ctargs;
 653    }
 654  0 @Override public Primary withArgs(List<Expression> args, Token last) {
 655  0 return new InnerAllocationPrimary(_outer, _targs, _name, Option.some(_ctargs), args, last);
 656    }
 657    }
 658   
 659    /**
 660    * An expresion followed by a dot, "new", optional type arguments, a class name, optional class type arguments,
 661    * and constructor arguments. May be an anonymous allocation if followed by a class body.
 662    */
 663    class InnerAllocationPrimary extends CompletedPrimary {
 664    private final Expression _outer;
 665    private final Option<List<TypeName>> _targs;
 666    private final String _name;
 667    private final Option<List<TypeName>> _ctargs;
 668    private final List<Expression> _args;
 669  1 public InnerAllocationPrimary(Expression outer, Option<List<TypeName>> targs, String name,
 670    Option<List<TypeName>> ctargs, List<Expression> args, Token last) {
 671  1 super(_range(outer, last));
 672  1 _outer = outer;
 673  1 _targs = targs;
 674  1 _name = name;
 675  1 _ctargs = ctargs;
 676  1 _args = args;
 677    }
 678  1 public Expression asExpression() {
 679  1 return new InnerAllocation(_outer, _targs, _name, _ctargs, _args, getSourceInfo());
 680    }
 681  0 @Override public Primary withClassBody(List<Node> members, Token last) {
 682  0 SourceInfo si = _range(this, last);
 683  0 return new ExpressionPrimary(new AnonymousInnerAllocation(_outer, _targs, _name, _ctargs, _args, members, si));
 684    }
 685    }
 686   
 687  0 void _errorChar(char c) throws ParseException {
 688  0 _throwParseException("'" + c + "' expected.");
 689    }
 690   
 691    /*
 692    * The syntactic grammar
 693    */
 694   
 695    // Productions for the intepreter ////////////////////////////////////////////////
 696   
 697    /**
 698    * Parses input stream. This production is
 699    * not a Java language rule. It is used by DynamicJava.
 700    * @return a list of nodes (possibly empty)
 701    * @see koala.dynamicjava.tree.Node
 702    */
 703  793 final public List<Node> parseStream() throws ParseException {
 704  793 List<Node> list = new LinkedList<Node>(); List<Node> ns;
 705  793 try {
 706  793 label_1:
 707    while (true) {
 708  1798 if (jj_2_1(1)) {
 709    ;
 710    } else {
 711  793 break label_1;
 712    }
 713  1005 ns = replStatement();
 714  1005 list.addAll(ns);
 715    }
 716  793 jj_consume_token(0);
 717  793 {if (true) return list;}
 718    } catch (ParseException pe) {
 719  0 _throwParseException(pe, "Invalid top level statement");
 720    }
 721  0 throw new Error("Missing return statement in function");
 722    }
 723   
 724    /**
 725    * Parses an item of the input stream. This production is
 726    * not a Java language rule. It is used by DynamicJava.
 727    * @return a list of nodes (a list because a single variable declaration
 728    * can be parsed to multiple VariableDeclaration nodes)
 729    * @see koala.dynamicjava.tree.Node
 730    */
 731  1005 final public List<Node> replStatement() throws ParseException {
 732  1005 ModifierSet mods; Node node = null; List<Node> nodes = null;
 733  1005 try {
 734  1005 if (jj_2_7(2)) {
 735  46 node = keywordStatement(false);
 736  959 } else if (jj_2_8(2)) {
 737  9 mods = modifiers();
 738  9 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 739  0 case PACKAGE:
 740  0 node = unmodifiedPackageDeclaration(mods, DeclType.REPL);
 741  0 break;
 742  1 case CLASS:
 743  0 case ENUM:
 744  0 case INTERFACE:
 745  0 case 132:
 746  1 node = unmodifiedTypeDeclaration(mods, DeclType.REPL);
 747  1 break;
 748  8 default:
 749  8 jj_la1[0] = jj_gen;
 750  8 if (jj_2_2(2147483647)) {
 751  1 node = unmodifiedMethodDeclaration(mods, DeclType.REPL);
 752  7 } else if (jj_2_3(2147483647)) {
 753  7 nodes = unmodifiedVariableDeclaration(mods, DeclType.REPL);
 754    } else {
 755  0 jj_consume_token(-1);
 756  0 throw new ParseException();
 757    }
 758    }
 759  950 } else if (jj_2_9(1)) {
 760  950 mods = noModifiers();
 761  950 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 762  1 case PACKAGE:
 763  1 node = unmodifiedPackageDeclaration(mods, DeclType.REPL);
 764  1 break;
 765  12 case IMPORT:
 766  12 node = importDeclaration();
 767  12 break;
 768  89 case CLASS:
 769  0 case ENUM:
 770  1 case INTERFACE:
 771  0 case 132:
 772  90 node = unmodifiedTypeDeclaration(mods, DeclType.REPL);
 773  90 break;
 774  847 default:
 775  847 jj_la1[1] = jj_gen;
 776  847 if (jj_2_4(2147483647)) {
 777  183 node = unmodifiedMethodDeclaration(mods, DeclType.REPL);
 778  664 } else if (jj_2_5(2147483647)) {
 779  441 nodes = unmodifiedVariableDeclaration(mods, DeclType.REPL);
 780  223 } else if (jj_2_6(1)) {
 781  223 node = nonKeywordStatement(false);
 782    } else {
 783  0 jj_consume_token(-1);
 784  0 throw new ParseException();
 785    }
 786    }
 787    } else {
 788  0 jj_consume_token(-1);
 789  0 throw new ParseException();
 790    }
 791  1005 {if (true) return (node != null) ? Collections.singletonList(node) : nodes;}
 792    } catch (ParseException pe) {
 793  0 _throwParseException(pe, "Invalid top level statement");
 794    }
 795  0 throw new Error("Missing return statement in function");
 796    }
 797   
 798    // Productions for Packages ////////////////////////////////////////////////////////
 799   
 800    /**
 801    * Parses a Java compilation unit
 802    * @return a list of nodes (possibly empty)
 803    * @see koala.dynamicjava.tree.Node
 804    */
 805  0 final public CompilationUnit parseCompilationUnit() throws ParseException {
 806  0 ModifierSet mods;
 807  0 Token start = getToken(1);
 808  0 PackageDeclaration pkg = null;
 809  0 List<ImportDeclaration> imps = new LinkedList<ImportDeclaration>();
 810  0 ImportDeclaration imp;
 811  0 List<Node> decls = new LinkedList<Node>();
 812  0 Node decl;
 813  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 814  0 case ABSTRACT:
 815  0 case CLASS:
 816  0 case ENUM:
 817  0 case FINAL:
 818  0 case IMPORT:
 819  0 case INTERFACE:
 820  0 case NATIVE:
 821  0 case PACKAGE:
 822  0 case PRIVATE:
 823  0 case PROTECTED:
 824  0 case PUBLIC:
 825  0 case STATIC:
 826  0 case STRICTFP:
 827  0 case SYNCHRONIZED:
 828  0 case TRANSIENT:
 829  0 case VOLATILE:
 830  0 case 132:
 831  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 832  0 case IMPORT:
 833  0 label_2:
 834    while (true) {
 835  0 imp = importDeclaration();
 836  0 imps.add(imp);
 837  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 838  0 case IMPORT:
 839    ;
 840  0 break;
 841  0 default:
 842  0 jj_la1[2] = jj_gen;
 843  0 break label_2;
 844    }
 845    }
 846  0 break;
 847  0 case ABSTRACT:
 848  0 case CLASS:
 849  0 case ENUM:
 850  0 case FINAL:
 851  0 case INTERFACE:
 852  0 case NATIVE:
 853  0 case PACKAGE:
 854  0 case PRIVATE:
 855  0 case PROTECTED:
 856  0 case PUBLIC:
 857  0 case STATIC:
 858  0 case STRICTFP:
 859  0 case SYNCHRONIZED:
 860  0 case TRANSIENT:
 861  0 case VOLATILE:
 862  0 case 132:
 863  0 mods = optionalModifiers();
 864  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 865  0 case PACKAGE:
 866  0 pkg = unmodifiedPackageDeclaration(mods, DeclType.TOP);
 867  0 label_3:
 868    while (true) {
 869  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 870  0 case IMPORT:
 871    ;
 872  0 break;
 873  0 default:
 874  0 jj_la1[3] = jj_gen;
 875  0 break label_3;
 876    }
 877  0 imp = importDeclaration();
 878  0 imps.add(imp);
 879    }
 880  0 break;
 881  0 case CLASS:
 882  0 case ENUM:
 883  0 case INTERFACE:
 884  0 case 132:
 885  0 decl = unmodifiedTypeDeclaration(mods, DeclType.TOP);
 886  0 decls.add(decl);
 887  0 break;
 888  0 default:
 889  0 jj_la1[4] = jj_gen;
 890  0 jj_consume_token(-1);
 891  0 throw new ParseException();
 892    }
 893  0 break;
 894  0 default:
 895  0 jj_la1[5] = jj_gen;
 896  0 jj_consume_token(-1);
 897  0 throw new ParseException();
 898    }
 899  0 label_4:
 900    while (true) {
 901  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 902  0 case ABSTRACT:
 903  0 case CLASS:
 904  0 case ENUM:
 905  0 case FINAL:
 906  0 case INTERFACE:
 907  0 case NATIVE:
 908  0 case PRIVATE:
 909  0 case PROTECTED:
 910  0 case PUBLIC:
 911  0 case STATIC:
 912  0 case STRICTFP:
 913  0 case SYNCHRONIZED:
 914  0 case TRANSIENT:
 915  0 case VOLATILE:
 916  0 case SEMICOLON:
 917  0 case 132:
 918    ;
 919  0 break;
 920  0 default:
 921  0 jj_la1[6] = jj_gen;
 922  0 break label_4;
 923    }
 924  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 925  0 case ABSTRACT:
 926  0 case CLASS:
 927  0 case ENUM:
 928  0 case FINAL:
 929  0 case INTERFACE:
 930  0 case NATIVE:
 931  0 case PRIVATE:
 932  0 case PROTECTED:
 933  0 case PUBLIC:
 934  0 case STATIC:
 935  0 case STRICTFP:
 936  0 case SYNCHRONIZED:
 937  0 case TRANSIENT:
 938  0 case VOLATILE:
 939  0 case 132:
 940  0 decl = typeDeclaration(DeclType.TOP);
 941  0 decls.add(decl);
 942  0 break;
 943  0 case SEMICOLON:
 944  0 jj_consume_token(SEMICOLON);
 945  0 break;
 946  0 default:
 947  0 jj_la1[7] = jj_gen;
 948  0 jj_consume_token(-1);
 949  0 throw new ParseException();
 950    }
 951    }
 952  0 break;
 953  0 default:
 954  0 jj_la1[8] = jj_gen;
 955    ;
 956    }
 957  0 jj_consume_token(0);
 958  0 {if (true) return new CompilationUnit(pkg, imps, decls, _range(start, token));}
 959  0 throw new Error("Missing return statement in function");
 960    }
 961   
 962  671 final public ModifierSet optionalModifiers() throws ParseException {
 963  671 ModifierSet mods = null;
 964  671 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 965  0 case ABSTRACT:
 966  0 case FINAL:
 967  0 case NATIVE:
 968  23 case PRIVATE:
 969  0 case PROTECTED:
 970  227 case PUBLIC:
 971  0 case STATIC:
 972  0 case STRICTFP:
 973  0 case SYNCHRONIZED:
 974  0 case TRANSIENT:
 975  0 case VOLATILE:
 976  0 case 132:
 977  250 mods = modifiers();
 978  250 {if (true) return mods;}
 979  0 break;
 980  421 default:
 981  421 jj_la1[9] = jj_gen;
 982  421 mods = noModifiers();
 983  421 {if (true) return mods;}
 984    }
 985  0 throw new Error("Missing return statement in function");
 986    }
 987   
 988    /** Create an empty modifier set at the current location. */
 989  1848 final public ModifierSet noModifiers() throws ParseException {
 990  1848 SourceInfo si = SourceInfo.point(file, getToken(1).beginLine, getToken(1).beginColumn);
 991  1848 {if (true) return new ModifierSet(EnumSet.noneOf(Modifier.class), new LinkedList<Annotation>(), si);}
 992  0 throw new Error("Missing return statement in function");
 993    }
 994   
 995    /**
 996    * Parse a nonempty list of modifiers and annotations
 997    */
 998  259 final public ModifierSet modifiers() throws ParseException {
 999  259 EnumSet<ModifierSet.Modifier> flags = EnumSet.noneOf(ModifierSet.Modifier.class);
 1000  259 Annotation ann;
 1001  259 List<Annotation> annots = new LinkedList<Annotation>();
 1002  259 Token first = getToken(1);
 1003  259 label_5:
 1004    while (true) {
 1005  261 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1006  1 case ABSTRACT:
 1007  1 jj_consume_token(ABSTRACT);
 1008  1 if (flags.contains(Modifier.ABSTRACT)) {
 1009  0 {if (true) throw new ParseError(reader.getMessage("abstract.abstract", null), _range(token, token));}
 1010    }
 1011  1 if (flags.contains(Modifier.FINAL)) {
 1012  0 {if (true) throw new ParseError(reader.getMessage("abstract.final", null), _range(token, token));}
 1013    }
 1014  1 if (flags.contains(Modifier.NATIVE)) {
 1015  0 {if (true) throw new ParseError(reader.getMessage("abstract.native", null), _range(token, token));}
 1016    }
 1017  1 flags.add(Modifier.ABSTRACT);
 1018  1 break;
 1019  0 case FINAL:
 1020  0 jj_consume_token(FINAL);
 1021  0 if (flags.contains(Modifier.FINAL)) {
 1022  0 {if (true) throw new ParseError(reader.getMessage("final.final", null), _range(token, token));}
 1023    }
 1024  0 if (flags.contains(Modifier.ABSTRACT)) {
 1025  0 {if (true) throw new ParseError(reader.getMessage("abstract.final", null), _range(token, token));}
 1026    }
 1027  0 flags.add(Modifier.FINAL);
 1028  0 break;
 1029  229 case PUBLIC:
 1030  229 jj_consume_token(PUBLIC);
 1031  229 if (flags.contains(Modifier.PUBLIC)) {
 1032  0 {if (true) throw new ParseError(reader.getMessage("public.public", null), _range(token, token));}
 1033    }
 1034  229 if (flags.contains(Modifier.PROTECTED)) {
 1035  0 {if (true) throw new ParseError(reader.getMessage("public.protected", null), _range(token, token));}
 1036    }
 1037  229 if (flags.contains(Modifier.PRIVATE)) {
 1038  0 {if (true) throw new ParseError(reader.getMessage("public.private", null), _range(token, token));}
 1039    }
 1040  229 flags.add(Modifier.PUBLIC);
 1041  229 break;
 1042  0 case PROTECTED:
 1043  0 jj_consume_token(PROTECTED);
 1044  0 if (flags.contains(Modifier.PROTECTED)) {
 1045  0 {if (true) throw new ParseError(reader.getMessage("protected.protected", null), _range(token, token));}
 1046    }
 1047  0 if (flags.contains(Modifier.PUBLIC)) {
 1048  0 {if (true) throw new ParseError(reader.getMessage("public.protected", null), _range(token, token));}
 1049    }
 1050  0 if (flags.contains(Modifier.PRIVATE)) {
 1051  0 {if (true) throw new ParseError(reader.getMessage("protected.private", null), _range(token, token));}
 1052    }
 1053  0 flags.add(Modifier.PROTECTED);
 1054  0 break;
 1055  23 case PRIVATE:
 1056  23 jj_consume_token(PRIVATE);
 1057  23 if (flags.contains(Modifier.PRIVATE)) {
 1058  0 {if (true) throw new ParseError(reader.getMessage("private.private", null), _range(token, token));}
 1059    }
 1060  23 if (flags.contains(Modifier.PUBLIC)) {
 1061  0 {if (true) throw new ParseError(reader.getMessage("public.private", null), _range(token, token));}
 1062    }
 1063  23 if (flags.contains(Modifier.PROTECTED)) {
 1064  0 {if (true) throw new ParseError(reader.getMessage("protected.private", null), _range(token, token));}
 1065    }
 1066  23 flags.add(Modifier.PRIVATE);
 1067  23 break;
 1068  0 case TRANSIENT:
 1069  0 jj_consume_token(TRANSIENT);
 1070  0 if (flags.contains(Modifier.TRANSIENT)) {
 1071  0 {if (true) throw new ParseError(reader.getMessage("transient.transient", null), _range(token, token));}
 1072    }
 1073  0 flags.add(Modifier.TRANSIENT);
 1074  0 break;
 1075  0 case VOLATILE:
 1076  0 jj_consume_token(VOLATILE);
 1077  0 if (flags.contains(Modifier.VOLATILE)) {
 1078  0 {if (true) throw new ParseError(reader.getMessage("volatile.volatile", null), _range(token, token));}
 1079    }
 1080  0 flags.add(Modifier.VOLATILE);
 1081  0 break;
 1082  0 case NATIVE:
 1083  0 jj_consume_token(NATIVE);
 1084  0 if (flags.contains(Modifier.NATIVE)) {
 1085  0 {if (true) throw new ParseError(reader.getMessage("native.native", null), _range(token, token));}
 1086    }
 1087  0 if (flags.contains(Modifier.ABSTRACT)) {
 1088  0 {if (true) throw new ParseError(reader.getMessage("abstract.native", null), _range(token, token));}
 1089    }
 1090  0 flags.add(Modifier.NATIVE);
 1091  0 break;
 1092  0 case STATIC:
 1093  0 jj_consume_token(STATIC);
 1094  0 if (flags.contains(Modifier.STATIC)) {
 1095  0 {if (true) throw new ParseError(reader.getMessage("static.static", null), _range(token, token));}
 1096    }
 1097  0 flags.add(Modifier.STATIC);
 1098  0 break;
 1099  0 case SYNCHRONIZED:
 1100  0 jj_consume_token(SYNCHRONIZED);
 1101  0 if (flags.contains(Modifier.SYNCHRONIZED)) {
 1102  0 {if (true) throw new ParseError(reader.getMessage("synchronized.synchronized", null), _range(token, token));}
 1103    }
 1104  0 flags.add(Modifier.SYNCHRONIZED);
 1105  0 break;
 1106  1 case STRICTFP:
 1107  1 jj_consume_token(STRICTFP);
 1108  1 if (flags.contains(Modifier.STRICT)) {
 1109  0 {if (true) throw new ParseError(reader.getMessage("strictfp.strictfp", null), _range(token, token));}
 1110    }
 1111  1 flags.add(Modifier.STRICT);
 1112  1 break;
 1113  7 case 132:
 1114  7 ann = annotation();
 1115  7 annots.add(ann);
 1116  7 break;
 1117  0 default:
 1118  0 jj_la1[10] = jj_gen;
 1119  0 jj_consume_token(-1);
 1120  0 throw new ParseException();
 1121    }
 1122  261 if (jj_2_10(2)) {
 1123    ;
 1124    } else {
 1125  259 break label_5;
 1126    }
 1127    }
 1128  259 {if (true) return new ModifierSet(flags, annots, _range(first, token));}
 1129  0 throw new Error("Missing return statement in function");
 1130    }
 1131   
 1132  0 final public PackageDeclaration packageDeclaration(DeclType level) throws ParseException {
 1133  0 ModifierSet mods; PackageDeclaration decl;
 1134  0 try {
 1135  0 mods = optionalModifiers();
 1136  0 decl = unmodifiedPackageDeclaration(mods, level);
 1137  0 {if (true) return decl;}
 1138    } catch (ParseException pe) {
 1139  0 _throwParseException(pe,"Invalid package declaration");
 1140    }
 1141  0 throw new Error("Missing return statement in function");
 1142    }
 1143   
 1144  1 final public PackageDeclaration unmodifiedPackageDeclaration(ModifierSet mods, DeclType level) throws ParseException {
 1145  1 ReferenceTypeName name = null;
 1146  1 try {
 1147  1 jj_consume_token(PACKAGE);
 1148  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1149  1 case IDENTIFIER:
 1150  1 name = referenceTypeName();
 1151  1 break;
 1152  0 default:
 1153  0 jj_la1[11] = jj_gen;
 1154    ;
 1155    }
 1156  1 optionalSemicolon();
 1157  1 if(name instanceof GenericReferenceTypeName){
 1158  0 _throwParseException("Package names cannot be parameterized.");
 1159    }
 1160  1 if(name == null) {
 1161  0 _throwParseException("Empty package name");
 1162    }
 1163  1 checkModifiers(mods); // only annotations are allowed
 1164  1 {if (true) return new PackageDeclaration(mods, name.getRepresentation(), _range(mods, token));}
 1165    } catch (ParseException pe) {
 1166  0 _throwParseException(pe,"Invalid package declaration");
 1167    }
 1168  0 throw new Error("Missing return statement in function");
 1169    }
 1170   
 1171  12 final public ImportDeclaration importDeclaration() throws ParseException {
 1172  12 ReferenceTypeName name = null;
 1173  12 Token star = null;
 1174  12 Token t1, t2;
 1175  12 Token sttic = null;
 1176  12 try {
 1177  12 t1 = jj_consume_token(IMPORT);
 1178  12 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1179  1 case STATIC:
 1180  1 sttic = jj_consume_token(STATIC);
 1181  1 break;
 1182  11 default:
 1183  11 jj_la1[12] = jj_gen;
 1184    ;
 1185    }
 1186  12 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1187  12 case IDENTIFIER:
 1188  12 name = referenceTypeName();
 1189  12 break;
 1190  0 default:
 1191  0 jj_la1[13] = jj_gen;
 1192    ;
 1193    }
 1194  12 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1195  11 case DOT:
 1196  11 jj_consume_token(DOT);
 1197  11 star = jj_consume_token(STAR);
 1198  11 break;
 1199  1 default:
 1200  1 jj_la1[14] = jj_gen;
 1201    ;
 1202    }
 1203  12 t2 = optionalSemicolon();
 1204  12 if(name instanceof GenericReferenceTypeName){
 1205  0 _throwParseException("Import names cannot be parameterized.");
 1206    }
 1207  12 if(name == null) {
 1208  0 _throwParseException("Missing name - Cannot import");
 1209    }
 1210  12 {if (true) return new ImportDeclaration(name.getRepresentation(), star != null, sttic != null, _range(t1, t2));}
 1211    } catch (ParseException pe) {
 1212  0 _throwParseException(pe,"Invalid Import Declaration");
 1213    }
 1214  0 throw new Error("Missing return statement in function");
 1215    }
 1216   
 1217  0 final public TypeDeclaration typeDeclaration(DeclType level) throws ParseException {
 1218  0 ModifierSet mods; TypeDeclaration decl;
 1219  0 try {
 1220  0 mods = optionalModifiers();
 1221  0 decl = unmodifiedTypeDeclaration(mods, level);
 1222  0 {if (true) return decl;}
 1223    } catch (ParseException pe) {
 1224  0 _throwParseException(pe,"Invalid declaration");
 1225    }
 1226  0 throw new Error("Missing return statement in function");
 1227    }
 1228   
 1229  91 final public TypeDeclaration unmodifiedTypeDeclaration(ModifierSet mods, DeclType level) throws ParseException {
 1230  91 TypeDeclaration node;
 1231  91 try {
 1232  91 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1233  90 case CLASS:
 1234  90 node = unmodifiedClassDeclaration(mods, level);
 1235  90 break;
 1236  0 case ENUM:
 1237  0 node = unmodifiedEnumDeclaration(mods, level);
 1238  0 break;
 1239  1 case INTERFACE:
 1240  0 case 132:
 1241  1 node = unmodifiedInterfaceDeclaration(mods, level);
 1242  1 break;
 1243  0 default:
 1244  0 jj_la1[15] = jj_gen;
 1245  0 jj_consume_token(-1);
 1246  0 throw new ParseException();
 1247    }
 1248  91 {if (true) return node;}
 1249    } catch (ParseException pe) {
 1250  0 _throwParseException(pe,"Invalid declaration");
 1251    }
 1252  0 throw new Error("Missing return statement in function");
 1253    }
 1254   
 1255    // Productions for Names ////////////////////////////////////////////////////////
 1256   
 1257    /**
 1258    * Parses a name
 1259    * @return a list of tree token
 1260    * @see koala.dynamicjava.parser.wrapper.TreeToken
 1261    */
 1262  69 final public List<IdentifierToken> name() throws ParseException {
 1263  69 Token id;
 1264  69 List<IdentifierToken> list = new LinkedList<IdentifierToken>();
 1265  69 id = jj_consume_token(IDENTIFIER);
 1266  69 list.add(new TreeToken(id, file));
 1267  69 label_6:
 1268    while (true) {
 1269  69 if (jj_2_11(2)) {
 1270    ;
 1271    } else {
 1272  69 break label_6;
 1273    }
 1274  0 jj_consume_token(DOT);
 1275  0 id = jj_consume_token(IDENTIFIER);
 1276  0 list.add(new TreeToken(id, file));
 1277    }
 1278  69 {if (true) return list;}
 1279  0 throw new Error("Missing return statement in function");
 1280    }
 1281   
 1282    // Production for a ReferenceTypeName ////////////////////////////////////////////////////////
 1283   
 1284    /**
 1285    * Consumes as large a name as possible: the type must not be followed by ".[id]" or "<", because
 1286    * the parser will assume those delimiters mark a continuation of the ReferenceTypeName.
 1287    */
 1288  1729 final public ReferenceTypeName referenceTypeName() throws ParseException {
 1289  1729 Token id = null;
 1290  1729 LinkedList<IdentifierToken> ids = new LinkedList<IdentifierToken>();
 1291  1729 List<TypeName> targs = null;
 1292  1729 boolean parameterized = false;
 1293  1729 List<List<? extends TypeName>> allTypeArgs = new LinkedList<List<? extends TypeName>>();
 1294  1729 try {
 1295  1729 id = jj_consume_token(IDENTIFIER);
 1296  1729 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1297  500 case LESS:
 1298  500 targs = typeArguments();
 1299  500 break;
 1300  1229 default:
 1301  1229 jj_la1[16] = jj_gen;
 1302    ;
 1303    }
 1304  1729 ids.add(new TreeToken(id, file));
 1305  1729 allTypeArgs.add((targs == null) ? new LinkedList<TypeName>() : targs);
 1306  1729 parameterized |= targs != null;
 1307  1729 targs = null;
 1308  1729 label_7:
 1309    while (true) {
 1310  2131 if (jj_2_12(2)) {
 1311    ;
 1312    } else {
 1313  1729 break label_7;
 1314    }
 1315  402 jj_consume_token(DOT);
 1316  402 id = jj_consume_token(IDENTIFIER);
 1317  402 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1318  7 case LESS:
 1319  7 targs = typeArguments();
 1320  7 break;
 1321  395 default:
 1322  395 jj_la1[17] = jj_gen;
 1323    ;
 1324    }
 1325  402 ids.add(new TreeToken(id, file));
 1326  402 allTypeArgs.add((targs == null) ? new LinkedList<TypeName>() : targs);
 1327  402 parameterized |= targs != null;
 1328  402 targs = null;
 1329    }
 1330  1729 SourceInfo si = _range(ids.getFirst(), token);
 1331  507 if (parameterized) { {if (true) return new GenericReferenceTypeName(ids, allTypeArgs, si);} }
 1332  1222 else { {if (true) return new ReferenceTypeName(ids, si);} }
 1333    } catch (ParseException pe) {
 1334  0 _throwParseException(pe,"Invalid reference name");
 1335    }
 1336  0 throw new Error("Missing return statement in function");
 1337    }
 1338   
 1339    /**
 1340    * Parses a comma separated list of ReferenceTypeName names
 1341    * @return a list of ReferenceTypeName
 1342    * @see koala.dynamicjava.tree.ReferenceTypeName
 1343    */
 1344  1 final public List<? extends ReferenceTypeName> ReferenceTypeNameList() throws ParseException {
 1345  1 List<ReferenceTypeName> list = new LinkedList<ReferenceTypeName>();
 1346  1 ReferenceTypeName obj;
 1347  1 obj = referenceTypeName();
 1348  1 list.add(obj);
 1349  1 label_8:
 1350    while (true) {
 1351  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1352  0 case COMMA:
 1353    ;
 1354  0 break;
 1355  1 default:
 1356  1 jj_la1[18] = jj_gen;
 1357  1 break label_8;
 1358    }
 1359  0 jj_consume_token(COMMA);
 1360  0 obj = referenceTypeName();
 1361  0 list.add(obj);
 1362    }
 1363  1 {if (true) return list;}
 1364  0 throw new Error("Missing return statement in function");
 1365    }
 1366   
 1367    // Productions for Classes //////////////////////////////////////////////////////
 1368   
 1369    // Productions for Class Declaration ============================================
 1370   
 1371    /**
 1372    * Parses a class declaration
 1373    * @see koala.dynamicjava.tree.ClassDeclaration
 1374    */
 1375  0 final public ClassDeclaration classDeclaration(DeclType level) throws ParseException {
 1376  0 ClassDeclaration cd; ModifierSet md;
 1377  0 md = optionalModifiers();
 1378  0 cd = unmodifiedClassDeclaration(md, level);
 1379  0 {if (true) return cd;}
 1380  0 throw new Error("Missing return statement in function");
 1381    }
 1382   
 1383    /**
 1384    * Parses a class declaration without modifier
 1385    * @see koala.dynamicjava.tree.ClassDeclaration
 1386    */
 1387  90 final public ClassDeclaration unmodifiedClassDeclaration(ModifierSet mods, DeclType level) throws ParseException {
 1388  90 Token t;
 1389  90 Token id;
 1390  90 List<TypeParameter> typeParameters = null;
 1391  90 ReferenceTypeName ext = null;
 1392  90 List<? extends ReferenceTypeName> impl = null;
 1393  90 List<Node> body;
 1394  90 t = jj_consume_token(CLASS);
 1395  90 id = jj_consume_token(IDENTIFIER);
 1396  90 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1397  69 case LESS:
 1398  69 typeParameters = typeParameters();
 1399  69 break;
 1400  21 default:
 1401  21 jj_la1[19] = jj_gen;
 1402    ;
 1403    }
 1404  90 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1405  47 case EXTENDS:
 1406  47 jj_consume_token(EXTENDS);
 1407  47 ext = referenceTypeName();
 1408  47 break;
 1409  43 default:
 1410  43 jj_la1[20] = jj_gen;
 1411    ;
 1412    }
 1413  90 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1414  1 case IMPLEMENTS:
 1415  1 jj_consume_token(IMPLEMENTS);
 1416  1 impl = ReferenceTypeNameList();
 1417  1 break;
 1418  89 default:
 1419  89 jj_la1[21] = jj_gen;
 1420    ;
 1421    }
 1422  90 body = classBody();
 1423  90 switch (level) {
 1424  0 case TOP: checkModifiers(mods, Modifier.PUBLIC, Modifier.FINAL, Modifier.ABSTRACT, Modifier.STRICT); break;
 1425  0 case CLASS_MEMBER: checkModifiers(mods, Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE,
 1426  0 Modifier.STATIC, Modifier.FINAL, Modifier.ABSTRACT, Modifier.STRICT); break;
 1427  0 case INTERFACE_MEMBER: checkModifiers(mods, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL,
 1428  0 Modifier.ABSTRACT, Modifier.STRICT); break;
 1429  0 case LOCAL: checkModifiers(mods, Modifier.FINAL, Modifier.ABSTRACT, Modifier.STRICT); break;
 1430  90 case REPL: checkModifiers(mods, Modifier.PUBLIC, Modifier.FINAL, Modifier.ABSTRACT, Modifier.STRICT); break;
 1431    }
 1432  90 {if (true) return new ClassDeclaration(mods, id.image, Option.wrap(typeParameters), ext, impl, body, _range(mods, token));}
 1433  0 throw new Error("Missing return statement in function");
 1434    }
 1435   
 1436    /**
 1437    * Used internally to parse the body of a class
 1438    */
 1439  91 final public List<Node> classBody() throws ParseException {
 1440  91 List<Node> list = new LinkedList<Node>();
 1441  91 List<Node> decl;
 1442  91 try {
 1443  91 jj_consume_token(LBRACE);
 1444  91 label_9:
 1445    while (true) {
 1446  342 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1447  0 case ABSTRACT:
 1448  0 case BOOLEAN:
 1449  0 case BYTE:
 1450  0 case CHAR:
 1451  0 case CLASS:
 1452  0 case DOUBLE:
 1453  0 case ENUM:
 1454  0 case FINAL:
 1455  0 case FLOAT:
 1456  0 case INT:
 1457  0 case INTERFACE:
 1458  0 case LONG:
 1459  0 case NATIVE:
 1460  23 case PRIVATE:
 1461  0 case PROTECTED:
 1462  227 case PUBLIC:
 1463  0 case SHORT:
 1464  0 case STATIC:
 1465  0 case STRICTFP:
 1466  0 case SYNCHRONIZED:
 1467  0 case TRANSIENT:
 1468  1 case VOID:
 1469  0 case VOLATILE:
 1470  0 case IDENTIFIER:
 1471  0 case LBRACE:
 1472  0 case SEMICOLON:
 1473  0 case LESS:
 1474  0 case 132:
 1475    ;
 1476  251 break;
 1477  91 default:
 1478  91 jj_la1[22] = jj_gen;
 1479  91 break label_9;
 1480    }
 1481  251 decl = classBodyDeclaration();
 1482  251 list.addAll(decl);
 1483    }
 1484  91 jj_consume_token(RBRACE);
 1485  91 {if (true) return list;}
 1486    } catch (ParseException pe) {
 1487  0 _throwParseException(pe,"Invalid class body");
 1488    }
 1489  0 throw new Error("Missing return statement in function");
 1490    }
 1491   
 1492    /**
 1493    * Parses one declaration in the body of a class.
 1494    * @return a list of node because one field declaration can
 1495    * contain multiple declarations.
 1496    * @see koala.dynamicjava.tree.Node
 1497    */
 1498  251 final public List<Node> classBodyDeclaration() throws ParseException {
 1499  251 ModifierSet mods;
 1500  251 Node node = null;
 1501  251 List<Node> list = new LinkedList<Node>();
 1502  251 try {
 1503  251 if (jj_2_16(2)) {
 1504  0 node = initializer();
 1505  0 list.add(node); {if (true) return list;}
 1506    } else {
 1507  251 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1508  0 case SEMICOLON:
 1509  0 jj_consume_token(SEMICOLON);
 1510  0 {if (true) return list;}
 1511  0 break;
 1512  0 case ABSTRACT:
 1513  0 case BOOLEAN:
 1514  0 case BYTE:
 1515  0 case CHAR:
 1516  0 case CLASS:
 1517  0 case DOUBLE:
 1518  0 case ENUM:
 1519  0 case FINAL:
 1520  0 case FLOAT:
 1521  0 case INT:
 1522  0 case INTERFACE:
 1523  0 case LONG:
 1524  0 case NATIVE:
 1525  23 case PRIVATE:
 1526  0 case PROTECTED:
 1527  227 case PUBLIC:
 1528  0 case SHORT:
 1529  0 case STATIC:
 1530  0 case STRICTFP:
 1531  0 case SYNCHRONIZED:
 1532  0 case TRANSIENT:
 1533  1 case VOID:
 1534  0 case VOLATILE:
 1535  0 case IDENTIFIER:
 1536  0 case LESS:
 1537  0 case 132:
 1538  251 mods = optionalModifiers();
 1539  251 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1540  0 case CLASS:
 1541  0 case ENUM:
 1542  0 case INTERFACE:
 1543  0 case 132:
 1544  0 node = unmodifiedTypeDeclaration(mods, DeclType.CLASS_MEMBER);
 1545  0 break;
 1546  251 default:
 1547  251 jj_la1[23] = jj_gen;
 1548  251 if (jj_2_13(2147483647)) {
 1549  69 node = unmodifiedConstructorDeclaration(mods);
 1550  182 } else if (jj_2_14(2147483647)) {
 1551  159 node = unmodifiedMethodDeclaration(mods, DeclType.CLASS_MEMBER);
 1552  23 } else if (jj_2_15(2147483647)) {
 1553  23 list = unmodifiedVariableDeclaration(mods, DeclType.CLASS_MEMBER);
 1554    } else {
 1555  0 jj_consume_token(-1);
 1556  0 throw new ParseException();
 1557    }
 1558    }
 1559  251 if (node != null) { list.add(node); } {if (true) return list;}
 1560  0 break;
 1561  0 default:
 1562  0 jj_la1[24] = jj_gen;
 1563  0 jj_consume_token(-1);
 1564  0 throw new ParseException();
 1565    }
 1566    }
 1567    } catch (ParseException pe) {
 1568  0 _throwParseException(pe,"Invalid member declaration");
 1569    }
 1570  0 throw new Error("Missing return statement in function");
 1571    }
 1572   
 1573    // Productions for variable declaration ============================================
 1574   
 1575    /**
 1576    * Parses a variable (field or local) declaration.
 1577    * @return a list of field declaration because one variable declaration can
 1578    * contain multiple declarations.
 1579    */
 1580  0 final public List<Node> variableDeclaration(DeclType level) throws ParseException {
 1581  0 ModifierSet mods; List<Node> decls;
 1582  0 try {
 1583  0 mods = optionalModifiers();
 1584  0 decls = unmodifiedVariableDeclaration(mods, level);
 1585  0 {if (true) return decls;}
 1586    } catch (ParseException pe) {
 1587  0 _throwParseException(pe, "Invalid variable declaration");
 1588    }
 1589  0 throw new Error("Missing return statement in function");
 1590    }
 1591   
 1592  692 final public List<Node> unmodifiedVariableDeclaration(ModifierSet mods, DeclType level) throws ParseException {
 1593  692 TypeName typ;
 1594  692 Token id;
 1595  692 int dim = 0;
 1596  692 Expression exp = null;
 1597  692 List<Node> list = new LinkedList<Node>();
 1598  692 try {
 1599  692 typ = type();
 1600  692 id = jj_consume_token(IDENTIFIER);
 1601  692 label_10:
 1602    while (true) {
 1603  692 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1604  0 case LBRACKET:
 1605    ;
 1606  0 break;
 1607  692 default:
 1608  692 jj_la1[25] = jj_gen;
 1609  692 break label_10;
 1610    }
 1611  0 jj_consume_token(LBRACKET);
 1612  0 jj_consume_token(RBRACKET);
 1613  0 dim++;
 1614    }
 1615  692 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1616  641 case ASSIGN:
 1617  641 jj_consume_token(ASSIGN);
 1618  641 exp = variableInitializer();
 1619  641 break;
 1620  51 default:
 1621  51 jj_la1[26] = jj_gen;
 1622    ;
 1623    }
 1624  692 switch (level) {
 1625  23 case CLASS_MEMBER:
 1626  23 checkModifiers(mods, Modifier.PUBLIC, Modifier.PRIVATE, Modifier.PROTECTED, Modifier.STATIC,
 1627    Modifier.FINAL, Modifier.VOLATILE, Modifier.TRANSIENT);
 1628  23 list.add(createFieldDeclaration(mods, typ, id, exp, dim));
 1629  23 break;
 1630  0 case INTERFACE_MEMBER:
 1631  0 checkModifiers(mods, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL);
 1632  0 list.add(createFieldDeclaration(mods, typ, id, exp, dim));
 1633  0 break;
 1634  448 case REPL:
 1635  448 checkModifiers(mods, Modifier.PUBLIC, Modifier.FINAL);
 1636  448 list.add(createVariableDeclaration(mods, typ, id, exp, dim));
 1637  448 break;
 1638  221 default:
 1639  221 checkModifiers(mods, Modifier.FINAL);
 1640  221 list.add(createVariableDeclaration(mods, typ, id, exp, dim));
 1641  221 break;
 1642    }
 1643  692 label_11:
 1644    while (true) {
 1645  694 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1646  2 case COMMA:
 1647    ;
 1648  2 break;
 1649  692 default:
 1650  692 jj_la1[27] = jj_gen;
 1651  692 break label_11;
 1652    }
 1653  2 jj_consume_token(COMMA);
 1654  2 dim = 0; exp = null;
 1655  2 id = jj_consume_token(IDENTIFIER);
 1656  2 label_12:
 1657    while (true) {
 1658  2 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1659  0 case LBRACKET:
 1660    ;
 1661  0 break;
 1662  2 default:
 1663  2 jj_la1[28] = jj_gen;
 1664  2 break label_12;
 1665    }
 1666  0 jj_consume_token(LBRACKET);
 1667  0 jj_consume_token(RBRACKET);
 1668  0 dim++;
 1669    }
 1670  2 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1671  1 case ASSIGN:
 1672  1 jj_consume_token(ASSIGN);
 1673  1 exp = variableInitializer();
 1674  1 break;
 1675  1 default:
 1676  1 jj_la1[29] = jj_gen;
 1677    ;
 1678    }
 1679  2 switch (level) {
 1680  0 case CLASS_MEMBER:
 1681  0 case INTERFACE_MEMBER:
 1682  0 list.add(createFieldDeclaration(mods, typ, id, exp, dim));
 1683  0 break;
 1684  2 default:
 1685  2 list.add(createVariableDeclaration(mods, typ, id, exp, dim));
 1686  2 break;
 1687    }
 1688    }
 1689  692 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1690  692 case SEMICOLON:
 1691  692 jj_consume_token(SEMICOLON);
 1692  692 break;
 1693  0 default:
 1694  0 jj_la1[30] = jj_gen;
 1695  0 Token lookahead = getToken(1);
 1696  0 boolean canSkip = !opt.requireSemicolon() && level.equals(DeclType.REPL) &&
 1697    (lookahead.kind == ParserConstants.EOF || lookahead.image.equals("}"));
 1698  0 if (!canSkip) {
 1699  0 _throwParseException("Invalid variable declaration");
 1700    }
 1701    }
 1702  692 {if (true) return list;}
 1703    } catch (ParseException pe) {
 1704  0 _throwParseException(pe, "Invalid variable declaration");
 1705    }
 1706  0 throw new Error("Missing return statement in function");
 1707    }
 1708   
 1709    // Productions for Method Declaration ===========================================
 1710  0 final public MethodDeclaration methodDeclaration(DeclType level) throws ParseException {
 1711  0 ModifierSet mods; MethodDeclaration decl;
 1712  0 try {
 1713  0 mods = optionalModifiers();
 1714  0 decl = unmodifiedMethodDeclaration(mods, level);
 1715  0 {if (true) return decl;}
 1716    } catch (ParseException pe) {
 1717  0 _throwParseException(pe, "Invalid method declaration");
 1718    }
 1719  0 throw new Error("Missing return statement in function");
 1720    }
 1721   
 1722  343 final public MethodDeclaration unmodifiedMethodDeclaration(ModifierSet mods, DeclType level) throws ParseException {
 1723  343 List<TypeParameter> typeParameters = null;
 1724  343 TypeName typ;
 1725  343 Token id;
 1726  343 int dim = 0;
 1727  343 List<FormalParameter> params;
 1728  343 List<? extends ReferenceTypeName> exceptions = new LinkedList<ReferenceTypeName>();
 1729  343 BlockStatement body = null;
 1730  343 try {
 1731  343 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1732  0 case LESS:
 1733  0 typeParameters = typeParameters();
 1734  0 break;
 1735  343 default:
 1736  343 jj_la1[31] = jj_gen;
 1737    ;
 1738    }
 1739  343 typ = resultType();
 1740  343 id = jj_consume_token(IDENTIFIER);
 1741  343 params = formalParameters();
 1742  343 label_13:
 1743    while (true) {
 1744  343 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1745  0 case LBRACKET:
 1746    ;
 1747  0 break;
 1748  343 default:
 1749  343 jj_la1[32] = jj_gen;
 1750  343 break label_13;
 1751    }
 1752  0 jj_consume_token(LBRACKET);
 1753  0 jj_consume_token(RBRACKET);
 1754  0 dim++;
 1755    }
 1756  343 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1757  0 case THROWS:
 1758  0 jj_consume_token(THROWS);
 1759  0 exceptions = ReferenceTypeNameList();
 1760  0 break;
 1761  343 default:
 1762  343 jj_la1[33] = jj_gen;
 1763    ;
 1764    }
 1765  343 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1766  343 case LBRACE:
 1767  343 body = block();
 1768  343 break;
 1769  0 case SEMICOLON:
 1770  0 jj_consume_token(SEMICOLON);
 1771  0 break;
 1772  0 default:
 1773  0 jj_la1[34] = jj_gen;
 1774  0 jj_consume_token(-1);
 1775  0 throw new ParseException();
 1776    }
 1777  343 switch (level) {
 1778  159 case CLASS_MEMBER:
 1779  159 checkModifiers(mods, Modifier.PUBLIC, Modifier.PRIVATE, Modifier.PROTECTED, Modifier.STATIC,
 1780    Modifier.FINAL, Modifier.ABSTRACT, Modifier.SYNCHRONIZED, Modifier.NATIVE,
 1781    Modifier.STRICT);
 1782  159 break;
 1783  0 case INTERFACE_MEMBER:
 1784  0 checkModifiers(mods, Modifier.PUBLIC, Modifier.ABSTRACT);
 1785  0 break;
 1786  184 case REPL:
 1787  184 checkModifiers(mods, Modifier.PUBLIC, Modifier.STRICT);
 1788  184 break;
 1789  0 default:
 1790  0 checkModifiers(mods, Modifier.STRICT);
 1791  0 break;
 1792    }
 1793  72 if (lastFormalParameterIsVarArgs) mods.getFlags().add(Modifier.VARARGS);
 1794   
 1795  343 if (dim > 0) {
 1796  0 typ = new ArrayTypeName(typ, dim, false, typ.getSourceInfo());
 1797    }
 1798  343 {if (true) return new MethodDeclaration(mods, Option.wrap(typeParameters), typ, id.image, params, exceptions, body,
 1799    _range(mods, token));}
 1800    } catch (ParseException pe) {
 1801  0 _throwParseException(pe, "Invalid method declaration");
 1802    }
 1803  0 throw new Error("Missing return statement in function");
 1804    }
 1805   
 1806    /**
 1807    * Parses formal parameters of the form '(param, param, ...)'
 1808    * @see koala.dynamicjava.tree.FormalParameter
 1809    */
 1810  412 final public List<FormalParameter> formalParameters() throws ParseException {
 1811  412 List<FormalParameter> list = new LinkedList<FormalParameter>();
 1812  412 FormalParameter node;
 1813  412 FormalParameter lastParam = null;
 1814  412 try {
 1815  412 jj_consume_token(LPAREN);
 1816  412 lastFormalParameterIsVarArgs = false;
 1817  412 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1818  0 case ABSTRACT:
 1819  183 case BOOLEAN:
 1820  0 case BYTE:
 1821  0 case CHAR:
 1822  0 case DOUBLE:
 1823  0 case FINAL:
 1824  0 case FLOAT:
 1825  54 case INT:
 1826  0 case LONG:
 1827  0 case NATIVE:
 1828  0 case PRIVATE:
 1829  0 case PROTECTED:
 1830  0 case PUBLIC:
 1831  0 case SHORT:
 1832  0 case STATIC:
 1833  0 case STRICTFP:
 1834  0 case SYNCHRONIZED:
 1835  0 case TRANSIENT:
 1836  0 case VOLATILE:
 1837  146 case IDENTIFIER:
 1838  0 case 132:
 1839  383 node = formalParameter();
 1840  383 list.add(node);
 1841  383 label_14:
 1842    while (true) {
 1843  419 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1844  36 case COMMA:
 1845    ;
 1846  36 break;
 1847  383 default:
 1848  383 jj_la1[35] = jj_gen;
 1849  383 break label_14;
 1850    }
 1851  36 jj_consume_token(COMMA);
 1852  0 if (lastFormalParameterIsVarArgs) _throwParseException("Varargs parameter must be last");
 1853  36 node = formalParameter();
 1854  36 list.add(node);
 1855    }
 1856  383 break;
 1857  29 default:
 1858  29 jj_la1[36] = jj_gen;
 1859    ;
 1860    }
 1861  412 jj_consume_token(RPAREN);
 1862  412 {if (true) return list;}
 1863    } catch (ParseException pe) {
 1864  0 _throwParseException(pe, "Invalid formal parameters");
 1865    }
 1866  0 throw new Error("Missing return statement in function");
 1867    }
 1868   
 1869    /**
 1870    * Parses one formal parameter
 1871    * @see koala.dynamicjava.tree.FormalParameter
 1872    */
 1873  420 final public FormalParameter formalParameter() throws ParseException {
 1874  420 ModifierSet mods;
 1875  420 TypeName typ;
 1876  420 Token id;
 1877  420 Token varargs = null;
 1878  420 int dim = 0;
 1879  420 try {
 1880  420 mods = optionalModifiers();
 1881  420 typ = type();
 1882  420 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1883  72 case VAR_ARGS:
 1884  72 varargs = jj_consume_token(VAR_ARGS);
 1885  72 break;
 1886  348 default:
 1887  348 jj_la1[37] = jj_gen;
 1888    ;
 1889    }
 1890  420 id = jj_consume_token(IDENTIFIER);
 1891  420 label_15:
 1892    while (true) {
 1893  420 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1894  0 case LBRACKET:
 1895    ;
 1896  0 break;
 1897  420 default:
 1898  420 jj_la1[38] = jj_gen;
 1899  420 break label_15;
 1900    }
 1901  0 jj_consume_token(LBRACKET);
 1902  0 jj_consume_token(RBRACKET);
 1903  0 dim++;
 1904    }
 1905  420 checkModifiers(mods, Modifier.FINAL);
 1906  420 if (dim > 0) {
 1907  0 typ = new ArrayTypeName(typ, dim, false, typ.getSourceInfo());
 1908    }
 1909  420 if (varargs != null) {
 1910  72 lastFormalParameterIsVarArgs = true;
 1911  72 typ = new ArrayTypeName(typ, 1, true, _range(typ, varargs));
 1912    }
 1913  420 {if (true) return new FormalParameter(mods, typ, id.image, _range(mods, token));}
 1914    } catch (ParseException pe) {
 1915  0 _throwParseException(pe, "Invalid formal parameter");
 1916    }
 1917  0 throw new Error("Missing return statement in function");
 1918    }
 1919   
 1920    // Production for Initializer ===================================================
 1921   
 1922    /**
 1923    * Parses one initializer
 1924    * @see koala.dynamicjava.tree.Initializer
 1925    */
 1926  0 final public Initializer initializer() throws ParseException {
 1927  0 Token t = null;
 1928  0 BlockStatement node;
 1929  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1930  0 case STATIC:
 1931  0 t = jj_consume_token(STATIC);
 1932  0 break;
 1933  0 default:
 1934  0 jj_la1[39] = jj_gen;
 1935    ;
 1936    }
 1937  0 node = block();
 1938  0 if (t == null) {
 1939  0 {if (true) return new InstanceInitializer(node, node.getSourceInfo());}
 1940    } else {
 1941  0 {if (true) return new ClassInitializer(node, _range(t, node));}
 1942    }
 1943  0 throw new Error("Missing return statement in function");
 1944    }
 1945   
 1946    // Productions for Constructor Declaration ======================================
 1947  0 final public ConstructorDeclaration constructorDeclaration() throws ParseException {
 1948  0 ModifierSet mods; ConstructorDeclaration decl;
 1949  0 try {
 1950  0 mods = optionalModifiers();
 1951  0 decl = unmodifiedConstructorDeclaration(mods);
 1952  0 {if (true) return decl;}
 1953    } catch (ParseException pe) {
 1954  0 _throwParseException(pe, "Invalid constructor declaration");
 1955    }
 1956  0 throw new Error("Missing return statement in function");
 1957    }
 1958   
 1959  69 final public ConstructorDeclaration unmodifiedConstructorDeclaration(ModifierSet mods) throws ParseException {
 1960  69 List<TypeParameter> typeParameters = null;
 1961  69 Token id;
 1962  69 List<FormalParameter> params;
 1963  69 List<? extends ReferenceTypeName> exceptions = new LinkedList<ReferenceTypeName>();
 1964  69 ConstructorCall ci = null;
 1965  69 List<Node> stmt;
 1966  69 LinkedList<Node> stmts = new LinkedList<Node>();
 1967  69 try {
 1968  69 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1969  0 case LESS:
 1970  0 typeParameters = typeParameters();
 1971  0 break;
 1972  69 default:
 1973  69 jj_la1[40] = jj_gen;
 1974    ;
 1975    }
 1976  69 id = jj_consume_token(IDENTIFIER);
 1977  69 params = formalParameters();
 1978  69 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 1979  0 case THROWS:
 1980  0 jj_consume_token(THROWS);
 1981  0 exceptions = ReferenceTypeNameList();
 1982  0 break;
 1983  69 default:
 1984  69 jj_la1[41] = jj_gen;
 1985    ;
 1986    }
 1987  69 jj_consume_token(LBRACE);
 1988  69 label_16:
 1989    while (true) {
 1990  138 if (jj_2_17(1)) {
 1991    ;
 1992    } else {
 1993  69 break label_16;
 1994    }
 1995  69 stmt = blockStatement();
 1996  69 stmts.addAll(stmt);
 1997    }
 1998  69 jj_consume_token(RBRACE);
 1999    // check for a constructor call ExpressionStatement
 2000  69 if (!stmts.isEmpty()) {
 2001  69 Node first = stmts.getFirst();
 2002  69 if (first instanceof ExpressionStatement) {
 2003  69 Expression exp = ((ExpressionStatement) first).getExpression();
 2004  69 if (exp instanceof ConstructorCall) {
 2005  46 ci = (ConstructorCall) exp;
 2006  46 stmts.removeFirst();
 2007    }
 2008    }
 2009    }
 2010  69 checkModifiers(mods, Modifier.PUBLIC, Modifier.PRIVATE, Modifier.PROTECTED);
 2011  0 if (lastFormalParameterIsVarArgs) mods.getFlags().add(Modifier.VARARGS);
 2012  69 {if (true) return new ConstructorDeclaration(mods, Option.wrap(typeParameters), id.image, params, exceptions, ci, stmts,
 2013    _range(mods, token));}
 2014    } catch (ParseException pe) {
 2015  0 _throwParseException(pe, "Invalid constructor declaration");
 2016    }
 2017  0 throw new Error("Missing return statement in function");
 2018    }
 2019   
 2020    // Productions for Interfaces ///////////////////////////////////////////////////
 2021   
 2022    /**
 2023    * Parses a interface declaration
 2024    * @see koala.dynamicjava.tree.InterfaceDeclaration
 2025    */
 2026  0 final public InterfaceDeclaration interfaceDeclaration(DeclType level) throws ParseException {
 2027  0 ModifierSet mods; InterfaceDeclaration decl;
 2028  0 try {
 2029  0 mods = optionalModifiers();
 2030  0 decl = unmodifiedInterfaceDeclaration(mods, level);
 2031  0 {if (true) return decl;}
 2032    } catch (ParseException pe) {
 2033  0 _throwParseException(pe, "Invalid interface declaration");
 2034    }
 2035  0 throw new Error("Missing return statement in function");
 2036    }
 2037   
 2038    /**
 2039    * Parses a interface declaration without modifier
 2040    * @see koala.dynamicjava.tree.InterfaceDeclaration
 2041    */
 2042  1 final public InterfaceDeclaration unmodifiedInterfaceDeclaration(ModifierSet mods, DeclType level) throws ParseException {
 2043  1 Token id;
 2044  1 Token isAnnotation = null;
 2045  1 List<TypeParameter> typeParameters = null;
 2046  1 List<? extends ReferenceTypeName> impl = null;
 2047  1 List<Node> list = new LinkedList<Node>();
 2048  1 List<Node> decl;
 2049  1 try {
 2050  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2051  0 case 132:
 2052  0 isAnnotation = jj_consume_token(132);
 2053  0 break;
 2054  1 default:
 2055  1 jj_la1[42] = jj_gen;
 2056    ;
 2057    }
 2058  1 jj_consume_token(INTERFACE);
 2059  1 id = jj_consume_token(IDENTIFIER);
 2060  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2061  0 case LESS:
 2062  0 typeParameters = typeParameters();
 2063  0 break;
 2064  1 default:
 2065  1 jj_la1[43] = jj_gen;
 2066    ;
 2067    }
 2068  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2069  0 case EXTENDS:
 2070  0 jj_consume_token(EXTENDS);
 2071  0 impl = ReferenceTypeNameList();
 2072  0 break;
 2073  1 default:
 2074  1 jj_la1[44] = jj_gen;
 2075    ;
 2076    }
 2077  1 jj_consume_token(LBRACE);
 2078  1 label_17:
 2079    while (true) {
 2080  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2081  0 case ABSTRACT:
 2082  0 case BOOLEAN:
 2083  0 case BYTE:
 2084  0 case CHAR:
 2085  0 case CLASS:
 2086  0 case DOUBLE:
 2087  0 case ENUM:
 2088  0 case FINAL:
 2089  0 case FLOAT:
 2090  0 case INT:
 2091  0 case INTERFACE:
 2092  0 case LONG:
 2093  0 case NATIVE:
 2094  0 case PRIVATE:
 2095  0 case PROTECTED:
 2096  0 case PUBLIC:
 2097  0 case SHORT:
 2098  0 case STATIC:
 2099  0 case STRICTFP:
 2100  0 case SYNCHRONIZED:
 2101  0 case TRANSIENT:
 2102  0 case VOID:
 2103  0 case VOLATILE:
 2104  0 case IDENTIFIER:
 2105  0 case SEMICOLON:
 2106  0 case LESS:
 2107  0 case 132:
 2108    ;
 2109  0 break;
 2110  1 default:
 2111  1 jj_la1[45] = jj_gen;
 2112  1 break label_17;
 2113    }
 2114  0 decl = interfaceMemberDeclaration();
 2115  0 list.addAll(decl);
 2116    }
 2117  1 jj_consume_token(RBRACE);
 2118  1 switch (level) {
 2119  0 case TOP: checkModifiers(mods, Modifier.PUBLIC, Modifier.ABSTRACT, Modifier.STRICT); break;
 2120  0 case CLASS_MEMBER: checkModifiers(mods, Modifier.PUBLIC, Modifier.PRIVATE, Modifier.PROTECTED,
 2121  0 Modifier.STATIC, Modifier.ABSTRACT, Modifier.STRICT); break;
 2122  0 case INTERFACE_MEMBER: checkModifiers(mods, Modifier.PUBLIC, Modifier.STATIC,
 2123  0 Modifier.ABSTRACT, Modifier.STRICT); break;
 2124  0 case LOCAL: checkModifiers(mods, Modifier.ABSTRACT, Modifier.STRICT); break;
 2125  1 case REPL: checkModifiers(mods, Modifier.PUBLIC, Modifier.ABSTRACT, Modifier.STRICT); break;
 2126    }
 2127   
 2128  1 {if (true) return new InterfaceDeclaration(mods, isAnnotation != null, id.image, Option.wrap(typeParameters), impl, list,
 2129    _range(mods, token));}
 2130    } catch (ParseException pe) {
 2131  0 _throwParseException(pe, "Invalid interface declaration");
 2132    }
 2133  0 throw new Error("Missing return statement in function");
 2134    }
 2135   
 2136    /**
 2137    * Parses one declaration in the body of an interface.
 2138    * @return a list of node because one field declaration can
 2139    * contain multiple declarations.
 2140    * @see koala.dynamicjava.tree.Node
 2141    */
 2142  0 final public List<Node> interfaceMemberDeclaration() throws ParseException {
 2143  0 ModifierSet mods;
 2144  0 Node node = null;
 2145  0 List<Node> list = new LinkedList<Node>();
 2146  0 try {
 2147  0 mods = optionalModifiers();
 2148  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2149  0 case CLASS:
 2150  0 case ENUM:
 2151  0 case INTERFACE:
 2152  0 case 132:
 2153  0 node = unmodifiedTypeDeclaration(mods, DeclType.INTERFACE_MEMBER);
 2154  0 break;
 2155  0 default:
 2156  0 jj_la1[46] = jj_gen;
 2157  0 if (jj_2_18(2147483647)) {
 2158  0 node = unmodifiedMethodDeclaration(mods, DeclType.INTERFACE_MEMBER);
 2159  0 } else if (jj_2_19(2147483647)) {
 2160  0 list = unmodifiedVariableDeclaration(mods, DeclType.INTERFACE_MEMBER);
 2161    } else {
 2162  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2163  0 case SEMICOLON:
 2164  0 jj_consume_token(SEMICOLON);
 2165  0 break;
 2166  0 default:
 2167  0 jj_la1[47] = jj_gen;
 2168  0 jj_consume_token(-1);
 2169  0 throw new ParseException();
 2170    }
 2171    }
 2172    }
 2173  0 if (node != null) { list.add(node); }
 2174  0 {if (true) return list;}
 2175    } catch (ParseException pe) {
 2176  0 _throwParseException(pe, "Invalid interface member declaration");
 2177    }
 2178  0 throw new Error("Missing return statement in function");
 2179    }
 2180   
 2181    // Productions for Enums ////////////////////////////////////////////////////////
 2182   
 2183    /**
 2184    * Parses an enum declaration
 2185    * @see koala.dynamicjava.tree.EnumDeclaration
 2186    */
 2187  0 final public EnumDeclaration enumDeclaration(DeclType level) throws ParseException {
 2188  0 ModifierSet mods; EnumDeclaration decl;
 2189  0 try {
 2190  0 mods = optionalModifiers();
 2191  0 decl = unmodifiedEnumDeclaration(mods, level);
 2192  0 {if (true) return decl;}
 2193    } catch (ParseException pe) {
 2194  0 _throwParseException(pe, "Invalid enum declaration");
 2195    }
 2196  0 throw new Error("Missing return statement in function");
 2197    }
 2198   
 2199  0 final public EnumDeclaration unmodifiedEnumDeclaration(ModifierSet mods, DeclType level) throws ParseException {
 2200  0 Token id;
 2201  0 List<? extends ReferenceTypeName> impl = null;
 2202  0 EnumDeclaration.EnumBody body;
 2203  0 jj_consume_token(ENUM);
 2204  0 id = jj_consume_token(IDENTIFIER);
 2205  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2206  0 case IMPLEMENTS:
 2207  0 jj_consume_token(IMPLEMENTS);
 2208  0 impl = ReferenceTypeNameList();
 2209  0 break;
 2210  0 default:
 2211  0 jj_la1[48] = jj_gen;
 2212    ;
 2213    }
 2214  0 jj_consume_token(LBRACE);
 2215  0 body = enumBody();
 2216  0 jj_consume_token(RBRACE);
 2217  0 switch (level) {
 2218  0 case TOP: checkModifiers(mods, Modifier.PUBLIC, Modifier.STRICT); break;
 2219  0 case CLASS_MEMBER: checkModifiers(mods, Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE,
 2220  0 Modifier.STATIC, Modifier.STRICT); break;
 2221  0 case INTERFACE_MEMBER: checkModifiers(mods, Modifier.PUBLIC, Modifier.STATIC, Modifier.STRICT); break;
 2222  0 case LOCAL: checkModifiers(mods, Modifier.STRICT); break;
 2223  0 case REPL: checkModifiers(mods, Modifier.PUBLIC, Modifier.STRICT); break;
 2224    }
 2225  0 {if (true) return new EnumDeclaration(mods, id.image, impl, body, _range(mods, token));}
 2226  0 throw new Error("Missing return statement in function");
 2227    }
 2228   
 2229    /**
 2230    * Parses the body of an enum
 2231    * @see koala.dynamicjava.tree.Node
 2232    */
 2233  0 final public EnumDeclaration.EnumBody enumBody() throws ParseException {
 2234  0 List<EnumDeclaration.EnumConstant> consts = null;
 2235  0 List<Node> decls = new LinkedList<Node>();
 2236  0 List<Node> ns;
 2237  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2238  0 case ABSTRACT:
 2239  0 case FINAL:
 2240  0 case NATIVE:
 2241  0 case PRIVATE:
 2242  0 case PROTECTED:
 2243  0 case PUBLIC:
 2244  0 case STATIC:
 2245  0 case STRICTFP:
 2246  0 case SYNCHRONIZED:
 2247  0 case TRANSIENT:
 2248  0 case VOLATILE:
 2249  0 case IDENTIFIER:
 2250  0 case 132:
 2251  0 consts = enumConstants();
 2252  0 break;
 2253  0 default:
 2254  0 jj_la1[49] = jj_gen;
 2255    ;
 2256    }
 2257  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2258  0 case SEMICOLON:
 2259  0 jj_consume_token(SEMICOLON);
 2260  0 label_18:
 2261    while (true) {
 2262  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2263  0 case ABSTRACT:
 2264  0 case BOOLEAN:
 2265  0 case BYTE:
 2266  0 case CHAR:
 2267  0 case CLASS:
 2268  0 case DOUBLE:
 2269  0 case ENUM:
 2270  0 case FINAL:
 2271  0 case FLOAT:
 2272  0 case INT:
 2273  0 case INTERFACE:
 2274  0 case LONG:
 2275  0 case NATIVE:
 2276  0 case PRIVATE:
 2277  0 case PROTECTED:
 2278  0 case PUBLIC:
 2279  0 case SHORT:
 2280  0 case STATIC:
 2281  0 case STRICTFP:
 2282  0 case SYNCHRONIZED:
 2283  0 case TRANSIENT:
 2284  0 case VOID:
 2285  0 case VOLATILE:
 2286  0 case IDENTIFIER:
 2287  0 case LBRACE:
 2288  0 case SEMICOLON:
 2289  0 case LESS:
 2290  0 case 132:
 2291    ;
 2292  0 break;
 2293  0 default:
 2294  0 jj_la1[50] = jj_gen;
 2295  0 break label_18;
 2296    }
 2297  0 ns = classBodyDeclaration();
 2298  0 decls.addAll(ns);
 2299    }
 2300  0 break;
 2301  0 default:
 2302  0 jj_la1[51] = jj_gen;
 2303    ;
 2304    }
 2305  0 {if (true) return new EnumDeclaration.EnumBody((consts==null) ? new LinkedList<EnumDeclaration.EnumConstant>() : consts,
 2306    decls);}
 2307  0 throw new Error("Missing return statement in function");
 2308    }
 2309   
 2310  0 final public List<EnumDeclaration.EnumConstant> enumConstants() throws ParseException {
 2311  0 List<EnumDeclaration.EnumConstant> list = new LinkedList<EnumDeclaration.EnumConstant>();
 2312  0 EnumDeclaration.EnumConstant c;
 2313  0 c = enumConstant();
 2314  0 list.add(c);
 2315  0 label_19:
 2316    while (true) {
 2317  0 if (jj_2_20(3)) {
 2318    ;
 2319    } else {
 2320  0 break label_19;
 2321    }
 2322  0 jj_consume_token(COMMA);
 2323  0 c = enumConstant();
 2324  0 list.add(c);
 2325    }
 2326  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2327  0 case COMMA:
 2328  0 jj_consume_token(COMMA);
 2329  0 break;
 2330  0 default:
 2331  0 jj_la1[52] = jj_gen;
 2332    ;
 2333    }
 2334  0 {if (true) return list;}
 2335  0 throw new Error("Missing return statement in function");
 2336    }
 2337   
 2338  0 final public EnumDeclaration.EnumConstant enumConstant() throws ParseException {
 2339  0 ModifierSet mods;
 2340  0 Token id;
 2341  0 List<Expression> args = null;
 2342  0 List<Node> body = null;
 2343  0 mods = optionalModifiers();
 2344  0 id = jj_consume_token(IDENTIFIER);
 2345  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2346  0 case LPAREN:
 2347  0 args = arguments();
 2348  0 break;
 2349  0 default:
 2350  0 jj_la1[53] = jj_gen;
 2351    ;
 2352    }
 2353  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2354  0 case LBRACE:
 2355  0 body = classBody();
 2356  0 break;
 2357  0 default:
 2358  0 jj_la1[54] = jj_gen;
 2359    ;
 2360    }
 2361  0 checkModifiers(mods); // can only have annotations
 2362  0 {if (true) return new EnumDeclaration.EnumConstant(mods, id.image, args, body, _range(mods, token));}
 2363  0 throw new Error("Missing return statement in function");
 2364    }
 2365   
 2366    // Productions for Arrays ////////////////////////////////////////////////////////
 2367   
 2368    /**
 2369    * Parses an array initializer
 2370    * @see koala.dynamicjava.tree.ArrayInitializer
 2371    */
 2372  13 final public ArrayInitializer arrayInitializer() throws ParseException {
 2373  13 Expression init;
 2374  13 Token t = null, b, e;
 2375  13 List<Expression> list = new LinkedList<Expression>();
 2376  13 b = jj_consume_token(LBRACE);
 2377  13 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2378  0 case BOOLEAN:
 2379  0 case BYTE:
 2380  0 case CHAR:
 2381  0 case DOUBLE:
 2382  0 case FALSE:
 2383  0 case FLOAT:
 2384  0 case INT:
 2385  0 case LONG:
 2386  0 case NEW:
 2387  0 case NULL:
 2388  0 case SHORT:
 2389  0 case SUPER:
 2390  0 case THIS:
 2391  0 case TRUE:
 2392  0 case VOID:
 2393  6 case INTEGER_LITERAL:
 2394  0 case LONG_LITERAL:
 2395  0 case FLOAT_LITERAL:
 2396  0 case DOUBLE_LITERAL:
 2397  0 case CHARACTER_LITERAL:
 2398  7 case STRING_LITERAL:
 2399  0 case IDENTIFIER:
 2400  0 case LPAREN:
 2401  0 case LBRACE:
 2402  0 case LESS:
 2403  0 case BANG:
 2404  0 case TILDE:
 2405  0 case INCREMENT:
 2406  0 case DECREMENT:
 2407  0 case PLUS:
 2408  0 case MINUS:
 2409  13 init = variableInitializer();
 2410  13 list.add(init);
 2411  13 label_20:
 2412    while (true) {
 2413  41 if (jj_2_21(2)) {
 2414    ;
 2415    } else {
 2416  13 break label_20;
 2417    }
 2418  28 jj_consume_token(COMMA);
 2419  28 init = variableInitializer();
 2420  28 list.add(init);
 2421    }
 2422  13 break;
 2423  0 default:
 2424  0 jj_la1[55] = jj_gen;
 2425    ;
 2426    }
 2427  13 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2428  0 case COMMA:
 2429  0 t = jj_consume_token(COMMA);
 2430  0 break;
 2431  13 default:
 2432  13 jj_la1[56] = jj_gen;
 2433    ;
 2434    }
 2435  13 e = jj_consume_token(RBRACE);
 2436  13 {if (true) return new ArrayInitializer(list, _range(b, e));}
 2437  0 throw new Error("Missing return statement in function");
 2438    }
 2439   
 2440    /**
 2441    * Parses a variable initializer (ie. an expression or an array initializer)
 2442    * @see koala.dynamicjava.tree.Expression
 2443    */
 2444  683 final public Expression variableInitializer() throws ParseException {
 2445  683 Expression exp;
 2446  683 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2447  0 case LBRACE:
 2448  0 exp = arrayInitializer();
 2449  0 break;
 2450  1 case BOOLEAN:
 2451  1 case BYTE:
 2452  1 case CHAR:
 2453  1 case DOUBLE:
 2454  48 case FALSE:
 2455  0 case FLOAT:
 2456  2 case INT:
 2457  1 case LONG:
 2458  190 case NEW:
 2459  4 case NULL:
 2460  1 case SHORT:
 2461  0 case SUPER:
 2462  0 case THIS:
 2463  1 case TRUE:
 2464  1 case VOID:
 2465  196 case INTEGER_LITERAL:
 2466  2 case LONG_LITERAL:
 2467  8 case FLOAT_LITERAL:
 2468  5 case DOUBLE_LITERAL:
 2469  7 case CHARACTER_LITERAL:
 2470  65 case STRING_LITERAL:
 2471  131 case IDENTIFIER:
 2472  10 case LPAREN:
 2473  0 case LESS:
 2474  0 case BANG:
 2475  0 case TILDE:
 2476  2 case INCREMENT:
 2477  2 case DECREMENT:
 2478  0 case PLUS:
 2479  3 case MINUS:
 2480  683 exp = expression();
 2481  683 break;
 2482  0 default:
 2483  0 jj_la1[57] = jj_gen;
 2484  0 jj_consume_token(-1);
 2485  0 throw new ParseException();
 2486    }
 2487  683 {if (true) return exp;}
 2488  0 throw new Error("Missing return statement in function");
 2489    }
 2490   
 2491    // Productions for Blocks And Statements ////////////////////////////////////////////
 2492   
 2493    /**
 2494    * Parses a block
 2495    * @see koala.dynamicjava.tree.BlockStatement
 2496    */
 2497  487 final public BlockStatement block() throws ParseException {
 2498  487 Token p1;
 2499  487 Token p2;
 2500  487 List<Node> nodes;
 2501  487 List<Node> list = new LinkedList<Node>();
 2502  487 try {
 2503  487 p1 = jj_consume_token(LBRACE);
 2504  487 label_21:
 2505    while (true) {
 2506  1215 if (jj_2_22(1)) {
 2507    ;
 2508    } else {
 2509  487 break label_21;
 2510    }
 2511  728 nodes = blockStatement();
 2512  728 list.addAll(nodes);
 2513    }
 2514  487 p2 = jj_consume_token(RBRACE);
 2515  487 {if (true) return new BlockStatement(list, _range(p1, p2));}
 2516    } catch (ParseException pe) {
 2517  0 _throwParseException(pe,"Invalid block statement");
 2518    }
 2519  0 throw new Error("Missing return statement in function");
 2520    }
 2521   
 2522    /**
 2523    * Parses one block statement.
 2524    * @return a list of node because one variable declaration can
 2525    * contain multiple declarations.
 2526    * @see koala.dynamicjava.tree.Node
 2527    */
 2528  801 final public List<Node> blockStatement() throws ParseException {
 2529  801 ModifierSet mods; Node node = null; List<Node> nodes = null;
 2530  801 try {
 2531  801 if (jj_2_26(2)) {
 2532  443 node = keywordStatement(true);
 2533  358 } else if (jj_2_27(2)) {
 2534  0 mods = modifiers();
 2535  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2536  0 case CLASS:
 2537  0 case ENUM:
 2538  0 case INTERFACE:
 2539  0 case 132:
 2540  0 node = unmodifiedTypeDeclaration(mods, DeclType.LOCAL);
 2541  0 break;
 2542  0 default:
 2543  0 jj_la1[58] = jj_gen;
 2544  0 if (jj_2_23(2147483647)) {
 2545  0 nodes = unmodifiedVariableDeclaration(mods, DeclType.LOCAL);
 2546    } else {
 2547  0 jj_consume_token(-1);
 2548  0 throw new ParseException();
 2549    }
 2550    }
 2551  358 } else if (jj_2_28(1)) {
 2552  358 mods = noModifiers();
 2553  358 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2554  0 case CLASS:
 2555  0 case ENUM:
 2556  0 case INTERFACE:
 2557  0 case 132:
 2558  0 node = unmodifiedTypeDeclaration(mods, DeclType.LOCAL);
 2559  0 break;
 2560  358 default:
 2561  358 jj_la1[59] = jj_gen;
 2562  358 if (jj_2_24(2147483647)) {
 2563  109 nodes = unmodifiedVariableDeclaration(mods, DeclType.LOCAL);
 2564  249 } else if (jj_2_25(1)) {
 2565  249 node = nonKeywordStatement(true);
 2566    } else {
 2567  0 jj_consume_token(-1);
 2568  0 throw new ParseException();
 2569    }
 2570    }
 2571    } else {
 2572  0 jj_consume_token(-1);
 2573  0 throw new ParseException();
 2574    }
 2575  801 {if (true) return (node != null) ? Collections.singletonList(node) : nodes;}
 2576    } catch (ParseException pe) {
 2577  0 _throwParseException(pe, "Invalid block statement");
 2578    }
 2579  0 throw new Error("Missing return statement in function");
 2580    }
 2581   
 2582  339 final public Node statement(boolean strictExpressions) throws ParseException {
 2583  339 Node node;
 2584  339 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2585  0 case ASSERT:
 2586  0 case BREAK:
 2587  0 case CONTINUE:
 2588  0 case DO:
 2589  0 case FOR:
 2590  2 case IF:
 2591  4 case RETURN:
 2592  0 case SWITCH:
 2593  0 case SYNCHRONIZED:
 2594  183 case THROW:
 2595  0 case TRY:
 2596  0 case WHILE:
 2597  139 case LBRACE:
 2598  0 case SEMICOLON:
 2599  328 node = keywordStatement(strictExpressions);
 2600  328 {if (true) return node;}
 2601  0 break;
 2602  11 default:
 2603  11 jj_la1[60] = jj_gen;
 2604  11 if (jj_2_29(1)) {
 2605  11 node = nonKeywordStatement(strictExpressions);
 2606  11 {if (true) return node;}
 2607    } else {
 2608  0 jj_consume_token(-1);
 2609  0 throw new ParseException();
 2610    }
 2611    }
 2612  0 throw new Error("Missing return statement in function");
 2613    }
 2614   
 2615    /** A statement that starts with a keyword or special delimiter. */
 2616  817 final public Node keywordStatement(boolean strictExpressions) throws ParseException {
 2617  817 Node node;
 2618  817 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2619  141 case LBRACE:
 2620  141 node = block();
 2621  141 break;
 2622  13 case SEMICOLON:
 2623  13 node = emptyStatement();
 2624  13 break;
 2625  202 case IF:
 2626  202 node = ifStatement();
 2627  202 break;
 2628  0 case ASSERT:
 2629  0 node = assertStatement();
 2630  0 break;
 2631  4 case WHILE:
 2632  4 node = whileStatement();
 2633  4 break;
 2634  4 case DO:
 2635  4 node = doStatement();
 2636  4 break;
 2637  1 case SWITCH:
 2638  1 node = switchStatement();
 2639  1 break;
 2640  119 case FOR:
 2641  119 node = forStatement();
 2642  119 break;
 2643  3 case BREAK:
 2644  3 node = breakStatement();
 2645  3 break;
 2646  1 case CONTINUE:
 2647  1 node = continueStatement();
 2648  1 break;
 2649  141 case RETURN:
 2650  141 node = returnStatement();
 2651  141 break;
 2652  186 case THROW:
 2653  186 node = throwStatement();
 2654  186 break;
 2655  1 case SYNCHRONIZED:
 2656  1 node = synchronizedStatement();
 2657  1 break;
 2658  1 case TRY:
 2659  1 node = tryStatement();
 2660  1 break;
 2661  0 default:
 2662  0 jj_la1[61] = jj_gen;
 2663  0 jj_consume_token(-1);
 2664  0 throw new ParseException();
 2665    }
 2666  817 {if (true) return node;}
 2667  0 throw new Error("Missing return statement in function");
 2668    }
 2669   
 2670    /** A statement that does not begin with a keyword (and thus may need special lookahead treatment). */
 2671  483 final public Node nonKeywordStatement(boolean strictExpressions) throws ParseException {
 2672  483 Node node;
 2673  483 if (jj_2_30(2)) {
 2674  1 node = labeledStatement();
 2675  1 {if (true) return node;}
 2676  482 } else if (jj_2_31(1)) {
 2677  482 node = expressionStatement(strictExpressions);
 2678  482 {if (true) return node;}
 2679    } else {
 2680  0 jj_consume_token(-1);
 2681  0 throw new ParseException();
 2682    }
 2683  0 throw new Error("Missing return statement in function");
 2684    }
 2685   
 2686    /**
 2687    * Parses a labeled statement
 2688    * @see koala.dynamicjava.tree.ContinueTarget
 2689    * @see koala.dynamicjava.tree.LabeledStatement
 2690    */
 2691  1 final public Statement labeledStatement() throws ParseException {
 2692  1 Token id;
 2693  1 Node node;
 2694  1 id = jj_consume_token(IDENTIFIER);
 2695  1 jj_consume_token(COLON);
 2696  1 node = statement(true);
 2697  1 if (node instanceof ContinueTarget) {
 2698  0 ((ContinueTarget)node).addLabel(id.image);
 2699  0 {if (true) return (Statement)node;}
 2700    } else {
 2701  1 {if (true) return new LabeledStatement(id.image, node, _range(id, node));}
 2702    }
 2703  0 throw new Error("Missing return statement in function");
 2704    }
 2705   
 2706    /**
 2707    * Parses an empty statement
 2708    * @see koala.dynamicjava.tree.EmptyStatement
 2709    */
 2710  13 final public EmptyStatement emptyStatement() throws ParseException {
 2711  13 Token t;
 2712  13 t = jj_consume_token(SEMICOLON);
 2713  13 {if (true) return new EmptyStatement(_range(t, t));}
 2714  0 throw new Error("Missing return statement in function");
 2715    }
 2716   
 2717    /**
 2718    * Parses an if statement
 2719    * @see koala.dynamicjava.tree.IfThenStatement
 2720    * @see koala.dynamicjava.tree.IfThenElseStatement
 2721    */
 2722  202 final public Statement ifStatement() throws ParseException {
 2723  202 Token t;
 2724  202 Expression exp;
 2725  202 Node stat1;
 2726  202 Node stat2 = null;
 2727  202 try {
 2728  202 t = jj_consume_token(IF);
 2729  202 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2730  202 case LPAREN:
 2731  202 jj_consume_token(LPAREN);
 2732  202 break;
 2733  0 default:
 2734  0 jj_la1[62] = jj_gen;
 2735  0 _errorChar('(');
 2736    }
 2737  202 exp = expression();
 2738  202 jj_consume_token(RPAREN);
 2739  202 stat1 = statement(true);
 2740  202 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2741  9 case ELSE:
 2742  9 jj_consume_token(ELSE);
 2743  9 stat2 = statement(true);
 2744  9 break;
 2745  193 default:
 2746  193 jj_la1[63] = jj_gen;
 2747    ;
 2748    }
 2749  202 if (stat2 == null) {
 2750  193 {if (true) return new IfThenStatement(exp, stat1, _range(t, stat1));}
 2751    } else {
 2752  9 {if (true) return new IfThenElseStatement(exp, stat1, stat2, _range(t, stat2));}
 2753    }
 2754    } catch (ParseException pe) {
 2755  0 _throwParseException(pe,"Invalid if statement");
 2756    }
 2757  0 throw new Error("Missing return statement in function");
 2758    }
 2759   
 2760    /**
 2761    * Parses an assert statement
 2762    * @see koala.dynamicjava.tree.AssertStatement
 2763    */
 2764  0 final public AssertStatement assertStatement() throws ParseException {
 2765  0 Token t, t2;
 2766  0 Expression exp, falseString = null;
 2767  0 try {
 2768  0 t = jj_consume_token(ASSERT);
 2769  0 exp = expression();
 2770  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2771  0 case COLON:
 2772  0 jj_consume_token(COLON);
 2773  0 falseString = expression();
 2774  0 break;
 2775  0 default:
 2776  0 jj_la1[64] = jj_gen;
 2777    ;
 2778    }
 2779  0 t2 = optionalSemicolon();
 2780  0 {if (true) return new AssertStatement(exp, falseString, _range(t, t2));}
 2781    } catch (ParseException pe) {
 2782  0 _throwParseException(pe,"Invalid assert statement");
 2783    }
 2784  0 throw new Error("Missing return statement in function");
 2785    }
 2786   
 2787    /**
 2788    * Parses a while statement
 2789    * @see koala.dynamicjava.tree.WhileStatement
 2790    */
 2791  4 final public WhileStatement whileStatement() throws ParseException {
 2792  4 Token t;
 2793  4 Expression exp;
 2794  4 Node stat;
 2795  4 try {
 2796  4 t = jj_consume_token(WHILE);
 2797  4 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2798  4 case LPAREN:
 2799  4 jj_consume_token(LPAREN);
 2800  4 break;
 2801  0 default:
 2802  0 jj_la1[65] = jj_gen;
 2803  0 _errorChar('(');
 2804    }
 2805  4 exp = expression();
 2806  4 jj_consume_token(RPAREN);
 2807  4 stat = statement(true);
 2808  4 {if (true) return new WhileStatement(exp, stat, _range(t, stat));}
 2809    } catch (ParseException pe) {
 2810  0 _throwParseException(pe,"Invalid while statement");
 2811    }
 2812  0 throw new Error("Missing return statement in function");
 2813    }
 2814   
 2815    /**
 2816    * Parses a do statement
 2817    * @see koala.dynamicjava.tree.DoStatement
 2818    */
 2819  4 final public DoStatement doStatement() throws ParseException {
 2820  4 Token t1, t2;
 2821  4 Expression exp;
 2822  4 Node stat;
 2823  4 try {
 2824  4 t1 = jj_consume_token(DO);
 2825  4 stat = statement(true);
 2826  4 jj_consume_token(WHILE);
 2827  4 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2828  4 case LPAREN:
 2829  4 jj_consume_token(LPAREN);
 2830  4 break;
 2831  0 default:
 2832  0 jj_la1[66] = jj_gen;
 2833  0 _errorChar('(');
 2834    }
 2835  4 exp = expression();
 2836  4 jj_consume_token(RPAREN);
 2837  4 t2 = optionalSemicolon();
 2838  4 {if (true) return new DoStatement(exp, stat, _range(t1, t2));}
 2839    } catch (ParseException pe) {
 2840  0 _throwParseException(pe,"Invalid do statement");
 2841    }
 2842  0 throw new Error("Missing return statement in function");
 2843    }
 2844   
 2845    /**
 2846    * Parses a switch statement
 2847    * @see koala.dynamicjava.tree.SwitchStatement
 2848    */
 2849  1 final public SwitchStatement switchStatement() throws ParseException {
 2850  1 Token b, e;
 2851  1 Expression sel;
 2852  1 SwitchBlock sb;
 2853  1 List<SwitchBlock> cases = new LinkedList<SwitchBlock>();
 2854  1 try {
 2855  1 b = jj_consume_token(SWITCH);
 2856  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2857  1 case LPAREN:
 2858  1 jj_consume_token(LPAREN);
 2859  1 break;
 2860  0 default:
 2861  0 jj_la1[67] = jj_gen;
 2862  0 _errorChar('(');
 2863    }
 2864  1 sel = expression();
 2865  1 jj_consume_token(RPAREN);
 2866  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2867  1 case LBRACE:
 2868  1 jj_consume_token(LBRACE);
 2869  1 break;
 2870  0 default:
 2871  0 jj_la1[68] = jj_gen;
 2872  0 _errorChar('{');
 2873    }
 2874  1 label_22:
 2875    while (true) {
 2876  4 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2877  3 case CASE:
 2878  0 case _DEFAULT:
 2879    ;
 2880  3 break;
 2881  1 default:
 2882  1 jj_la1[69] = jj_gen;
 2883  1 break label_22;
 2884    }
 2885  3 sb = switchBlock();
 2886  3 cases.add(sb);
 2887    }
 2888  1 e = jj_consume_token(RBRACE);
 2889  1 {if (true) return new SwitchStatement(sel, cases, _range(b, e));}
 2890    } catch (ParseException pe) {
 2891  0 _throwParseException(pe,"Invalid switch statement");
 2892    }
 2893  0 throw new Error("Missing return statement in function");
 2894    }
 2895   
 2896  3 final public SwitchBlock switchBlock() throws ParseException {
 2897  3 Token t, t2;
 2898  3 Expression val = null;
 2899  3 List<Node> stat;
 2900  3 List<Node> allStats = new LinkedList<Node>();
 2901  3 SourceInfo si;
 2902  3 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2903  3 case CASE:
 2904  3 t = jj_consume_token(CASE);
 2905  3 val = expression();
 2906  3 break;
 2907  0 case _DEFAULT:
 2908  0 t = jj_consume_token(_DEFAULT);
 2909  0 break;
 2910  0 default:
 2911  0 jj_la1[70] = jj_gen;
 2912  0 jj_consume_token(-1);
 2913  0 throw new ParseException();
 2914    }
 2915  3 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2916  3 case COLON:
 2917  3 t2 = jj_consume_token(COLON);
 2918  3 si = _range(t, t2);
 2919  3 break;
 2920  0 default:
 2921  0 jj_la1[71] = jj_gen;
 2922  0 _errorChar(':');
 2923  0 si = _range(t, t);
 2924    }
 2925  3 label_23:
 2926    while (true) {
 2927  7 if (jj_2_32(1)) {
 2928    ;
 2929    } else {
 2930  3 break label_23;
 2931    }
 2932  4 stat = blockStatement();
 2933  4 allStats.addAll(stat);
 2934  4 if (stat.size() > 0)
 2935  4 si = _range(si, stat.get(stat.size()-1).getSourceInfo());
 2936    }
 2937  3 {if (true) return new SwitchBlock(val, (allStats.isEmpty()) ? null: allStats, si);}
 2938  0 throw new Error("Missing return statement in function");
 2939    }
 2940   
 2941    /**
 2942    * Parses a for statement (with standard or foreach syntax)
 2943    * @see koala.dynamicjava.tree.ForStatement
 2944    * Modified by Adam Wulf and David Peters
 2945    * March 2004: Dr. Java team.
 2946    * @see koala.dynamicjava.tree.ForSlashEachStatement
 2947    * @see koala.dynamicjava.tree.ForEachStatement
 2948    */
 2949  119 final public ForSlashEachStatement forStatement() throws ParseException {
 2950  119 Token start;
 2951  119 ModifierSet mods;
 2952  119 FormalParameter param = null;
 2953  119 List<Node> init = null;
 2954  119 Expression exp = null;
 2955  119 List<Node> update = null;
 2956  119 Node stmt;
 2957  119 try {
 2958  119 start = jj_consume_token(FOR);
 2959  119 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2960  119 case LPAREN:
 2961  119 jj_consume_token(LPAREN);
 2962  119 break;
 2963  0 default:
 2964  0 jj_la1[72] = jj_gen;
 2965  0 _errorChar('(');
 2966    }
 2967  119 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 2968  0 case ABSTRACT:
 2969  0 case FINAL:
 2970  0 case NATIVE:
 2971  0 case PRIVATE:
 2972  0 case PROTECTED:
 2973  0 case PUBLIC:
 2974  0 case STATIC:
 2975  0 case STRICTFP:
 2976  0 case SYNCHRONIZED:
 2977  0 case TRANSIENT:
 2978  0 case VOLATILE:
 2979  0 case 132:
 2980  0 mods = modifiers();
 2981  0 if (jj_2_33(2147483647)) {
 2982  0 param = forEachParameter(mods);
 2983  0 jj_consume_token(COLON);
 2984  0 exp = expression();
 2985  0 } else if (jj_2_34(2147483647)) {
 2986  0 init = unmodifiedVariableDeclaration(mods, DeclType.LOCAL);
 2987    } else {
 2988  0 jj_consume_token(-1);
 2989  0 throw new ParseException();
 2990    }
 2991  0 break;
 2992  0 case BOOLEAN:
 2993  0 case BYTE:
 2994  0 case CHAR:
 2995  0 case DOUBLE:
 2996  0 case FALSE:
 2997  0 case FLOAT:
 2998  113 case INT:
 2999  0 case LONG:
 3000  0 case NEW:
 3001  0 case NULL:
 3002  0 case SHORT:
 3003  0 case SUPER:
 3004  0 case THIS:
 3005  0 case TRUE:
 3006  0 case VOID:
 3007  0 case INTEGER_LITERAL:
 3008  0 case LONG_LITERAL:
 3009  0 case FLOAT_LITERAL:
 3010  0 case DOUBLE_LITERAL:
 3011  0 case CHARACTER_LITERAL:
 3012  0 case STRING_LITERAL:
 3013  6 case IDENTIFIER:
 3014  0 case LPAREN:
 3015  0 case SEMICOLON:
 3016  0 case LESS:
 3017  0 case INCREMENT:
 3018  0 case DECREMENT:
 3019  119 mods = noModifiers();
 3020  119 if (jj_2_35(2147483647)) {
 3021  7 param = forEachParameter(mods);
 3022  7 jj_consume_token(COLON);
 3023  7 exp = expression();
 3024  112 } else if (jj_2_36(2147483647)) {
 3025  112 init = unmodifiedVariableDeclaration(mods, DeclType.LOCAL);
 3026    } else {
 3027  0 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 3028  0 case BOOLEAN:
 3029  0 case BYTE:
 3030  0 case CHAR:
 3031  0 case DOUBLE:
 3032  0 case FALSE:
 3033  0 case FLOAT:
 3034  0 case INT:
 3035  0 case LONG:
 3036  0 case NEW:
 3037  0 case NULL:
 3038  0 case SHORT:
 3039  0 case SUPER:
 3040  0 case THIS:
 3041  0 case TRUE:
 3042  0 case VOID:
 3043  0 case INTEGER_LITERAL:
 3044  0 case LONG_LITERAL:
 3045  0 case FLOAT_LITERAL:
 3046  0 case DOUBLE_LITERAL:
 3047  0 case CHARACTER_LITERAL:
 3048  0 case STRING_LITERAL:
 3049  0 case IDENTIFIER:
 3050  0 case LPAREN:
 3051  0 case LESS:
 3052  0 case INCREMENT:
 3053  0 case DECREMENT:
 3054  0 init = expressionStatementList();
 3055  0 jj_consume_token(SEMICOLON);
 3056  0 break;
 3057  0 case SEMICOLON:
 3058  0 jj_consume_token(SEMICOLON);
 3059  0 break;
 3060  0 default:
 3061  0 jj_la1[73] = jj_gen;
 3062  0 jj_consume_token(-1);
 3063  0 throw new ParseException();
 3064    }
 3065    }
 3066  119 break;
 3067  0 default:
 3068  0 jj_la1[74] = jj_gen;
 3069  0 jj_consume_token(-1);
 3070  0 throw new ParseException();
 3071    }
 3072  119 if (param == null) {
 3073  112 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 3074  0 case BOOLEAN:
 3075  0 case BYTE:
 3076  0 case CHAR:
 3077  0 case DOUBLE:
 3078  0 case FALSE:
 3079  0 case FLOAT:
 3080  0 case INT:
 3081  0 case LONG:
 3082  0 case NEW:
 3083  0 case NULL:
 3084  0 case SHORT:
 3085  0 case SUPER:
 3086  0 case THIS:
 3087  0 case TRUE:
 3088  0 case VOID:
 3089  0 case INTEGER_LITERAL:
 3090  0 case LONG_LITERAL:
 3091  0 case FLOAT_LITERAL:
 3092  0 case DOUBLE_LITERAL:
 3093  0 case CHARACTER_LITERAL:
 3094  0 case STRING_LITERAL:
 3095  111 case IDENTIFIER:
 3096  1 case LPAREN:
 3097  0 case LESS:
 3098  0 case BANG:
 3099  0 case TILDE:
 3100  0 case INCREMENT:
 3101  0 case DECREMENT:
 3102  0 case PLUS:
 3103  0 case MINUS:
 3104  112 exp = expression();
 3105  112 break;
 3106  0 default:
 3107  0 jj_la1[75] = jj_gen;
 3108    ;
 3109    }
 3110  112 jj_consume_token(SEMICOLON);
 3111  112 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 3112  0 case BOOLEAN:
 3113  0 case BYTE:
 3114  0 case CHAR:
 3115  0 case DOUBLE:
 3116  0 case FALSE:
 3117  0 case FLOAT:
 3118  0 case INT:
 3119  0 case LONG:
 3120  0 case NEW:
 3121  0 case NULL:
 3122  0 case SHORT:
 3123  0 case SUPER:
 3124  0 case THIS:
 3125  0 case TRUE:
 3126  0 case VOID:
 3127  0 case INTEGER_LITERAL:
 3128  0 case LONG_LITERAL:
 3129  0 case FLOAT_LITERAL:
 3130  0 case DOUBLE_LITERAL:
 3131  0 case CHARACTER_LITERAL:
 3132  0 case STRING_LITERAL:
 3133  111 case IDENTIFIER:
 3134  1 case LPAREN:
 3135  0 case LESS:
 3136  0 case INCREMENT:
 3137  0 case DECREMENT:
 3138  112 update = expressionStatementList();
 3139  112 break;
 3140  0 default:
 3141  0 jj_la1[76] = jj_gen;
 3142    ;
 3143    }
 3144    } else {
 3145    ;
 3146    }
 3147  119 jj_consume_token(RPAREN);
 3148  119 stmt = statement(true);
 3149  119 if (param == null) {
 3150  112 {if (true) return new ForStatement(init, exp, update, stmt, _range(start, stmt));}
 3151    }
 3152    else {
 3153  7 {if (true) return new ForEachStatement(param, exp, stmt, _range(start, stmt));}
 3154    }
 3155    } catch (ParseException pe) {
 3156  0 _throwParseException(pe,"Invalid for statement");
 3157    }
 3158  0 throw new Error("Missing return statement in function");
 3159    }
 3160   
 3161    /**
 3162    * A for-each parameter, which is more restricted than a general formal parameter (no additional array
 3163    * brackets, and no varargs)
 3164    */
 3165  7 final public FormalParameter forEachParameter(ModifierSet mods) throws ParseException {
 3166  7 TypeName typ; Token id; Expression exp;
 3167  7 typ = type();
 3168  7 id = jj_consume_token(IDENTIFIER);
 3169  7 checkModifiers(mods, Modifier.FINAL);
 3170  7 {if (true) return new FormalParameter(mods, typ, id.image, _range(mods, id));}
 3171  0 throw new Error("Missing return statement in function");
 3172    }
 3173   
 3174    /**
 3175    * Parses a comma separated list of strict ExpressionStatements
 3176    */
 3177  112 final public List<Node> expressionStatementList() throws ParseException {
 3178  112 List<Node> list = new LinkedList<Node>(); Expression exp;
 3179  112 exp = statementExpression();
 3180  112 list.add(new ExpressionStatement(exp, true, exp.getSourceInfo()));
 3181  112 label_24:
 3182    while (true) {
 3183  112 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 3184  0 case COMMA:
 3185    ;
 3186  0 break;
 3187  112 default:
 3188  112 jj_la1[77] = jj_gen;
 3189  112 break label_24;
 3190    }
 3191  0 jj_consume_token(COMMA);
 3192  0 exp = statementExpression();
 3193  0 list.add(new ExpressionStatement(exp, true, exp.getSourceInfo()));
 3194    }
 3195  112 {if (true) return list;}
 3196  0 throw new Error("Missing return statement in function");
 3197    }
 3198   
 3199    /**
 3200    * Parses a break statement
 3201    * @see koala.dynamicjava.tree.BreakStatement
 3202    */
 3203  3 final public BreakStatement breakStatement() throws ParseException {
 3204  3 Token b, e;
 3205  3 Token id = null;
 3206  3 try {
 3207  3 b = jj_consume_token(BREAK);
 3208  3 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 3209  0 case IDENTIFIER:
 3210  0 id = jj_consume_token(IDENTIFIER);
 3211  0 break;
 3212  3 default:
 3213  3 jj_la1[78] = jj_gen;
 3214    ;
 3215    }
 3216  3 e = jj_consume_token(SEMICOLON);
 3217  3 {if (true) return new BreakStatement((id != null) ? id.image : null, _range(b, e));}
 3218    } catch (ParseException pe) {
 3219  0 _throwParseException(pe,"Invalid break statement");
 3220    }
 3221  0 throw new Error("Missing return statement in function");
 3222    }
 3223   
 3224    /**
 3225    * Parses a continue statement
 3226    * @see koala.dynamicjava.tree.ContinueStatement
 3227    */
 3228  1 final public ContinueStatement continueStatement() throws ParseException {
 3229  1 Token b, e;
 3230  1 Token id = null;
 3231  1 try {
 3232  1 b = jj_consume_token(CONTINUE);
 3233  1 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 3234  0 case IDENTIFIER:
 3235  0 id = jj_consume_token(IDENTIFIER);
 3236  0 break;
 3237  1 default:
 3238  1 jj_la1[79] = jj_gen;
 3239    ;
 3240    }
 3241  1 e = jj_consume_token(SEMICOLON);
 3242  1 {if (true) return new ContinueStatement((id != null) ? id.image : null, _range(b, e));}
 3243    } catch (ParseException pe) {
 3244  0 _throwParseException(pe,"Invalid continue statement");
 3245    }
 3246  0 throw new Error("Missing return statement in function");
 3247    }
 3248   
 3249    /**
 3250    * Parses a return statement
 3251    * @see koala.dynamicjava.tree.ReturnStatement
 3252    */
 3253  141 final public ReturnStatement returnStatement() throws ParseException {
 3254  141 Token b, e;
 3255  141 Expression exp = null;
 3256  141 try {
 3257  141 b = jj_consume_token(RETURN);
 3258  141 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 3259  0 case BOOLEAN:
 3260  0 case BYTE:
 3261  0 case CHAR:
 3262  0 case DOUBLE:
 3263  2 case FALSE:
 3264  0 case FLOAT:
 3265  0 case INT:
 3266  0 case LONG:
 3267  0 case NEW:
 3268  0 case NULL:
 3269  0 case SHORT:
 3270  0 case SUPER:
 3271  0 case THIS:
 3272  3 case TRUE:
 3273  0 case VOID:
 3274  1 case INTEGER_LITERAL:
 3275  0 case LONG_LITERAL:
 3276  0 case FLOAT_LITERAL:
 3277  0 case DOUBLE_LITERAL:
 3278  0 case CHARACTER_LITERAL:
 3279  0 case STRING_LITERAL:
 3280  135 case IDENTIFIER:
 3281  0 case LPAREN:
 3282  0 case LESS:
 3283  0 case BANG:
 3284  0 case TILDE:
 3285  0 case INCREMENT:
 3286  0 case DECREMENT:
 3287  0 case PLUS:
 3288  0 case MINUS:
 3289  141 exp = expression();
 3290  141 break;
 3291  0 default:
 3292  0 jj_la1[80] = jj_gen;
 3293    ;
 3294    }
 3295  141 e = optionalSemicolon();
 3296  141 {if (true) return new ReturnStatement(exp, _range(b, e));}
 3297    } catch (ParseException pe) {
 3298  0 _throwParseException(pe,"Invalid return statement");
 3299    }
 3300  0 throw new Error("Missing return statement in function");
 3301    }
 3302   
 3303    /**
 3304    * Parses a throw statement
 3305    * @see koala.dynamicjava.tree.ThrowStatement
 3306    */
 3307  186 final public ThrowStatement throwStatement() throws ParseException {
 3308  186 Token b, e;
 3309  186 Expression exp;
 3310  186 try {
 3311  186 b = jj_consume_token(THROW);
 3312  186 exp = expression();
 3313  186 e = optionalSemicolon();
 3314  186 {if (true) return new ThrowStatement(exp, _range(b, e));}
 3315    } catch (ParseException pe) {
 3316  0 _throwParseException(pe,"Invalid throw statement");
 3317    }
 3318  0 throw new Error("Missing return statement in function");
 3319    }
 3320   
 3321    /**
 3322    * Parses a synchronized statement
 3323    * @see koala.dynamicjava.tree.SynchronizedStatement
 3324    */
 3325  1 final public SynchronizedStatement synchronizedStatement() throws ParseException {
 3326  1 Token t;
 3327  1 Expression exp;
 3328  1 Node stmt;
 3329  1 try {
 3330  1 t = jj_consume_token(SYNCHRONIZED);
 3331  1