
Grammar connected by Vadim Zaytsev, see the Grammar Zoo entry for details: java/java-1/jls/impl/connected
Source used for this grammar: James Gosling, Bill Joy, Guy Steele, Java Language Specification, 1996, §19: LALR(1) Grammar, pages 439–453 [HTML] [PDF]
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), 1 root (CompilationUnit), 0 top (—), 7 bottom (StringLiteral, IntegerLiteral, Identifier 14, NullLiteral, BooleanLiteral, CharacterLiteral, FloatingPointLiteral).ClassBodyDeclarations ::= ClassBodyDeclaration
ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
PostDecrementExpression ::=
PostfixExpression "--"ExpressionStatement ::=
StatementExpression ";"PrimitiveType ::= NumericType
PrimitiveType ::=
"boolean"InterfaceTypeList ::= InterfaceType
InterfaceTypeList ::=
InterfaceTypeList "," InterfaceTypeInterfaceDeclaration ::= Modifiers "interface" Identifier ExtendsInterfaces InterfaceBody
Statement ::= StatementWithoutTrailingSubstatement
Statement ::= LabeledStatement
Statement ::= IfThenStatement
Statement ::= IfThenElseStatement
Statement ::= WhileStatement
Statement ::= ForStatement
AndExpression ::= EqualityExpression
AndExpression ::=
AndExpression "&" EqualityExpressionConstructorBody ::= "{" ExplicitConstructorInvocation BlockStatements "}"
ArgumentList ::= Expression
ArgumentList ::=
ArgumentList "," ExpressionClassMemberDeclaration ::= FieldDeclaration
ClassMemberDeclaration ::= MethodDeclaration
Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
Interfaces ::=
"implements" InterfaceTypeListCatchClause ::= "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 ::=
"++" UnaryExpressionExplicitConstructorInvocation ::= "this" "(" ArgumentList ")" ";"
ExplicitConstructorInvocation ::= "super" "(" ArgumentList ")" ";"
UnaryExpression ::= PreIncrementExpression
UnaryExpression ::= PreDecrementExpression
UnaryExpression ::=
"+" UnaryExpressionUnaryExpression ::=
"-" UnaryExpressionUnaryExpression ::= UnaryExpressionNotPlusMinus
VariableInitializers ::= VariableInitializer
VariableInitializers ::=
VariableInitializers "," VariableInitializerDimExpr ::= "[" Expression "]"
Throws ::=
"throws" ClassTypeListBlockStatements ::= BlockStatement
BlockStatements ::= BlockStatements BlockStatement
ConstantDeclaration ::= FieldDeclaration
ClassTypeList ::= ClassType
ClassTypeList ::=
ClassTypeList "," ClassTypePrimaryNoNewArray ::= 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" BlockEmptyStatement ::=
";"ReturnStatement ::= "return" Expression ";"
VariableDeclarator ::= VariableDeclaratorId
VariableDeclarator ::=
VariableDeclaratorId "=" VariableInitializerPostfixExpression ::= Primary
PostfixExpression ::= Name
PostfixExpression ::= PostIncrementExpression
PostfixExpression ::= PostDecrementExpression
SwitchLabel ::= "case" ConstantExpression ":"
SwitchLabel ::= "default" ":"
AssignmentExpression ::= ConditionalExpression
AssignmentExpression ::= Assignment
FormalParameter ::= Type VariableDeclaratorId
ConditionalAndExpression ::= InclusiveOrExpression
ConditionalAndExpression ::=
ConditionalAndExpression "&&" InclusiveOrExpressionType ::= PrimitiveType
Type ::= ReferenceType
EqualityExpression ::= RelationalExpression
EqualityExpression ::=
EqualityExpression "==" RelationalExpressionEqualityExpression ::=
EqualityExpression "!=" RelationalExpressionInterfaceMemberDeclaration ::= ConstantDeclaration
InterfaceMemberDeclaration ::= AbstractMethodDeclaration
MultiplicativeExpression ::= UnaryExpression
MultiplicativeExpression ::=
MultiplicativeExpression "*" UnaryExpressionMultiplicativeExpression ::=
MultiplicativeExpression "/" UnaryExpressionMultiplicativeExpression ::=
MultiplicativeExpression "%" UnaryExpressionBreakStatement ::= "break" Identifier ";"
IfThenStatement ::= "if" "(" Expression ")" Statement
SynchronizedStatement ::= "synchronized" "(" Expression ")" Block
ClassInstanceCreationExpression ::= "new" ClassType "(" ArgumentList ")"
Super ::=
"extends" ClassTypeArrayCreationExpression ::= "new" PrimitiveType DimExprs Dims
ArrayCreationExpression ::= "new" ClassOrInterfaceType DimExprs Dims
ArrayInitializer ::= "{" VariableInitializers "," "}"
UnaryExpressionNotPlusMinus ::= PostfixExpression
UnaryExpressionNotPlusMinus ::=
"~" UnaryExpressionUnaryExpressionNotPlusMinus ::=
"!" UnaryExpressionUnaryExpressionNotPlusMinus ::= 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 "," VariableDeclaratorThrowStatement ::= "throw" Expression ";"
ExclusiveOrExpression ::= AndExpression
ExclusiveOrExpression ::=
ExclusiveOrExpression "^" AndExpressionPrimary ::= PrimaryNoNewArray
Primary ::= ArrayCreationExpression
PackageDeclaration ::= "package" Name ";"
RelationalExpression ::= ShiftExpression
RelationalExpression ::=
RelationalExpression "<" ShiftExpressionRelationalExpression ::=
RelationalExpression ">" ShiftExpressionRelationalExpression ::=
RelationalExpression "<=" ShiftExpressionRelationalExpression ::=
RelationalExpression ">=" ShiftExpressionRelationalExpression ::=
RelationalExpression "instanceof" ReferenceTypeWhileStatementNoShortIf ::= "while" "(" Expression ")" StatementNoShortIf
ExtendsInterfaces ::=
"extends" InterfaceTypeExtendsInterfaces ::=
ExtendsInterfaces "," InterfaceTypeConstantExpression ::= Expression
VariableInitializer ::= Expression
VariableInitializer ::= ArrayInitializer
StaticInitializer ::=
"static" BlockLiteral ::= IntegerLiteral
Literal ::= FloatingPointLiteral
Literal ::= BooleanLiteral
Literal ::= CharacterLiteral
Literal ::= StringLiteral
Literal ::= NullLiteral
ConstructorDeclaration ::= Modifiers ConstructorDeclarator Throws ConstructorBody
TypeImportOnDemandDeclaration ::= "import" Name "." "*" ";"
PreDecrementExpression ::=
"--" UnaryExpressionInterfaceMemberDeclarations ::= 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 "||" ConditionalAndExpressionClassBodyDeclaration ::= 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 CatchesTryStatement ::= "try" Block Catches Finally
SwitchLabels ::= SwitchLabel
SwitchLabels ::= SwitchLabels SwitchLabel
FormalParameterList ::= FormalParameter
FormalParameterList ::=
FormalParameterList "," FormalParameterExpression ::= AssignmentExpression
StatementExpressionList ::= StatementExpression
StatementExpressionList ::=
StatementExpressionList "," StatementExpressionAdditiveExpression ::= MultiplicativeExpression
AdditiveExpression ::=
AdditiveExpression "+" MultiplicativeExpressionAdditiveExpression ::=
AdditiveExpression "-" MultiplicativeExpressionFloatingPointType ::=
"float"FloatingPointType ::=
"double"LocalVariableDeclaration ::= Type VariableDeclarators
ConstructorDeclarator ::= SimpleName "(" FormalParameterList ")"
InclusiveOrExpression ::= ExclusiveOrExpression
InclusiveOrExpression ::=
InclusiveOrExpression "|" ExclusiveOrExpressionClassType ::= 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 ":" StatementArrayType ::= 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 "." IdentifierNumericType ::= IntegralType
NumericType ::= FloatingPointType
LeftHandSide ::= Name
LeftHandSide ::= FieldAccess
LeftHandSide ::= ArrayAccess
IfThenElseStatementNoShortIf ::= "if" "(" Expression ")" StatementNoShortIf "else" StatementNoShortIf
LocalVariableDeclarationStatement ::=
LocalVariableDeclaration ";"ShiftExpression ::= AdditiveExpression
ShiftExpression ::=
ShiftExpression "<<" AdditiveExpressionShiftExpression ::=
ShiftExpression ">>" AdditiveExpressionShiftExpression ::=
ShiftExpression ">>>" AdditiveExpressionMethodBody ::= Block
MethodBody ::=
";"Name ::= SimpleName
Name ::= QualifiedName
SimpleName ::= Identifier
ReferenceType ::= ClassOrInterfaceType
ReferenceType ::= ArrayType
CompilationUnit ::= PackageDeclaration ImportDeclarations TypeDeclarations
ForStatementNoShortIf ::= "for" "(" ForInit ";" Expression ";" ForUpdate ")" StatementNoShortIf
MethodHeader ::= Modifiers Type MethodDeclarator Throws
MethodHeader ::= Modifiers "void" MethodDeclarator Throws
LabeledStatementNoShortIf ::=
Identifier ":" StatementNoShortIfInterfaceBody ::= "{" InterfaceMemberDeclarations "}"
FieldAccess ::=
Primary "." IdentifierFieldAccess ::= "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