'JLS7' refers to the Java Language Specification, Java SE 7 Edition.
| Modifier and Type | Class and Description |
|---|---|
| public static enum | Parser.ClassDeclarationContext
The kinds of context where a class declaration can occur. |
| public static enum | Parser.InterfaceDeclarationContext
The kinds of context where an interface declaration can occur. |
| public static enum | Parser.MethodDeclarationContext
The kinds of context where a method declaration can occur. |
| Modifier and Type | Field and Description |
|---|---|
| private static final String[] | |
| private String | docComment
The optional JAVADOC comment preceding the |
| private static final List | |
| private boolean | |
| private final Scanner | |
| private int | |
| private final TokenStream | |
| private WarningHandler |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private Java. | |
| private Java. | Returns: modifiersVerifies that the modifiers are consistent. |
| private Java. | |
| protected final CompileException | |
| protected static CompileException | compileException(String message, Location location)
Convenience method for throwing a |
| private Java. | |
| private Java. | |
| public String | Returns: null if the next token is not preceded by a doc commentGets the text of the doc comment (a.k.a. "JAVADOC comment") preceding the next token. |
| private Java. | |
| private Java. | |
| public Scanner | |
| private int | |
| private static boolean | |
| private static boolean | |
| private Java. | |
| private Java. | |
| private static String | |
| public Location | |
| private Java. | |
| private Java. | |
| private Java. | |
| private Java. | |
| public Java. | parseAbstractCompilationUnit()
CompilationUnit := [ PackageDeclaration ]
{ ImportDeclaration }
{ TypeDeclaration }
|
| public Java. | parseAdditiveExpression()
AdditiveExpression :=
MultiplicativeExpression { ( '+' | '-' ) MultiplicativeExpression }
|
| public Java. | |
| private Java. | parseAnnotation()
Annotation :=
MarkerAnnotation // JLS7 9.7.2
| SingleElementAnnotation // JLS7 9.7.3
| NormalAnnotation // JLS7 9.7.1
MarkerAnnotation := '@' Identifier
SingleElementAnnotation := '@' Identifier '(' ElementValue ')'
NormalAnnotation := '@' TypeName '(' ElementValuePairsOpt ')'
ElementValuePairsOpt := [ ElementValuePair { ',' ElementValuePair } ]
|
| public Java. | parseAnnotationTypeDeclarationRest(String docComment, Java.
AnnotationTypeDeclarationRest := Identifier AnnotationTypeBody |
| public Java. | |
| public Java. | |
| public Java. | parseArrayInitializer()
ArrayInitializer :=
'{' [ VariableInitializer { ',' VariableInitializer } [ ',' ] '}'
|
| public Java. | |
| public Java. | parseAssignmentExpression()
AssignmentExpression :=
ConditionalExpression [ AssignmentOperator AssignmentExpression ]
AssignmentOperator :=
'=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' |
'>>=' | '>>>=' | '&=' | '^=' | '|='
|
| public Java. | |
| public Java. | |
| public List | |
| pack-priv int | |
| public Java. | |
| public Java. | parseCatchParameter()
CatchFormalParameter := { VariableModifier } CatchType VariableDeclaratorId
CatchType := UnannClassType { '|' ClassType }
VariableModifier := Annotation | 'final'
VariableDeclaratorId := Identifier [ Dims ]
Dims := { Annotation } '[' ']' { { Annotation } '[' ']' }
UnannClassType :=
Identifier [ TypeArguments ]
| UnannClassOrInterfaceType '.' { Annotation } Identifier [ TypeArguments ]
UnannInterfaceType := UnannClassType
UnannClassOrInterfaceType := UnannClassType | UnannInterfaceType
ClassType :=
{ Annotation } Identifier [ TypeArguments ]
| ClassOrInterfaceType '.' { Annotation } Identifier [ TypeArguments ]
|
| public void | parseClassBody(Java.
ClassBody := '{' { ClassBodyDeclaration } '}'
|
| public void | parseClassBodyDeclaration(Java.
ClassBodyDeclaration :=
';' |
ModifiersOpt (
Block | // Instance (JLS7 8.6) or static initializer (JLS7 8.7)
'void' Identifier MethodDeclarationRest |
'class' ClassDeclarationRest |
'interface' InterfaceDeclarationRest |
ConstructorDeclarator |
[ TypeArguments ] Type Identifier MethodDeclarationRest |
Type Identifier FieldDeclarationRest ';'
)
|
| public Java. | parseClassDeclarationRest(String docComment, Java.
ClassDeclarationRest :=
Identifier [ typeParameters ]
[ 'extends' ReferenceType ]
[ 'implements' ReferenceTypeList ]
ClassBody
|
| public Java. | parseConditionalAndExpression()
ConditionalAndExpression :=
InclusiveOrExpression { '&&' InclusiveOrExpression }
|
| public Java. | parseConditionalExpression()
ConditionalExpression :=
ConditionalOrExpression [ '?' Expression ':' ConditionalExpression ]
|
| public Java. | parseConditionalOrExpression()
ConditionalOrExpression :=
ConditionalAndExpression { '||' ConditionalAndExpression ]
|
| public Java. | parseConstructorDeclarator(String docComment, Java.
ConstructorDeclarator :=
Identifier
FormalParameters
[ 'throws' ReferenceTypeList ]
'{'
[ 'this' Arguments ';' | 'super' Arguments ';' | Primary '.' 'super' Arguments ';' ]
BlockStatements
'}'
|
| public Java. | |
| public Java. | |
| public Java. | |
| public Java. | |
| private Java. | parseElementValue()
ElementValue :=
ConditionalExpression
| Annotation
| ElementValueArrayInitializer
|
| private Java. | |
| private Java. | |
| public Java. | |
| public void | parseEnumBody(Java.
EnumBody := '{' [ EnumConstant { ',' EnumConstant } [ ',' ] [ ';' ] { ClassBodyDeclaration } '}'
|
| public Java. | |
| public Java. | parseEnumDeclarationRest(String docComment, Java.
EnumDeclarationRest := Identifier [ 'implements' ReferenceTypeList ] EnumBody |
| public Java. | parseEqualityExpression()
EqualityExpression :=
RelationalExpression { ( '==' | '!=' ) RelationalExpression }
|
| public Java. | |
| public Java. | |
| public Java. | |
| public Java. | parseExpressionOrType()
Same as |
| public Java. | |
| public Java. | parseFieldDeclarationRest(String name)
FieldDeclarationRest :=
VariableDeclaratorRest
{ ',' VariableDeclarator }
|
| public Java. | |
| public Java. | |
| public Java. | parseFormalParameterListRest(Java.
FormalParameterListRest := Identifier { ',' FormalParameter }
|
| public Java. | parseFormalParameterRest(Java.
After return, the zeroth element indicates whether the formal parameter was declared with an
ellipsis hasEllipsis)FormalParameterRest := [ '.' '.' '.' ] Identifier BracketsOpt |
| public Java. | |
| public Java. | parseForStatement()
ForStatement :=
'for' '(' [ ForInit ] ';' [ Expression ] ';' [ ExpressionList ] ')' Statement
| 'for' '(' FormalParameter ':' Expression ')' Statement
ForInit :=
Modifiers Type VariableDeclarators
| ModifiersOpt PrimitiveType VariableDeclarators
| Expression VariableDeclarators (1)
| Expression { ',' Expression }
|
| public Java. | |
| public Java. | |
| public Java. | parseImportDeclarationBody()
ImportDeclarationBody := [ 'static' ] Identifier { '.' Identifier } [ '.' '*' ]
|
| public Java. | parseInclusiveOrExpression()
InclusiveOrExpression :=
ExclusiveOrExpression { '|' ExclusiveOrExpression }
|
| public void | parseInterfaceBody(Java.
InterfaceBody := '{' {
';' |
ModifiersOpt (
'void' Identifier MethodDeclarationRest |
'class' ClassDeclarationRest |
'interface' InterfaceDeclarationRest |
Type Identifier (
MethodDeclarationRest |
FieldDeclarationRest
)
)
} '}'
|
| public Java. | parseInterfaceDeclarationRest(String docComment, Java.
InterfaceDeclarationRest :=
Identifier [ typeParameters ]
[ 'extends' ReferenceTypeList ]
InterfaceBody
|
| public Java. | |
| private Java. | |
| private Java. | |
| private Java. | parseLambdaParameters()
LambdaParameters :=
Identifier
| '(' [ FormalParameterList ] ')'
| '(' InferredFormalParameterList ')'
|
| public Java. | parseLiteral()
Literal :=
IntegerLiteral
| FloatingPointLiteral
| BooleanLiteral
| CharacterLiteral
| StringLiteral
| NullLiteral
|
| public Java. | |
| public Java. | parseMethodDeclaration()
Equivalent with |
| public Java. | parseMethodDeclaration(boolean
Whether a "default clause" for an "annotation type element" (JLS8 9.6.2) should be
parsed allowDefaultClause, Parser.
MethodDeclaration :=
[ DocComment ] Modifiers [ TypeParameters ] VoidOrType Identifier MethodDeclarationRest
|
| public Java. | parseMethodDeclarationRest(String docComment, Java.
Whether a "default clause" for an "annotation type element" (JLS8 9.6.2) should be
parsed allowDefaultClause, Parser.
MethodDeclarationRest :=
FormalParameters
{ '[' ']' }
[ 'throws' ReferenceTypeList ]
[ 'default' expression ]
( ';' | MethodBody )
|
| public Java. | |
| public Java. | parseModuleDeclarationRest(Java.
ModuleDeclarationRest := [ 'open' ] 'module' identifier { '.' identifier} '{' { ModuleDirective } '}'
|
| public Java. | parseMultiplicativeExpression()
MultiplicativeExpression :=
UnaryExpression { ( '*' | '/' | '%' ) UnaryExpression }
|
| public Java. | parseOptionalModifier()
Modifier :=
Annotation
| 'public' | 'protected' | 'private'
| 'static' | 'abstract' | 'final' | 'native' | 'synchronized' | 'transient' | 'volatile' | 'strictfp'
| 'default'
|
| public Java. | |
| public Java. | parsePackageDeclarationRest(String docComment, Java.
PackageDeclaration := { PackageModifier } 'package' identifier { '.' identifier} ';'
|
| public Java. | parsePackageMemberTypeDeclaration()
PackageMemberTypeDeclaration := ModifiersOpt PackageMemberTypeDeclarationRest |
| private Java. | parsePackageMemberTypeDeclarationRest(String docComment, Java.
PackageMemberTypeDeclarationRest :=
'class' ClassDeclarationRest |
'enum' EnumDeclarationRest |
'interface' InterfaceDeclarationRest
'@' 'interface' AnnotationTypeDeclarationRest
|
| public Java. | parsePrimary()
Primary :=
CastExpression | // CastExpression 15.16
'(' Expression ')' | // ParenthesizedExpression 15.8.5
Literal | // Literal 15.8.1
Name | // AmbiguousName
Name Arguments | // MethodInvocation
Name '[]' { '[]' } | // ArrayType 10.1
Name '[]' { '[]' } '.' 'class' | // ClassLiteral 15.8.2
'this' | // This 15.8.3
'this' Arguments | // Alternate constructor invocation 8.8.5.1
'super' Arguments | // Unqualified superclass constructor invocation 8.8.5.1
'super' '.' Identifier | // SuperclassFieldAccess 15.11.2
'super' '.' Identifier Arguments | // SuperclassMethodInvocation 15.12.4.9
NewClassInstance |
NewAnonymousClassInstance | // ClassInstanceCreationExpression 15.9
NewArray | // ArrayCreationExpression 15.10
NewInitializedArray | // ArrayInitializer 10.6
PrimitiveType { '[]' } | // Type
PrimitiveType { '[]' } '.' 'class' | // ClassLiteral 15.8.2
'void' '.' 'class' | // ClassLiteral 15.8.2
MethodReference // MethodReference JLS9 15.13
Name :=
Identifier { '.' Identifier }
CastExpression :=
'(' PrimitiveType { '[]' } ')' UnaryExpression |
'(' Expression ')' UnaryExpression
NewClassInstance := 'new' ReferenceType Arguments
NewAnonymousClassInstance := 'new' ReferenceType Arguments [ ClassBody ]
NewArray := 'new' Type DimExprs { '[]' }
NewInitializedArray := 'new' ArrayType ArrayInitializer
|
| public String[] | |
| public Java. | |
| public Java. | |
| public Java. | parseRelationalExpression()
RelationalExpression :=
ShiftExpression {
'instanceof' ReferenceType
| '<' ShiftExpression [ { ',' TypeArgument } '>' ]
| '<' TypeArgument [ { ',' TypeArgument } '>' ]
| ( '>' | '<=' | '>=' ) ShiftExpression
}
|
| private Java. | |
| public Java. | |
| public Java. | parseSelector(Java.
Selector :=
'.' Identifier | // FieldAccess 15.11.1
'.' Identifier Arguments | // MethodInvocation
'.' '<' TypeList '>' 'super' Arguments // Superconstructor invocation (?)
'.' '<' TypeList '>' 'super' '.' .
|
| public Java. | parseShiftExpression()
ShiftExpression :=
AdditiveExpression { ( '<<' | '>>' | '>>>' ) AdditiveExpression }
|
| public Java. | parseStatement()
Statement :=
LabeledStatement |
Block |
IfStatement |
ForStatement |
WhileStatement |
DoStatement |
TryStatement |
'switch' ...
|
| public Java. | parseSwitchStatement()
SwitchStatement :=
'switch' '(' Expression ')' '{' { SwitchLabels BlockStatements } '}'
SwitchLabels := SwitchLabels { SwitchLabels }
SwitchLabel := 'case' Expression ':' | 'default' ':'
|
| public Java. | |
| public Java. | |
| public Java. | parseTryStatement()
TryStatement :=
'try' Block Catches [ Finally ] |
'try' Block Finally
Catches := CatchClause { CatchClause }
CatchClause := 'catch' '(' FormalParameter ')' Block
Finally := 'finally' Block
|
| public Java. | parseType()
Type := (
'byte' | 'short' | 'char' | 'int' | 'long' |
'float' | 'double' | 'boolean' |
ReferenceType
) { '[' ']' }
|
| private Java. | parseTypeArgument()
TypeArgument :=
ReferenceType { '[' ']' } <= The optional brackets are missing in JLS7, section 18!?
|
| private Java. | Returns: null iff there are no type arguments
TypeArguments := '<' [ TypeArgument { ',' TypeArgument } ] '>'
|
| private Java. | parseTypeParameter()
TypeParameter := identifier [ 'extends' ( identifier | ReferenceType { '&' ReferenceType }
|
| private Java. | |
| public Java. | parseUnaryExpression()
UnaryExpression :=
{ PrefixOperator } Primary { Selector } { PostfixOperator }
PrefixOperator := '++' | '--' | '+' | '-' | '~' | '!'
PostfixOperator := '++' | '--'
|
| public Java. | |
| public Java. | parseVariableDeclaratorRest(String name)
VariableDeclaratorRest := { '[' ']' } [ '=' VariableInitializer ]
|
| public Java. | |
| public Java. | |
| public Java. | |
| public Java. | |
| public Token | |
| public boolean | |
| public int | |
| public boolean | |
| public int | |
| private boolean | |
| public Token | |
| public boolean | |
| public boolean | |
| public boolean | |
| public int | |
| public String | |
| public Token | |
| public void | |
| public int | |
| public String | |
| public void | |
| public void | setWarningHandler(WarningHandler
null to indicate that no warnings be issuedBy default, warnings are discarded, but an application my install a |
| private Java. | |
| private void | verifyIdentifierIsConventionalClassOrInterfaceName(String id, Location loc)
Issues a warning if the given identifier does not comply with the class and interface type naming conventions (JLS7 6.8.2). |
| private void | verifyIdentifierIsConventionalFieldName(String id, Location loc)
Issues a warning if the given identifier does not comply with the field naming conventions (JLS7 6.8.4) and constant naming conventions (JLS7 6.8.5). |
| private void | verifyIdentifierIsConventionalLocalVariableOrParameterName(String id, Location loc)
Issues a warning if the given identifier does not comply with the local variable and parameter naming conventions (JLS7 6.8.6). |
| private void | verifyIdentifierIsConventionalMethodName(String id, Location loc)
Issues a warning if the given identifier does not comply with the method naming conventions (JLS7 6.8.3). |
| private void | verifyStringIsConventionalPackageName(String s, Location loc)
Issues a warning if the given string does not comply with the package naming conventions. |
| private void | |
| private void |