
Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: java/java-5/stahl/extracted
Source used for this grammar: Michael Stahl, java15.g, 2004 [ANTLR2]
compilationUnit, packageDefinition, annotations, annotation, AT, identifier, IDENT, DOT, annotationInit, LPAREN, annotationMemberInit, ASSIGN, annotationMemberValue, conditionalExpression, logicalOrExpression, logicalAndExpression, inclusiveOrExpression, exclusiveOrExpression, andExpression, equalityExpression, relationalExpression, shiftExpression, additiveExpression, multiplicativeExpression, unaryExpression, INC, DEC, MINUS, PLUS, unaryExpressionNotPlusMinus, BNOT, LNOT, builtInTypeSpec, builtInType, LBRACK, RBRACK, RPAREN, classTypeSpec, classOrInterfaceType, typeArguments, LT, typeArgument, QUESTION, referenceTypeSpec, arrayTypeSpec, COMMA, typeArgumentsEnd, GT, SR, BSR, postfixExpression, primaryExpression, identPrimary, argList, expressionList, expression, assignmentExpression, PLUS_ASSIGN, MINUS_ASSIGN, STAR_ASSIGN, DIV_ASSIGN, MOD_ASSIGN, SR_ASSIGN, BSR_ASSIGN, SL_ASSIGN, BAND_ASSIGN, BXOR_ASSIGN, BOR_ASSIGN, constant, NUM_INT, EXPONENT, FLOAT_SUFFIX, HEX_DIGIT, CHAR_LITERAL, ESC, STRING_LITERAL, NUM_FLOAT, NUM_LONG, NUM_DOUBLE, newExpression, type, classBlock, LCURLY, classField, modifiers, modifier, innerTypeDef, enumDefinition, ENUM, implementsClause, enumBlock, enumConst, enumConstInit, SEMI, RCURLY, classDefinition, typeParameters, typeParameter, BAND, superClassClause, interfaceDefinition, interfaceExtends, interfaceBlock, interfaceField, memberDef, typeSpec, parameterDeclarationList, parameterDeclaration, parameterModifier, ELLIPSIS, declaratorBrackets, throwsClause, compoundStatement, statement, declaration, variableDefinitions, variableDeclarator, varInitializer, initializer, arrayInitializer, COLON, forInit, forCond, forIter, casesGroup, aCase, caseSList, tryBlock, handler, finallyClause, ASSERT, annotationTypeDefinition, annotationBlock, annotationField, defaultValue, ctorHead, constructorBody, explicitConstructorInvocation, newArrayDeclarator, STAR, DIV, MOD, SL, LE, GE, NOT_EQUAL, EQUAL, BXOR, BOR, LAND, LOR, annotationMemberArrayInitializer, importDefinition, identifierStar, typeDefinition), 1 root (compilationUnit), 0 top (—), 0 bottom (—).[p], [lp] 5, [lpb], [lb] 6, [lt] 2, [q], [ta1] 2, [lp3], [ta2] 2, [lps], [in], [de], [lbt], [lbc], [f1], [f2], [f3], [f4], [mods] 3, [it] 3, [tp] 4, [h], [s] 2, [md] 2, [s3], [s4], [ed], [cd], [id] 3, [ad], [ic] 2, [eb], [i] 3, [sc], [cb], [ie], [ib], [e], [t] 3, [param], [rt], [tc], [s2], [v] 4, [pm], [el], [pd], [lc] 4, [m] 3, [c], [d], [ab], [ts], [dv], [lp1], [lp2].compilationUnit ::= packageDefinitionε importDefinition typeDefinition
packageDefinition ::=
annotations [p]::"package" identifier SEMIannotations ::=
annotationannotation ::= AT identifier annotationInit
AT ::=
"@"identifier ::= IDENT DOT IDENT
IDENT ::= "a""b""c""d""e""f""g""h""i""j""k""l""m""n""o""p""q""r""s""t""u""v""w""x""y""z""A""B""C""D""E""F""G""H""I""J""K""L""M""N""O""P""Q""R""S""T""U""V""W""X""Y""Z""_""$" "a""b""c""d""e""f""g""h""i""j""k""l""m""n""o""p""q""r""s""t""u""v""w""x""y""z""A""B""C""D""E""F""G""H""I""J""K""L""M""N""O""P""Q""R""S""T""U""V""W""X""Y""Z""_""0""1""2""3""4""5""6""7""8""9""$"
DOT ::=
"."annotationInit ::= [lp]::LPAREN annotationMemberInit COMMA annotationMemberInitannotationMemberValueε RPAREN ε
LPAREN ::=
"("annotationMemberInit ::= IDENT ASSIGN annotationMemberValue
ASSIGN ::=
"="annotationMemberValue ::= annotation conditionalExpression annotationMemberArrayInitializer
conditionalExpression ::= logicalOrExpression QUESTION assignmentExpression COLON conditionalExpression
logicalOrExpression ::= logicalAndExpression LOR logicalAndExpression
logicalAndExpression ::= inclusiveOrExpression LAND inclusiveOrExpression
inclusiveOrExpression ::= exclusiveOrExpression BOR exclusiveOrExpression
exclusiveOrExpression ::= andExpression BXOR andExpression
andExpression ::= equalityExpression BAND equalityExpression
equalityExpression ::= relationalExpression NOT_EQUALEQUAL relationalExpression
relationalExpression ::= shiftExpression LTGTLEGE shiftExpression"instanceof" typeSpec
shiftExpression ::= additiveExpression SLSRBSR additiveExpression
additiveExpression ::= multiplicativeExpression PLUSMINUS multiplicativeExpression
multiplicativeExpression ::= unaryExpression STARDIVMOD unaryExpression
unaryExpression ::= INC unaryExpression DEC unaryExpression MINUS unaryExpression PLUS unaryExpression unaryExpressionNotPlusMinus
INC ::=
"++"DEC ::=
"--"MINUS ::=
"-"PLUS ::=
"+"unaryExpressionNotPlusMinus ::= BNOT unaryExpression LNOT unaryExpression [lpb]::LPAREN builtInTypeSpec RPAREN unaryExpression [lp]::LPAREN classTypeSpec RPAREN unaryExpressionNotPlusMinus postfixExpression
BNOT ::=
"~"LNOT ::=
"!"builtInTypeSpec ::= builtInType [lb]::LBRACK RBRACK
builtInType ::= "void" "boolean" "byte" "char" "short" "int" "float" "long" "double"
LBRACK ::=
"["RBRACK ::=
"]"RPAREN ::=
")"classTypeSpec ::= classOrInterfaceType [lb]::LBRACK RBRACK
classOrInterfaceType ::= IDENT typeArguments DOT IDENT typeArguments
typeArguments ::= [lt]::LT typeArgument COMMA typeArgument typeArgumentsEnd ε
LT ::=
"<"typeArgument ::= [q]::QUESTION "extends" referenceTypeSpec"super" referenceTypeSpec referenceTypeSpec
QUESTION ::=
"?"referenceTypeSpec ::= classTypeSpec arrayTypeSpec
arrayTypeSpec ::= builtInType [lb]::LBRACK RBRACK
COMMA ::=
","typeArgumentsEnd ::= GT SR BSR
GT ::=
">"SR ::=
">>"BSR ::=
">>>"postfixExpression ::= primaryExpression DOT "this"DOT [ta1]::typeArguments IDENT [lp]::LPAREN argList RPAREN"super" [lp3]::LPAREN argList RPARENDOT [ta2]::typeArguments IDENT [lps]::LPAREN argList RPARENDOT newExpression[lb]::LBRACK expression RBRACK [in]::INC[de]::DEC
primaryExpression ::= identPrimary DOT "class" constant "true" "false" "null" newExpression "this" "super" LPAREN assignmentExpression RPAREN builtInType [lbt]::LBRACK RBRACK DOT "class"
identPrimary ::= [ta1]::typeArguments IDENT DOT [ta2]::typeArguments IDENTε [lp]::LPAREN argList RPAREN[lbc]::LBRACK RBRACK
argList ::= expressionList ε
expressionList ::= expression COMMA expression
expression ::= assignmentExpression
assignmentExpression ::= conditionalExpression ASSIGNPLUS_ASSIGNMINUS_ASSIGNSTAR_ASSIGNDIV_ASSIGNMOD_ASSIGNSR_ASSIGNBSR_ASSIGNSL_ASSIGNBAND_ASSIGNBXOR_ASSIGNBOR_ASSIGN assignmentExpression
PLUS_ASSIGN ::=
"+="MINUS_ASSIGN ::=
"-="STAR_ASSIGN ::=
"*="DIV_ASSIGN ::=
"/="MOD_ASSIGN ::=
"%="SR_ASSIGN ::=
">>="BSR_ASSIGN ::=
">>>="SL_ASSIGN ::=
"<<="BAND_ASSIGN ::=
"&="BXOR_ASSIGN ::=
"^="BOR_ASSIGN ::=
"|="constant ::= NUM_INT CHAR_LITERAL STRING_LITERAL NUM_FLOAT NUM_LONG NUM_DOUBLE
NUM_INT ::= "." "." ".""0""1""2""3""4""5""6""7""8""9" EXPONENT [f1]::FLOAT_SUFFIX "0" "x""X" HEX_DIGIT"0""1""2""3""4""5""6""7""8""9""0""1""2""3""4""5""6""7""1""2""3""4""5""6""7""8""9" "0""1""2""3""4""5""6""7""8""9" "l""L""." "0""1""2""3""4""5""6""7""8""9" EXPONENT [f2]::FLOAT_SUFFIXEXPONENT [f3]::FLOAT_SUFFIX[f4]::FLOAT_SUFFIX
EXPONENT ::= "e""E" "+""-" "0""1""2""3""4""5""6""7""8""9"
FLOAT_SUFFIX ::= "f" "F" "d" "D"
HEX_DIGIT ::= "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F" "a" "b" "c" "d" "e" "f"
CHAR_LITERAL ::= "\'" ESCstring "\'"
ESC ::= "\\" "n""r""t""b""f"""""\'""\\""u" HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT"0""1""2""3" "0""1""2""3""4""5""6""7" "0""1""2""3""4""5""6""7""4""5""6""7" "0""1""2""3""4""5""6""7"
STRING_LITERAL ::= """ ESCstring """
NUM_FLOAT ::= "." "0""1""2""3""4""5""6""7""8""9" EXPONENT "f""F" "0" "0""1""2""3""4""5""6""7""8""9" "."EXPONENT"f""F" "1""2""3""4""5""6""7""8""9" "0""1""2""3""4""5""6""7""8""9" "." "0""1""2""3""4""5""6""7""8""9" EXPONENT "f""F"EXPONENT
NUM_LONG ::= "1""2""3""4""5""6""7""8""9" "0""1""2""3""4""5""6""7""8""9" "l""L"
NUM_DOUBLE ::= "." "0""1""2""3""4""5""6""7""8""9" EXPONENT "d""D" "0" "0""1""2""3""4""5""6""7""8""9" "."EXPONENT"d""D" "1""2""3""4""5""6""7""8""9" "0""1""2""3""4""5""6""7""8""9" "." "0""1""2""3""4""5""6""7""8""9" EXPONENT "d""D"EXPONENT
newExpression ::= "new" typeArguments type LPAREN argList RPAREN classBlocknewArrayDeclarator arrayInitializer
type ::= classOrInterfaceType builtInType
classBlock ::= LCURLY classFieldSEMI RCURLY
LCURLY ::=
"{"classField ::= [mods]::modifiers [it]::innerTypeDef[tp]::typeParameters [h]::ctorHead [s]::constructorBody[md]::memberDef "static" [s3]::compoundStatement [s4]::compoundStatement
modifiers ::= modifierannotation
modifier ::= "private" "public" "protected" "static" "transient" "final" "abstract" "native" "threadsafe" "synchronized" "volatile" "strictfp"
innerTypeDef ::= [ed]::enumDefinition [cd]::classDefinition [id]::interfaceDefinition [ad]::annotationTypeDefinition
enumDefinition ::= ENUM IDENT [ic]::implementsClause [eb]::enumBlock
ENUM ::=
"enum"implementsClause ::= [i]::"implements" classOrInterfaceType COMMA classOrInterfaceType
enumBlock ::= LCURLY enumConst COMMA enumConst COMMA SEMI classFieldSEMI RCURLY
enumConst ::=
annotations IDENT enumConstInit classBlockenumConstInit ::= [lp]::LPAREN argList RPAREN ε
SEMI ::=
";"RCURLY ::=
"}"classDefinition ::=
"class" IDENT [tp]::typeParameters [sc]::superClassClause [ic]::implementsClause [cb]::classBlocktypeParameters ::= [lt]::LT typeParameter COMMA typeParameter typeArgumentsEnd ε
typeParameter ::= IDENT "extends" classOrInterfaceType BAND classOrInterfaceType
BAND ::=
"&"superClassClause ::= "extends" classOrInterfaceType
interfaceDefinition ::=
"interface" IDENT [tp]::typeParameters [ie]::interfaceExtends [ib]::interfaceBlockinterfaceExtends ::= [e]::"extends" classOrInterfaceType COMMA classOrInterfaceType
interfaceBlock ::= LCURLY interfaceFieldSEMI RCURLY
interfaceField ::= [mods]::modifiers [it]::innerTypeDef[tp]::typeParameters [md]::memberDef
memberDef ::= [t]::typeSpec IDENT LPAREN [param]::parameterDeclarationList RPAREN [rt]::declaratorBrackets [tc]::throwsClause SEMI[s2]::compoundStatement[v]::variableDefinitions SEMI
typeSpec ::= classTypeSpec builtInTypeSpec
parameterDeclarationList ::= parameterDeclaration COMMA parameterDeclaration
parameterDeclaration ::=
[pm]::parameterModifier [t]::typeSpec [el]::ELLIPSIS [id]::IDENT [pd]::declaratorBracketsparameterModifier ::= "final"annotation
ELLIPSIS ::=
"..."declaratorBrackets ::= [lb]::LBRACK RBRACK
throwsClause ::= "throws" identifier COMMA identifier
compoundStatement ::=
[lc]::LCURLY statement RCURLYstatement ::= compoundStatement declaration SEMI expression SEMI [m]::modifiers enumDefinitionclassDefinition IDENT [c]::COLON statement "if" LPAREN expression RPAREN statement "else" statement "for" LPAREN parameterDeclaration COLON expressionforInit SEMI forCond SEMI forIter RPAREN statement "while" LPAREN expression RPAREN statement "do" statement "while" LPAREN expression RPAREN SEMI "break" IDENT SEMI "continue" IDENT SEMI "return" expression SEMI "switch" LPAREN expression RPAREN LCURLY casesGroup RCURLY tryBlock "throw" expression SEMI "synchronized" LPAREN expression RPAREN compoundStatement ASSERT expression COLON expression SEMI [s]::SEMI
declaration ::= [m]::modifiers [t]::typeSpec [v]::variableDefinitions
variableDefinitions ::= variableDeclarator COMMA variableDeclarator
variableDeclarator ::= [id]::IDENT [d]::declaratorBrackets [v]::varInitializer
varInitializer ::= ASSIGN initializer
initializer ::= expression arrayInitializer
arrayInitializer ::= [lc]::LCURLY initializer COMMA initializer COMMA RCURLY
COLON ::=
":"forInit ::= declarationexpressionList
forCond ::=
expressionforIter ::=
expressionListcasesGroup ::=
aCase caseSListaCase ::= "case" expression"default" COLON
caseSList ::=
statementtryBlock ::= "try" compoundStatement handler finallyClause
handler ::=
"catch" LPAREN parameterDeclaration RPAREN compoundStatementfinallyClause ::=
"finally" compoundStatementASSERT ::=
"assert"annotationTypeDefinition ::=
AT "interface" IDENT [ab]::annotationBlockannotationBlock ::= LCURLY annotationFieldSEMI RCURLY
annotationField ::= [mods]::modifiers [it]::innerTypeDef[ts]::typeSpec [i]::IDENT LPAREN RPAREN [dv]::defaultValue SEMI[v]::variableDefinitions SEMI
defaultValue ::= "default" annotationMemberValue
ctorHead ::=
IDENT LPAREN parameterDeclarationList RPAREN throwsClauseconstructorBody ::= [lc]::LCURLY explicitConstructorInvocation statement RCURLY
explicitConstructorInvocation ::= typeArguments "this" [lp1]::LPAREN argList RPAREN SEMI"super" [lp2]::LPAREN argList RPAREN SEMI
newArrayDeclarator ::= [lb]::LBRACK expression RBRACK
STAR ::=
"*"DIV ::=
"/"MOD ::=
"%"SL ::=
"<<"LE ::=
"<="GE ::=
">="NOT_EQUAL ::=
"!="EQUAL ::=
"=="BXOR ::=
"^"BOR ::=
"|"LAND ::=
"&&"LOR ::=
"||"annotationMemberArrayInitializer ::= [lc]::LCURLY annotationMemberValue COMMA annotationMemberValue COMMA RCURLY
importDefinition ::= [i]::"import" "static" identifierStar SEMI
identifierStar ::= IDENT DOT IDENT DOT STAR
typeDefinition ::= [m]::modifiers classDefinitionenumDefinitioninterfaceDefinitionannotationTypeDefinition SEMI