{ $ = ; WhiteSpace = [\ \t\n\r]+ ; MultiLineComment = /\* ( [^/\*] | \n )* \*/ ; EndOfLineComment = \/\/ .* \n ; WSP = ( | | ) ; Digit = [0-9] ; Letter = [a-zA-Z_] ; Identifier = ( | )* ; Exponent = [eE] [+\-]? [0-9]+ ; FLit1 = [0-9]+ \. [0-9]* ? [fFdD]? ; FLit2 = \. [0-9]+ ? [fFdD]? ; FLit3 = [0-9]+ [fFdD]? ; FLit4 = [0-9]+ ? [fFdD] ; BooleanLiteral = true | false ; DecimalLiteral = 0 | [1-9] [0-9]* [lL]? ; HexLiteral = 0 [xX] [0-9a-fA-F]+ [lL]? ; OctalLiteral = 0 [0-7]* [lL]? ; FloatingPointLiteral = | | | ; Ucode = \\ u [0-9a-fA-F] ; Unicode = ; CharChar = [^\'\\\n\r] | ( \\ ( [ntbrf\\\'\"] | [0-7] [0-7]? | [0-3] [0-7] [0-7] ) ) | ; StringChar = [^\"\\\n\r] | ( \\ ( [ntbrf\\\'\"] | [0-7] [0-7]? | [0-3] [0-7] [0-7] ) ) | ; CharacterLiteral = \' \' ; StringLiteral = \" * \" ; Goal.unit : CompilationUnit ; // 19.3 Productions from §3: Lexical Structure IntegerLiteral.decimalliteral : DecimalLiteral ; IntegerLiteral.hexliteral : HexLiteral ; IntegerLiteral.octalliteral : OctalLiteral ; Literal.int : IntegerLiteral ; Literal.float : FloatingPointLiteral ; Literal.boolean : BooleanLiteral ; Literal.char : CharacterLiteral ; Literal.string : StringLiteral ; Literal.null : "null" ; // 19.4 Productions from §4: Types, Values, and Variables Type.primitive : PrimitiveType ; Type.reference : ReferenceType ; PrimitiveType.numeric : NumericType ; PrimitiveType.boolean : "boolean" ; NumericType.integral : IntegralType ; NumericType.float : FloatingPointType ; IntegralType.byte : "byte" ; IntegralType.short : "short" ; IntegralType.int : "int" ; IntegralType.long : "long" ; IntegralType.char : "char" ; FloatingPointType.float : "float" ; FloatingPointType.double : "double" ; ReferenceType.class : ClassOrInterfaceType ; ReferenceType.array : ArrayType ; ClassOrInterfaceType.name : Name ; ClassType.class : ClassOrInterfaceType ; InterfaceType.class : ClassOrInterfaceType ; ArrayType.primitive : PrimitiveType "[" "]" ; ArrayType.name : Name "[" "]" ; ArrayType.array : ArrayType "[" "]" ; // 19.5 Productions from §6: Names Name.simple : SimpleName ; Name.qualified : QualifiedName ; SimpleName.id : Identifier ; QualifiedName.name : Name "." Identifier ; // 19.6 Productions from §7: Packages CompilationUnit.unit : PackageDeclaration_opt ImportDeclarations_opt TypeDeclarations_opt ; ImportDeclarations_opt.absent : ; ImportDeclarations_opt.present : ImportDeclarations ; ImportDeclarations.one : ImportDeclaration ; ImportDeclarations.more : ImportDeclarations ImportDeclaration ; TypeDeclarations_opt.absent : ; TypeDeclarations_opt.present : TypeDeclarations ; TypeDeclarations.one : TypeDeclaration ; TypeDeclarations.more : TypeDeclarations TypeDeclaration ; PackageDeclaration_opt.absent : ; PackageDeclaration_opt.present : PackageDeclaration ; PackageDeclaration.package : "package" Name ";" ; ImportDeclaration.single : SingleTypeImportDeclaration ; ImportDeclaration.demand : TypeImportOnDemandDeclaration ; SingleTypeImportDeclaration.import : "import" Name ";" ; TypeImportOnDemandDeclaration.import : "import" Name "." "*" ";" ; TypeDeclaration.class : ClassDeclaration ; TypeDeclaration.interface : InterfaceDeclaration ; TypeDeclaration.semicolon : ";" ; // 19.7 Productions Used Only in the LALR(1) Grammar Modifiers_opt.absent : ; Modifiers_opt.present : Modifiers ; Modifiers.one : WSP Modifier ; Modifiers.more : Modifiers WSP Modifier ; Modifier.public : "public" ; Modifier.protected : "protected" ; Modifier.private : "private" ; Modifier.static : "static" ; Modifier.abstract : "abstract" ; Modifier.final : "final" ; Modifier.native : "native" ; Modifier.synchronized : "synchronized" ; Modifier.transient : "transient" ; Modifier.volatile : "volatile" ; // 19.8 Productions from §8: Classes // 19.8.1 Productions from §8.1: Class Declaration ClassDeclaration.class : Modifiers_opt "class" WSP Identifier Super_opt Interfaces_opt ClassBody ; Super_opt.absent : ; Super_opt.present : Super ; Super.extends : WSP "extends" ClassType ; Interfaces_opt.absent : ; Interfaces_opt.present : Interfaces ; Interfaces.implements : WSP "implements" InterfaceTypeList ; InterfaceTypeList.one : InterfaceType ; InterfaceTypeList.more : InterfaceTypeList "," InterfaceType ; ClassBody.body : "{" ClassBodyDeclarations_opt "}" ; ClassBodyDeclarations_opt.absent : ; ClassBodyDeclarations_opt.present : ClassBodyDeclarations ; ClassBodyDeclarations.one : ClassBodyDeclaration ; ClassBodyDeclarations.more : ClassBodyDeclarations ClassBodyDeclaration ; ClassBodyDeclaration.classmember : ClassMemberDeclaration ; ClassBodyDeclaration.static : StaticInitializer ; ClassBodyDeclaration.constructor : ConstructorDeclaration ; ClassMemberDeclaration.field : FieldDeclaration ; ClassMemberDeclaration.method : MethodDeclaration ; // 19.8.2 Productions from §8.3: Field Declarations FieldDeclaration.field : Modifiers_opt Type WSP VariableDeclarators ";" ; VariableDeclarators.one : VariableDeclarator ; VariableDeclarators.more : VariableDeclarators "," VariableDeclarator ; VariableDeclarator.var : VariableDeclaratorId ; VariableDeclarator.init : VariableDeclaratorId "=" VariableInitializer ; VariableDeclaratorId.id : Identifier ; VariableDeclaratorId.array : VariableDeclaratorId "[" "]" ; VariableInitializer.exp : Expression ; VariableInitializer.array : ArrayInitializer ; // 19.8.3 Productions from §8.4: Method Declarations MethodDeclaration.method : MethodHeader MethodBody ; MethodHeader.type : Modifiers_opt Type WSP MethodDeclarator Throws_opt ; MethodHeader.void : Modifiers_opt "void" WSP MethodDeclarator Throws_opt ; MethodDeclarator.id : Identifier "(" FormalParameterList_opt ")" ; MethodDeclarator.array : MethodDeclarator "[" "]" ; FormalParameterList_opt.absent : ; FormalParameterList_opt.present : FormalParameterList ; FormalParameterList.one : FormalParameter ; FormalParameterList.more : FormalParameterList "," FormalParameter ; FormalParameter.formal : Type WSP VariableDeclaratorId ; Throws_opt.absent : ; Throws_opt.present : Throws ; Throws.throws : WSP "throws" ClassTypeList ; ClassTypeList.one : ClassType ; ClassTypeList.more : ClassTypeList "," ClassType ; MethodBody.block : Block ; MethodBody.empty : ";" ; // 19.8.4 Productions from §8.5: Static Initializers StaticInitializer.static : "static" Block ; // 19.8.5 Productions from §8.6: Constructor Declarations ConstructorDeclaration.constructor : Modifiers_opt ConstructorDeclarator Throws_opt ConstructorBody ; ConstructorDeclarator.constructor : SimpleName "(" FormalParameterList_opt ")" ; ConstructorBody.body : "{" ExplicitConstructorInvocation_opt BlockStatements_opt "}" ; ExplicitConstructorInvocation_opt.absent : ; ExplicitConstructorInvocation_opt.present : ExplicitConstructorInvocation ; ExplicitConstructorInvocation.this : "this" "(" ArgumentList_opt ")" ";" ; ExplicitConstructorInvocation.super : "super" "(" ArgumentList_opt ")" ";" ; // 19.9 Productions from §9: Interfaces // 19.9.1 Productions from §9.1: Interface Declarations InterfaceDeclaration.interface : Modifiers_opt "interface" WSP Identifier ExtendsInterfaces_opt InterfaceBody ; ExtendsInterfaces_opt.absent : ; ExtendsInterfaces_opt.present : ExtendsInterfaces ; ExtendsInterfaces.one : WSP "extends" InterfaceType ; ExtendsInterfaces.more : ExtendsInterfaces "," InterfaceType ; InterfaceBody.body : "{" InterfaceMemberDeclarations_opt "}" ; InterfaceMemberDeclarations_opt.absent : ; InterfaceMemberDeclarations_opt.present : InterfaceMemberDeclarations ; InterfaceMemberDeclarations.one : InterfaceMemberDeclaration ; InterfaceMemberDeclarations.more : InterfaceMemberDeclarations InterfaceMemberDeclaration ; InterfaceMemberDeclaration.constant : ConstantDeclaration ; InterfaceMemberDeclaration.abstract : AbstractMethodDeclaration ; ConstantDeclaration.field : FieldDeclaration ; AbstractMethodDeclaration.method : MethodHeader ";" ; // 19.10 Productions from §10: Arrays ArrayInitializer.init : "{" VariableInitializers_opt Comma_opt "}" ; Comma_opt.absent : ; Comma_opt.present : "," ; VariableInitializers_opt.absent : ; VariableInitializers_opt.present : VariableInitializers ; VariableInitializers.one : VariableInitializer ; VariableInitializers.more : VariableInitializers "," VariableInitializer ; // 19.11 Productions from §14: Blocks and Statements Block.block : "{" BlockStatements_opt "}" ; BlockStatements_opt.absent : ; BlockStatements_opt.present : BlockStatements ; BlockStatements.one : BlockStatement ; BlockStatements.more : BlockStatements BlockStatement ; BlockStatement.local : LocalVariableDeclarationStatement ; BlockStatement.statement : Statement ; LocalVariableDeclarationStatement.local : LocalVariableDeclaration ";" ; LocalVariableDeclaration.local : Type WSP VariableDeclarators ; Statement.wts : StatementWithoutTrailingSubstatement ; Statement.label : LabeledStatement ; Statement.if : IfThenStatement ; Statement.ifelse : IfThenElseStatement ; Statement.while : WhileStatement ; Statement.for : ForStatement ; StatementNoShortIf.wts : StatementWithoutTrailingSubstatement ; StatementNoShortIf.label : LabeledStatementNoShortIf ; StatementNoShortIf.ifelse : IfThenElseStatementNoShortIf ; StatementNoShortIf.while : WhileStatementNoShortIf ; StatementNoShortIf.for : ForStatementNoShortIf ; StatementWithoutTrailingSubstatement.block : Block ; StatementWithoutTrailingSubstatement.empty : EmptyStatement ; StatementWithoutTrailingSubstatement.exp : ExpressionStatement ; StatementWithoutTrailingSubstatement.switch : SwitchStatement ; StatementWithoutTrailingSubstatement.do : DoStatement ; StatementWithoutTrailingSubstatement.break : BreakStatement ; StatementWithoutTrailingSubstatement.continue : ContinueStatement ; StatementWithoutTrailingSubstatement.return : ReturnStatement ; StatementWithoutTrailingSubstatement.synchronized : SynchronizedStatement ; StatementWithoutTrailingSubstatement.throw : ThrowStatement ; StatementWithoutTrailingSubstatement.try : TryStatement ; EmptyStatement.empty : ";" ; LabeledStatement.label : Identifier ":" Statement ; LabeledStatementNoShortIf.label : Identifier ":" StatementNoShortIf ; ExpressionStatement.stmexp : StatementExpression ";" ; StatementExpression.assignment : Assignment ; StatementExpression.preinc : PreIncrementExpression ; StatementExpression.predec : PreDecrementExpression ; StatementExpression.postinc : PostIncrementExpression ; StatementExpression.postdec : PostDecrementExpression ; StatementExpression.invoke : MethodInvocation ; StatementExpression.instance : ClassInstanceCreationExpression ; IfThenStatement.if : "if" "(" Expression ")" Statement ; IfThenElseStatement.if : "if" "(" Expression ")" StatementNoShortIf "else" Statement ; IfThenElseStatementNoShortIf.if : "if" "(" Expression ")" StatementNoShortIf "else" StatementNoShortIf ; SwitchStatement.switch : "switch" "(" Expression ")" SwitchBlock ; SwitchBlock.switchblock : "{" SwitchBlockStatementGroups_opt SwitchLabels_opt "}" ; SwitchBlockStatementGroups_opt.absent : ; SwitchBlockStatementGroups_opt.present : SwitchBlockStatementGroups ; SwitchBlockStatementGroups.one : SwitchBlockStatementGroup ; SwitchBlockStatementGroups.more : SwitchBlockStatementGroups SwitchBlockStatementGroup ; SwitchBlockStatementGroup.group : SwitchLabels BlockStatements ; SwitchLabels.one : SwitchLabel ; SwitchLabels.more : SwitchLabels SwitchLabel ; SwitchLabels_opt.absent : ; SwitchLabels_opt.present : SwitchLabels ; SwitchLabel.case : "case" ConstantExpression ":" ; SwitchLabel.default : "default" ":" ; WhileStatement.while : "while" "(" Expression ")" Statement ; WhileStatementNoShortIf.while : "while" "(" Expression ")" StatementNoShortIf ; DoStatement.do : "do" Statement "while" "(" Expression ")" ";" ; ForStatement.for : "for" "(" ForInit_opt ";" Expression_opt ";" ForUpdate_opt ")" Statement ; ForStatementNoShortIf.for : "for" "(" ForInit_opt ";" Expression_opt ";" ForUpdate_opt ")" StatementNoShortIf ; ForInit_opt.absent : ; ForInit_opt.present : ForInit ; ForInit.stmexp : StatementExpressionList ; ForInit.local : LocalVariableDeclaration ; ForUpdate_opt.absent : ; ForUpdate_opt.present : ForUpdate ; ForUpdate.stmexp : StatementExpressionList ; StatementExpressionList.one : StatementExpression ; StatementExpressionList.more : StatementExpressionList "," StatementExpression ; BreakStatement.break : "break" Identifier_opt ";" ; ContinueStatement.continue : "continue" Identifier_opt ";" ; ReturnStatement.return : "return" Expression_opt ";" ; ThrowStatement.throw : "throw" Expression ";" ; SynchronizedStatement.synchronized : "synchronized" "(" Expression ")" Block ; TryStatement.try : "try" Block Catches ; TryStatement.finally : "try" Block Catches_opt Finally ; Catches_opt.absent : ; Catches_opt.present : Catches ; Catches.one : CatchClause ; Catches.more : Catches CatchClause ; CatchClause.catch : "catch" "(" FormalParameter ")" Block ; Finally.finally : "finally" Block ; // 19.12 Productions from §15: Expressions Primary.nonew : PrimaryNoNewArray ; Primary.array : ArrayCreationExpression ; PrimaryNoNewArray.literal : Literal ; PrimaryNoNewArray.this : "this" ; PrimaryNoNewArray.par : "(" Expression ")" ; PrimaryNoNewArray.create : ClassInstanceCreationExpression ; PrimaryNoNewArray.field : FieldAccess ; PrimaryNoNewArray.invoke : MethodInvocation ; PrimaryNoNewArray.array : ArrayAccess ; ClassInstanceCreationExpression.new : "new" ClassType "(" ArgumentList_opt ")" ; ArgumentList_opt.absent : ; ArgumentList_opt.present : ArgumentList ; ArgumentList.one : Expression ; ArgumentList.more : ArgumentList "," Expression ; ArrayCreationExpression.primitive : "new" PrimitiveType DimExprs Dims_opt ; ArrayCreationExpression.class : "new" ClassOrInterfaceType DimExprs Dims_opt ; DimExprs.one : DimExpr ; DimExprs.more : DimExprs DimExpr ; DimExpr.exp : "[" Expression "]" ; Dims_opt.absent : ; Dims_opt.present : Dims ; Dims.simple : "[" "]" ; Dims.dims : Dims "[" "]" ; FieldAccess.primary : Primary "." Identifier ; FieldAccess.super : "super" "." Identifier ; MethodInvocation.name : Name "(" ArgumentList_opt ")" ; MethodInvocation.primary : Primary "." Identifier "(" ArgumentList_opt ")" ; MethodInvocation.super : "super" "." Identifier "(" ArgumentList_opt ")" ; ArrayAccess.name : Name "[" Expression "]" ; ArrayAccess.none : PrimaryNoNewArray "[" Expression "]" ; PostfixExpression.primary : Primary ; PostfixExpression.name : Name ; PostfixExpression.postinc : PostIncrementExpression ; PostfixExpression.postdec : PostDecrementExpression ; PostIncrementExpression.plusplus : PostfixExpression "++" ; PostDecrementExpression.minusminus : PostfixExpression "--" ; UnaryExpression.preinc : PreIncrementExpression ; UnaryExpression.predec : PreDecrementExpression ; UnaryExpression.plus : "+" UnaryExpression ; UnaryExpression.minus : "-" UnaryExpression ; UnaryExpression.unary : UnaryExpressionNotPlusMinus ; PreIncrementExpression.plusplus : "++" UnaryExpression ; PreDecrementExpression.minusminus : "--" UnaryExpression ; UnaryExpressionNotPlusMinus.postfix : PostfixExpression ; UnaryExpressionNotPlusMinus.tilde : "~" UnaryExpression ; UnaryExpressionNotPlusMinus.not : "!" UnaryExpression ; UnaryExpressionNotPlusMinus.cast : CastExpression ; CastExpression.primitive : "(" PrimitiveType Dims_opt ")" UnaryExpression ; CastExpression.exp : "(" Expression ")" UnaryExpressionNotPlusMinus ; CastExpression.namedims : "(" Name Dims ")" UnaryExpressionNotPlusMinus ; MultiplicativeExpression.unary : UnaryExpression ; MultiplicativeExpression.mult : MultiplicativeExpression "*" UnaryExpression ; MultiplicativeExpression.div : MultiplicativeExpression "/" UnaryExpression ; MultiplicativeExpression.mod : MultiplicativeExpression "%" UnaryExpression ; AdditiveExpression.multiplicative : MultiplicativeExpression ; AdditiveExpression.plus : AdditiveExpression "+" MultiplicativeExpression ; AdditiveExpression.minus : AdditiveExpression "-" MultiplicativeExpression ; ShiftExpression.additive : AdditiveExpression ; ShiftExpression.lshift : ShiftExpression "<<" AdditiveExpression ; ShiftExpression.rshift : ShiftExpression ">>" AdditiveExpression ; ShiftExpression.rrshift : ShiftExpression ">>>" AdditiveExpression ; RelationalExpression.shift : ShiftExpression ; RelationalExpression.less : RelationalExpression "<" ShiftExpression ; RelationalExpression.great : RelationalExpression ">" ShiftExpression ; RelationalExpression.lesseq : RelationalExpression "<=" ShiftExpression ; RelationalExpression.greateq : RelationalExpression ">=" ShiftExpression ; RelationalExpression.instanceof : RelationalExpression "instanceof" ReferenceType ; EqualityExpression.relational : RelationalExpression ; EqualityExpression.equal : EqualityExpression "==" RelationalExpression ; EqualityExpression.nequal : EqualityExpression "!=" RelationalExpression ; AndExpression.equality : EqualityExpression ; AndExpression.and : AndExpression "&" EqualityExpression ; ExclusiveOrExpression.and : AndExpression ; ExclusiveOrExpression.hat : ExclusiveOrExpression "^" AndExpression ; InclusiveOrExpression.xor : ExclusiveOrExpression ; InclusiveOrExpression.or : InclusiveOrExpression "|" ExclusiveOrExpression ; ConditionalAndExpression.or : InclusiveOrExpression ; ConditionalAndExpression.andand : ConditionalAndExpression "&&" InclusiveOrExpression ; ConditionalOrExpression.and : ConditionalAndExpression ; ConditionalOrExpression.oror : ConditionalOrExpression "||" ConditionalAndExpression ; ConditionalExpression.or : ConditionalOrExpression ; ConditionalExpression.cond : ConditionalOrExpression "?" Expression ":" ConditionalExpression ; AssignmentExpression.cond : ConditionalExpression ; AssignmentExpression.assignment : Assignment ; Assignment.assignment : LeftHandSide AssignmentOperator AssignmentExpression ; LeftHandSide.name : Name ; LeftHandSide.field : FieldAccess ; LeftHandSide.array : ArrayAccess ; AssignmentOperator.assign : "=" ; AssignmentOperator.mult : "*=" ; AssignmentOperator.div : "/=" ; AssignmentOperator.mod : "%=" ; AssignmentOperator.plus : "+=" ; AssignmentOperator.minus : "-=" ; AssignmentOperator.lshift : "<<=" ; AssignmentOperator.rshift : ">>=" ; AssignmentOperator.rrshift : ">>>=" ; AssignmentOperator.and : "&=" ; AssignmentOperator.hat : "^=" ; AssignmentOperator.or : "|=" ; Expression_opt.absent : ; Expression_opt.present : Expression ; Expression.assignment : AssignmentExpression ; ConstantExpression.exp : Expression ; Identifier_opt.absent : ; Identifier_opt.present : Identifier ; }