Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: java/java-1/jls/impl/extracted
Source used for this grammar: James Gosling, Bill Joy, Guy Steele, Java Language Specification, 1996, §19: LALR(1) Grammar, pages 439–453 [HTML] [PDF]
Goal
, ClassBodyDeclarations
, PostDecrementExpression
, ExpressionStatement
, PrimitiveType
, InterfaceTypeList
, InterfaceDeclaration
, Statement
, AndExpression
, ConstructorBody
, ArgumentList
, ClassMemberDeclaration
, Assignment
, Interfaces
, CatchClause
, PostIncrementExpression
, InterfaceType
, BlockStatement
, SwitchBlockStatementGroups
, SingleTypeImportDeclaration
, ConditionalExpression
, PreIncrementExpression
, ExplicitConstructorInvocation
, UnaryExpression
, VariableInitializers
, DimExpr
, Throws
, BlockStatements
, ConstantDeclaration
, ClassTypeList
, PrimaryNoNewArray
, AssignmentOperator
, Finally
, EmptyStatement
, ReturnStatement
, VariableDeclarator
, PostfixExpression
, SwitchLabel
, AssignmentExpression
, FormalParameter
, ConditionalAndExpression
, Type
, EqualityExpression
, InterfaceMemberDeclaration
, MultiplicativeExpression
, BreakStatement
, IfThenStatement
, SynchronizedStatement
, ClassInstanceCreationExpression
, Super
, ArrayCreationExpression
, ArrayInitializer
, UnaryExpressionNotPlusMinus
, SwitchBlock
, FieldDeclaration
, StatementNoShortIf
, MethodInvocation
, AbstractMethodDeclaration
, IfThenElseStatement
, ArrayAccess
, Modifier
, Block
, ForUpdate
, ForInit
, VariableDeclarators
, ThrowStatement
, ExclusiveOrExpression
, Primary
, PackageDeclaration
, RelationalExpression
, WhileStatementNoShortIf
, ExtendsInterfaces
, ConstantExpression
, VariableInitializer
, StaticInitializer
, Literal
, ConstructorDeclaration
, TypeImportOnDemandDeclaration
, PreDecrementExpression
, InterfaceMemberDeclarations
, ForStatement
, ContinueStatement
, ImportDeclaration
, SwitchStatement
, Dims
, ClassBody
, ConditionalOrExpression
, ClassBodyDeclaration
, SwitchBlockStatementGroup
, MethodDeclaration
, Catches
, Modifiers
, DoStatement
, ClassOrInterfaceType
, TryStatement
, SwitchLabels
, FormalParameterList
, Expression
, StatementExpressionList
, AdditiveExpression
, FloatingPointType
, LocalVariableDeclaration
, ConstructorDeclarator
, InclusiveOrExpression
, ClassType
, WhileStatement
, ClassDeclaration
, CastExpression
, ImportDeclarations
, TypeDeclaration
, LabeledStatement
, ArrayType
, StatementExpression
, MethodDeclarator
, VariableDeclaratorId
, IntegralType
, QualifiedName
, NumericType
, LeftHandSide
, IfThenElseStatementNoShortIf
, LocalVariableDeclarationStatement
, ShiftExpression
, MethodBody
, Name
, SimpleName
, ReferenceType
, CompilationUnit
, ForStatementNoShortIf
, MethodHeader
, LabeledStatementNoShortIf
, InterfaceBody
, FieldAccess
, TypeDeclarations
, StatementWithoutTrailingSubstatement
, DimExprs
), 0 root (—), 1 top (Goal
), 7 bottom (StringLiteral
, IntegerLiteral
, Identifier
14, NullLiteral
, BooleanLiteral
, CharacterLiteral
, FloatingPointLiteral
).Goal ::= CompilationUnit
ClassBodyDeclarations ::= ClassBodyDeclaration
ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
PostDecrementExpression ::=
PostfixExpression "--"
ExpressionStatement ::=
StatementExpression ";"
PrimitiveType ::= NumericType
PrimitiveType ::=
"boolean"
InterfaceTypeList ::= InterfaceType
InterfaceTypeList ::=
InterfaceTypeList "," InterfaceType
InterfaceDeclaration ::= Modifiers"interface" Identifier ExtendsInterfaces InterfaceBody
Statement ::= StatementWithoutTrailingSubstatement
Statement ::= LabeledStatement
Statement ::= IfThenStatement
Statement ::= IfThenElseStatement
Statement ::= WhileStatement
Statement ::= ForStatement
AndExpression ::= EqualityExpression
AndExpression ::=
AndExpression "&" EqualityExpression
ConstructorBody ::= "{" ExplicitConstructorInvocation BlockStatements "}"
ArgumentList ::= Expression
ArgumentList ::=
ArgumentList "," Expression
ClassMemberDeclaration ::= FieldDeclaration
ClassMemberDeclaration ::= MethodDeclaration
Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
Interfaces ::=
"implements" InterfaceTypeList
CatchClause ::= "catch" "(" FormalParameter ")" Block
PostIncrementExpression ::=
PostfixExpression "++"
InterfaceType ::= ClassOrInterfaceType
BlockStatement ::= LocalVariableDeclarationStatement
BlockStatement ::= Statement
SwitchBlockStatementGroups ::= SwitchBlockStatementGroup
SwitchBlockStatementGroups ::= SwitchBlockStatementGroups SwitchBlockStatementGroup
SingleTypeImportDeclaration ::= "import" Name ";"
ConditionalExpression ::= ConditionalOrExpression
ConditionalExpression ::= ConditionalOrExpression "?" Expression ":" ConditionalExpression
PreIncrementExpression ::=
"++" UnaryExpression
ExplicitConstructorInvocation ::= "this" "(" ArgumentList ")" ";"
ExplicitConstructorInvocation ::= "super" "(" ArgumentList ")" ";"
UnaryExpression ::= PreIncrementExpression
UnaryExpression ::= PreDecrementExpression
UnaryExpression ::=
"+" UnaryExpression
UnaryExpression ::=
"-" UnaryExpression
UnaryExpression ::= UnaryExpressionNotPlusMinus
VariableInitializers ::= VariableInitializer
VariableInitializers ::=
VariableInitializers "," VariableInitializer
DimExpr ::= "[" Expression "]"
Throws ::=
"throws" ClassTypeList
BlockStatements ::= BlockStatement
BlockStatements ::= BlockStatements BlockStatement
ConstantDeclaration ::= FieldDeclaration
ClassTypeList ::= ClassType
ClassTypeList ::=
ClassTypeList "," ClassType
PrimaryNoNewArray ::= Literal
PrimaryNoNewArray ::=
"this"
PrimaryNoNewArray ::= "(" Expression ")"
PrimaryNoNewArray ::= ClassInstanceCreationExpression
PrimaryNoNewArray ::= FieldAccess
PrimaryNoNewArray ::= MethodInvocation
PrimaryNoNewArray ::= ArrayAccess
AssignmentOperator ::=
"="
AssignmentOperator ::=
"*="
AssignmentOperator ::=
"/="
AssignmentOperator ::=
"%="
AssignmentOperator ::=
"+="
AssignmentOperator ::=
"-="
AssignmentOperator ::=
"<<="
AssignmentOperator ::=
">>="
AssignmentOperator ::=
">>>="
AssignmentOperator ::=
"&="
AssignmentOperator ::=
"^="
AssignmentOperator ::=
"|="
Finally ::=
"finally" Block
EmptyStatement ::=
";"
ReturnStatement ::= "return" Expression ";"
VariableDeclarator ::= VariableDeclaratorId
VariableDeclarator ::=
VariableDeclaratorId "=" VariableInitializer
PostfixExpression ::= Primary
PostfixExpression ::= Name
PostfixExpression ::= PostIncrementExpression
PostfixExpression ::= PostDecrementExpression
SwitchLabel ::= "case" ConstantExpression ":"
SwitchLabel ::= "default" ":"
AssignmentExpression ::= ConditionalExpression
AssignmentExpression ::= Assignment
FormalParameter ::= Type VariableDeclaratorId
ConditionalAndExpression ::= InclusiveOrExpression
ConditionalAndExpression ::=
ConditionalAndExpression "&&" InclusiveOrExpression
Type ::= PrimitiveType
Type ::= ReferenceType
EqualityExpression ::= RelationalExpression
EqualityExpression ::=
EqualityExpression "==" RelationalExpression
EqualityExpression ::=
EqualityExpression "!=" RelationalExpression
InterfaceMemberDeclaration ::= ConstantDeclaration
InterfaceMemberDeclaration ::= AbstractMethodDeclaration
MultiplicativeExpression ::= UnaryExpression
MultiplicativeExpression ::=
MultiplicativeExpression "*" UnaryExpression
MultiplicativeExpression ::=
MultiplicativeExpression "/" UnaryExpression
MultiplicativeExpression ::=
MultiplicativeExpression "%" UnaryExpression
BreakStatement ::= "break" Identifier ";"
IfThenStatement ::= "if" "(" Expression ")" Statement
SynchronizedStatement ::= "synchronized" "(" Expression ")" Block
ClassInstanceCreationExpression ::= "new" ClassType "(" ArgumentList ")"
Super ::=
"extends" ClassType
ArrayCreationExpression ::= "new" PrimitiveType DimExprs Dims
ArrayCreationExpression ::= "new" ClassOrInterfaceType DimExprs Dims
ArrayInitializer ::= "{" VariableInitializers "," "}"
UnaryExpressionNotPlusMinus ::= PostfixExpression
UnaryExpressionNotPlusMinus ::=
"~" UnaryExpression
UnaryExpressionNotPlusMinus ::=
"!" UnaryExpression
UnaryExpressionNotPlusMinus ::= CastExpression
SwitchBlock ::= "{" SwitchBlockStatementGroups SwitchLabels "}"
FieldDeclaration ::= Modifiers";"Type VariableDeclarators
StatementNoShortIf ::= StatementWithoutTrailingSubstatement
StatementNoShortIf ::= LabeledStatementNoShortIf
StatementNoShortIf ::= IfThenElseStatementNoShortIf
StatementNoShortIf ::= WhileStatementNoShortIf
StatementNoShortIf ::= ForStatementNoShortIf
MethodInvocation ::= Name "(" ArgumentList ")"
MethodInvocation ::= Primary "." Identifier "(" ArgumentList ")"
MethodInvocation ::= "super" "." Identifier "(" ArgumentList ")"
AbstractMethodDeclaration ::=
MethodHeader ";"
IfThenElseStatement ::= "if" "(" Expression ")" StatementNoShortIf "else" Statement
ArrayAccess ::= Name "[" Expression "]"
ArrayAccess ::= PrimaryNoNewArray "[" Expression "]"
Modifier ::=
"public"
Modifier ::=
"protected"
Modifier ::=
"private"
Modifier ::=
"static"
Modifier ::=
"abstract"
Modifier ::=
"final"
Modifier ::=
"native"
Modifier ::=
"synchronized"
Modifier ::=
"transient"
Modifier ::=
"volatile"
Block ::= "{" BlockStatements "}"
ForUpdate ::= StatementExpressionList
ForInit ::= StatementExpressionList
ForInit ::= LocalVariableDeclaration
VariableDeclarators ::= VariableDeclarator
VariableDeclarators ::=
VariableDeclarators "," VariableDeclarator
ThrowStatement ::= "throw" Expression ";"
ExclusiveOrExpression ::= AndExpression
ExclusiveOrExpression ::=
ExclusiveOrExpression "^" AndExpression
Primary ::= PrimaryNoNewArray
Primary ::= ArrayCreationExpression
PackageDeclaration ::= "package" Name ";"
RelationalExpression ::= ShiftExpression
RelationalExpression ::=
RelationalExpression "<" ShiftExpression
RelationalExpression ::=
RelationalExpression ">" ShiftExpression
RelationalExpression ::=
RelationalExpression "<=" ShiftExpression
RelationalExpression ::=
RelationalExpression ">=" ShiftExpression
RelationalExpression ::=
RelationalExpression "instanceof" ReferenceType
WhileStatementNoShortIf ::= "while" "(" Expression ")" StatementNoShortIf
ExtendsInterfaces ::=
"extends" InterfaceType
ExtendsInterfaces ::=
ExtendsInterfaces "," InterfaceType
ConstantExpression ::= Expression
VariableInitializer ::= Expression
VariableInitializer ::= ArrayInitializer
StaticInitializer ::=
"static" Block
Literal ::= IntegerLiteral
Literal ::= FloatingPointLiteral
Literal ::= BooleanLiteral
Literal ::= CharacterLiteral
Literal ::= StringLiteral
Literal ::= NullLiteral
ConstructorDeclaration ::= ModifiersConstructorDeclarator Throws ConstructorBody
TypeImportOnDemandDeclaration ::= "import" Name "." "*" ";"
PreDecrementExpression ::=
"--" UnaryExpression
InterfaceMemberDeclarations ::= InterfaceMemberDeclaration
InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
ForStatement ::= "for" "(" ForInit ";" Expression ";" ForUpdate ")" Statement
ContinueStatement ::= "continue" Identifier ";"
ImportDeclaration ::= SingleTypeImportDeclaration
ImportDeclaration ::= TypeImportOnDemandDeclaration
SwitchStatement ::= "switch" "(" Expression ")" SwitchBlock
Dims ::= "[" "]"
Dims ::= Dims "[" "]"
ClassBody ::= "{" ClassBodyDeclarations "}"
ConditionalOrExpression ::= ConditionalAndExpression
ConditionalOrExpression ::=
ConditionalOrExpression "||" ConditionalAndExpression
ClassBodyDeclaration ::= ClassMemberDeclaration
ClassBodyDeclaration ::= StaticInitializer
ClassBodyDeclaration ::= ConstructorDeclaration
SwitchBlockStatementGroup ::= SwitchLabels BlockStatements
MethodDeclaration ::= MethodHeader MethodBody
Catches ::= CatchClause
Catches ::= Catches CatchClause
Modifiers ::= Modifier
Modifiers ::= Modifiers Modifier
DoStatement ::= "do" Statement "while" "(" Expression ")" ";"
ClassOrInterfaceType ::= Name
TryStatement ::=
"try" Block Catches
TryStatement ::= "try" Block Catches Finally
SwitchLabels ::= SwitchLabel
SwitchLabels ::= SwitchLabels SwitchLabel
FormalParameterList ::= FormalParameter
FormalParameterList ::=
FormalParameterList "," FormalParameter
Expression ::= AssignmentExpression
StatementExpressionList ::= StatementExpression
StatementExpressionList ::=
StatementExpressionList "," StatementExpression
AdditiveExpression ::= MultiplicativeExpression
AdditiveExpression ::=
AdditiveExpression "+" MultiplicativeExpression
AdditiveExpression ::=
AdditiveExpression "-" MultiplicativeExpression
FloatingPointType ::=
"float"
FloatingPointType ::=
"double"
LocalVariableDeclaration ::= Type VariableDeclarators
ConstructorDeclarator ::= SimpleName "(" FormalParameterList ")"
InclusiveOrExpression ::= ExclusiveOrExpression
InclusiveOrExpression ::=
InclusiveOrExpression "|" ExclusiveOrExpression
ClassType ::= ClassOrInterfaceType
WhileStatement ::= "while" "(" Expression ")" Statement
ClassDeclaration ::= Modifiers"class" Identifier Super Interfaces ClassBody
CastExpression ::= "(" PrimitiveType Dims ")" UnaryExpression
CastExpression ::= "(" Expression ")" UnaryExpressionNotPlusMinus
CastExpression ::= "(" Name Dims ")" UnaryExpressionNotPlusMinus
ImportDeclarations ::= ImportDeclaration
ImportDeclarations ::= ImportDeclarations ImportDeclaration
TypeDeclaration ::= ClassDeclaration
TypeDeclaration ::= InterfaceDeclaration
TypeDeclaration ::=
";"
LabeledStatement ::=
Identifier ":" Statement
ArrayType ::= PrimitiveType "[" "]"
ArrayType ::= Name "[" "]"
ArrayType ::= ArrayType "[" "]"
StatementExpression ::= Assignment
StatementExpression ::= PreIncrementExpression
StatementExpression ::= PreDecrementExpression
StatementExpression ::= PostIncrementExpression
StatementExpression ::= PostDecrementExpression
StatementExpression ::= MethodInvocation
StatementExpression ::= ClassInstanceCreationExpression
MethodDeclarator ::= Identifier "(" FormalParameterList ")"
MethodDeclarator ::= MethodDeclarator "[" "]"
VariableDeclaratorId ::= Identifier
VariableDeclaratorId ::= VariableDeclaratorId "[" "]"
IntegralType ::=
"byte"
IntegralType ::=
"short"
IntegralType ::=
"int"
IntegralType ::=
"long"
IntegralType ::=
"char"
QualifiedName ::=
Name "." Identifier
NumericType ::= IntegralType
NumericType ::= FloatingPointType
LeftHandSide ::= Name
LeftHandSide ::= FieldAccess
LeftHandSide ::= ArrayAccess
IfThenElseStatementNoShortIf ::= "if" "(" Expression ")" StatementNoShortIf "else" StatementNoShortIf
LocalVariableDeclarationStatement ::=
LocalVariableDeclaration ";"
ShiftExpression ::= AdditiveExpression
ShiftExpression ::=
ShiftExpression "<<" AdditiveExpression
ShiftExpression ::=
ShiftExpression ">>" AdditiveExpression
ShiftExpression ::=
ShiftExpression ">>>" AdditiveExpression
MethodBody ::= Block
MethodBody ::=
";"
Name ::= SimpleName
Name ::= QualifiedName
SimpleName ::= Identifier
ReferenceType ::= ClassOrInterfaceType
ReferenceType ::= ArrayType
CompilationUnit ::= PackageDeclarationImportDeclarations TypeDeclarations
ForStatementNoShortIf ::= "for" "(" ForInit ";" Expression ";" ForUpdate ")" StatementNoShortIf
MethodHeader ::= ModifiersType MethodDeclarator Throws
MethodHeader ::= Modifiers"void" MethodDeclarator Throws
LabeledStatementNoShortIf ::=
Identifier ":" StatementNoShortIf
InterfaceBody ::= "{" InterfaceMemberDeclarations "}"
FieldAccess ::=
Primary "." Identifier
FieldAccess ::= "super" "." Identifier
TypeDeclarations ::= TypeDeclaration
TypeDeclarations ::= TypeDeclarations TypeDeclaration
StatementWithoutTrailingSubstatement ::= Block
StatementWithoutTrailingSubstatement ::= EmptyStatement
StatementWithoutTrailingSubstatement ::= ExpressionStatement
StatementWithoutTrailingSubstatement ::= SwitchStatement
StatementWithoutTrailingSubstatement ::= DoStatement
StatementWithoutTrailingSubstatement ::= BreakStatement
StatementWithoutTrailingSubstatement ::= ContinueStatement
StatementWithoutTrailingSubstatement ::= ReturnStatement
StatementWithoutTrailingSubstatement ::= SynchronizedStatement
StatementWithoutTrailingSubstatement ::= ThrowStatement
StatementWithoutTrailingSubstatement ::= TryStatement
DimExprs ::= DimExpr
DimExprs ::= DimExprs DimExpr