Java 1.5 Parser - Grammar Rules - Part 9

<- back

Next Chapter Grammar Rules - part 10

Primary

Primary is one of the last rules in the expression rule tree.

Java Syntax Rule
Primary:
PrimaryNoNewArray
ArrayCreationExpression

PrimaryNoNewArray:
Literal
Type . class
void . class
this
ClassName . this
( Expression )
ClassInstanceCreationExpression
FieldAccess
MethodInvocation
ArrayAccess

ArrayCreationExpression:
new PrimitiveType DimExprs Dimsopt
new ClassOrInterfaceType DimExprs Dimsopt
new PrimitiveType Dims ArrayInitializer
new ClassOrInterfaceType Dims ArrayInitializer
        
 DimExprs:
DimExpr
DimExprs DimExpr

DimExpr:
[ Expression ]

Dims:
[ ]
Dims [ ]

Literal:
IntegerLiteral
FloatingPointLiteral
BooleanLiteral
CharacterLiteral
StringLiteral
NullLiteral

ClassInstanceCreationExpression:
new TypeArgumentsopt ClassOrInterfaceType ( ArgumentListopt ) ClassBodyopt
Primary . new TypeArgumentsopt Identifier TypeArgumentsopt (ArgumentListopt )
ClassBodyopt

ArgumentList:
Expression
ArgumentList , Expression

FieldAccess:
Primary . Identifier
super . Identifier
ClassName . super . Identifier

MethodInvocation:
MethodName ( ArgumentListopt )
Primary . NonWildTypeArgumentsopt Identifier ( ArgumentListopt )
super . NonWildTypeArgumentsopt Identifier ( ArgumentListopt )
ClassName . super . NonWildTypeArgumentsopt Identifier ( ArgumentListopt )
TypeName . NonWildTypeArguments Identifier ( ArgumentListopt )

ArrayAccess:
ExpressionName [ Expression ]
PrimaryNoNewArray [ Expression ]

Type:
PrimitiveType
ReferenceType

ReferenceType:
ClassOrInterfaceType
TypeVariable
ArrayType

ClassOrInterfaceType:
ClassType
InterfaceType

ClassType:
TypeDeclSpecifier TypeArgumentsopt

InterfaceType:
TypeDeclSpecifier TypeArgumentsopt

TypeDeclSpecifier:
TypeName
ClassOrInterfaceType . Identifier

TypeName:
Identifier
TypeName . Identifier

TypeArguments:
< ActualTypeArgumentList >

ActualTypeArgumentList:
ActualTypeArgument
ActualTypeArgumentList , ActualTypeArgument

ActualTypeArgument:
ReferenceType
Wildcard

Wildcard:
? WildcardBoundsOpt

WildcardBounds:
extends ReferenceType
super ReferenceType

TypeVariable:
Identifier

ArrayType:
Type [ ]

Next Chapter Grammar Rules - part 10


<- back

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License