Tuesday, February 21, 2012

The Java JLS2 Grammar

This is the formal syntax of Java (JLS2 2000) from The Java Language Specification, Second Edition. The grammar is written in ISO/IEC 14977 EBNF notation (ISO/IEC 1996).

Grammar | The goal symbol Input | The goal symbol CompilationUnit | Index

Grammar

UnicodeInputCharacter =
UnicodeEscape | RawInputCharacter ;

UnicodeEscape =
'\', UnicodeMarker, HexDigit, HexDigit, HexDigit, HexDigit ;

UnicodeMarker =
'u' | UnicodeMarker, 'u' ;

RawInputCharacter =
? any Unicode character ? ;

HexDigit =
'0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' ;

LineTerminator =
? the ASCII LF character, also known as "newline" ? | ? the ASCII CR character, also known as "return" ? | ? the ASCII CR character followed by the ASCII LF character ? ;

InputCharacter =
UnicodeInputCharacter - (? CR ? | ? LF ?) ;

Input =
[InputElements], [Sub] ;

InputElements =
InputElement | InputElements, InputElement ;

InputElement =
WhiteSpace | Comment | Token ;

Token =
Identifier | Keyword | Literal | Separator | Operator ;

Sub =
? the ASCII SUB character, also known as "control-Z" ? ;

WhiteSpace =
? the ASCII SP character, also known as "space" ? | ? the ASCII HT character, also known as "horizontal tab" ? | ? the ASCII FF character, also known as "form feed" ? | LineTerminator ;

Comment =
TraditionalComment | EndOfLineComment ;

TraditionalComment =
'/', '*', NotStar, CommentTail ;

EndOfLineComment =
'/', '/', [CharactersInLine], LineTerminator ;

CommentTail =
'*', CommentTailStar | NotStar, CommentTail ;

CommentTailStar =
'/' | '*', CommentTailStar | NotStarNotSlash, CommentTail ;

NotStar =
InputCharacter - '*' | LineTerminator ;

NotStarNotSlash =
InputCharacter - ('*' | '/') | LineTerminator ;

CharactersInLine =
InputCharacter | CharactersInLine, InputCharacter ;

Identifier =
IdentifierChars - (Keyword | BooleanLiteral | NullLiteral) ;

IdentifierChars =
JavaLetter | IdentifierChars, JavaLetterOrDigit ;

JavaLetter =
? any Unicode character that is a Java letter ? ;

JavaLetterOrDigit =
? any Unicode character that is a Java letter-or-digit ? ;

Keyword =
'abstract' | 'boolean' | 'break' | 'byte' | 'case' | 'catch' | 'char' | 'class' | 'const' | 'continue' | 'default' | 'do' | 'double' | 'else' | 'extends' | 'final' | 'finally' | 'float' | 'for' | 'goto' | 'if' | 'implements' | 'import' | 'instanceof' | 'int' | 'interface' | 'long' | 'native' | 'new' | 'package' | 'private' | 'protected' | 'public' | 'return' | 'short' | 'static' | 'strictfp' | 'super' | 'switch' | 'synchronized' | 'this' | 'throw' | 'throws' | 'transient' | 'try' | 'void' | 'volatile' | 'while' ;

Literal =
IntegerLiteral | FloatingPointLiteral | BooleanLiteral | CharacterLiteral | StringLiteral | NullLiteral ;

IntegerLiteral =
DecimalIntegerLiteral | HexIntegerLiteral | OctalIntegerLiteral ;

DecimalIntegerLiteral =
DecimalNumeral, [IntegerTypeSuffix] ;

HexIntegerLiteral =
HexNumeral, [IntegerTypeSuffix] ;

OctalIntegerLiteral =
OctalNumeral, [IntegerTypeSuffix] ;

IntegerTypeSuffix =
'l' | 'L' ;

DecimalNumeral =
'0' | NonZeroDigit, [Digits] ;

Digits =
Digit | Digits, Digit ;

Digit =
'0' | NonZeroDigit ;

NonZeroDigit =
'1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ;

HexNumeral =
'0', 'x', HexDigits | '0', 'X', HexDigits ;

HexDigits =
HexDigit | HexDigit, HexDigits ;

OctalNumeral =
'0', OctalDigits ;

OctalDigits =
OctalDigit | OctalDigit, OctalDigits ;

OctalDigit =
'0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' ;

FloatingPointLiteral =
Digits, '.', [Digits], [ExponentPart], [FloatTypeSuffix] | '.', Digits, [ExponentPart], [FloatTypeSuffix] | Digits, ExponentPart, [FloatTypeSuffix] | Digits, [ExponentPart], FloatTypeSuffix ;

ExponentPart =
ExponentIndicator, SignedInteger ;

ExponentIndicator =
'e' | 'E' ;

SignedInteger =
[Sign], Digits ;

Sign =
'+' | '-' ;

FloatTypeSuffix =
'f' | 'F' | 'd' | 'D' ;

BooleanLiteral =
'true' | 'false' ;

CharacterLiteral =
"'", SingleCharacter, "'" | "'", EscapeSequence, "'" ;

SingleCharacter =
InputCharacter - ("'" | '\') ;

StringLiteral =
'"', [StringCharacters], '"' ;

StringCharacters =
StringCharacter | StringCharacters, StringCharacter ;

StringCharacter =
InputCharacter - ('"' | '\') | EscapeSequence ;

EscapeSequence =
'\', 'b' | '\', 't' | '\', 'n' | '\', 'f' | '\', 'r' | '\', '"' | '\', "'" | '\', '\' | OctalEscape ;

OctalEscape =
'\', OctalDigit | '\', OctalDigit, OctalDigit | '\', ZeroToThree, OctalDigit, OctalDigit ;

OctalDigit =
'0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' ;

ZeroToThree =
'0' | '1' | '2' | '3' ;

NullLiteral =
'null' ;

Separator =
'(' | ')' | '{' | '}' | '[' | ']' | ';' | ',' | '.' ;

Operator =
'!' | '!=' | '%' | '%=' | '&' | '&&' | '&=' | '*' | '*=' | '+' | '++' | '+=' | '-' | '--' | '-=' | '/' | '/=' | ':' | '<' | '<<' | '<<=' | '<=' | '=' | '==' | '>' | '>=' | '>>' | '>>=' | '>>>' | '>>>=' | '?' | '^' | '^=' | '|' | '|=' | '||' | '~' ;

Type =
PrimitiveType | ReferenceType ;

PrimitiveType =
NumericType | 'boolean' ;

NumericType =
IntegralType | FloatingPointType ;

IntegralType =
'byte' | 'short' | 'int' | 'long' | 'char' ;

FloatingPointType =
'float' | 'double' ;

ReferenceType =
ClassOrInterfaceType | ArrayType ;

ClassOrInterfaceType =
ClassType | InterfaceType ;

ClassType =
TypeName ;

InterfaceType =
TypeName ;

ArrayType =
Type, '[', ']' ;

PackageName =
Identifier | PackageName, '.', Identifier ;

TypeName =
Identifier | PackageOrTypeName, '.', Identifier ;

ExpressionName =
Identifier | AmbiguousName, '.', Identifier ;

MethodName =
Identifier | AmbiguousName, '.', Identifier ;

PackageOrTypeName =
Identifier | PackageOrTypeName, '.', Identifier ;

AmbiguousName =
Identifier | AmbiguousName, '.', Identifier ;

CompilationUnit =
[PackageDeclaration], [ImportDeclarations], [TypeDeclarations] ;

ImportDeclarations =
ImportDeclaration | ImportDeclarations, ImportDeclaration ;

TypeDeclarations =
TypeDeclaration | TypeDeclarations, TypeDeclaration ;

PackageDeclaration =
'package', PackageName, ';' ;

ImportDeclaration =
SingleTypeImportDeclaration | TypeImportOnDemandDeclaration ;

SingleTypeImportDeclaration =
'import', TypeName, ';' ;

TypeImportOnDemandDeclaration =
'import', PackageOrTypeName, '.', '*', ';' ;

TypeDeclaration =
ClassDeclaration | InterfaceDeclaration | ';' ;

ClassDeclaration =
[ClassModifiers], 'class', Identifier, [Super], [Interfaces], ClassBody ;

ClassModifiers =
ClassModifier | ClassModifiers, ClassModifier ;

ClassModifier =
'public' | 'protected' | 'private' | 'abstract' | 'static' | 'final' | 'strictfp' ;

Super =
'extends', ClassType ;

ClassType =
TypeName ;

Interfaces =
'implements', InterfaceTypeList ;

InterfaceTypeList =
InterfaceType | InterfaceTypeList, ',', InterfaceType ;

ClassBody =
'{', [ClassBodyDeclarations], '}' ;

ClassBodyDeclarations =
ClassBodyDeclaration | ClassBodyDeclarations, ClassBodyDeclaration ;

ClassBodyDeclaration =
ClassMemberDeclaration | InstanceInitializer | StaticInitializer | ConstructorDeclaration ;

ClassMemberDeclaration =
FieldDeclaration | MethodDeclaration | ClassDeclaration | InterfaceDeclaration | ';' ;

FieldDeclaration =
[FieldModifiers], Type, VariableDeclarators, ';' ;

VariableDeclarators =
VariableDeclarator | VariableDeclarators, ',', VariableDeclarator ;

VariableDeclarator =
VariableDeclaratorId | VariableDeclaratorId, '=', VariableInitializer ;

VariableDeclaratorId =
Identifier | VariableDeclaratorId, '[', ']' ;

VariableInitializer =
Expression | ArrayInitializer ;

FieldModifiers =
FieldModifier | FieldModifiers, FieldModifier ;

FieldModifier =
'public' | 'protected' | 'private' | 'static' | 'final' | 'transient' | 'volatile' ;

MethodDeclaration =
MethodHeader, MethodBody ;

MethodHeader =
[MethodModifiers], ResultType, MethodDeclarator, [Throws] ;

ResultType =
Type | 'void' ;

MethodDeclarator =
Identifier, '(', [FormalParameterList], ')' | MethodDeclarator, '[', ']' ;

FormalParameterList =
FormalParameter | FormalParameterList, ',', FormalParameter ;

FormalParameter =
['final'], Type, VariableDeclaratorId ;

VariableDeclaratorId =
Identifier | VariableDeclaratorId, '[', ']' ;

MethodModifiers =
MethodModifier | MethodModifiers, MethodModifier ;

MethodModifier =
'public' | 'protected' | 'private' | 'abstract' | 'static' | 'final' | 'native' | 'synchronized' | 'strictfp' ;

Throws =
'throws', ClassTypeList ;

ClassTypeList =
ClassType | ClassTypeList, ',', ClassType ;

MethodBody =
Block | ';' ;

InstanceInitializer =
Block ;

StaticInitializer =
'static', Block ;

ConstructorDeclaration =
[ConstructorModifiers], ConstructorDeclarator, [Throws], ConstructorBody ;

ConstructorDeclarator =
SimpleTypeName, '(', [FormalParameterList], ')' ;

ConstructorModifiers =
ConstructorModifier | ConstructorModifiers, ConstructorModifier ;

ConstructorModifier =
'public' | 'protected' | 'private' ;

ConstructorBody =
'{', [ExplicitConstructorInvocation], [BlockStatements], '}' ;

ExplicitConstructorInvocation =
'this', '(', [ArgumentList], ')', ';' | 'super', '(', [ArgumentList], ')', ';' | Primary, '.', 'super', '(', [ArgumentList], ')', ';' ;

InterfaceDeclaration =
[InterfaceModifiers], 'interface', Identifier, [ExtendsInterfaces], InterfaceBody ;

InterfaceModifiers =
InterfaceModifier | InterfaceModifiers, InterfaceModifier ;

InterfaceModifier =
'public' | 'protected' | 'private' | 'abstract' | 'static' | 'strictfp' ;

ExtendsInterfaces =
'extends', InterfaceType | ExtendsInterfaces, ',', InterfaceType ;

InterfaceType =
TypeName ;

InterfaceBody =
'{', [InterfaceMemberDeclarations], '}' ;

InterfaceMemberDeclarations =
InterfaceMemberDeclaration | InterfaceMemberDeclarations, InterfaceMemberDeclaration ;

InterfaceMemberDeclaration =
ConstantDeclaration | AbstractMethodDeclaration | ClassDeclaration | InterfaceDeclaration | ';' ;

ConstantDeclaration =
[ConstantModifiers], Type, VariableDeclarators ;

ConstantModifiers =
ConstantModifier | ConstantModifiers, ConstantModifier ;

ConstantModifier =
'public' | 'static' | 'final' ;

AbstractMethodDeclaration =
[AbstractMethodModifiers], ResultType, MethodDeclarator, [Throws], ';' ;

AbstractMethodModifiers =
AbstractMethodModifier | AbstractMethodModifiers, AbstractMethodModifier ;

AbstractMethodModifier =
'public', 'abstract' ;

ArrayInitializer =
'{', [VariableInitializers], [','], '}' ;

VariableInitializers =
VariableInitializer | VariableInitializers, ',', VariableInitializer ;

Block =
'{', [BlockStatements], '}' ;

BlockStatements =
BlockStatement | BlockStatements, BlockStatement ;

BlockStatement =
LocalVariableDeclarationStatement | ClassDeclaration | Statement ;

LocalVariableDeclarationStatement =
LocalVariableDeclaration, ';' ;

LocalVariableDeclaration =
['final'], Type, VariableDeclarators ;

VariableDeclarators =
VariableDeclarator | VariableDeclarators, ',', VariableDeclarator ;

VariableDeclarator =
VariableDeclaratorId | VariableDeclaratorId, '=', VariableInitializer ;

VariableDeclaratorId =
Identifier | VariableDeclaratorId, '[', ']' ;

VariableInitializer =
Expression | ArrayInitializer ;

Statement =
StatementWithoutTrailingSubstatement | LabeledStatement | IfThenStatement | IfThenElseStatement | WhileStatement | ForStatement ;

StatementWithoutTrailingSubstatement =
Block | EmptyStatement | ExpressionStatement | SwitchStatement | DoStatement | BreakStatement | ContinueStatement | ReturnStatement | SynchronizedStatement | ThrowStatement | TryStatement ;

StatementNoShortIf =
StatementWithoutTrailingSubstatement | LabeledStatementNoShortIf | IfThenElseStatementNoShortIf | WhileStatementNoShortIf | ForStatementNoShortIf ;

EmptyStatement =
';' ;

LabeledStatement =
Identifier, ':', Statement ;

LabeledStatementNoShortIf =
Identifier, ':', StatementNoShortIf ;

ExpressionStatement =
StatementExpression, ';' ;

StatementExpression =
Assignment | PreIncrementExpression | PreDecrementExpression | PostIncrementExpression | PostDecrementExpression | MethodInvocation | ClassInstanceCreationExpression ;

IfThenStatement =
'if', '(', Expression, ')', Statement ;

IfThenElseStatement =
'if', '(', Expression, ')', StatementNoShortIf, 'else', Statement ;

IfThenElseStatementNoShortIf =
'if', '(', Expression, ')', StatementNoShortIf, 'else', StatementNoShortIf ;

SwitchStatement =
'switch', '(', Expression, ')', SwitchBlock ;

SwitchBlock =
'{', [SwitchBlockStatementGroups], [SwitchLabels], '}' ;

SwitchBlockStatementGroups =
SwitchBlockStatementGroup | SwitchBlockStatementGroups, SwitchBlockStatementGroup ;

SwitchBlockStatementGroup =
SwitchLabels, BlockStatements ;

SwitchLabels =
SwitchLabel | SwitchLabels, SwitchLabel ;

SwitchLabel =
'case', ConstantExpression, ':' | 'default', ':' ;

WhileStatement =
'while', '(', Expression, ')', Statement ;

WhileStatementNoShortIf =
'while', '(', Expression, ')', StatementNoShortIf ;

DoStatement =
'do', Statement, 'while', '(', Expression, ')', ';' ;

ForStatement =
'for', '(', [ForInit], ';', [Expression], ';', [ForUpdate], ')', Statement ;

ForStatementNoShortIf =
'for', '(', [ForInit], ';', [Expression], ';', [ForUpdate], ')', StatementNoShortIf ;

ForInit =
StatementExpressionList | LocalVariableDeclaration ;

ForUpdate =
StatementExpressionList ;

StatementExpressionList =
StatementExpression | StatementExpressionList, ',', StatementExpression ;

BreakStatement =
'break', [Identifier], ';' ;

ContinueStatement =
'continue', [Identifier], ';' ;

ReturnStatement =
'return', [Expression], ';' ;

ThrowStatement =
'throw', Expression, ';' ;

SynchronizedStatement =
'synchronized', '(', Expression, ')', Block ;

TryStatement =
'try', Block, Catches | 'try', Block, [Catches], Finally ;

Catches =
CatchClause | Catches, CatchClause ;

CatchClause =
'catch', '(', FormalParameter, ')', Block ;

Finally =
'finally', Block ;

Primary =
PrimaryNoNewArray | ArrayCreationExpression ;

PrimaryNoNewArray =
Literal | Type, '.', 'class' | 'void', '.', 'class' | 'this' | ClassName, '.', 'this' | '(', Expression, ')' | ClassInstanceCreationExpression | FieldAccess | MethodInvocation | ArrayAccess ;

Literal =
IntegerLiteral | FloatingPointLiteral | BooleanLiteral | CharacterLiteral | StringLiteral | NullLiteral ;

ClassInstanceCreationExpression =
'new', ClassOrInterfaceType, '(', [ArgumentList], ')', [ClassBody] | Primary, '.', 'new', Identifier, '(', [ArgumentList], ')', [ClassBody] ;

ArgumentList =
Expression | ArgumentList, ',', Expression ;

ArrayCreationExpression =
'new', PrimitiveType, DimExprs, [Dims] | 'new', TypeName, DimExprs, [Dims] | 'new', PrimitiveType, Dims, ArrayInitializer | 'new', TypeName, Dims, ArrayInitializer ;

DimExprs =
DimExpr | DimExprs, DimExpr ;

DimExpr =
'[', Expression, ']' ;

Dims =
'[', ']' | Dims, '[', ']' ;

FieldAccess =
Primary, '.', Identifier | 'super', '.', Identifier | ClassName, '.', 'super', '.', Identifier ;

MethodInvocation =
MethodName, '(', [ArgumentList], ')' | Primary, '.', Identifier, '(', [ArgumentList], ')' | 'super', '.', Identifier, '(', [ArgumentList], ')' | ClassName, '.', 'super', '.', Identifier, '(', [ArgumentList], ')' ;

ArgumentList =
Expression | ArgumentList, ',', Expression ;

ArrayAccess =
ExpressionName, '[', Expression, ']' | PrimaryNoNewArray, '[', Expression, ']' ;

PostfixExpression =
Primary | ExpressionName | PostIncrementExpression | PostDecrementExpression ;

PostIncrementExpression =
PostfixExpression, '++' ;

PostDecrementExpression =
PostfixExpression, '--' ;

UnaryExpression =
PreIncrementExpression | PreDecrementExpression | '+', UnaryExpression | '-', UnaryExpression | UnaryExpressionNotPlusMinus ;

PreIncrementExpression =
'++', UnaryExpression ;

PreDecrementExpression =
'--', UnaryExpression ;

UnaryExpressionNotPlusMinus =
PostfixExpression | '~', UnaryExpression | '!', UnaryExpression | CastExpression ;

CastExpression =
'(', PrimitiveType, [Dims], ')', UnaryExpression | '(', ReferenceType, ')', UnaryExpressionNotPlusMinus ;

MultiplicativeExpression =
UnaryExpression | MultiplicativeExpression, '*', UnaryExpression | MultiplicativeExpression, '/', UnaryExpression | MultiplicativeExpression, '%', UnaryExpression ;

AdditiveExpression =
MultiplicativeExpression | AdditiveExpression, '+', MultiplicativeExpression | AdditiveExpression, '-', MultiplicativeExpression ;

ShiftExpression =
AdditiveExpression | ShiftExpression, '<<', AdditiveExpression | ShiftExpression, '>>', AdditiveExpression | ShiftExpression, '>>>', AdditiveExpression ;

RelationalExpression =
ShiftExpression | RelationalExpression, '<', ShiftExpression | RelationalExpression, '>', ShiftExpression | RelationalExpression, '<=', ShiftExpression | RelationalExpression, '>=', ShiftExpression | RelationalExpression, 'instanceof', ReferenceType ;

EqualityExpression =
RelationalExpression | EqualityExpression, '==', RelationalExpression | EqualityExpression, '!=', RelationalExpression ;

AndExpression =
EqualityExpression | AndExpression, '&', EqualityExpression ;

ExclusiveOrExpression =
AndExpression | ExclusiveOrExpression, '^', AndExpression ;

InclusiveOrExpression =
ExclusiveOrExpression | InclusiveOrExpression, '|', ExclusiveOrExpression ;

ConditionalAndExpression =
InclusiveOrExpression | ConditionalAndExpression, '&&', InclusiveOrExpression ;

ConditionalOrExpression =
ConditionalAndExpression | ConditionalOrExpression, '||', ConditionalAndExpression ;

ConditionalExpression =
ConditionalOrExpression | ConditionalOrExpression, '?', Expression, ':', ConditionalExpression ;

AssignmentExpression =
ConditionalExpression | Assignment ;

Assignment =
LeftHandSide, AssignmentOperator, AssignmentExpression ;

LeftHandSide =
ExpressionName | FieldAccess | ArrayAccess ;

AssignmentOperator =
'=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|=' ;

Expression =
AssignmentExpression ;

ConstantExpression =
Expression ;

Index

'!'
Operator
UnaryExpressionNotPlusMinus

'!='
EqualityExpression
Operator

'%'
MultiplicativeExpression
Operator

'%='
AssignmentOperator
Operator

'&'
AndExpression
Operator

'&&'
ConditionalAndExpression
Operator

'&='
AssignmentOperator
Operator

"'"
CharacterLiteral
EscapeSequence
SingleCharacter

'('
CastExpression
CatchClause
ClassInstanceCreationExpression
ConstructorDeclarator
DoStatement
ExplicitConstructorInvocation
ForStatement
ForStatementNoShortIf
IfThenElseStatement
IfThenElseStatementNoShortIf
IfThenStatement
MethodDeclarator
MethodInvocation
PrimaryNoNewArray
Separator
SwitchStatement
SynchronizedStatement
WhileStatement
WhileStatementNoShortIf

')'
CastExpression
CatchClause
ClassInstanceCreationExpression
ConstructorDeclarator
DoStatement
ExplicitConstructorInvocation
ForStatement
ForStatementNoShortIf
IfThenElseStatement
IfThenElseStatementNoShortIf
IfThenStatement
MethodDeclarator
MethodInvocation
PrimaryNoNewArray
Separator
SwitchStatement
SynchronizedStatement
WhileStatement
WhileStatementNoShortIf

'"'
EscapeSequence
StringCharacter
StringLiteral

'*'
CommentTail
CommentTailStar
MultiplicativeExpression
NotStar
NotStarNotSlash
Operator
TraditionalComment
TypeImportOnDemandDeclaration

'*='
AssignmentOperator
Operator

'+'
AdditiveExpression
Operator
Sign
UnaryExpression

'++'
Operator
PostIncrementExpression
PreIncrementExpression

'+='
AssignmentOperator
Operator

','
ArgumentList
ArrayInitializer
ClassTypeList
ExtendsInterfaces
FormalParameterList
InterfaceTypeList
Separator
StatementExpressionList
VariableDeclarators
VariableInitializers

'-'
AdditiveExpression
Operator
Sign
UnaryExpression

'--'
Operator
PostDecrementExpression
PreDecrementExpression

'-='
AssignmentOperator
Operator

'.'
AmbiguousName
ClassInstanceCreationExpression
ExplicitConstructorInvocation
ExpressionName
FieldAccess
FloatingPointLiteral
MethodInvocation
MethodName
PackageName
PackageOrTypeName
PrimaryNoNewArray
Separator
TypeImportOnDemandDeclaration
TypeName

'/'
CommentTailStar
EndOfLineComment
MultiplicativeExpression
NotStarNotSlash
Operator
TraditionalComment

'/='
AssignmentOperator
Operator

'0'
DecimalNumeral
Digit
HexDigit
HexNumeral
OctalDigit
OctalNumeral
ZeroToThree

'1'
HexDigit
NonZeroDigit
OctalDigit
ZeroToThree

'2'
HexDigit
NonZeroDigit
OctalDigit
ZeroToThree

'3'
HexDigit
NonZeroDigit
OctalDigit
ZeroToThree

'4'
HexDigit
NonZeroDigit
OctalDigit

'5'
HexDigit
NonZeroDigit
OctalDigit

'6'
HexDigit
NonZeroDigit
OctalDigit

'7'
HexDigit
NonZeroDigit
OctalDigit

'8'
HexDigit
NonZeroDigit

'9'
HexDigit
NonZeroDigit

':'
ConditionalExpression
LabeledStatement
LabeledStatementNoShortIf
Operator
SwitchLabel

';'
AbstractMethodDeclaration
BreakStatement
ClassMemberDeclaration
ContinueStatement
DoStatement
EmptyStatement
ExplicitConstructorInvocation
ExpressionStatement
FieldDeclaration
ForStatement
ForStatementNoShortIf
InterfaceMemberDeclaration
LocalVariableDeclarationStatement
MethodBody
PackageDeclaration
ReturnStatement
Separator
SingleTypeImportDeclaration
ThrowStatement
TypeDeclaration
TypeImportOnDemandDeclaration

'<'
Operator
RelationalExpression

'<<'
Operator
ShiftExpression

'<<='
AssignmentOperator
Operator

'<='
Operator
RelationalExpression

'='
AssignmentOperator
Operator
VariableDeclarator

'=='
EqualityExpression
Operator

'>'
Operator
RelationalExpression

'>='
Operator
RelationalExpression

'>>'
Operator
ShiftExpression

'>>='
AssignmentOperator
Operator

'>>>'
Operator
ShiftExpression

'>>>='
AssignmentOperator
Operator

'?'
ConditionalExpression
Operator

'A'
HexDigit

AbstractMethodDeclaration
AbstractMethodDeclaration
InterfaceMemberDeclaration

AbstractMethodModifier
AbstractMethodModifier
AbstractMethodModifiers

AbstractMethodModifiers
AbstractMethodDeclaration
AbstractMethodModifiers

AdditiveExpression
AdditiveExpression
ShiftExpression

AmbiguousName
AmbiguousName
ExpressionName
MethodName

AndExpression
AndExpression
ExclusiveOrExpression

ArgumentList
ArgumentList
ClassInstanceCreationExpression
ExplicitConstructorInvocation
MethodInvocation

ArrayAccess
ArrayAccess
LeftHandSide
PrimaryNoNewArray

ArrayCreationExpression
ArrayCreationExpression
Primary

ArrayInitializer
ArrayCreationExpression
ArrayInitializer
VariableInitializer

ArrayType
ArrayType
ReferenceType

Assignment
Assignment
AssignmentExpression
StatementExpression

AssignmentExpression
Assignment
AssignmentExpression
Expression

AssignmentOperator
Assignment
AssignmentOperator

'B'
HexDigit

Block
Block
CatchClause
Finally
InstanceInitializer
MethodBody
StatementWithoutTrailingSubstatement
StaticInitializer
SynchronizedStatement
TryStatement

BlockStatement
BlockStatement
BlockStatements

BlockStatements
Block
BlockStatements
ConstructorBody
SwitchBlockStatementGroup

BooleanLiteral
BooleanLiteral
Identifier
Literal

BreakStatement
BreakStatement
StatementWithoutTrailingSubstatement

'C'
HexDigit

? CR ?
InputCharacter

CastExpression
CastExpression
UnaryExpressionNotPlusMinus

CatchClause
CatchClause
Catches

Catches
Catches
TryStatement

CharacterLiteral
CharacterLiteral
Literal

CharactersInLine
CharactersInLine
EndOfLineComment

ClassBody
ClassBody
ClassDeclaration
ClassInstanceCreationExpression

ClassBodyDeclaration
ClassBodyDeclaration
ClassBodyDeclarations

ClassBodyDeclarations
ClassBody
ClassBodyDeclarations

ClassDeclaration
BlockStatement
ClassDeclaration
ClassMemberDeclaration
InterfaceMemberDeclaration
TypeDeclaration

ClassInstanceCreationExpression
ClassInstanceCreationExpression
PrimaryNoNewArray
StatementExpression

ClassMemberDeclaration
ClassBodyDeclaration
ClassMemberDeclaration

ClassModifier
ClassModifier
ClassModifiers

ClassModifiers
ClassDeclaration
ClassModifiers

ClassName
FieldAccess
MethodInvocation
PrimaryNoNewArray

ClassOrInterfaceType
ClassInstanceCreationExpression
ClassOrInterfaceType
ReferenceType

ClassType
ClassOrInterfaceType
ClassType
ClassTypeList
Super

ClassTypeList
ClassTypeList
Throws

Comment
Comment
InputElement

CommentTail
CommentTail
CommentTailStar
TraditionalComment

CommentTailStar
CommentTail
CommentTailStar

CompilationUnit
CompilationUnit

ConditionalAndExpression
ConditionalAndExpression
ConditionalOrExpression

ConditionalExpression
AssignmentExpression
ConditionalExpression

ConditionalOrExpression
ConditionalExpression
ConditionalOrExpression

ConstantDeclaration
ConstantDeclaration
InterfaceMemberDeclaration

ConstantExpression
ConstantExpression
SwitchLabel

ConstantModifier
ConstantModifier
ConstantModifiers

ConstantModifiers
ConstantDeclaration
ConstantModifiers

ConstructorBody
ConstructorBody
ConstructorDeclaration

ConstructorDeclaration
ClassBodyDeclaration
ConstructorDeclaration

ConstructorDeclarator
ConstructorDeclaration
ConstructorDeclarator

ConstructorModifier
ConstructorModifier
ConstructorModifiers

ConstructorModifiers
ConstructorDeclaration
ConstructorModifiers

ContinueStatement
ContinueStatement
StatementWithoutTrailingSubstatement

'D'
FloatTypeSuffix
HexDigit

DecimalIntegerLiteral
DecimalIntegerLiteral
IntegerLiteral

DecimalNumeral
DecimalIntegerLiteral
DecimalNumeral

Digit
Digit
Digits

Digits
DecimalNumeral
Digits
FloatingPointLiteral
SignedInteger

DimExpr
DimExpr
DimExprs

DimExprs
ArrayCreationExpression
DimExprs

Dims
ArrayCreationExpression
CastExpression
Dims

DoStatement
DoStatement
StatementWithoutTrailingSubstatement

'E'
ExponentIndicator
HexDigit

EmptyStatement
EmptyStatement
StatementWithoutTrailingSubstatement

EndOfLineComment
Comment
EndOfLineComment

EqualityExpression
AndExpression
EqualityExpression

EscapeSequence
CharacterLiteral
EscapeSequence
StringCharacter

ExclusiveOrExpression
ExclusiveOrExpression
InclusiveOrExpression

ExplicitConstructorInvocation
ConstructorBody
ExplicitConstructorInvocation

ExponentIndicator
ExponentIndicator
ExponentPart

ExponentPart
ExponentPart
FloatingPointLiteral

Expression
ArgumentList
ArrayAccess
ConditionalExpression
ConstantExpression
DimExpr
DoStatement
Expression
ForStatement
ForStatementNoShortIf
IfThenElseStatement
IfThenElseStatementNoShortIf
IfThenStatement
PrimaryNoNewArray
ReturnStatement
SwitchStatement
SynchronizedStatement
ThrowStatement
VariableInitializer
WhileStatement
WhileStatementNoShortIf

ExpressionName
ArrayAccess
ExpressionName
LeftHandSide
PostfixExpression

ExpressionStatement
ExpressionStatement
StatementWithoutTrailingSubstatement

ExtendsInterfaces
ExtendsInterfaces
InterfaceDeclaration

'F'
FloatTypeSuffix
HexDigit

FieldAccess
FieldAccess
LeftHandSide
PrimaryNoNewArray

FieldDeclaration
ClassMemberDeclaration
FieldDeclaration

FieldModifier
FieldModifier
FieldModifiers

FieldModifiers
FieldDeclaration
FieldModifiers

Finally
Finally
TryStatement

FloatTypeSuffix
FloatTypeSuffix
FloatingPointLiteral

FloatingPointLiteral
FloatingPointLiteral
Literal

FloatingPointType
FloatingPointType
NumericType

ForInit
ForInit
ForStatement
ForStatementNoShortIf

ForStatement
ForStatement
Statement

ForStatementNoShortIf
ForStatementNoShortIf
StatementNoShortIf

ForUpdate
ForStatement
ForStatementNoShortIf
ForUpdate

FormalParameter
CatchClause
FormalParameter
FormalParameterList

FormalParameterList
ConstructorDeclarator
FormalParameterList
MethodDeclarator

HexDigit
HexDigit
HexDigits
UnicodeEscape

HexDigits
HexDigits
HexNumeral

HexIntegerLiteral
HexIntegerLiteral
IntegerLiteral

HexNumeral
HexIntegerLiteral
HexNumeral

Identifier
AmbiguousName
BreakStatement
ClassDeclaration
ClassInstanceCreationExpression
ContinueStatement
ExpressionName
FieldAccess
Identifier
InterfaceDeclaration
LabeledStatement
LabeledStatementNoShortIf
MethodDeclarator
MethodInvocation
MethodName
PackageName
PackageOrTypeName
Token
TypeName
VariableDeclaratorId

IdentifierChars
Identifier
IdentifierChars

IfThenElseStatement
IfThenElseStatement
Statement

IfThenElseStatementNoShortIf
IfThenElseStatementNoShortIf
StatementNoShortIf

IfThenStatement
IfThenStatement
Statement

ImportDeclaration
ImportDeclaration
ImportDeclarations

ImportDeclarations
CompilationUnit
ImportDeclarations

InclusiveOrExpression
ConditionalAndExpression
InclusiveOrExpression

Input
Input

InputCharacter
CharactersInLine
InputCharacter
NotStar
NotStarNotSlash
SingleCharacter
StringCharacter

InputElement
InputElement
InputElements

InputElements
Input
InputElements

InstanceInitializer
ClassBodyDeclaration
InstanceInitializer

IntegerLiteral
IntegerLiteral
Literal

IntegerTypeSuffix
DecimalIntegerLiteral
HexIntegerLiteral
IntegerTypeSuffix
OctalIntegerLiteral

IntegralType
IntegralType
NumericType

InterfaceBody
InterfaceBody
InterfaceDeclaration

InterfaceDeclaration
ClassMemberDeclaration
InterfaceDeclaration
InterfaceMemberDeclaration
TypeDeclaration

InterfaceMemberDeclaration
InterfaceMemberDeclaration
InterfaceMemberDeclarations

InterfaceMemberDeclarations
InterfaceBody
InterfaceMemberDeclarations

InterfaceModifier
InterfaceModifier
InterfaceModifiers

InterfaceModifiers
InterfaceDeclaration
InterfaceModifiers

InterfaceType
ClassOrInterfaceType
ExtendsInterfaces
InterfaceType
InterfaceTypeList

InterfaceTypeList
InterfaceTypeList
Interfaces

Interfaces
ClassDeclaration
Interfaces

JavaLetter
IdentifierChars
JavaLetter

JavaLetterOrDigit
IdentifierChars
JavaLetterOrDigit

Keyword
Identifier
Keyword
Token

'L'
IntegerTypeSuffix

? LF ?
InputCharacter

LabeledStatement
LabeledStatement
Statement

LabeledStatementNoShortIf
LabeledStatementNoShortIf
StatementNoShortIf

LeftHandSide
Assignment
LeftHandSide

LineTerminator
EndOfLineComment
LineTerminator
NotStar
NotStarNotSlash
WhiteSpace

Literal
Literal
PrimaryNoNewArray
Token

LocalVariableDeclaration
ForInit
LocalVariableDeclaration
LocalVariableDeclarationStatement

LocalVariableDeclarationStatement
BlockStatement
LocalVariableDeclarationStatement

MethodBody
MethodBody
MethodDeclaration

MethodDeclaration
ClassMemberDeclaration
MethodDeclaration

MethodDeclarator
AbstractMethodDeclaration
MethodDeclarator
MethodHeader

MethodHeader
MethodDeclaration
MethodHeader

MethodInvocation
MethodInvocation
PrimaryNoNewArray
StatementExpression

MethodModifier
MethodModifier
MethodModifiers

MethodModifiers
MethodHeader
MethodModifiers

MethodName
MethodInvocation
MethodName

MultiplicativeExpression
AdditiveExpression
MultiplicativeExpression

NonZeroDigit
DecimalNumeral
Digit
NonZeroDigit

NotStar
CommentTail
NotStar
TraditionalComment

NotStarNotSlash
CommentTailStar
NotStarNotSlash

NullLiteral
Identifier
Literal
NullLiteral

NumericType
NumericType
PrimitiveType

OctalDigit
OctalDigit
OctalDigits
OctalEscape

OctalDigits
OctalDigits
OctalNumeral

OctalEscape
EscapeSequence
OctalEscape

OctalIntegerLiteral
IntegerLiteral
OctalIntegerLiteral

OctalNumeral
OctalIntegerLiteral
OctalNumeral

Operator
Operator
Token

PackageDeclaration
CompilationUnit
PackageDeclaration

PackageName
PackageDeclaration
PackageName

PackageOrTypeName
PackageOrTypeName
TypeImportOnDemandDeclaration
TypeName

PostDecrementExpression
PostDecrementExpression
PostfixExpression
StatementExpression

PostIncrementExpression
PostIncrementExpression
PostfixExpression
StatementExpression

PostfixExpression
PostDecrementExpression
PostIncrementExpression
PostfixExpression
UnaryExpressionNotPlusMinus

PreDecrementExpression
PreDecrementExpression
StatementExpression
UnaryExpression

PreIncrementExpression
PreIncrementExpression
StatementExpression
UnaryExpression

Primary
ClassInstanceCreationExpression
ExplicitConstructorInvocation
FieldAccess
MethodInvocation
PostfixExpression
Primary

PrimaryNoNewArray
ArrayAccess
Primary
PrimaryNoNewArray

PrimitiveType
ArrayCreationExpression
CastExpression
PrimitiveType
Type

RawInputCharacter
RawInputCharacter
UnicodeInputCharacter

ReferenceType
CastExpression
ReferenceType
RelationalExpression
Type

RelationalExpression
EqualityExpression
RelationalExpression

ResultType
AbstractMethodDeclaration
MethodHeader
ResultType

ReturnStatement
ReturnStatement
StatementWithoutTrailingSubstatement

Separator
Separator
Token

ShiftExpression
RelationalExpression
ShiftExpression

Sign
Sign
SignedInteger

SignedInteger
ExponentPart
SignedInteger

SimpleTypeName
ConstructorDeclarator

SingleCharacter
CharacterLiteral
SingleCharacter

SingleTypeImportDeclaration
ImportDeclaration
SingleTypeImportDeclaration

Statement
BlockStatement
DoStatement
ForStatement
IfThenElseStatement
IfThenStatement
LabeledStatement
Statement
WhileStatement

StatementExpression
ExpressionStatement
StatementExpression
StatementExpressionList

StatementExpressionList
ForInit
ForUpdate
StatementExpressionList

StatementNoShortIf
ForStatementNoShortIf
IfThenElseStatement
IfThenElseStatementNoShortIf
LabeledStatementNoShortIf
StatementNoShortIf
WhileStatementNoShortIf

StatementWithoutTrailingSubstatement
Statement
StatementNoShortIf
StatementWithoutTrailingSubstatement

StaticInitializer
ClassBodyDeclaration
StaticInitializer

StringCharacter
StringCharacter
StringCharacters

StringCharacters
StringCharacters
StringLiteral

StringLiteral
Literal
StringLiteral

Sub
Input
Sub

Super
ClassDeclaration
Super

SwitchBlock
SwitchBlock
SwitchStatement

SwitchBlockStatementGroup
SwitchBlockStatementGroup
SwitchBlockStatementGroups

SwitchBlockStatementGroups
SwitchBlock
SwitchBlockStatementGroups

SwitchLabel
SwitchLabel
SwitchLabels

SwitchLabels
SwitchBlock
SwitchBlockStatementGroup
SwitchLabels

SwitchStatement
StatementWithoutTrailingSubstatement
SwitchStatement

SynchronizedStatement
StatementWithoutTrailingSubstatement
SynchronizedStatement

ThrowStatement
StatementWithoutTrailingSubstatement
ThrowStatement

Throws
AbstractMethodDeclaration
ConstructorDeclaration
MethodHeader
Throws

Token
InputElement
Token

TraditionalComment
Comment
TraditionalComment

TryStatement
StatementWithoutTrailingSubstatement
TryStatement

Type
ArrayType
ConstantDeclaration
FieldDeclaration
FormalParameter
LocalVariableDeclaration
PrimaryNoNewArray
ResultType
Type

TypeDeclaration
TypeDeclaration
TypeDeclarations

TypeDeclarations
CompilationUnit
TypeDeclarations

TypeImportOnDemandDeclaration
ImportDeclaration
TypeImportOnDemandDeclaration

TypeName
ArrayCreationExpression
ClassType
InterfaceType
SingleTypeImportDeclaration
TypeName

UnaryExpression
CastExpression
MultiplicativeExpression
PreDecrementExpression
PreIncrementExpression
UnaryExpression
UnaryExpressionNotPlusMinus

UnaryExpressionNotPlusMinus
CastExpression
UnaryExpression
UnaryExpressionNotPlusMinus

UnicodeEscape
UnicodeEscape
UnicodeInputCharacter

UnicodeInputCharacter
InputCharacter
UnicodeInputCharacter

UnicodeMarker
UnicodeEscape
UnicodeMarker

VariableDeclarator
VariableDeclarator
VariableDeclarators

VariableDeclaratorId
FormalParameter
VariableDeclarator
VariableDeclaratorId

VariableDeclarators
ConstantDeclaration
FieldDeclaration
LocalVariableDeclaration
VariableDeclarators

VariableInitializer
VariableDeclarator
VariableInitializer
VariableInitializers

VariableInitializers
ArrayInitializer
VariableInitializers

WhileStatement
Statement
WhileStatement

WhileStatementNoShortIf
StatementNoShortIf
WhileStatementNoShortIf

WhiteSpace
InputElement
WhiteSpace

'X'
HexNumeral

ZeroToThree
OctalEscape
ZeroToThree

'['
ArrayAccess
ArrayType
DimExpr
Dims
MethodDeclarator
Separator
VariableDeclaratorId

'\'
EscapeSequence
OctalEscape
SingleCharacter
StringCharacter
UnicodeEscape

']'
ArrayAccess
ArrayType
DimExpr
Dims
MethodDeclarator
Separator
VariableDeclaratorId

'^'
ExclusiveOrExpression
Operator

'^='
AssignmentOperator
Operator

'a'
HexDigit

'abstract'
AbstractMethodModifier
ClassModifier
InterfaceModifier
Keyword
MethodModifier

? any Unicode character that is a Java letter ?
JavaLetter

? any Unicode character that is a Java letter-or-digit ?
JavaLetterOrDigit

? any Unicode character ?
RawInputCharacter

'b'
EscapeSequence
HexDigit

'boolean'
Keyword
PrimitiveType

'break'
BreakStatement
Keyword

'byte'
IntegralType
Keyword

'c'
HexDigit

'case'
Keyword
SwitchLabel

'catch'
CatchClause
Keyword

'char'
IntegralType
Keyword

'class'
ClassDeclaration
Keyword
PrimaryNoNewArray

'const'
Keyword

'continue'
ContinueStatement
Keyword

'd'
FloatTypeSuffix
HexDigit

'default'
Keyword
SwitchLabel

'do'
DoStatement
Keyword

'double'
FloatingPointType
Keyword

'e'
ExponentIndicator
HexDigit

'else'
IfThenElseStatement
IfThenElseStatementNoShortIf
Keyword

'extends'
ExtendsInterfaces
Keyword
Super

'f'
EscapeSequence
FloatTypeSuffix
HexDigit

'false'
BooleanLiteral

'final'
ClassModifier
ConstantModifier
FieldModifier
FormalParameter
Keyword
LocalVariableDeclaration
MethodModifier

'finally'
Finally
Keyword

'float'
FloatingPointType
Keyword

'for'
ForStatement
ForStatementNoShortIf
Keyword

'goto'
Keyword

'if'
IfThenElseStatement
IfThenElseStatementNoShortIf
IfThenStatement
Keyword

'implements'
Interfaces
Keyword

'import'
Keyword
SingleTypeImportDeclaration
TypeImportOnDemandDeclaration

'instanceof'
Keyword
RelationalExpression

'int'
IntegralType
Keyword

'interface'
InterfaceDeclaration
Keyword

'l'
IntegerTypeSuffix

'long'
IntegralType
Keyword

'n'
EscapeSequence

'native'
Keyword
MethodModifier

'new'
ArrayCreationExpression
ClassInstanceCreationExpression
Keyword

'null'
NullLiteral

'package'
Keyword
PackageDeclaration

'private'
ClassModifier
ConstructorModifier
FieldModifier
InterfaceModifier
Keyword
MethodModifier

'protected'
ClassModifier
ConstructorModifier
FieldModifier
InterfaceModifier
Keyword
MethodModifier

'public'
AbstractMethodModifier
ClassModifier
ConstantModifier
ConstructorModifier
FieldModifier
InterfaceModifier
Keyword
MethodModifier

'r'
EscapeSequence

'return'
Keyword
ReturnStatement

'short'
IntegralType
Keyword

'static'
ClassModifier
ConstantModifier
FieldModifier
InterfaceModifier
Keyword
MethodModifier
StaticInitializer

'strictfp'
ClassModifier
InterfaceModifier
Keyword
MethodModifier

'super'
ExplicitConstructorInvocation
FieldAccess
Keyword
MethodInvocation

'switch'
Keyword
SwitchStatement

'synchronized'
Keyword
MethodModifier
SynchronizedStatement

't'
EscapeSequence

? the ASCII CR character followed by the ASCII LF character ?
LineTerminator

? the ASCII CR character, also known as "return" ?
LineTerminator

? the ASCII FF character, also known as "form feed" ?
WhiteSpace

? the ASCII HT character, also known as "horizontal tab" ?
WhiteSpace

? the ASCII LF character, also known as "newline" ?
LineTerminator

? the ASCII SP character, also known as "space" ?
WhiteSpace

? the ASCII SUB character, also known as "control-Z" ?
Sub

'this'
ExplicitConstructorInvocation
Keyword
PrimaryNoNewArray

'throw'
Keyword
ThrowStatement

'throws'
Keyword
Throws

'transient'
FieldModifier
Keyword

'true'
BooleanLiteral

'try'
Keyword
TryStatement

'u'
UnicodeMarker

'void'
Keyword
PrimaryNoNewArray
ResultType

'volatile'
FieldModifier
Keyword

'while'
DoStatement
Keyword
WhileStatement
WhileStatementNoShortIf

'x'
HexNumeral

'{'
ArrayInitializer
Block
ClassBody
ConstructorBody
InterfaceBody
Separator
SwitchBlock

'|'
InclusiveOrExpression
Operator

'|='
AssignmentOperator
Operator

'||'
ConditionalOrExpression
Operator

'}'
ArrayInitializer
Block
ClassBody
ConstructorBody
InterfaceBody
Separator
SwitchBlock

'~'
Operator
UnaryExpressionNotPlusMinus

References

No comments: