Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: java/java-5/studman/extracted
Source used for this grammar: Michael Studman, java15.g
, 2004 [ANTLR2]
compilationUnit
, packageDefinition
, annotations
, annotation
, AT
, identifier
, IDENT
, DOT
, LPAREN
, annotationArguments
, annotationMemberValueInitializer
, 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
, typeArgumentSpec
, builtInTypeArraySpec
, wildcardType
, QUESTION
, typeArgumentBounds
, COMMA
, typeArgumentsOrParametersEnd
, GT
, SR
, BSR
, postfixExpression
, primaryExpression
, identPrimary
, argList
, expressionList
, expression
, assignmentExpression
, ASSIGN
, 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
, typeDefinitionInternal
, classDefinition
, typeParameters
, typeParameter
, typeParameterBounds
, BAND
, superClassClause
, implementsClause
, interfaceDefinition
, interfaceExtends
, interfaceBlock
, interfaceField
, typeSpec
, parameterDeclarationList
, parameterDeclaration
, parameterModifier
, declaratorBrackets
, variableLengthParameterDeclaration
, TRIPLE_DOT
, throwsClause
, SEMI
, variableDefinitions
, variableDeclarator
, varInitializer
, initializer
, arrayInitializer
, RCURLY
, enumDefinition
, enumBlock
, enumConstant
, enumConstantBlock
, enumConstantField
, compoundStatement
, statement
, declaration
, COLON
, forStatement
, traditionalForClause
, forInit
, forCond
, forIter
, forEachClause
, casesGroup
, aCase
, caseSList
, tryBlock
, handler
, finallyClause
, annotationDefinition
, annotationBlock
, annotationField
, ctorHead
, constructorBody
, explicitConstructorInvocation
, newArrayDeclarator
, STAR
, DIV
, MOD
, SL
, LE
, GE
, NOT_EQUAL
, EQUAL
, BXOR
, BOR
, LAND
, LOR
, annotationMemberArrayInitializer
, annotationMemberArrayValueInitializer
, anntotationMemberValuePairs
, annotationMemberValuePair
, importDefinition
, identifierStar
, typeDefinition
), 1 root (compilationUnit
), 0 top (—), 0 bottom (—).[p]
2, [i]
6, [args]
, [lpb]
, [lp]
3, [lb]
6, [q]
, [lp3]
, [lps]
, [in]
, [de]
, [lbt]
, [ta1]
, [ta2]
, [lbc]
, [f1]
, [f2]
, [f3]
, [f4]
, [mods]
4, [td]
4, [tp]
5, [h]
, [s]
2, [t]
7, [param]
3, [rt]
4, [tc]
3, [s2]
2, [v]
7, [s3]
, [s4]
2, [sc]
, [ic]
2, [cb]
, [id]
4, [c]
2, [ie]
, [ib]
, [e]
, [pm]
2, [pd]
2, [f]
2, [d]
, [lc]
4, [eb]
, [an]
, [a]
, [b]
, [m]
3, [ab]
, [amvi]
, [lp1]
, [lp2]
.compilationUnit ::=packageDefinition ε importDefinition typeDefinition
packageDefinition ::=
annotations [p]::"package" identifier SEMI
annotations ::=
annotation
annotation ::= AT [i]::identifierLPAREN [args]::annotationArguments RPAREN
AT ::=
"@"
identifier ::= IDENTDOT 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 ::=
"."
LPAREN ::=
"("
annotationArguments ::= annotationMemberValueInitializer anntotationMemberValuePairs
annotationMemberValueInitializer ::= conditionalExpression annotation annotationMemberArrayInitializer
conditionalExpression ::= logicalOrExpressionQUESTION assignmentExpression COLON conditionalExpression
logicalOrExpression ::= logicalAndExpressionLOR logicalAndExpression
logicalAndExpression ::= inclusiveOrExpressionLAND inclusiveOrExpression
inclusiveOrExpression ::= exclusiveOrExpressionBOR exclusiveOrExpression
exclusiveOrExpression ::= andExpressionBXOR andExpression
andExpression ::= equalityExpressionBAND equalityExpression
equalityExpression ::= relationalExpressionNOT_EQUAL EQUAL relationalExpression
relationalExpression ::= shiftExpression "instanceof" typeSpecLT GT LE GE shiftExpression
shiftExpression ::= additiveExpressionSL SR BSR additiveExpression
additiveExpression ::= multiplicativeExpressionPLUS MINUS multiplicativeExpression
multiplicativeExpression ::= unaryExpressionSTAR DIV MOD 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 typeArgumentsDOT IDENT typeArguments
typeArguments ::= LT typeArgumentCOMMA typeArgument typeArgumentsOrParametersEnd
LT ::=
"<"
typeArgument ::= typeArgumentSpec wildcardType
typeArgumentSpec ::= classTypeSpec builtInTypeArraySpec
builtInTypeArraySpec ::= builtInType[lb]::LBRACK RBRACK
wildcardType ::=
[q]::QUESTION typeArgumentBounds
QUESTION ::=
"?"
typeArgumentBounds ::= "extends""super" classOrInterfaceType
COMMA ::=
","
typeArgumentsOrParametersEnd ::= GT SR BSR
GT ::=
">"
SR ::=
">>"
BSR ::=
">>>"
postfixExpression ::= primaryExpression "super" [lp3]::LPAREN argList RPAREN DOT typeArguments IDENT [lps]::LPAREN argList RPAREN DOT "this" DOT newExpression [lb]::LBRACK expression RBRACK [in]::INC [de]::DECDOT typeArguments IDENT [lp]::LPAREN argList RPAREN
primaryExpression ::= identPrimary "class" constant "true" "false" "null" newExpression "this" "super" LPAREN assignmentExpression RPAREN builtInType [lbt]::LBRACK RBRACK DOT "class"DOT
identPrimary ::= [ta1]::typeArgumentsIDENT DOT [ta2]::typeArguments IDENT ε [lp]::LPAREN argList RPAREN [lbc]::LBRACK RBRACK
argList ::= expressionList ε
expressionList ::= expressionCOMMA expression
expression ::= assignmentExpression
assignmentExpression ::= conditionalExpressionASSIGN PLUS_ASSIGN MINUS_ASSIGN STAR_ASSIGN DIV_ASSIGN MOD_ASSIGN SR_ASSIGN BSR_ASSIGN SL_ASSIGN BAND_ASSIGN BXOR_ASSIGN BOR_ASSIGN assignmentExpression
ASSIGN ::=
"="
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_SUFFIX EXPONENT [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 ::= "\'" ESC string "\'"
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 ::= """ ESC string """
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 classBlock newArrayDeclarator arrayInitializer
type ::= classOrInterfaceType builtInType
classBlock ::= LCURLYclassField SEMI RCURLY
LCURLY ::=
"{"
classField ::= [mods]::modifiers "static" [s3]::compoundStatement [s4]::compoundStatement[td]::typeDefinitionInternal [tp]::typeParameters [h]::ctorHead [s]::constructorBody [t]::typeSpec IDENT LPAREN [param]::parameterDeclarationList RPAREN [rt]::declaratorBrackets [tc]::throwsClause [s2]::compoundStatement SEMI [v]::variableDefinitions SEMI
modifiers ::=modifier annotation
modifier ::= "private" "public" "protected" "static" "transient" "final" "abstract" "native" "threadsafe" "synchronized" "volatile" "strictfp"
typeDefinitionInternal ::= classDefinition interfaceDefinition enumDefinition annotationDefinition
classDefinition ::= "class" IDENT [tp]::typeParameters [sc]::superClassClause [ic]::implementsClause [cb]::classBlock
typeParameters ::= LT typeParameterCOMMA typeParameter typeArgumentsOrParametersEnd
typeParameter ::=
[id]::IDENT typeParameterBounds
typeParameterBounds ::= "extends" classOrInterfaceType BAND classOrInterfaceType
BAND ::=
"&"
superClassClause ::= "extends" [c]::classOrInterfaceType
implementsClause ::= "implements" classOrInterfaceType COMMA classOrInterfaceType[i]::
interfaceDefinition ::= "interface" IDENT [tp]::typeParameters [ie]::interfaceExtends [ib]::interfaceBlock
interfaceExtends ::= "extends" classOrInterfaceType COMMA classOrInterfaceType[e]::
interfaceBlock ::= LCURLYinterfaceField SEMI RCURLY
interfaceField ::= [mods]::modifiers[td]::typeDefinitionInternal [tp]::typeParameters [t]::typeSpec IDENT LPAREN [param]::parameterDeclarationList RPAREN [rt]::declaratorBrackets [tc]::throwsClause SEMI [v]::variableDefinitions SEMI
typeSpec ::= classTypeSpec builtInTypeSpec
parameterDeclarationList ::=parameterDeclaration COMMA parameterDeclaration COMMA variableLengthParameterDeclaration variableLengthParameterDeclaration
parameterDeclaration ::= [pm]::parameterModifier [t]::typeSpec [id]::IDENT [pd]::declaratorBrackets
parameterModifier ::= annotation"final" annotation[f]::
declaratorBrackets ::=[lb]::LBRACK RBRACK
variableLengthParameterDeclaration ::= [pm]::parameterModifier [t]::typeSpec TRIPLE_DOT [id]::IDENT [pd]::declaratorBrackets
TRIPLE_DOT ::=
"..."
throwsClause ::= "throws" identifier COMMA identifier
SEMI ::=
";"
variableDefinitions ::= variableDeclaratorCOMMA variableDeclarator
variableDeclarator ::= [id]::IDENT [d]::declaratorBrackets [v]::varInitializer
varInitializer ::=ASSIGN initializer
initializer ::= expression arrayInitializer
arrayInitializer ::= [lc]::LCURLYinitializer COMMA initializer COMMA RCURLY
RCURLY ::=
"}"
enumDefinition ::=
"enum" IDENT [ic]::implementsClause [eb]::enumBlock
enumBlock ::= LCURLYenumConstant COMMA enumConstant COMMA SEMI classField SEMI RCURLY
enumConstant ::= [an]::annotations [i]::IDENTLPAREN [a]::argList RPAREN [b]::enumConstantBlock
enumConstantBlock ::= LCURLYenumConstantField SEMI RCURLY
enumConstantField ::= [mods]::modifiers[td]::typeDefinitionInternal [tp]::typeParameters [t]::typeSpec IDENT LPAREN [param]::parameterDeclarationList RPAREN [rt]::declaratorBrackets [tc]::throwsClause [s2]::compoundStatement SEMI [v]::variableDefinitions SEMI [s4]::compoundStatement
compoundStatement ::=
[lc]::LCURLY statement
RCURLYstatement ::= compoundStatement declaration SEMI expression SEMI [m]::modifiers classDefinition IDENT [c]::COLON statement "if" LPAREN expression RPAREN statement "else" statement forStatement "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
COLON ::=
":"
forStatement ::= [f]::"for" LPAREN traditionalForClause forEachClause RPAREN statement
traditionalForClause ::= forInit SEMI forCond SEMI forIter
forInit ::=declaration expressionList
forCond ::=
expression
forIter ::=
expressionList
forEachClause ::= [p]::parameterDeclaration COLON expression
casesGroup ::=
aCase
caseSListaCase ::= "case" expression"default" COLON
caseSList ::=
statement
tryBlock ::= "try" compoundStatement handler finallyClause
handler ::=
"catch" LPAREN parameterDeclaration RPAREN compoundStatement
finallyClause ::=
"finally" compoundStatement
annotationDefinition ::=
AT "interface" IDENT [ab]::annotationBlock
annotationBlock ::= LCURLYannotationField SEMI RCURLY
annotationField ::= [mods]::modifiers "default" [amvi]::annotationMemberValueInitializer SEMI [v]::variableDefinitions SEMI[td]::typeDefinitionInternal [t]::typeSpec [i]::IDENT LPAREN RPAREN [rt]::declaratorBrackets
ctorHead ::=
IDENT LPAREN parameterDeclarationList RPAREN throwsClause
constructorBody ::= [lc]::LCURLY explicitConstructorInvocationstatement 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]::LCURLYannotationMemberArrayValueInitializer COMMA annotationMemberArrayValueInitializer COMMA RCURLY
annotationMemberArrayValueInitializer ::= conditionalExpression annotation
anntotationMemberValuePairs ::= annotationMemberValuePairCOMMA annotationMemberValuePair
annotationMemberValuePair ::= [i]::IDENT ASSIGN [v]::annotationMemberValueInitializer
importDefinition ::= [i]::"import" "static" identifierStar SEMI
identifierStar ::= IDENTDOT IDENT DOT STAR
typeDefinition ::= [m]::modifiers typeDefinitionInternal SEMI