Chapter 19. Syntax

This chapter repeats the syntactic grammar given in Chapters 4, 6-10, 14, and 15, as well as key parts of the lexical grammar from Chapter 3, using the notation from §2.4.

Productions from §3 (Lexical Structure)

Identifier:
IdentifierChars:
JavaLetter:
any Unicode character that is a "Java letter"
JavaLetterOrDigit:
any Unicode character that is a "Java letter-or-digit"

Productions from §4 (Types, Values, and Variables)

PrimitiveType:
IntegralType:
byte short int long char
FloatingPointType:
float double
ClassOrInterfaceType:
InterfaceType:
TypeVariable:
Dims:
{Annotation} [ ] {{Annotation} [ ]}
TypeBound:
AdditionalBound:
TypeArguments:
TypeArgumentList:
TypeArgument:
Wildcard:
WildcardBounds:

Productions from §7 (Packages)

PackageDeclaration:
PackageModifier:
SingleTypeImportDeclaration:
import TypeName ;
TypeImportOnDemandDeclaration:
import PackageOrTypeName . * ;
SingleStaticImportDeclaration:
import static TypeName . Identifier ;
StaticImportOnDemandDeclaration:
import static TypeName . * ;

Productions from §8 (Classes)

ClassModifier:
Annotation public protected private
abstract static final strictfp
TypeParameters:
TypeParameterList:
Superclass:
extends ClassType
Superinterfaces:
implements InterfaceTypeList
InterfaceTypeList:
ClassBody:
FieldModifier:
Annotation public protected private
static final transient volatile
VariableDeclaratorList:
VariableDeclarator:
VariableDeclaratorId:
VariableInitializer:
UnannPrimitiveType:
NumericType
boolean
UnannClassOrInterfaceType:
UnannInterfaceType:
UnannTypeVariable:
MethodDeclaration:
MethodModifier:
Annotation public protected private
abstract static final synchronized native strictfp
Result:
UnannType
void
MethodDeclarator:
VariableModifier:
Annotation final
ReceiverParameter:
Throws:
ExceptionTypeList:
ExceptionType:
MethodBody:
Block
;
InstanceInitializer:
StaticInitializer:
static Block
ConstructorModifier:
Annotation public protected private
ConstructorDeclarator:
ExplicitConstructorInvocation:
EnumDeclaration:
EnumBody:
EnumConstantList:
EnumConstantModifier:
EnumBodyDeclarations:

Productions from §9 (Interfaces)

NormalInterfaceDeclaration:
InterfaceModifier:
Annotation public protected private
abstract static strictfp
ExtendsInterfaces:
InterfaceBody:
ConstantModifier:
Annotation public
static final
InterfaceMethodDeclaration:
InterfaceMethodModifier:
Annotation public
abstract default static strictfp
AnnotationTypeDeclaration:
AnnotationTypeBody:
AnnotationTypeElementDeclaration:
AnnotationTypeElementModifier:
Annotation public
abstract
DefaultValue:
default ElementValue
NormalAnnotation:
ElementValuePairList:
ElementValuePair:
ElementValueArrayInitializer:
{ [ElementValueList] [,] }
ElementValueList:
MarkerAnnotation:
SingleElementAnnotation:

Productions from §10 (Arrays)

ArrayInitializer:
VariableInitializerList:

Productions from §14 (Blocks and Statements)

Block:
BlockStatements:
LocalVariableDeclarationStatement:
LocalVariableDeclaration:
EmptyStatement:
;
LabeledStatement:
LabeledStatementNoShortIf:
ExpressionStatement:
IfThenStatement:
IfThenElseStatement:
IfThenElseStatementNoShortIf:
AssertStatement:
assert Expression ;
assert Expression : Expression ;
SwitchStatement:
switch ( Expression ) SwitchBlock
SwitchBlock:
SwitchBlockStatementGroup:
SwitchLabels:
SwitchLabel:
case ConstantExpression :
case EnumConstantName :
default :
EnumConstantName:
WhileStatement:
while ( Expression ) Statement
WhileStatementNoShortIf:
DoStatement:
do Statement while ( Expression ) ;
BasicForStatement:
BasicForStatementNoShortIf:
StatementExpressionList:
EnhancedForStatementNoShortIf:
BreakStatement:
break [Identifier] ;
ContinueStatement:
continue [Identifier] ;
ReturnStatement:
return [Expression] ;
ThrowStatement:
throw Expression ;
SynchronizedStatement:
synchronized ( Expression ) Block
CatchClause:
CatchType:
Finally:
finally Block
TryWithResourcesStatement:
ResourceSpecification:
( ResourceList [;] )
ResourceList:

Productions from §15 (Expressions)

TypeArgumentsOrDiamond:
FieldAccess:
ArgumentList:
DimExprs:
DimExpr:
ConstantExpression:
LambdaExpression:
InferredFormalParameterList:
LambdaBody:
AssignmentExpression:
AssignmentOperator:
=  *=  /=  %=  +=  -=  <<=  >>=  >>>=  &=  ^=  |=
ConditionalOrExpression:
PreIncrementExpression:
PreDecrementExpression:
PostIncrementExpression:
PostDecrementExpression: