|
janino.net | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
org.codehaus.janino.Parser
public class Parser
A parser for the Java™ programming language.
'JLS7' refers to the .
Nested Class Summary | |
---|---|
static class |
Parser.ClassDeclarationContext
Enumerator for the kinds of context where a class declaration can occur. |
static class |
Parser.InterfaceDeclarationContext
Enumerator for the kinds of context where an interface declaration can occur. |
Constructor Summary | |
---|---|
Parser(Scanner scanner)
|
Method Summary | |
---|---|
protected CompileException |
compileException( message)
Convenience method for throwing a CompileException . |
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.Statement |
parseAssertStatement()
AssertStatement := 'assert' Expression [ ':' Expression ] ';' |
Java.Atom |
parseAssignmentExpression()
AssignmentExpression := ConditionalExpression [ AssignmentOperator AssignmentExpression ] AssignmentOperator := '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|=' |
Java.Block |
parseBlock()
'{' BlockStatements '}' |
Java.BlockStatement |
parseBlockStatement()
BlockStatement := { Identifier ':' } ( ( Modifiers Type | ModifiersOpt BasicType ) VariableDeclarators ';' | 'class' ... | Statement | 'final' Type VariableDeclarators ';' | Expression ';' | Expression VariableDeclarators ';' (1) ) (1) "Expression" must pose a type, and has optional trailing brackets. |
<Java.BlockStatement> |
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 (JLS7 8.6) or static initializer (JLS7 8.7) 'void' Identifier MethodDeclarationRest | 'class' ClassDeclarationRest | 'interface' InterfaceDeclarationRest | ConstructorDeclarator | Type Identifier ( MethodDeclarationRest | FieldDeclarationRest ';' ) ) |
Java.NamedClassDeclaration |
parseClassDeclarationRest( optionalDocComment,
Java.Modifiers modifiers,
Parser.ClassDeclarationContext context)
ClassDeclarationRest := Identifier [ typeParameters ] [ 'extends' ReferenceType ] [ 'implements' ReferenceTypeList ] ClassBody |
Java.CompilationUnit |
parseCompilationUnit()
CompilationUnit := [ PackageDeclaration ] { ImportDeclaration } { TypeDeclaration } |
Java.Atom |
parseConditionalAndExpression()
ConditionalAndExpression := InclusiveOrExpression { '&&' InclusiveOrExpression } |
Java.Atom |
parseConditionalExpression()
ConditionalExpression := ConditionalOrExpression [ '?' |
Java.Atom |
parseConditionalOrExpression()
ConditionalOrExpression := ConditionalAndExpression { '||' ConditionalAndExpression ] |
Java.ConstructorDeclarator |
parseConstructorDeclarator( optionalDocComment,
Java.Modifiers modifiers)
ConstructorDeclarator := Identifier FormalParameters [ 'throws' ReferenceTypeList ] '{' [ 'this' Arguments ';' | 'super' Arguments ';' | Primary '.' |
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 { ( '==' | '! |
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( name)
FieldDeclarationRest := VariableDeclaratorRest { ',' VariableDeclarator } |
Java.FunctionDeclarator.FormalParameter |
parseFormalParameter(boolean[] hasEllipsis)
FormalParameter := [ 'final' ] Type [ '.' '.' '.' ] Identifier BracketsOpt |
Java.FunctionDeclarator.FormalParameters |
parseFormalParameters()
FormalParameters := '(' [ FormalParameter { ',' FormalParameter } ] ')' |
Java.Statement |
parseForStatement()
ForStatement := 'for' '(' [ ForInit ] ';' [ Expression ] ';' [ ExpressionList ] ')' Statement | 'for' '(' FormalParameter ':' Expression ')' Statement ForInit := Modifiers Type VariableDeclarators | ModifiersOpt BasicType VariableDeclarators | Expression VariableDeclarators (1) | Expression { ',' Expression } (1) "Expression" must pose a type. |
Java.Statement |
parseIfStatement()
IfStatement := 'if' '(' Expression ')' Statement [ 'else' Statement ] |
Java.CompilationUnit.ImportDeclaration |
parseImportDeclaration()
ImportDeclaration := 'import' ImportDeclarationBody ';' |
Java.CompilationUnit.ImportDeclaration |
parseImportDeclarationBody()
ImportDeclarationBody := [ 'static' ] 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( optionalDocComment,
Java.Modifiers modifiers,
Parser.InterfaceDeclarationContext context)
InterfaceDeclarationRest := Identifier [ typeParameters ] [ 'extends' ReferenceTypeList ] InterfaceBody |
Java.Statement |
parseLabeledStatement()
LabeledStatement := Identifier ':' Statement |
Java.Rvalue |
parseLiteral()
Literal := IntegerLiteral | FloatingPointLiteral | BooleanLiteral | CharacterLiteral | StringLiteral | NullLiteral |
Java.Block |
parseMethodBody()
MethodBody := Block |
Java.MethodDeclarator |
parseMethodDeclarationRest( optionalDocComment,
Java.Modifiers modifiers,
Java.Type type,
name)
MethodDeclarationRest := FormalParameters { '[' ']' } [ 'throws' ReferenceTypeList ] ( ';' | MethodBody ) |
Java.Modifiers |
parseModifiers()
ModifiersAndAnnotations := { 'public' | 'protected' | 'private' | 'static' | 'abstract' | 'final' | 'native' | 'synchronized' | 'transient' | 'volatile' | 'strictfp' | Annotation } |
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 '[]' { '[]' } '.' |
[] |
parseQualifiedIdentifier()
QualifiedIdentifier := Identifier { '.' |
Java.ReferenceType |
parseReferenceType()
ReferenceType := QualifiedIdentifier [ TypeArguments ] |
Java.ReferenceType[] |
parseReferenceTypeList()
ReferenceTypeList := ReferenceType { ',' ReferenceType } |
Java.Atom |
parseRelationalExpression()
RelationalExpression := ShiftExpression { 'instanceof' ReferenceType | '<' ShiftExpression [ { ',' TypeArgument } '>' ] | '<' TypeArgument [ { ',' TypeArgument } '>' ] | ( '>' | '<=' | '>=' ) ShiftExpression } |
Java.Statement |
parseReturnStatement()
ReturnStatement := 'return' [ Expression ] ';' |
Java.Atom |
parseSelector(Java.Atom atom)
Selector := '.' |
Java.Atom |
parseShiftExpression()
ShiftExpression := AdditiveExpression { ( '<<' | '>>' | '>>>' ) AdditiveExpression } |
Java.Statement |
parseStatement()
Statement := LabeledStatement | Block | IfStatement | ForStatement | WhileStatement | DoStatement | TryStatement | 'switch' ... | 'synchronized' ... | ReturnStatement | ThrowStatement | BreakStatement | ContinueStatement | EmptyStatement | ExpressionStatement |
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 := '++' | '--' | '+' | '-' | '~' | '!' |
Java.VariableDeclarator |
parseVariableDeclarator()
VariableDeclarator := Identifier VariableDeclaratorRest |
Java.VariableDeclarator |
parseVariableDeclaratorRest( name)
VariableDeclaratorRest := { '[' ']' } [ '=' VariableInitializer ] Used by field declarations and local variable declarations. |
Java.VariableDeclarator[] |
parseVariableDeclarators()
VariableDeclarators := VariableDeclarator { ',' VariableDeclarator } |
Java.ArrayInitializerOrRvalue |
parseVariableInitializer()
VariableInitializer := ArrayInitializer | Expression |
Java.Statement |
parseWhileStatement()
WhileStatement := 'while' '(' Expression ')' Statement |
Scanner.Token |
peek()
|
int |
peek(int[] suspected)
Checks whether the type of the next token is any of the suspected ; does not consume the next token. |
boolean |
peek( suspected)
|
int |
peek([] suspected)
Checks whether the value of the next token equals any of the suspected ; does not consume the next
token. |
boolean |
peekEof()
|
|
peekIdentifier()
|
boolean |
peekLiteral()
|
Scanner.Token |
peekNextButOne()
|
boolean |
peekNextButOne( suspected)
|
boolean |
peekRead( suspected)
|
int |
peekRead([] values)
|
Scanner.Token |
read()
|
void |
read( expected)
Verifies that the value of the next token equals expected , and consumes the token. |
int |
read([] expected)
Verifies that the value of the next token equals one of the expected , and consumes the token. |
|
readIdentifier()
|
|
readOperator()
|
void |
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a WarningHandler . |
Methods inherited from class java.lang. |
---|
, , , , , , , , , , |
Constructor Detail |
---|
public Parser(Scanner scanner)
Method Detail |
---|
public Scanner getScanner()
public Java.CompilationUnit parseCompilationUnit() throws CompileException,
CompilationUnit := [ PackageDeclaration ] { ImportDeclaration } { TypeDeclaration }
CompileException
public Java.PackageDeclaration parsePackageDeclaration() throws CompileException,
PackageDeclaration := 'package' QualifiedIdentifier ';'
CompileException
public Java.CompilationUnit.ImportDeclaration parseImportDeclaration() throws CompileException,
ImportDeclaration := 'import' ImportDeclarationBody ';'
CompileException
public Java.CompilationUnit.ImportDeclaration parseImportDeclarationBody() throws CompileException,
ImportDeclarationBody := [ 'static' ] Identifier { '.' Identifier } [ '.' '*' ]
CompileException
public [] parseQualifiedIdentifier() throws CompileException,
QualifiedIdentifier := Identifier { '.' Identifier }
CompileException
public Java.PackageMemberTypeDeclaration parsePackageMemberTypeDeclaration() throws CompileException,
PackageMemberTypeDeclaration := ModifiersOpt 'class' ClassDeclarationRest | ModifiersOpt 'interface' InterfaceDeclarationRest
CompileException
public Java.Modifiers parseModifiers() throws CompileException,
ModifiersAndAnnotations := { 'public' | 'protected' | 'private' | 'static' | 'abstract' | 'final' | 'native' | 'synchronized' | 'transient' | 'volatile' | 'strictfp' | Annotation }
CompileException
public Java.NamedClassDeclaration parseClassDeclarationRest( optionalDocComment, Java.Modifiers modifiers, Parser.ClassDeclarationContext context) throws CompileException,
ClassDeclarationRest := Identifier [ typeParameters ] [ 'extends' ReferenceType ] [ 'implements' ReferenceTypeList ] ClassBody
CompileException
public void parseClassBody(Java.ClassDeclaration classDeclaration) throws CompileException,
ClassBody := '{' { ClassBodyDeclaration } '}'
CompileException
public void parseClassBodyDeclaration(Java.ClassDeclaration classDeclaration) throws CompileException,
ClassBodyDeclaration := ';' | ModifiersOpt ( Block | // Instance (JLS7 8.6) or static initializer (JLS7 8.7) 'void' Identifier MethodDeclarationRest | 'class' ClassDeclarationRest | 'interface' InterfaceDeclarationRest | ConstructorDeclarator | Type Identifier ( MethodDeclarationRest | FieldDeclarationRest ';' ) )
CompileException
public Java.InterfaceDeclaration parseInterfaceDeclarationRest( optionalDocComment, Java.Modifiers modifiers, Parser.InterfaceDeclarationContext context) throws CompileException,
InterfaceDeclarationRest := Identifier [ typeParameters ] [ 'extends' ReferenceTypeList ] InterfaceBody
CompileException
public void parseInterfaceBody(Java.InterfaceDeclaration interfaceDeclaration) throws CompileException,
InterfaceBody := '{' { ';' | ModifiersOpt ( 'void' Identifier MethodDeclarationRest | 'class' ClassDeclarationRest | 'interface' InterfaceDeclarationRest | Type Identifier ( MethodDeclarationRest | FieldDeclarationRest ) ) } '}'
CompileException
public Java.ConstructorDeclarator parseConstructorDeclarator( optionalDocComment, Java.Modifiers modifiers) throws CompileException,
ConstructorDeclarator := Identifier FormalParameters [ 'throws' ReferenceTypeList ] '{' [ 'this' Arguments ';' | 'super' Arguments ';' | Primary '.' 'super' Arguments ';' ] BlockStatements '}'
CompileException
public Java.MethodDeclarator parseMethodDeclarationRest( optionalDocComment, Java.Modifiers modifiers, Java.Type type, name) throws CompileException,
MethodDeclarationRest := FormalParameters { '[' ']' } [ 'throws' ReferenceTypeList ] ( ';' | MethodBody )
CompileException
public Java.ArrayInitializerOrRvalue parseVariableInitializer() throws CompileException,
VariableInitializer := ArrayInitializer | Expression
CompileException
public Java.ArrayInitializer parseArrayInitializer() throws CompileException,
ArrayInitializer := '{' [ VariableInitializer { ',' VariableInitializer } [ ',' ] '}'
CompileException
public Java.FunctionDeclarator.FormalParameters parseFormalParameters() throws CompileException,
FormalParameters := '(' [ FormalParameter { ',' FormalParameter } ] ')'
CompileException
public Java.FunctionDeclarator.FormalParameter parseFormalParameter(boolean[] hasEllipsis) throws CompileException,
FormalParameter := [ 'final' ] Type [ '.' '.' '.' ] Identifier BracketsOpt
CompileException
public Java.Block parseMethodBody() throws CompileException,
MethodBody := Block
CompileException
public Java.Block parseBlock() throws CompileException,
'{' BlockStatements '}'
CompileException
public <Java.BlockStatement> parseBlockStatements() throws CompileException,
BlockStatements := { BlockStatement }
CompileException
public Java.BlockStatement parseBlockStatement() throws CompileException,
BlockStatement := { Identifier ':' } ( ( Modifiers Type | ModifiersOpt BasicType ) VariableDeclarators ';' | 'class' ... | Statement | 'final' Type VariableDeclarators ';' | Expression ';' | Expression VariableDeclarators ';' (1) )(1) "Expression" must pose a type, and has optional trailing brackets.
CompileException
public Java.VariableDeclarator[] parseVariableDeclarators() throws CompileException,
VariableDeclarators := VariableDeclarator { ',' VariableDeclarator }
CompileException
public Java.VariableDeclarator[] parseFieldDeclarationRest( name) throws CompileException,
FieldDeclarationRest := VariableDeclaratorRest { ',' VariableDeclarator }
CompileException
public Java.VariableDeclarator parseVariableDeclarator() throws CompileException,
VariableDeclarator := Identifier VariableDeclaratorRest
CompileException
public Java.VariableDeclarator parseVariableDeclaratorRest( name) throws CompileException,
VariableDeclaratorRest := { '[' ']' } [ '=' VariableInitializer ]Used by field declarations and local variable declarations.
CompileException
public Java.Statement parseStatement() throws CompileException,
Statement := LabeledStatement | Block | IfStatement | ForStatement | WhileStatement | DoStatement | TryStatement | 'switch' ... | 'synchronized' ... | ReturnStatement | ThrowStatement | BreakStatement | ContinueStatement | EmptyStatement | ExpressionStatement
CompileException
public Java.Statement parseLabeledStatement() throws CompileException,
LabeledStatement := Identifier ':' Statement
CompileException
public Java.Statement parseIfStatement() throws CompileException,
IfStatement := 'if' '(' Expression ')' Statement [ 'else' Statement ]
CompileException
public Java.Statement parseForStatement() throws CompileException,
ForStatement := 'for' '(' [ ForInit ] ';' [ Expression ] ';' [ ExpressionList ] ')' Statement | 'for' '(' FormalParameter ':' Expression ')' Statement ForInit := Modifiers Type VariableDeclarators | ModifiersOpt BasicType VariableDeclarators | Expression VariableDeclarators (1) | Expression { ',' Expression }(1) "Expression" must pose a type.
CompileException
public Java.Statement parseWhileStatement() throws CompileException,
WhileStatement := 'while' '(' Expression ')' Statement
CompileException
public Java.Statement parseDoStatement() throws CompileException,
DoStatement := 'do' Statement 'while' '(' Expression ')' ';'
CompileException
public Java.Statement parseTryStatement() throws CompileException,
TryStatement := 'try' Block Catches [ Finally ] | 'try' Block Finally Catches := CatchClause { CatchClause } CatchClause := 'catch' '(' FormalParameter ')' Block Finally := 'finally' Block
CompileException
public Java.Statement parseSwitchStatement() throws CompileException,
SwitchStatement := 'switch' '(' Expression ')' '{' { SwitchLabels BlockStatements } '}' SwitchLabels := SwitchLabels { SwitchLabels } SwitchLabel := 'case' Expression ':' | 'default' ':'
CompileException
public Java.Statement parseSynchronizedStatement() throws CompileException,
SynchronizedStatement := 'synchronized' '(' expression ')' Block
CompileException
public Java.Statement parseReturnStatement() throws CompileException,
ReturnStatement := 'return' [ Expression ] ';'
CompileException
public Java.Statement parseThrowStatement() throws CompileException,
ThrowStatement := 'throw' Expression ';'
CompileException
public Java.Statement parseBreakStatement() throws CompileException,
BreakStatement := 'break' [ Identifier ] ';'
CompileException
public Java.Statement parseContinueStatement() throws CompileException,
ContinueStatement := 'continue' [ Identifier ] ';'
CompileException
public Java.Statement parseAssertStatement() throws CompileException,
AssertStatement := 'assert' Expression [ ':' Expression ] ';'
CompileException
public Java.Statement parseEmptyStatement() throws CompileException,
EmptyStatement := ';'
CompileException
public Java.Rvalue[] parseExpressionList() throws CompileException,
ExpressionList := Expression { ',' Expression }
CompileException
public Java.Type parseType() throws CompileException,
Type := ( 'byte' | 'short' | 'char' | 'int' | 'long' | 'float' | 'double' | 'boolean' | ReferenceType ) { '[' ']' }
CompileException
public Java.ReferenceType parseReferenceType() throws CompileException,
ReferenceType := QualifiedIdentifier [ TypeArguments ]
CompileException
public Java.ReferenceType[] parseReferenceTypeList() throws CompileException,
ReferenceTypeList := ReferenceType { ',' ReferenceType }
CompileException
public Java.Atom parseExpression() throws CompileException,
Expression := AssignmentExpression
CompileException
public Java.Atom parseAssignmentExpression() throws CompileException,
AssignmentExpression := ConditionalExpression [ AssignmentOperator AssignmentExpression ] AssignmentOperator := '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
CompileException
public Java.Atom parseConditionalExpression() throws CompileException,
ConditionalExpression := ConditionalOrExpression [ '?' Expression ':' ConditionalExpression ]
CompileException
public Java.Atom parseConditionalOrExpression() throws CompileException,
ConditionalOrExpression := ConditionalAndExpression { '||' ConditionalAndExpression ]
CompileException
public Java.Atom parseConditionalAndExpression() throws CompileException,
ConditionalAndExpression := InclusiveOrExpression { '&&' InclusiveOrExpression }
CompileException
public Java.Atom parseInclusiveOrExpression() throws CompileException,
InclusiveOrExpression := ExclusiveOrExpression { '|' ExclusiveOrExpression }
CompileException
public Java.Atom parseExclusiveOrExpression() throws CompileException,
ExclusiveOrExpression := AndExpression { '^' AndExpression }
CompileException
public Java.Atom parseAndExpression() throws CompileException,
AndExpression := EqualityExpression { '&' EqualityExpression }
CompileException
public Java.Atom parseEqualityExpression() throws CompileException,
EqualityExpression := RelationalExpression { ( '==' | '!=' ) RelationalExpression }
CompileException
public Java.Atom parseRelationalExpression() throws CompileException,
RelationalExpression := ShiftExpression { 'instanceof' ReferenceType | '<' ShiftExpression [ { ',' TypeArgument } '>' ] | '<' TypeArgument [ { ',' TypeArgument } '>' ] | ( '>' | '<=' | '>=' ) ShiftExpression }
CompileException
public Java.Atom parseShiftExpression() throws CompileException,
ShiftExpression := AdditiveExpression { ( '<<' | '>>' | '>>>' ) AdditiveExpression }
CompileException
public Java.Atom parseAdditiveExpression() throws CompileException,
AdditiveExpression := MultiplicativeExpression { ( '+' | '-' ) MultiplicativeExpression }
CompileException
public Java.Atom parseMultiplicativeExpression() throws CompileException,
MultiplicativeExpression := UnaryExpression { ( '*' | '/' | '%' ) UnaryExpression }
CompileException
public Java.Atom parseUnaryExpression() throws CompileException,
UnaryExpression := { PrefixOperator } Primary { Selector } { PostfixOperator } PrefixOperator := '++' | '--' | '+' | '-' | '~' | '!' PostfixOperator := '++' | '--'
CompileException
public Java.Atom parsePrimary() throws CompileException,
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
public Java.Atom parseSelector(Java.Atom atom) throws CompileException,
Selector := '.' Identifier | // FieldAccess 15.11.1 '.' Identifier Arguments | // MethodInvocation '.' 'this' // QualifiedThis 15.8.4 '.' 'super' Arguments // Qualified superclass constructor invocation (JLS7 8.8.7.1) '.' 'super' '.' Identifier | // SuperclassFieldReference (JLS7 15.11.2) '.' 'super' '.' Identifier Arguments | // SuperclassMethodInvocation (JLS7 15.12.3) '.' 'new' Identifier Arguments [ ClassBody ] | // QualifiedClassInstanceCreationExpression 15.9 '.' 'class' '[' Expression ']' // ArrayAccessExpression 15.13
CompileException
public Java.Rvalue[] parseDimExprs() throws CompileException,
DimExprs := DimExpr { DimExpr }
CompileException
public Java.Rvalue parseDimExpr() throws CompileException,
DimExpr := '[' Expression ']'
CompileException
public Java.Rvalue[] parseArguments() throws CompileException,
Arguments := '(' [ ArgumentList ] ')'
CompileException
public Java.Rvalue[] parseArgumentList() throws CompileException,
ArgumentList := Expression { ',' Expression }
CompileException
public Java.Rvalue parseLiteral() throws CompileException,
Literal := IntegerLiteral | FloatingPointLiteral | BooleanLiteral | CharacterLiteral | StringLiteral | NullLiteral
CompileException
public Java.Statement parseExpressionStatement() throws CompileException,
ExpressionStatement := Expression ';'
CompileException
public Location location()
peek()
ed or read()
tokenpublic Scanner.Token peek() throws CompileException,
CompileException
public Scanner.Token peekNextButOne() throws CompileException,
CompileException
public Scanner.Token read() throws CompileException,
null
iff the scanner is at end-of-input
CompileException
public boolean peek( suspected) throws CompileException,
suspected
; does not consume the next token
CompileException
public int peek([] suspected) throws CompileException,
suspected
; does not consume the next
token.
suspected
that equals the value of the next token, or -1 if the
value of the next token equals none of the suspected
CompileException
public int peek(int[] suspected) throws CompileException,
suspected
; does not consume the next token.
suspected
types that is the next token's type, or -1 if the type
of the next token is none of the suspected
types
CompileException
public boolean peekNextButOne( suspected) throws CompileException,
suspected
; consumes neither the next
nor the next-but-one token
CompileException
public void read( expected) throws CompileException,
expected
, and consumes the token.
CompileException
- The value of the next token does not equal expected
(this includes the case
that the scanner is at end-of-input)
public int read([] expected) throws CompileException,
expected
, and consumes the token.
expected
CompileException
- The value of the next token does not equal any of the expected
(this includes
the case where the scanner is at end-of-input)
public boolean peekRead( suspected) throws CompileException,
suspected
; if so, it consumes the next token
CompileException
public int peekRead([] values) throws CompileException,
values
CompileException
public boolean peekEof() throws CompileException,
CompileException
public peekIdentifier() throws CompileException,
null
iff the next token is not an identifier, otherwise the value of the identifier token
CompileException
public boolean peekLiteral() throws CompileException,
CompileException
public readIdentifier() throws CompileException,
CompileException
- The next token is not an identifier
public readOperator() throws CompileException,
CompileException
- The next token is not an operator
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 CompileException compileException( message)
CompileException
.
|
janino.net | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |