public class Parser extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Parser.ClassDeclarationContext |
static class |
Parser.InterfaceDeclarationContext |
Modifier and Type | Method and Description |
---|---|
void |
eatToken() |
Scanner |
getScanner() |
Location |
location() |
Java.Atom |
parseAdditiveExpression()
AdditiveExpression :=
MultiplicativeExpression { ( '+' | '-' ) MultiplicativeExpression }
|
Java.Atom |
parseAndExpression()
AndExpression :=
EqualityExpression { '&' EqualityExpression }
|
Java.Rvalue[] |
parseArgumentList()
ArgumentList := Expression { ',' Expression }
|
Java.Rvalue[] |
parseArguments()
Arguments := '(' [ ArgumentList ] ')'
|
Java.ArrayInitializer |
parseArrayInitializer()
ArrayInitializer :=
'{' [ VariableInitializer { ',' VariableInitializer } [ ',' ] '}'
|
Java.Atom |
parseAssignmentExpression()
AssignmentExpression :=
ConditionalExpression [ AssignmentOperator AssignmentExpression ]
AssignmentOperator :=
'=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' |
'>>=' | '>>>=' | '&=' | '^=' | '|='
|
Java.Block |
parseBlock()
'{' BlockStatements '}'
|
Java.BlockStatement |
parseBlockStatement()
BlockStatement := { Identifier ':' } (
( Modifiers Type | ModifiersOpt BasicType ) LocalVariableDeclarators ';' |
'class' ...
|
List |
parseBlockStatements()
BlockStatements := { BlockStatement }
|
Java.Statement |
parseBreakStatement()
BreakStatement := 'break' [ Identifier ] ';'
|
void |
parseClassBody(Java.ClassDeclaration classDeclaration)
ClassBody := '{' { ClassBodyDeclaration } '}'
|
void |
parseClassBodyDeclaration(Java.ClassDeclaration classDeclaration)
ClassBodyDeclaration :=
';' |
ModifiersOpt (
Block | // Instance (JLS2 8.6) or static initializer (JLS2 8.7)
'void' Identifier MethodDeclarationRest |
'class' ClassDeclarationRest |
'interface' InterfaceDeclarationRest |
ConstructorDeclarator |
Type Identifier (
MethodDeclarationRest |
FieldDeclarationRest ';'
)
)
|
Java.NamedClassDeclaration |
parseClassDeclarationRest(String optionalDocComment,
short modifiers,
Parser.ClassDeclarationContext context)
ClassDeclarationRest :=
Identifier
[ 'extends' ReferenceType ]
[ 'implements' ReferenceTypeList ]
ClassBody
|
Java.CompilationUnit |
parseCompilationUnit()
CompilationUnit := [ PackageDeclaration ]
{ ImportDeclaration }
{ TypeDeclaration }
|
Java.Atom |
parseConditionalAndExpression()
ConditionalAndExpression :=
InclusiveOrExpression { '&&' InclusiveOrExpression }
|
Java.Atom |
parseConditionalExpression()
ConditionalExpression :=
ConditionalOrExpression [ '?' Expression ':' ConditionalExpression ]
|
Java.Atom |
parseConditionalOrExpression()
ConditionalOrExpression :=
ConditionalAndExpression { '||' ConditionalAndExpression ]
|
Java.ConstructorDeclarator |
parseConstructorDeclarator(String optionalDocComment,
short modifiers)
ConstructorDeclarator :=
Identifier
FormalParameters
[ 'throws' ReferenceTypeList ]
'{'
[ 'this' Arguments ';' | 'super' Arguments ';' | Primary '.' 'super' Arguments ';' ]
BlockStatements
'}'
|
Java.Statement |
parseContinueStatement()
ContinueStatement := 'continue' [ Identifier ] ';'
|
Java.Rvalue |
parseDimExpr()
DimExpr := '[' Expression ']'
|
Java.Rvalue[] |
parseDimExprs()
DimExprs := DimExpr { DimExpr }
|
Java.Statement |
parseDoStatement()
DoStatement := 'do' Statement 'while' '(' Expression ')' ';'
|
Java.Statement |
parseEmptyStatement()
EmptyStatement := ';'
|
Java.Atom |
parseEqualityExpression()
EqualityExpression :=
RelationalExpression { ( '==' | '!=' ) RelationalExpression }
|
Java.Atom |
parseExclusiveOrExpression()
ExclusiveOrExpression :=
AndExpression { '^' AndExpression }
|
Java.Atom |
parseExpression()
Expression := AssignmentExpression
|
Java.Rvalue[] |
parseExpressionList()
ExpressionList := Expression { ',' Expression }
|
Java.Statement |
parseExpressionStatement()
ExpressionStatement := Expression ';'
|
Java.VariableDeclarator[] |
parseFieldDeclarationRest(String name)
FieldDeclarationRest :=
VariableDeclaratorRest
{ ',' VariableDeclarator }
|
Java.FunctionDeclarator.FormalParameter |
parseFormalParameter()
FormalParameter := [ 'final' ] Type Identifier BracketsOpt
|
Java.FunctionDeclarator.FormalParameter[] |
parseFormalParameters()
FormalParameters := '(' [ FormalParameter { ',' FormalParameter } ] ')'
|
Java.Statement |
parseForStatement()
ForStatement :=
'for' '('
[ ForInit ] ';'
[ Expression ] ';'
[ ExpressionList ]
')' Statement
|
Java.Statement |
parseIfStatement()
IfStatement := 'if' '(' Expression ')' Statement [ 'else' Statement ]
|
Java.CompilationUnit.ImportDeclaration |
parseImportDeclaration()
ImportDeclaration := 'import' ImportDeclarationBody ';'
|
Java.CompilationUnit.ImportDeclaration |
parseImportDeclarationBody()
ImportDeclarationBody := [ 'static' ] Identifier { '.' Identifier } [ '.' '*' ]
|
Java.Atom |
parseInclusiveOrExpression()
InclusiveOrExpression :=
ExclusiveOrExpression { '|' ExclusiveOrExpression }
|
void |
parseInterfaceBody(Java.InterfaceDeclaration interfaceDeclaration)
InterfaceBody := '{' {
';' |
ModifiersOpt (
'void' Identifier MethodDeclarationRest |
'class' ClassDeclarationRest |
'interface' InterfaceDeclarationRest |
Type Identifier (
MethodDeclarationRest |
FieldDeclarationRest
)
)
} '}'
|
Java.InterfaceDeclaration |
parseInterfaceDeclarationRest(String optionalDocComment,
short modifiers,
Parser.InterfaceDeclarationContext context)
InterfaceDeclarationRest :=
Identifier
[ 'extends' ReferenceTypeList ]
InterfaceBody
|
Java.Statement |
parseLabeledStatement()
LabeledStatement := Identifier ':' Statement
|
Java.Atom |
parseLiteral() |
Java.VariableDeclarator[] |
parseLocalVariableDeclarators()
LocalVariableDeclarators := VariableDeclarator { ',' VariableDeclarator }
|
Java.Block |
parseMethodBody()
MethodBody := Block
|
Java.MethodDeclarator |
parseMethodDeclarationRest(String optionalDocComment,
short modifiers,
Java.Type type,
String name)
MethodDeclarationRest :=
FormalParameters
{ '[' ']' }
[ 'throws' ReferenceTypeList ]
( ';' | MethodBody )
|
short |
parseModifiersOpt()
ModifiersOpt := { 'public' | 'protected' | 'private' | 'static' |
'abstract' | 'final' | 'native' | 'synchronized' |
'transient' | 'volatile' | 'strictfp'
|
Java.Atom |
parseMultiplicativeExpression()
MultiplicativeExpression :=
UnaryExpression { ( '*' | '/' | '%' ) UnaryExpression }
|
Java.PackageDeclaration |
parsePackageDeclaration()
PackageDeclaration := 'package' QualifiedIdentifier ';'
|
Java.PackageMemberTypeDeclaration |
parsePackageMemberTypeDeclaration()
PackageMemberTypeDeclaration :=
ModifiersOpt 'class' ClassDeclarationRest |
ModifiersOpt 'interface' InterfaceDeclarationRest
|
Java.Atom |
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
BasicType { '[]' } | // Type
BasicType { '[]' } '.' 'class' | // ClassLiteral 15.8.2
'void' '.' 'class' // ClassLiteral 15.8.2
CastExpression :=
'(' PrimitiveType { '[]' } ')' UnaryExpression |
'(' Expression ')' UnaryExpression
NewClassInstance := 'new' ReferenceType Arguments
NewAnonymousClassInstance := 'new' ReferenceType Arguments [ ClassBody ]
NewArray := 'new' Type DimExprs { '[]' }
NewInitializedArray := 'new' ArrayType ArrayInitializer
|
String[] |
parseQualifiedIdentifier()
QualifiedIdentifier := Identifier { '.' Identifier }
|
Java.ReferenceType |
parseReferenceType()
ReferenceType := QualifiedIdentifier
|
Java.ReferenceType[] |
parseReferenceTypeList()
ReferenceTypeList := ReferenceType { ',' ReferenceType }
|
Java.Atom |
parseRelationalExpression()
RelationalExpression :=
ShiftExpression {
( ( '<' | '>' | '<=' | '>=' ) ShiftExpression ) |
( 'instanceof' ReferenceType )
}
|
Java.Statement |
parseReturnStatement()
ReturnStatement := 'return' [ Expression ] ';'
|
Java.Atom |
parseSelector(Java.Atom atom)
Selector :=
'.' Identifier | // FieldAccess 15.11.1
'.' Identifier Arguments | // MethodInvocation
'.' 'this' // QualifiedThis 15.8.4
'.' 'super' Arguments // Qualified superclass constructor invocation (JLS 8.8.5.1)
'.' 'super' '.' Identifier | // SuperclassFieldReference (JLS 15.11.2)
'.' 'super' '.' Identifier Arguments | // SuperclassMethodInvocation (JLS 15.12.4.9)
'.' 'new' Identifier Arguments [ ClassBody ] | // QualifiedClassInstanceCreationExpression 15.9
'.' 'class'
'[' Expression ']' // ArrayAccessExpression 15.13
|
Java.Atom |
parseShiftExpression()
ShiftExpression :=
AdditiveExpression { ( '<<' | '>>' | '>>>' ) AdditiveExpression }
|
Java.Statement |
parseStatement()
Statement :=
LabeledStatement |
Block |
IfStatement |
ForStatement |
WhileStatement |
DoStatement |
TryStatement |
'switch' ...
|
Java.Statement |
parseSwitchStatement()
SwitchStatement :=
'switch' '(' Expression ')' '{' { SwitchLabels BlockStatements } '}'
SwitchLabels := SwitchLabels { SwitchLabels }
SwitchLabel := 'case' Expression ':' | 'default' ':'
|
Java.Statement |
parseSynchronizedStatement()
SynchronizedStatement :=
'synchronized' '(' expression ')' Block
|
Java.Statement |
parseThrowStatement()
ThrowStatement := 'throw' Expression ';'
|
Java.Statement |
parseTryStatement()
TryStatement :=
'try' Block Catches [ Finally ] |
'try' Block Finally
Catches := CatchClause { CatchClause }
CatchClause := 'catch' '(' FormalParameter ')' Block
Finally := 'finally' Block
|
Java.Type |
parseType()
Type := (
'byte' | 'short' | 'char' | 'int' | 'long' |
'float' | 'double' | 'boolean' |
ReferenceType
) { '[' ']' }
|
Java.Atom |
parseUnaryExpression()
UnaryExpression :=
{ PrefixOperator } Primary { Selector } { PostfixOperator }
PrefixOperator := '++' | '--' | '+' | '-' | '~' | '!'
PostfixOperator := '++' | '--'
|
Java.VariableDeclarator |
parseVariableDeclarator()
VariableDeclarator := Identifier VariableDeclaratorRest
|
Java.VariableDeclarator |
parseVariableDeclaratorRest(String name)
VariableDeclaratorRest := { '[' ']' } [ '=' VariableInitializer ]
|
Java.ArrayInitializerOrRvalue |
parseVariableInitializer()
VariableInitializer :=
ArrayInitializer |
Expression
|
Java.Statement |
parseWhileStatement()
WhileStatement := 'while' '(' Expression ')' Statement
|
boolean |
peekIdentifier() |
boolean |
peekKeyword() |
boolean |
peekKeyword(String keyword) |
boolean |
peekKeyword(String[] keywords) |
boolean |
peekOperator(String operator) |
boolean |
peekOperator(String[] operators) |
String |
readIdentifier() |
void |
readKeyword(String keyword) |
String |
readOperator() |
void |
readOperator(String operator) |
void |
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a
WarningHandler . |
protected void |
throwCompileException(String message)
Convenience method for throwing a CompileException.
|
public Parser(Scanner scanner)
public Scanner getScanner()
public Java.CompilationUnit parseCompilationUnit() throws CompileException, IOException
CompilationUnit := [ PackageDeclaration ] { ImportDeclaration } { TypeDeclaration }
CompileException
IOException
public Java.PackageDeclaration parsePackageDeclaration() throws CompileException, IOException
PackageDeclaration := 'package' QualifiedIdentifier ';'
CompileException
IOException
public Java.CompilationUnit.ImportDeclaration parseImportDeclaration() throws CompileException, IOException
ImportDeclaration := 'import' ImportDeclarationBody ';'
CompileException
IOException
public Java.CompilationUnit.ImportDeclaration parseImportDeclarationBody() throws CompileException, IOException
ImportDeclarationBody := [ 'static' ] Identifier { '.' Identifier } [ '.' '*' ]
CompileException
IOException
public String[] parseQualifiedIdentifier() throws CompileException, IOException
CompileException
IOException
public Java.PackageMemberTypeDeclaration parsePackageMemberTypeDeclaration() throws CompileException, IOException
PackageMemberTypeDeclaration := ModifiersOpt 'class' ClassDeclarationRest | ModifiersOpt 'interface' InterfaceDeclarationRest
CompileException
IOException
public short parseModifiersOpt() throws CompileException, IOException
ModifiersOpt := { 'public' | 'protected' | 'private' | 'static' | 'abstract' | 'final' | 'native' | 'synchronized' | 'transient' | 'volatile' | 'strictfp'
CompileException
IOException
public Java.NamedClassDeclaration parseClassDeclarationRest(String optionalDocComment, short modifiers, Parser.ClassDeclarationContext context) throws CompileException, IOException
ClassDeclarationRest := Identifier [ 'extends' ReferenceType ] [ 'implements' ReferenceTypeList ] ClassBody
CompileException
IOException
public void parseClassBody(Java.ClassDeclaration classDeclaration) throws CompileException, IOException
ClassBody := '{' { ClassBodyDeclaration } '}'
CompileException
IOException
public void parseClassBodyDeclaration(Java.ClassDeclaration classDeclaration) throws CompileException, IOException
ClassBodyDeclaration := ';' | ModifiersOpt ( Block | // Instance (JLS2 8.6) or static initializer (JLS2 8.7) 'void' Identifier MethodDeclarationRest | 'class' ClassDeclarationRest | 'interface' InterfaceDeclarationRest | ConstructorDeclarator | Type Identifier ( MethodDeclarationRest | FieldDeclarationRest ';' ) )
CompileException
IOException
public Java.InterfaceDeclaration parseInterfaceDeclarationRest(String optionalDocComment, short modifiers, Parser.InterfaceDeclarationContext context) throws CompileException, IOException
InterfaceDeclarationRest := Identifier [ 'extends' ReferenceTypeList ] InterfaceBody
CompileException
IOException
public void parseInterfaceBody(Java.InterfaceDeclaration interfaceDeclaration) throws CompileException, IOException
InterfaceBody := '{' { ';' | ModifiersOpt ( 'void' Identifier MethodDeclarationRest | 'class' ClassDeclarationRest | 'interface' InterfaceDeclarationRest | Type Identifier ( MethodDeclarationRest | FieldDeclarationRest ) ) } '}'
CompileException
IOException
public Java.ConstructorDeclarator parseConstructorDeclarator(String optionalDocComment, short modifiers) throws CompileException, IOException
ConstructorDeclarator := Identifier FormalParameters [ 'throws' ReferenceTypeList ] '{' [ 'this' Arguments ';' | 'super' Arguments ';' | Primary '.' 'super' Arguments ';' ] BlockStatements '}'
CompileException
IOException
public Java.MethodDeclarator parseMethodDeclarationRest(String optionalDocComment, short modifiers, Java.Type type, String name) throws CompileException, IOException
MethodDeclarationRest := FormalParameters { '[' ']' } [ 'throws' ReferenceTypeList ] ( ';' | MethodBody )
CompileException
IOException
public Java.ArrayInitializerOrRvalue parseVariableInitializer() throws CompileException, IOException
VariableInitializer := ArrayInitializer | Expression
CompileException
IOException
public Java.ArrayInitializer parseArrayInitializer() throws CompileException, IOException
ArrayInitializer := '{' [ VariableInitializer { ',' VariableInitializer } [ ',' ] '}'
CompileException
IOException
public Java.FunctionDeclarator.FormalParameter[] parseFormalParameters() throws CompileException, IOException
FormalParameters := '(' [ FormalParameter { ',' FormalParameter } ] ')'
CompileException
IOException
public Java.FunctionDeclarator.FormalParameter parseFormalParameter() throws CompileException, IOException
FormalParameter := [ 'final' ] Type Identifier BracketsOpt
CompileException
IOException
public Java.Block parseMethodBody() throws CompileException, IOException
MethodBody := Block
CompileException
IOException
public Java.Block parseBlock() throws CompileException, IOException
'{' BlockStatements '}'
CompileException
IOException
public List parseBlockStatements() throws CompileException, IOException
BlockStatements := { BlockStatement }
CompileException
IOException
public Java.BlockStatement parseBlockStatement() throws CompileException, IOException
BlockStatement := { Identifier ':' } ( ( Modifiers Type | ModifiersOpt BasicType ) LocalVariableDeclarators ';' | 'class' ... | Statement | 'final' Type LocalVariableDeclarators ';' | Expression ';' | Expression LocalVariableDeclarators ';' (1) )(1) "Expression" must pose a type, and has optional trailing brackets.
CompileException
IOException
public Java.VariableDeclarator[] parseLocalVariableDeclarators() throws CompileException, IOException
LocalVariableDeclarators := VariableDeclarator { ',' VariableDeclarator }
CompileException
IOException
public Java.VariableDeclarator[] parseFieldDeclarationRest(String name) throws CompileException, IOException
FieldDeclarationRest := VariableDeclaratorRest { ',' VariableDeclarator }
CompileException
IOException
public Java.VariableDeclarator parseVariableDeclarator() throws CompileException, IOException
VariableDeclarator := Identifier VariableDeclaratorRest
CompileException
IOException
public Java.VariableDeclarator parseVariableDeclaratorRest(String name) throws CompileException, IOException
VariableDeclaratorRest := { '[' ']' } [ '=' VariableInitializer ]Used by field declarations and local variable declarations.
CompileException
IOException
public Java.Statement parseStatement() throws CompileException, IOException
Statement := LabeledStatement | Block | IfStatement | ForStatement | WhileStatement | DoStatement | TryStatement | 'switch' ... | 'synchronized' ... | ReturnStatement | ThrowStatement | BreakStatement | ContinueStatement | EmptyStatement | ExpressionStatement
CompileException
IOException
public Java.Statement parseLabeledStatement() throws CompileException, IOException
LabeledStatement := Identifier ':' Statement
CompileException
IOException
public Java.Statement parseIfStatement() throws CompileException, IOException
IfStatement := 'if' '(' Expression ')' Statement [ 'else' Statement ]
CompileException
IOException
public Java.Statement parseForStatement() throws CompileException, IOException
ForStatement := 'for' '(' [ ForInit ] ';' [ Expression ] ';' [ ExpressionList ] ')' Statement
CompileException
IOException
public Java.Statement parseWhileStatement() throws CompileException, IOException
WhileStatement := 'while' '(' Expression ')' Statement
CompileException
IOException
public Java.Statement parseDoStatement() throws CompileException, IOException
DoStatement := 'do' Statement 'while' '(' Expression ')' ';'
CompileException
IOException
public Java.Statement parseTryStatement() throws CompileException, IOException
TryStatement := 'try' Block Catches [ Finally ] | 'try' Block Finally Catches := CatchClause { CatchClause } CatchClause := 'catch' '(' FormalParameter ')' Block Finally := 'finally' Block
CompileException
IOException
public Java.Statement parseSwitchStatement() throws CompileException, IOException
SwitchStatement := 'switch' '(' Expression ')' '{' { SwitchLabels BlockStatements } '}' SwitchLabels := SwitchLabels { SwitchLabels } SwitchLabel := 'case' Expression ':' | 'default' ':'
CompileException
IOException
public Java.Statement parseSynchronizedStatement() throws CompileException, IOException
SynchronizedStatement := 'synchronized' '(' expression ')' Block
CompileException
IOException
public Java.Statement parseReturnStatement() throws CompileException, IOException
ReturnStatement := 'return' [ Expression ] ';'
CompileException
IOException
public Java.Statement parseThrowStatement() throws CompileException, IOException
ThrowStatement := 'throw' Expression ';'
CompileException
IOException
public Java.Statement parseBreakStatement() throws CompileException, IOException
BreakStatement := 'break' [ Identifier ] ';'
CompileException
IOException
public Java.Statement parseContinueStatement() throws CompileException, IOException
ContinueStatement := 'continue' [ Identifier ] ';'
CompileException
IOException
public Java.Statement parseEmptyStatement() throws CompileException, IOException
EmptyStatement := ';'
CompileException
IOException
public Java.Rvalue[] parseExpressionList() throws CompileException, IOException
ExpressionList := Expression { ',' Expression }
CompileException
IOException
public Java.Type parseType() throws CompileException, IOException
Type := ( 'byte' | 'short' | 'char' | 'int' | 'long' | 'float' | 'double' | 'boolean' | ReferenceType ) { '[' ']' }
CompileException
IOException
public Java.ReferenceType parseReferenceType() throws CompileException, IOException
ReferenceType := QualifiedIdentifier
CompileException
IOException
public Java.ReferenceType[] parseReferenceTypeList() throws CompileException, IOException
ReferenceTypeList := ReferenceType { ',' ReferenceType }
CompileException
IOException
public Java.Atom parseExpression() throws CompileException, IOException
Expression := AssignmentExpression
CompileException
IOException
public Java.Atom parseAssignmentExpression() throws CompileException, IOException
AssignmentExpression := ConditionalExpression [ AssignmentOperator AssignmentExpression ] AssignmentOperator := '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
CompileException
IOException
public Java.Atom parseConditionalExpression() throws CompileException, IOException
ConditionalExpression := ConditionalOrExpression [ '?' Expression ':' ConditionalExpression ]
CompileException
IOException
public Java.Atom parseConditionalOrExpression() throws CompileException, IOException
ConditionalOrExpression := ConditionalAndExpression { '||' ConditionalAndExpression ]
CompileException
IOException
public Java.Atom parseConditionalAndExpression() throws CompileException, IOException
ConditionalAndExpression := InclusiveOrExpression { '&&' InclusiveOrExpression }
CompileException
IOException
public Java.Atom parseInclusiveOrExpression() throws CompileException, IOException
InclusiveOrExpression := ExclusiveOrExpression { '|' ExclusiveOrExpression }
CompileException
IOException
public Java.Atom parseExclusiveOrExpression() throws CompileException, IOException
ExclusiveOrExpression := AndExpression { '^' AndExpression }
CompileException
IOException
public Java.Atom parseAndExpression() throws CompileException, IOException
AndExpression := EqualityExpression { '&' EqualityExpression }
CompileException
IOException
public Java.Atom parseEqualityExpression() throws CompileException, IOException
EqualityExpression := RelationalExpression { ( '==' | '!=' ) RelationalExpression }
CompileException
IOException
public Java.Atom parseRelationalExpression() throws CompileException, IOException
RelationalExpression := ShiftExpression { ( ( '<' | '>' | '<=' | '>=' ) ShiftExpression ) | ( 'instanceof' ReferenceType ) }
CompileException
IOException
public Java.Atom parseShiftExpression() throws CompileException, IOException
ShiftExpression := AdditiveExpression { ( '<<' | '>>' | '>>>' ) AdditiveExpression }
CompileException
IOException
public Java.Atom parseAdditiveExpression() throws CompileException, IOException
AdditiveExpression := MultiplicativeExpression { ( '+' | '-' ) MultiplicativeExpression }
CompileException
IOException
public Java.Atom parseMultiplicativeExpression() throws CompileException, IOException
MultiplicativeExpression := UnaryExpression { ( '*' | '/' | '%' ) UnaryExpression }
CompileException
IOException
public Java.Atom parseUnaryExpression() throws CompileException, IOException
UnaryExpression := { PrefixOperator } Primary { Selector } { PostfixOperator } PrefixOperator := '++' | '--' | '+' | '-' | '~' | '!' PostfixOperator := '++' | '--'
CompileException
IOException
public Java.Atom parsePrimary() throws CompileException, IOException
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 BasicType { '[]' } | // Type BasicType { '[]' } '.' 'class' | // ClassLiteral 15.8.2 'void' '.' 'class' // ClassLiteral 15.8.2 CastExpression := '(' PrimitiveType { '[]' } ')' UnaryExpression | '(' Expression ')' UnaryExpression NewClassInstance := 'new' ReferenceType Arguments NewAnonymousClassInstance := 'new' ReferenceType Arguments [ ClassBody ] NewArray := 'new' Type DimExprs { '[]' } NewInitializedArray := 'new' ArrayType ArrayInitializer
CompileException
IOException
public Java.Atom parseSelector(Java.Atom atom) throws CompileException, IOException
Selector := '.' Identifier | // FieldAccess 15.11.1 '.' Identifier Arguments | // MethodInvocation '.' 'this' // QualifiedThis 15.8.4 '.' 'super' Arguments // Qualified superclass constructor invocation (JLS 8.8.5.1) '.' 'super' '.' Identifier | // SuperclassFieldReference (JLS 15.11.2) '.' 'super' '.' Identifier Arguments | // SuperclassMethodInvocation (JLS 15.12.4.9) '.' 'new' Identifier Arguments [ ClassBody ] | // QualifiedClassInstanceCreationExpression 15.9 '.' 'class' '[' Expression ']' // ArrayAccessExpression 15.13
CompileException
IOException
public Java.Rvalue[] parseDimExprs() throws CompileException, IOException
DimExprs := DimExpr { DimExpr }
CompileException
IOException
public Java.Rvalue parseDimExpr() throws CompileException, IOException
DimExpr := '[' Expression ']'
CompileException
IOException
public Java.Rvalue[] parseArguments() throws CompileException, IOException
Arguments := '(' [ ArgumentList ] ')'
CompileException
IOException
public Java.Rvalue[] parseArgumentList() throws CompileException, IOException
ArgumentList := Expression { ',' Expression }
CompileException
IOException
public Java.Atom parseLiteral() throws CompileException, IOException
CompileException
IOException
public Location location()
public void eatToken() throws CompileException, IOException
CompileException
IOException
public boolean peekKeyword()
public boolean peekKeyword(String keyword)
public boolean peekKeyword(String[] keywords)
public void readKeyword(String keyword) throws CompileException, IOException
CompileException
IOException
public boolean peekOperator(String operator)
public boolean peekOperator(String[] operators)
public String readOperator() throws CompileException, IOException
CompileException
IOException
public void readOperator(String operator) throws CompileException, IOException
CompileException
IOException
public boolean peekIdentifier()
public String readIdentifier() throws CompileException, IOException
CompileException
IOException
public Java.Statement parseExpressionStatement() throws CompileException, IOException
ExpressionStatement := Expression ';'
CompileException
IOException
public void setWarningHandler(WarningHandler optionalWarningHandler)
WarningHandler
.
Notice that there is no Parser.setErrorHandler()
method, but parse errors always throw a CompileException
. The reason being is that there is no reasonable way to recover from parse errors and continue
parsing, so there is no need to install a custom parse error handler.
optionalWarningHandler
- null
to indicate that no warnings be issuedprotected final void throwCompileException(String message) throws CompileException
CompileException
Copyright © 2001–2014. All rights reserved.