# BNF for java_1_5.jj

## NON-TERMINALS

CompilationUnit | ::= | ( PackageDeclaration )? ( ImportDeclaration )* ( TypeDeclaration )* ( <EOF> | "\u001a" )
PackageDeclaration | ::= | ( Annotation )* "package" Name ";"
ImportDeclaration | ::= | "import" ( "static" )? Name ( "." "*" )? ";"
Modifiers | ::= | ( ( "public" | "static" | "protected" | "private" | "final" | "abstract" | "synchronized" | "native" | "transient" | "volatile" | "strictfp" | Annotation ) )*
TypeDeclaration | ::= | ( ";" | Modifiers ( ClassOrInterfaceDeclaration | EnumDeclaration | AnnotationTypeDeclaration ) )
ClassOrInterfaceDeclaration | ::= | ( "class" | "interface" ) <IDENTIFIER> ( TypeParameters )? ( ExtendsList )? ( ImplementsList )? ClassOrInterfaceBody
ExtendsList | ::= | "extends" ClassOrInterfaceType ( "," ClassOrInterfaceType )*
ImplementsList | ::= | "implements" ClassOrInterfaceType ( "," ClassOrInterfaceType )*
EnumDeclaration | ::= | "enum" <IDENTIFIER> ( ImplementsList )? "{" ( EnumConstantDeclaration ( "," EnumConstantDeclaration )* )? ( "," )? ( ( ";" ( ClassOrInterfaceBodyDeclaration )* ) )? "}"
EnumConstantDeclaration | ::= | ( Annotation )* <IDENTIFIER> ( Arguments )? ( ClassOrInterfaceBody )?
TypeParameters | ::= | "<" TypeParameter ( "," TypeParameter )* ">"
TypeParameter | ::= | <IDENTIFIER> ( TypeBound )?
TypeBound | ::= | "extends" ClassOrInterfaceType ( "&" ClassOrInterfaceType )*
ClassOrInterfaceBody | ::= | "{" ( ClassOrInterfaceBodyDeclaration )* "}"
ClassOrInterfaceBodyDeclaration | ::= | ( InitializerDeclaration | Modifiers ( ClassOrInterfaceDeclaration | EnumDeclaration | AnnotationTypeDeclaration | ConstructorDeclaration | FieldDeclaration | MethodDeclaration ) | ";" )
FieldDeclaration | ::= | Type VariableDeclarator ( "," VariableDeclarator )* ";"
VariableDeclarator | ::= | VariableDeclaratorId ( "=" VariableInitializer )?
VariableDeclaratorId | ::= | <IDENTIFIER> ( "[" "]" )*
VariableInitializer | ::= | ( ArrayInitializer | Expression )
ArrayInitializer | ::= | "{" ( VariableInitializer ( "," VariableInitializer )* )? ( "," )? "}"
MethodDeclaration | ::= | ( TypeParameters )? ResultType <IDENTIFIER> FormalParameters ( "[" "]" )* ( "throws" NameList )? ( Block | ";" )
FormalParameters | ::= | "(" ( FormalParameter ( "," FormalParameter )* )? ")"
FormalParameter | ::= | Modifiers Type ( "..." )? VariableDeclaratorId
ConstructorDeclaration | ::= | ( TypeParameters )? <IDENTIFIER> FormalParameters ( "throws" NameList )? "{" ( ExplicitConstructorInvocation )? Statements "}"
ExplicitConstructorInvocation | ::= | ( ( TypeArguments )? "this" Arguments ";" | ( PrimaryExpressionWithoutSuperSuffix "." )? ( TypeArguments )? "super" Arguments ";" )
Statements | ::= | ( BlockStatement )*
InitializerDeclaration | ::= | ( "static" )? Block
Type | ::= | ( ReferenceType | PrimitiveType )
ReferenceType | ::= | ( PrimitiveType ( "[" "]" )+ | ClassOrInterfaceType ( "[" "]" )* )
ClassOrInterfaceType | ::= | <IDENTIFIER> ( TypeArguments )? ( "." <IDENTIFIER> ( TypeArguments )? )*
TypeArguments | ::= | "<" TypeArgument ( "," TypeArgument )* ">"
TypeArgument | ::= | ( ReferenceType | Wildcard )
Wildcard | ::= | "?" ( "extends" ReferenceType | "super" ReferenceType )?
PrimitiveType | ::= | ( "boolean" | "char" | "byte" | "short" | "int" | "long" | "float" | "double" )
ResultType | ::= | ( "void" | Type )
Name | ::= | <IDENTIFIER> ( "." <IDENTIFIER> )*
NameList | ::= | Name ( "," Name )*
Expression | ::= | ConditionalExpression ( AssignmentOperator Expression )?
AssignmentOperator | ::= | ( "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|=" )
ConditionalExpression | ::= | ConditionalOrExpression ( "?" Expression ":" ConditionalExpression )?
ConditionalOrExpression | ::= | ConditionalAndExpression ( "||" ConditionalAndExpression )*
ConditionalAndExpression | ::= | InclusiveOrExpression ( "&&" InclusiveOrExpression )*
InclusiveOrExpression | ::= | ExclusiveOrExpression ( "|" ExclusiveOrExpression )*
ExclusiveOrExpression | ::= | AndExpression ( "^" AndExpression )*
AndExpression | ::= | EqualityExpression ( "&" EqualityExpression )*
EqualityExpression | ::= | InstanceOfExpression ( ( "==" | "!=" ) InstanceOfExpression )*
InstanceOfExpression | ::= | RelationalExpression ( "instanceof" Type )?
RelationalExpression | ::= | ShiftExpression ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression )*
ShiftExpression | ::= | AdditiveExpression ( ( "<<" | RSIGNEDSHIFT | RUNSIGNEDSHIFT ) AdditiveExpression )*
AdditiveExpression | ::= | MultiplicativeExpression ( ( "+" | "-" ) MultiplicativeExpression )*
MultiplicativeExpression | ::= | UnaryExpression ( ( "*" | "/" | "%" ) UnaryExpression )*
UnaryExpression | ::= | ( ( "+" | "-" ) UnaryExpression | PreIncrementExpression | PreDecrementExpression | UnaryExpressionNotPlusMinus )
PreIncrementExpression | ::= | "++" PrimaryExpression
PreDecrementExpression | ::= | "--" PrimaryExpression
UnaryExpressionNotPlusMinus | ::= | ( ( "~" | "!" ) UnaryExpression | CastExpression | PostfixExpression )
CastLookahead | ::= | "(" Type "[" "]"
| | | "(" Type ")" UnaryExpression
PostfixExpression | ::= | PrimaryExpression ( ( "++" | "--" ) )?
CastExpression | ::= | "(" Type ")" UnaryExpression
PrimaryExpression | ::= | PrimaryPrefix ( PrimarySuffix )*
PrimaryExpressionWithoutSuperSuffix | ::= | PrimaryPrefix ( PrimarySuffixWithoutSuper )*
PrimaryPrefix | ::= | ( Literal | "this" | "super" "." ( TypeArguments )? <IDENTIFIER> ( Arguments )? | "(" Expression ")" | AllocationExpression | ResultType "." "class" | <IDENTIFIER> ( Arguments )? )
PrimarySuffix | ::= | ( PrimarySuffixWithoutSuper | "." "super" )
PrimarySuffixWithoutSuper | ::= | ( "." ( "this" | AllocationExpression | ( TypeArguments )? <IDENTIFIER> ( Arguments )? ) | "[" Expression "]" )
Literal | ::= | ( <INTEGER_LITERAL> | <LONG_LITERAL> | <FLOATING_POINT_LITERAL> | <CHARACTER_LITERAL> | <STRING_LITERAL> | BooleanLiteral | NullLiteral )
BooleanLiteral | ::= | ( "true" | "false" )
NullLiteral | ::= | "null"
Arguments | ::= | "(" ( ArgumentList )? ")"
ArgumentList | ::= | Expression ( "," Expression )*
AllocationExpression | ::= | "new" ( PrimitiveType ArrayDimsAndInits | ( TypeArguments )? ClassOrInterfaceType ( ArrayDimsAndInits | Arguments ( ClassOrInterfaceBody )? ) )
ArrayDimsAndInits | ::= | ( ( "[" Expression "]" )+ ( "[" "]" )* | ( "[" "]" )+ ArrayInitializer )
Statement | ::= | ( LabeledStatement | AssertStatement | Block | EmptyStatement | StatementExpression | SwitchStatement | IfStatement | WhileStatement | DoStatement | ForStatement | BreakStatement | ContinueStatement | ReturnStatement | ThrowStatement | SynchronizedStatement | TryStatement )
AssertStatement | ::= | "assert" Expression ( ":" Expression )? ";"
LabeledStatement | ::= | <IDENTIFIER> ":" Statement
Block | ::= | "{" Statements "}"
BlockStatement | ::= | ( Modifiers ClassOrInterfaceDeclaration | VariableDeclarationExpression ";" | Statement )
VariableDeclarationExpression | ::= | Modifiers Type VariableDeclarator ( "," VariableDeclarator )*
EmptyStatement | ::= | ";"
StatementExpression | ::= | ( PreIncrementExpression | PreDecrementExpression | PrimaryExpression ( "++" | "--" | AssignmentOperator Expression )? ) ";"
SwitchStatement | ::= | "switch" "(" Expression ")" "{" ( SwitchEntry )* "}"
SwitchEntry | ::= | ( "case" Expression | "default" ) ":" Statements
IfStatement | ::= | "if" "(" Expression ")" Statement ( "else" Statement )?
WhileStatement | ::= | "while" "(" Expression ")" Statement
DoStatement | ::= | "do" Statement "while" "(" Expression ")" ";"
ForStatement | ::= | "for" "(" ( VariableDeclarationExpression ":" Expression | ( ForInit )? ";" ( Expression )? ";" ( ForUpdate )? ) ")" Statement
ForInit | ::= | ( VariableDeclarationExpression | ExpressionList )
ExpressionList | ::= | Expression ( "," Expression )*
ForUpdate | ::= | ExpressionList
BreakStatement | ::= | "break" ( <IDENTIFIER> )? ";"
ContinueStatement | ::= | "continue" ( <IDENTIFIER> )? ";"
ReturnStatement | ::= | "return" ( Expression )? ";"
ThrowStatement | ::= | "throw" Expression ";"
SynchronizedStatement | ::= | "synchronized" "(" Expression ")" Block
TryStatement | ::= | "try" Block ( ( "catch" "(" FormalParameter ")" Block )+ ( "finally" Block )? | "finally" Block )
RUNSIGNEDSHIFT | ::= | ( ">" ">" ">" )
RSIGNEDSHIFT | ::= | ( ">" ">" )
Annotation | ::= | ( NormalAnnotation | SingleMemberAnnotation | MarkerAnnotation )
NormalAnnotation | ::= | "@" Name "(" ( MemberValuePairs )? ")"
MarkerAnnotation | ::= | "@" Name
SingleMemberAnnotation | ::= | "@" Name "(" MemberValue ")"
MemberValuePairs | ::= | MemberValuePair ( "," MemberValuePair )*
MemberValuePair | ::= | <IDENTIFIER> "=" MemberValue
MemberValue | ::= | ( Annotation | MemberValueArrayInitializer | ConditionalExpression )
MemberValueArrayInitializer | ::= | "{" ( MemberValue ( "," MemberValue )* )? ( "," )? "}"
AnnotationTypeDeclaration | ::= | "@" "interface" <IDENTIFIER> AnnotationTypeBody
AnnotationTypeBody | ::= | "{" ( AnnotationBodyDeclaration )* "}"
AnnotationBodyDeclaration | ::= | ( ";" | Modifiers ( AnnotationTypeMemberDeclaration | ClassOrInterfaceDeclaration | EnumDeclaration | AnnotationTypeDeclaration | FieldDeclaration ) )
AnnotationTypeMemberDeclaration | ::= | Type <IDENTIFIER> "(" ")" ( DefaultValue )? ";"
DefaultValue | ::= | "default" MemberValue