
Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: java/java-5/jls/impl/extracted
Source used for this grammar: James Gosling, Bill Joy, Guy Steele, Gilad Bracha, Java Language Specification, 3rd edition, 2004, §18: Syntax, pages 585–596 [HTML] [PDF]
NormalClassDeclaration, ExplicitGenericInvocation, InterfaceDeclaration, Statement, Annotations, ElementValue, TypeParameter, CatchClause, ClassCreatorRest, ClassBodyDeclaration, BlockStatement, Annotation, SwitchBlockStatementGroups, EnumConstant, QualifiedIdentifier, ConstantDeclaratorsRest, AnnotationTypeDeclaration, NonWildcardTypeArguments, MoreStatementExpressions, Expression3, BlockStatements, IdentifierSuffix, InterfaceMethodDeclaratorRest, FormalParameterDeclsRest, AssignmentOperator, ParExpression, AnnotationTypeElementDeclarations, VariableDeclaratorsRest, ForControl, VariableDeclarator, ConstantExpression, SwitchLabel, ElementValues, InterfaceMemberDecl, AnnotationConstantRest, QualifiedIdentifierList, GenericMethodOrConstructorRest, ArrayCreatorRest, Type, FormalParameters, TypeList, Selector, VoidInterfaceMethodDeclaratorRest, InterfaceBodyDeclaration, MethodDeclaratorRest, ArrayInitializer, EnumConstants, VariableDeclaratorRest, MethodOrFieldRest, Modifier, Block, PostfixOp, ForInit, EnumDeclaration, VariableDeclarators, Primary, Expression2Rest, VariableInitializer, Literal, ExplicitGenericInvocationSuffix, Identifier, ImportDeclaration, BasicType, GenericMethodOrConstructorDecl, ConstantDeclarator, ClassBody, MemberDecl, SwitchBlockStatementGroup, Catches, InterfaceMethodOrFieldRest, Expression1Rest, TypeArguments, Expression, ConditionalExpression, Creator, InfixOp, ClassOrInterfaceDeclaration, ConstructorDeclaratorRest, InterfaceMethodOrFieldDecl, ClassDeclaration, MethodOrFieldDecl, InnerCreator, PrefixOp, CreatedName, TypeDeclaration, FormalParameterDecls, ConstantDeclaratorRest, StatementExpression, Arguments, ElementValueArrayInitializer, VariableDeclaratorId, AnnotationMethodRest, VoidMethodDeclaratorRest, AnnotationTypeBody, LocalVariableDeclarationStatement, Expression1, TypeParameters, Expression2, MethodBody, ForVarControlRest, EnumBodyDeclarations, DefaultValue, AnnotationMethodOrConstantRest, SuperSuffix, InterfaceGenericMethodDecl, EnumBody, CompilationUnit, InterfaceBody, EnumConstantName, Bound, TypeArgument, AnnotationTypeElementRest, AnnotationTypeElementDeclaration, NormalInterfaceDeclaration), 0 root (—), 2 top (MoreStatementExpressions, CompilationUnit), 12 bottom (ForVarControl, StringLiteral, Expressions, FormalParameter, ForUpdate 2, IntegerLiteral, IDENTIFIER, NullLiteral, BooleanLiteral, CharacterLiteral, TypeName, FloatingPointLiteral).NormalClassDeclaration ::= "class" Identifier TypeParameters "extends" Type "implements" TypeList ClassBody
ExplicitGenericInvocation ::= NonWildcardTypeArguments ExplicitGenericInvocationSuffix
InterfaceDeclaration ::= NormalInterfaceDeclaration
InterfaceDeclaration ::= AnnotationTypeDeclaration
Statement ::= Block
Statement ::= "assert" Expression ":" Expression ";"
Statement ::= "if" ParExpression Statement "else" Statement
Statement ::= "for" "(" ForControl ")" Statement
Statement ::=
"while" ParExpression StatementStatement ::= "do" Statement "while" ParExpression ";"
Statement ::= "try" Block CatchesCatches "finally" Block
Statement ::= "switch" ParExpression "{" SwitchBlockStatementGroups "}"
Statement ::=
"synchronized" ParExpression BlockStatement ::= "return" Expression ";"
Statement ::= "throw" Expression ";"
Statement ::= "break" Identifier
Statement ::= "continue" Identifier
Statement ::=
";"Statement ::=
StatementExpression ";"Statement ::=
Identifier ":" StatementAnnotations ::=
Annotation AnnotationsElementValue ::= ConditionalExpression
ElementValue ::= Annotation
ElementValue ::= ElementValueArrayInitializer
TypeParameter ::= Identifier "extends" Bound
CatchClause ::= "catch" "(" FormalParameter ")" Block
ClassCreatorRest ::=
Arguments ClassBodyClassBodyDeclaration ::=
";"ClassBodyDeclaration ::= "static" Block
ClassBodyDeclaration ::=
Modifier MemberDeclBlockStatement ::= LocalVariableDeclarationStatement
BlockStatement ::= ClassOrInterfaceDeclaration
BlockStatement ::= Identifier ":" Statement
Annotation ::= "@" TypeName "(" Identifier "=" ElementValue ")"
SwitchBlockStatementGroups ::=
SwitchBlockStatementGroupEnumConstant ::= Annotations Identifier Arguments ClassBody
QualifiedIdentifier ::= Identifier "." Identifier
ConstantDeclaratorsRest ::= ConstantDeclaratorRest "," ConstantDeclarator
AnnotationTypeDeclaration ::= "@" "interface" Identifier AnnotationTypeBody
NonWildcardTypeArguments ::= "<" TypeList ">"
MoreStatementExpressions ::= "," StatementExpression
Expression3 ::= PrefixOp Expression3
Expression3 ::= "(" ExpressionType ")" Expression3
Expression3 ::= Primary Selector PostfixOp
BlockStatements ::=
BlockStatementIdentifierSuffix ::= "[" "]" "[" "]" "." "class"Expression "]"
IdentifierSuffix ::= Arguments
IdentifierSuffix ::= "." "class"ExplicitGenericInvocation"this""super" Arguments"new" NonWildcardTypeArguments InnerCreator
InterfaceMethodDeclaratorRest ::= FormalParameters "[" "]" "throws" QualifiedIdentifierList ";"
FormalParameterDeclsRest ::= VariableDeclaratorId "," FormalParameterDecls
FormalParameterDeclsRest ::=
"..." VariableDeclaratorIdAssignmentOperator ::=
"="AssignmentOperator ::=
"+="AssignmentOperator ::=
"-="AssignmentOperator ::=
"*="AssignmentOperator ::=
"/="AssignmentOperator ::=
"&="AssignmentOperator ::=
"|="AssignmentOperator ::=
"^="AssignmentOperator ::=
"%="AssignmentOperator ::=
"<<="AssignmentOperator ::=
">>="AssignmentOperator ::=
">>>="ParExpression ::= "(" Expression ")"
AnnotationTypeElementDeclarations ::= AnnotationTypeElementDeclaration
AnnotationTypeElementDeclarations ::= AnnotationTypeElementDeclarations AnnotationTypeElementDeclaration
VariableDeclaratorsRest ::= VariableDeclaratorRest "," VariableDeclarator
ForControl ::= ForVarControl
ForControl ::= ForInit ";" Expression ";" ForUpdate
ForControl ::= "final" Annotations Type Identifier ForVarControlRest
VariableDeclarator ::= Identifier VariableDeclaratorRest
ConstantExpression ::= Expression
SwitchLabel ::= "case" ConstantExpression ":"
SwitchLabel ::= "case" EnumConstantName ":"
SwitchLabel ::= "default" ":"
ElementValues ::=
ElementValue ElementValuesInterfaceMemberDecl ::= InterfaceMethodOrFieldDecl
InterfaceMemberDecl ::= InterfaceGenericMethodDecl
InterfaceMemberDecl ::=
"void" Identifier VoidInterfaceMethodDeclaratorRestInterfaceMemberDecl ::= InterfaceDeclaration
InterfaceMemberDecl ::= ClassDeclaration
AnnotationConstantRest ::= VariableDeclarators
QualifiedIdentifierList ::= QualifiedIdentifier "," QualifiedIdentifier
GenericMethodOrConstructorRest ::= Type"void" Identifier MethodDeclaratorRest
GenericMethodOrConstructorRest ::= Identifier ConstructorDeclaratorRest
ArrayCreatorRest ::= "[" "]" "[" "]" ArrayInitializerExpression "]" "[" Expression "]" "[" "]"
Type ::= Identifier TypeArguments "." Identifier TypeArguments "[" "]"
Type ::= BasicType
FormalParameters ::= "(" FormalParameterDecls ")"
TypeList ::= Type "," Type
Selector ::= "." Identifier Arguments
Selector ::=
"." ExplicitGenericInvocationSelector ::= "." "this"
Selector ::= "." "super" SuperSuffix
Selector ::= "." "new" NonWildcardTypeArguments InnerCreator
Selector ::=
ExpressionVoidInterfaceMethodDeclaratorRest ::= FormalParameters "throws" QualifiedIdentifierList ";"
InterfaceBodyDeclaration ::=
";"InterfaceBodyDeclaration ::=
Modifier InterfaceMemberDeclMethodDeclaratorRest ::= FormalParameters "[" "]" "throws" QualifiedIdentifierList MethodBody";"
ArrayInitializer ::= VariableInitializer "," VariableInitializer ","
EnumConstants ::= EnumConstant
EnumConstants ::=
EnumConstants "," EnumConstantVariableDeclaratorRest ::= "[" "]" "=" VariableInitializer
MethodOrFieldRest ::= VariableDeclaratorRest
MethodOrFieldRest ::= MethodDeclaratorRest
Modifier ::= Annotation
Modifier ::=
"public"Modifier ::=
"protected"Modifier ::=
"private"Modifier ::=
"static"Modifier ::=
"abstract"Modifier ::=
"final"Modifier ::=
"native"Modifier ::=
"synchronized"Modifier ::=
"transient"Modifier ::=
"volatile"Modifier ::=
"strictfp"Block ::=
BlockStatementsPostfixOp ::=
"++"PostfixOp ::=
"--"ForInit ::= StatementExpression Expressions
EnumDeclaration ::= "enum" Identifier "implements" TypeList EnumBody
VariableDeclarators ::= VariableDeclarator "," VariableDeclarator
Primary ::= ParExpression
Primary ::= NonWildcardTypeArguments ExplicitGenericInvocationSuffix"this" Arguments
Primary ::= "this" Arguments
Primary ::=
"super" SuperSuffixPrimary ::= Literal
Primary ::=
"new" CreatorPrimary ::= Identifier "." Identifier IdentifierSuffix
Primary ::= BasicType "[" "]" "." "class"
Primary ::= "void" "." "class"
Expression2Rest ::= InfixOp Expression3
Expression2Rest ::=
Expression3 "instanceof" TypeVariableInitializer ::= ArrayInitializer
VariableInitializer ::= Expression
Literal ::= IntegerLiteral
Literal ::= FloatingPointLiteral
Literal ::= CharacterLiteral
Literal ::= StringLiteral
Literal ::= BooleanLiteral
Literal ::= NullLiteral
ExplicitGenericInvocationSuffix ::=
"super" SuperSuffixExplicitGenericInvocationSuffix ::= Identifier Arguments
Identifier ::= IDENTIFIER
ImportDeclaration ::= "import" "static" Identifier "." Identifier "." "*" ";"
BasicType ::=
"byte"BasicType ::=
"short"BasicType ::=
"char"BasicType ::=
"int"BasicType ::=
"long"BasicType ::=
"float"BasicType ::=
"double"BasicType ::=
"boolean"GenericMethodOrConstructorDecl ::= TypeParameters GenericMethodOrConstructorRest
ConstantDeclarator ::= Identifier ConstantDeclaratorRest
ClassBody ::= "{" ClassBodyDeclaration "}"
MemberDecl ::= GenericMethodOrConstructorDecl
MemberDecl ::= MethodOrFieldDecl
MemberDecl ::=
"void" Identifier VoidMethodDeclaratorRestMemberDecl ::= Identifier ConstructorDeclaratorRest
MemberDecl ::= InterfaceDeclaration
MemberDecl ::= ClassDeclaration
SwitchBlockStatementGroup ::= SwitchLabel BlockStatements
Catches ::=
CatchClause CatchClauseInterfaceMethodOrFieldRest ::=
ConstantDeclaratorsRest ";"InterfaceMethodOrFieldRest ::= InterfaceMethodDeclaratorRest
Expression1Rest ::= "?" Expression ":" Expression1
TypeArguments ::= "<" TypeArgument "," TypeArgument ">"
Expression ::= Expression1 AssignmentOperator Expression1
ConditionalExpression ::= Expression2 Expression1Rest
Creator ::= NonWildcardTypeArguments CreatedName ArrayCreatorRestClassCreatorRest
InfixOp ::=
"||"InfixOp ::=
"&&"InfixOp ::=
"|"InfixOp ::=
"^"InfixOp ::=
"&"InfixOp ::=
"=="InfixOp ::=
"!="InfixOp ::=
"<"InfixOp ::=
">"InfixOp ::=
"<="InfixOp ::=
">="InfixOp ::=
"<<"InfixOp ::=
">>"InfixOp ::=
">>>"InfixOp ::=
"+"InfixOp ::=
"-"InfixOp ::=
"*"InfixOp ::=
"/"InfixOp ::=
"%"ClassOrInterfaceDeclaration ::= Modifier ClassDeclarationInterfaceDeclaration
ConstructorDeclaratorRest ::= FormalParameters "throws" QualifiedIdentifierList MethodBody
InterfaceMethodOrFieldDecl ::= Type Identifier InterfaceMethodOrFieldRest
ClassDeclaration ::= NormalClassDeclaration
ClassDeclaration ::= EnumDeclaration
MethodOrFieldDecl ::= Type Identifier MethodOrFieldRest
InnerCreator ::= Identifier ClassCreatorRest
PrefixOp ::=
"++"PrefixOp ::=
"--"PrefixOp ::=
"!"PrefixOp ::=
"~"PrefixOp ::=
"+"PrefixOp ::=
"-"CreatedName ::= Identifier NonWildcardTypeArguments "." Identifier NonWildcardTypeArguments
TypeDeclaration ::= ClassOrInterfaceDeclaration
TypeDeclaration ::=
";"FormalParameterDecls ::= "final" Annotations Type FormalParameterDeclsRest
ConstantDeclaratorRest ::= "[" "]" "=" VariableInitializer
StatementExpression ::= Expression
Arguments ::= "(" Expression "," Expression ")"
ElementValueArrayInitializer ::= "{" ElementValues "," "}"
VariableDeclaratorId ::= Identifier "[" "]"
AnnotationMethodRest ::= "(" ")" DefaultValue
VoidMethodDeclaratorRest ::= FormalParameters "throws" QualifiedIdentifierList MethodBody";"
AnnotationTypeBody ::= AnnotationTypeElementDeclarations
LocalVariableDeclarationStatement ::= "final" Type VariableDeclarators ";"
Expression1 ::=
Expression2 Expression1RestTypeParameters ::= "<" TypeParameter "," TypeParameter ">"
Expression2 ::=
Expression3 Expression2RestMethodBody ::= Block
ForVarControlRest ::= VariableDeclaratorsRest ";" Expression ";" ForUpdate
ForVarControlRest ::=
":" ExpressionEnumBodyDeclarations ::= ";" ClassBodyDeclaration
DefaultValue ::=
"default" ElementValueAnnotationMethodOrConstantRest ::= AnnotationMethodRest
AnnotationMethodOrConstantRest ::= AnnotationConstantRest
SuperSuffix ::= Arguments
SuperSuffix ::= "." Identifier Arguments
InterfaceGenericMethodDecl ::= TypeParameters Type"void" Identifier InterfaceMethodDeclaratorRest
EnumBody ::= EnumConstants "," EnumBodyDeclarations
CompilationUnit ::= Annotations "package" QualifiedIdentifier ";" ImportDeclaration TypeDeclaration
InterfaceBody ::= "{" InterfaceBodyDeclaration "}"
EnumConstantName ::= Identifier
Bound ::= Type "&" Type
TypeArgument ::= Type
TypeArgument ::= "?" "extends""super" Type
AnnotationTypeElementRest ::=
Type Identifier AnnotationMethodOrConstantRest ";"AnnotationTypeElementRest ::= ClassDeclaration
AnnotationTypeElementRest ::= InterfaceDeclaration
AnnotationTypeElementRest ::= EnumDeclaration
AnnotationTypeElementRest ::= AnnotationTypeDeclaration
AnnotationTypeElementDeclaration ::=
Modifier AnnotationTypeElementRestNormalInterfaceDeclaration ::= "interface" Identifier TypeParameters "extends" TypeList InterfaceBody