| java.lang.Object org.codehaus.janino.Parser
Parser | public class Parser (Code) | | A parser for the JavaTM programming language.
|
Method Summary | |
public void | eatToken() | public Scanner | getScanner() | public Location | location() | public Java.Atom | parseAdditiveExpression() | public Java.Atom | parseAndExpression() | public Java.Rvalue[] | parseArgumentList() | public Java.Rvalue[] | parseArguments() | public Java.ArrayInitializer | parseArrayInitializer() | public Java.Atom | parseAssignmentExpression() | public Java.Block | parseBlock() | public Java.BlockStatement | parseBlockStatement()
BlockStatement := { Identifier ':' } (
( Modifiers Type | ModifiersOpt BasicType ) LocalVariableDeclarators ';' |
'class' ... | public List | parseBlockStatements() | int | parseBracketsOpt() | public Java.Statement | parseBreakStatement() | public void | parseClassBody(Java.ClassDeclaration classDeclaration) | public void | parseClassBodyDeclaration(Java.ClassDeclaration classDeclaration) | public Java.NamedClassDeclaration | parseClassDeclarationRest(String optionalDocComment, short modifiers, ClassDeclarationContext context) | public Java.CompilationUnit | parseCompilationUnit() | public Java.Atom | parseConditionalAndExpression() | public Java.Atom | parseConditionalExpression() | public Java.Atom | parseConditionalOrExpression() | public Java.ConstructorDeclarator | parseConstructorDeclarator(Java.ClassDeclaration declaringClass, String optionalDocComment, short modifiers) | public Java.Statement | parseContinueStatement() | public Java.Rvalue | parseDimExpr() | public Java.Rvalue[] | parseDimExprs() | public Java.Statement | parseDoStatement() | public Java.Statement | parseEmptyStatement() | public Java.Atom | parseEqualityExpression() | public Java.Atom | parseExclusiveOrExpression() | public Java.Atom | parseExpression() | public Java.Rvalue[] | parseExpressionList() | public Java.Statement | parseExpressionStatement() | public Java.VariableDeclarator[] | parseFieldDeclarationRest(String name) | public Java.Statement | parseForStatement() | public Java.FunctionDeclarator.FormalParameter | parseFormalParameter() | public Java.FunctionDeclarator.FormalParameter[] | parseFormalParameters(Java.Scope enclosingScope) | public Java.Statement | parseIfStatement() | public Java.CompilationUnit.ImportDeclaration | parseImportDeclaration() | public Java.CompilationUnit.ImportDeclaration | parseImportDeclarationBody() | public Java.Atom | parseInclusiveOrExpression() | public void | parseInterfaceBody(Java.InterfaceDeclaration interfaceDeclaration) | public Java.InterfaceDeclaration | parseInterfaceDeclarationRest(String optionalDocComment, short modifiers, InterfaceDeclarationContext context) | public Java.Statement | parseLabeledStatement() | public Java.Atom | parseLiteral() | public Java.VariableDeclarator[] | parseLocalVariableDeclarators() | public Java.Block | parseMethodBody() | public Java.MethodDeclarator | parseMethodDeclarationRest(Java.AbstractTypeDeclaration declaringType, String optionalDocComment, short modifiers, Java.Type type, String name) | public short | parseModifiersOpt() | public Java.Atom | parseMultiplicativeExpression() | public Java.PackageDeclaration | parsePackageDeclaration() | public Java.PackageMemberTypeDeclaration | parsePackageMemberTypeDeclaration() | public Java.Atom | parsePrimary() | public String[] | parseQualifiedIdentifier() | public Java.ReferenceType | parseReferenceType() | public Java.ReferenceType[] | parseReferenceTypeList() | public Java.Atom | parseRelationalExpression() | public Java.Statement | parseReturnStatement() | public Java.Atom | parseSelector(Java.Atom atom) | public Java.Atom | parseShiftExpression() | public Java.Statement | parseStatement()
Statement :=
LabeledStatement |
Block |
IfStatement |
ForStatement |
WhileStatement |
DoStatement |
TryStatement |
'switch' ... | public Java.Statement | parseSwitchStatement() | public Java.Statement | parseSynchronizedStatement() | public Java.Statement | parseThrowStatement() | public Java.Statement | parseTryStatement() | public Java.Type | parseType() | public Java.Atom | parseUnaryExpression() | public Java.VariableDeclarator | parseVariableDeclarator() | public Java.VariableDeclarator | parseVariableDeclaratorRest(String name)
VariableDeclaratorRest := { '[' ']' } [ '=' VariableInitializer ]
Used by field declarations and local variable declarations. | public Java.ArrayInitializerOrRvalue | parseVariableInitializer() | public Java.Statement | parseWhileStatement() | public boolean | peekIdentifier() | public boolean | peekKeyword() | public boolean | peekKeyword(String keyword) | public boolean | peekKeyword(String[] keywords) | public boolean | peekOperator(String operator) | public boolean | peekOperator(String[] operators) | public String | readIdentifier() | public void | readKeyword(String keyword) | public String | readOperator() | public void | readOperator(String operator) | public void | setWarningHandler(WarningHandler optionalWarningHandler) By default, warnings are discarded, but an application my install a
WarningHandler .
Notice that there is no Parser.setErrorHandler() method, but parse errors
always throw a
ParseException . | final protected void | throwParseException(String message) Convenience method for throwing a ParseException. |
parseAssignmentExpression | public Java.Atom parseAssignmentExpression() throws ParseException, Scanner.ScanException, IOException(Code) | |
AssignmentExpression :=
ConditionalExpression [ AssignmentOperator AssignmentExpression ]
AssignmentOperator :=
'=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' |
'>>=' | '>>>=' | '&=' | '^=' | '|='
|
parseBlockStatement | public Java.BlockStatement parseBlockStatement() throws ParseException, Scanner.ScanException, IOException(Code) | |
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.
|
parseClassBodyDeclaration | public void parseClassBodyDeclaration(Java.ClassDeclaration classDeclaration) throws ParseException, Scanner.ScanException, IOException(Code) | |
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 ';'
)
)
|
parseInterfaceBody | public void parseInterfaceBody(Java.InterfaceDeclaration interfaceDeclaration) throws ParseException, Scanner.ScanException, IOException(Code) | |
InterfaceBody := '{' {
';' |
ModifiersOpt (
'void' Identifier MethodDeclarationRest |
'class' ClassDeclarationRest |
'interface' InterfaceDeclarationRest |
Type Identifier (
MethodDeclarationRest |
FieldDeclarationRest
)
)
} '}'
|
parseModifiersOpt | public short parseModifiersOpt() throws ParseException, Scanner.ScanException, IOException(Code) | |
ModifiersOpt := { 'public' | 'protected' | 'private' | 'static' |
'abstract' | 'final' | 'native' | 'synchronized' |
'transient' | 'volatile' | 'strictfp'
|
parsePrimary | public Java.Atom parsePrimary() throws ParseException, Scanner.ScanException, IOException(Code) | |
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
|
parseRelationalExpression | public Java.Atom parseRelationalExpression() throws ParseException, Scanner.ScanException, IOException(Code) | |
RelationalExpression :=
ShiftExpression {
( ( '<' | '>' | '<=' | '>=' ) ShiftExpression ) |
( 'instanceof' ReferenceType )
}
|
parseSelector | public Java.Atom parseSelector(Java.Atom atom) throws ParseException, Scanner.ScanException, IOException(Code) | |
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
|
parseStatement | public Java.Statement parseStatement() throws ParseException, Scanner.ScanException, IOException(Code) | |
Statement :=
LabeledStatement |
Block |
IfStatement |
ForStatement |
WhileStatement |
DoStatement |
TryStatement |
'switch' ... |
'synchronized' ... |
ReturnStatement |
ThrowStatement |
BreakStatement |
ContinueStatement |
EmptyStatement |
ExpressionStatement
|
parseSwitchStatement | public Java.Statement parseSwitchStatement() throws ParseException, Scanner.ScanException, IOException(Code) | |
SwitchStatement :=
'switch' '(' Expression ')' '{' { SwitchLabels BlockStatements } '}'
SwitchLabels := SwitchLabels { SwitchLabels }
SwitchLabel := 'case' Expression ':' | 'default' ':'
|
parseTryStatement | public Java.Statement parseTryStatement() throws ParseException, Scanner.ScanException, IOException(Code) | |
TryStatement :=
'try' Block Catches [ Finally ] |
'try' Block Finally
Catches := CatchClause { CatchClause }
CatchClause := 'catch' '(' FormalParameter ')' Block
Finally := 'finally' Block
|
parseUnaryExpression | public Java.Atom parseUnaryExpression() throws ParseException, Scanner.ScanException, IOException(Code) | |
UnaryExpression :=
{ PrefixOperator } Primary { Selector } { PostfixOperator }
PrefixOperator := '++' | '--' | '+' | '-' | '~' | '!'
PostfixOperator := '++' | '--'
|
peekIdentifier | public boolean peekIdentifier()(Code) | | |
peekKeyword | public boolean peekKeyword()(Code) | | |
peekKeyword | public boolean peekKeyword(String[] keywords)(Code) | | |
peekOperator | public boolean peekOperator(String operator)(Code) | | |
peekOperator | public boolean peekOperator(String[] operators)(Code) | | |
setWarningHandler | public void setWarningHandler(WarningHandler optionalWarningHandler)(Code) | | By default, warnings are discarded, but an application my install a
WarningHandler .
Notice that there is no Parser.setErrorHandler() method, but parse errors
always throw a
ParseException . 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.
Parameters: optionalWarningHandler - null to indicate that no warnings be issued |
throwParseException | final protected void throwParseException(String message) throws ParseException(Code) | | Convenience method for throwing a ParseException.
|
|
|