org.owasp.orizon.mirage.java.parser
Class JavaParser

java.lang.Object
  extended by org.owasp.orizon.mirage.java.parser.JavaParser
All Implemented Interfaces:
JavaConstants

public class JavaParser
extends java.lang.Object
implements JavaConstants


Field Summary
 JavaLexer token_source
          Generated Lexer.
 
Fields inherited from interface org.owasp.orizon.mirage.java.parser.JavaConstants
_DEFAULT, ABSTRACT, ADDITIVEEXPRESSION, ALLOCATIONEXPRESSION, ANDASSIGN, ANDEXPRESSION, ANNOTATION, ANNOTATIONTYPEBODY, ANNOTATIONTYPEMEMBERDECLARATION, ARRAYDIMSANDINITS, ARRAYINITIALIZER, ASSERT, ASSERTSTATEMENT, ASSIGN, ASSIGNMENTEXPRESSION, BANG, BIT_AND, BIT_OR, BOOLEAN, BREAK, BREAKSTATEMENT, BYTE, CASE, CASTEXPRESSION, CASTLOOKAHEAD, CATCH, CATCHBLOCK, CHAR, CHARACTER_LITERAL, CLASS, CLASSORINTERFACEBODY, CLASSORINTERFACEBODYDECLARATION, CODEBLOCK, COLON, COMMA, COMPILATIONUNIT, CONDITIONALANDEXPRESSION, CONDITIONALOREXPRESSION, CONST, CONSTRUCTORDECLARATION, CONTINUE, CONTINUESTATEMENT, DECIMAL_EXPONENT, DECIMAL_FLOATING_POINT_LITERAL, DECIMAL_LITERAL, DECR, DEFAULT, DEFAULTVALUE, DO, DOSTATEMENT, DOT, DOUBLE, ELSE, EMPTYSTATEMENT, ENUM, ENUMBODY, ENUMCONSTANT, EOF, EQ, EQUALITYEXPRESSION, EXCLUSIVEOREXPRESSION, EXPLICITCONSTRUCTORINVOCATION, EXPRESSION, EXTENDS, EXTENDSLIST, FALSE, FIELDDECLARATION, FINAL, FINALLY, FINALLYBLOCK, FLOAT, FLOATING_POINT_LITERAL, FOR, FORINIT, FORMAL_COMMENT, FORMALPARAMETER, FORMALPARAMS, FORSTATEMENT, FORUPDATE, GE, GOTO, GT, HEX_LITERAL, HEXADECIMAL_EXPONENT, HEXADECIMAL_FLOATING_POINT_LITERAL, HOOK, IDENTIFIER, IF, IFSTATEMENT, IMPLEMENTS, IMPLEMENTSLIST, IMPORT, IMPORTDECLARATION, IN_FORMAL_COMMENT, IN_MULTI_LINE_COMMENT, IN_SINGLE_LINE_COMMENT, INCLUSIVEOREXPRESSION, INCR, INITIALIZER, INSTANCEOF, INSTANCEOFEXPRESSION, INT, INTEGER_LITERAL, INTEGERLITERAL, INTERFACE, INVOCATIONARGS, LABELEDSTATEMENT, LBRACE, LBRACKET, LE, LETTER, LOCALVARIABLEDECLARATION, LONG, LPAREN, LSHIFT, LSHIFTASSIGN, LT, MEMBERSELECTOR, MEMBERVALUE, MEMBERVALUEARRAYINITIALIZER, MEMBERVALUEPAIR, MEMBERVALUEPAIRS, METHODDECLARATION, MINUS, MINUSASSIGN, MULTI_LINE_COMMENT, MULTIPLICATIVEEXPRESSION, NAME, NATIVE, NE, NEW, nodeNames, NULL, OBJECTTYPE, OCTAL_LITERAL, ORASSIGN, PACKAGE, PACKAGEDECLARATION, PART_LETTER, PLUS, PLUSASSIGN, POSTFIXEXPRESSION, PREDECREMENTEXPRESSION, PREINCREMENTEXPRESSION, PRIMARYEXPRESSION, PRIMARYPREFIX, PRIMARYSUFFIX, PRIMITIVEARRAYTYPE, PRIVATE, PROTECTED, PUBLIC, RBRACE, RBRACKET, REFERENCETYPE, RELATIONALEXPRESSION, REM, REMASSIGN, RETURN, RETURNSTATEMENT, RETURNTYPE, RPAREN, RSIGNEDSHIFT, RSIGNEDSHIFTASSIGN, RUNSIGNEDSHIFT, RUNSIGNEDSHIFTASSIGN, SC_AND, SC_OR, SEMICOLON, SHIFTEXPRESSION, SHORT, SINGLE_LINE_COMMENT, SLASH, SLASHASSIGN, STAR, STARASSIGN, STATEMENTEXPRESSION, STATEMENTEXPRESSIONLIST, STATIC, STRICTFP, STRING_LITERAL, SUPER, SWITCH, SWITCHLABEL, SWITCHSTATEMENT, SYNCHRONIZED, SYNCHRONIZEDSTATEMENT, TERNARYEXPRESSION, THIS, THROW, THROWS, THROWSLIST, THROWSTATEMENT, TILDE, tokenImage, TRANSIENT, TRUE, TRY, TRYSTATEMENT, TYPE, TYPEARGUMENT, TYPEARGUMENTS, TYPEBOUND, TYPEDECLARATION, TYPEPARAMETER, TYPEPARAMETERLIST, UNARYEXPRESSION, UNARYEXPRESSIONNOTPLUSMINUS, VARIABLEDECLARATOR, VARIABLEDECLARATORID, VARIABLEINITIALIZER, VOID, VOLATILE, WHILE, WHILESTATEMENT, WHITESPACE, WILDCARDBOUNDS, XOR, XORASSIGN
 
Constructor Summary
JavaParser(JavaLexer tm)
          Constructor with generated Token Manager.
JavaParser(java.io.Reader stream)
           
 
Method Summary
 void AdditiveExpression()
           
 void AllocationExpression()
           
 void AndExpression()
           
 void Annotation()
           
 void AnnotationTypeBody()
           
 void AnnotationTypeDeclaration()
           
 void AnnotationTypeMemberDeclaration()
           
 InvocationArgs Arguments()
           
 void ArrayDimsAndInits()
           
 void ArrayInitializer()
           
 void AssertStatement()
           
 void AssignmentExpression()
           
 void AssignmentOperator()
           
 CodeBlock Block()
           
 void BlockStatement()
           
 void BreakStatement()
           
 void CastExpression()
           
 void CastLookahead()
           
 CatchBlock CatchBlock()
           
 void ClassDeclaration()
           
 ClassOrInterfaceBody ClassOrInterfaceBody(boolean isInterface)
           
 void ClassOrInterfaceBodyDeclaration(boolean isInterface)
           
 ObjectType ClassOrInterfaceType()
           
 void clearNodeScope()
           
 void closeNodeScope(Node n, boolean condition)
          A conditional node is constructed if its condition is true.
 void closeNodeScope(Node n, int num)
           
 CompilationUnit CompilationUnit()
           
 void ConditionalAndExpression()
           
 void ConditionalOrExpression()
           
 void ConstructorDeclaration()
           
 void ContinueStatement()
           
 void DefaultValue()
           
 void disable_tracing()
          Disable tracing.
 void DoStatement()
           
 void EmptyStatement()
           
 void enable_tracing()
          Enable tracing.
 void EnumBody()
           
 void EnumConstant()
           
 void EnumDeclaration()
           
 void EqualityExpression()
           
 void ExclusiveOrExpression()
           
 void ExplicitConstructorInvocation()
           
 Expression Expression()
           
 ExtendsList ExtendsList(boolean isInterface)
           
 void FieldDeclaration()
           
 FinallyBlock FinallyBlock()
           
 void ForInit()
           
 FormalParameter FormalParameter()
           
 FormalParams FormalParameters()
           
 void ForStatement()
           
 void ForUpdate()
           
 ParseException generateParseException()
           
 boolean getBuildTree()
           
 Token getNextToken()
          Get the next Token.
 Token getToken(int index)
          Get the specific Token.
 void IfStatement()
           
 ImplementsList ImplementsList(boolean isInterface)
           
 ImportDeclaration ImportDeclaration()
           
 void InclusiveOrExpression()
           
 void Initializer()
           
 void InstanceOfExpression()
           
 int IntegerLiteral()
           
 void InterfaceDeclaration()
           
 void LabeledStatement()
           
 void Literal()
           
 void LocalVariableDeclaration()
           
static void main(java.lang.String[] args)
           
 void MarkerAnnotation()
           
 void MemberSelector()
           
 void MemberValue()
           
 void MemberValueArrayInitializer()
           
 void MemberValuePair()
           
 void MemberValuePairs()
           
 void MethodDeclaration()
           
 void MethodDeclarator()
           
 void Modifiers()
           
 void MultiplicativeExpression()
           
 Name Name()
           
 int nodeArity()
          Returns the number of children on the stack in the current node scope.
 boolean nodeCreated()
          Determines whether the current node was actually closed and pushed.
 void NormalAnnotation()
           
 void openNodeScope(Node n)
           
 PackageDeclaration PackageDeclaration()
           
static void parseFile(java.io.File file, boolean dumpTree)
          A test harness for parsing Java files from the command line.
 Node peekNode()
          Returns the node currently on the top of the stack.
 void pokeNode(Node n)
          Puts the node on the top of the stack.
 void pokeNode(Node n, boolean clearNodeScope)
          Puts the node on the top of the stack.
 Node popNode()
          Returns the node on the top of the stack, and remove it from the stack.
 void PostfixExpression()
           
 void PreDecrementExpression()
           
 void PreIncrementExpression()
           
 Expression PrimaryExpression()
           
 void PrimaryPrefix()
           
 void PrimarySuffix()
           
 void PrimitiveArrayType()
           
 void PrimitiveType()
           
 void pushNode(Node n)
          push a node onto the top of the node stack
 void ReferenceType()
           
 void RelationalExpression()
           
 void ReturnStatement()
           
 ReturnType ReturnType()
           
 Node rootNode()
          Returns the root node of the AST.
 void setBuildTree(boolean buildTree)
           
 void setInputSource(java.lang.String inputSource)
           
 void ShiftExpression()
           
 void SingleMemberAnnotation()
           
 void Statement()
           
 void StatementExpression()
           
 void StatementExpressionList()
           
 void SwitchLabel()
           
 void SwitchStatement()
           
 void SynchronizedStatement()
           
 void TernaryExpression()
           
 ThrowsList ThrowsList()
           
 void ThrowStatement()
           
 TryStatement TryStatement()
           
 void Type()
           
 void TypeArgument()
           
 void TypeArguments()
           
 void TypeBound()
           
 TypeDeclaration TypeDeclaration()
           
 void TypeParameter()
           
 TypeParameterList TypeParameters()
           
 void UnaryExpression()
           
 void UnaryExpressionNotPlusMinus()
           
static void usage()
           
 void VariableDeclarator()
           
 void VariableDeclaratorId()
           
 void VariableInitializer()
           
 void WhileStatement()
           
 void WildcardBounds()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public JavaLexer token_source
Generated Lexer.

Constructor Detail

JavaParser

public JavaParser(java.io.Reader stream)

JavaParser

public JavaParser(JavaLexer tm)
Constructor with generated Token Manager.

Method Detail

parseFile

public static void parseFile(java.io.File file,
                             boolean dumpTree)
                      throws java.io.IOException,
                             ParseException
A test harness for parsing Java files from the command line.

Throws:
java.io.IOException
ParseException

main

public static void main(java.lang.String[] args)

usage

public static void usage()

nodeCreated

public boolean nodeCreated()
Determines whether the current node was actually closed and pushed. This should only be called in the final user action of a node scope.


rootNode

public Node rootNode()
Returns the root node of the AST. It only makes sense to call this after a successful parse.


pushNode

public void pushNode(Node n)
push a node onto the top of the node stack


popNode

public Node popNode()
Returns the node on the top of the stack, and remove it from the stack.


peekNode

public Node peekNode()
Returns the node currently on the top of the stack.


pokeNode

public void pokeNode(Node n)
Puts the node on the top of the stack. However, unlike pushNode() it replaces the node that is currently on the top of the stack. This is effectively equivalent to popNode() followed by pushNode(n)


pokeNode

public void pokeNode(Node n,
                     boolean clearNodeScope)
Puts the node on the top of the stack. If clearNodeScope is true, it removes all the nodes in the current node scope and pushes n onto the top. Otherwise, it simply replaces the node at the top of the stack with n.


nodeArity

public int nodeArity()
Returns the number of children on the stack in the current node scope.


clearNodeScope

public void clearNodeScope()

openNodeScope

public void openNodeScope(Node n)

closeNodeScope

public void closeNodeScope(Node n,
                           int num)

closeNodeScope

public void closeNodeScope(Node n,
                           boolean condition)
A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node was opened are made children of the conditional node, which is then pushed on to the stack. If the condition is false the node is not constructed and they are left on the stack.


getBuildTree

public boolean getBuildTree()

setBuildTree

public void setBuildTree(boolean buildTree)

setInputSource

public void setInputSource(java.lang.String inputSource)

getNextToken

public final Token getNextToken()
Get the next Token.


getToken

public final Token getToken(int index)
Get the specific Token.


generateParseException

public ParseException generateParseException()

enable_tracing

public final void enable_tracing()
Enable tracing.


disable_tracing

public final void disable_tracing()
Disable tracing.


CompilationUnit

public final CompilationUnit CompilationUnit()
                                      throws ParseException
Throws:
ParseException

PackageDeclaration

public final PackageDeclaration PackageDeclaration()
                                            throws ParseException
Throws:
ParseException

ImportDeclaration

public final ImportDeclaration ImportDeclaration()
                                          throws ParseException
Throws:
ParseException

Modifiers

public final void Modifiers()
                     throws ParseException
Throws:
ParseException

TypeDeclaration

public final TypeDeclaration TypeDeclaration()
                                      throws ParseException
Throws:
ParseException

ClassDeclaration

public final void ClassDeclaration()
                            throws ParseException
Throws:
ParseException

InterfaceDeclaration

public final void InterfaceDeclaration()
                                throws ParseException
Throws:
ParseException

ExtendsList

public final ExtendsList ExtendsList(boolean isInterface)
                              throws ParseException
Throws:
ParseException

ImplementsList

public final ImplementsList ImplementsList(boolean isInterface)
                                    throws ParseException
Throws:
ParseException

EnumDeclaration

public final void EnumDeclaration()
                           throws ParseException
Throws:
ParseException

EnumBody

public final void EnumBody()
                    throws ParseException
Throws:
ParseException

EnumConstant

public final void EnumConstant()
                        throws ParseException
Throws:
ParseException

TypeParameters

public final TypeParameterList TypeParameters()
                                       throws ParseException
Throws:
ParseException

TypeParameter

public final void TypeParameter()
                         throws ParseException
Throws:
ParseException

TypeBound

public final void TypeBound()
                     throws ParseException
Throws:
ParseException

ClassOrInterfaceBody

public final ClassOrInterfaceBody ClassOrInterfaceBody(boolean isInterface)
                                                throws ParseException
Throws:
ParseException

ClassOrInterfaceBodyDeclaration

public final void ClassOrInterfaceBodyDeclaration(boolean isInterface)
                                           throws ParseException
Throws:
ParseException

FieldDeclaration

public final void FieldDeclaration()
                            throws ParseException
Throws:
ParseException

VariableDeclarator

public final void VariableDeclarator()
                              throws ParseException
Throws:
ParseException

VariableDeclaratorId

public final void VariableDeclaratorId()
                                throws ParseException
Throws:
ParseException

VariableInitializer

public final void VariableInitializer()
                               throws ParseException
Throws:
ParseException

ArrayInitializer

public final void ArrayInitializer()
                            throws ParseException
Throws:
ParseException

MethodDeclaration

public final void MethodDeclaration()
                             throws ParseException
Throws:
ParseException

MethodDeclarator

public final void MethodDeclarator()
                            throws ParseException
Throws:
ParseException

FormalParameters

public final FormalParams FormalParameters()
                                    throws ParseException
Throws:
ParseException

FormalParameter

public final FormalParameter FormalParameter()
                                      throws ParseException
Throws:
ParseException

ConstructorDeclaration

public final void ConstructorDeclaration()
                                  throws ParseException
Throws:
ParseException

ExplicitConstructorInvocation

public final void ExplicitConstructorInvocation()
                                         throws ParseException
Throws:
ParseException

Initializer

public final void Initializer()
                       throws ParseException
Throws:
ParseException

Type

public final void Type()
                throws ParseException
Throws:
ParseException

ReferenceType

public final void ReferenceType()
                         throws ParseException
Throws:
ParseException

ClassOrInterfaceType

public final ObjectType ClassOrInterfaceType()
                                      throws ParseException
Throws:
ParseException

TypeArguments

public final void TypeArguments()
                         throws ParseException
Throws:
ParseException

TypeArgument

public final void TypeArgument()
                        throws ParseException
Throws:
ParseException

WildcardBounds

public final void WildcardBounds()
                          throws ParseException
Throws:
ParseException

PrimitiveType

public final void PrimitiveType()
                         throws ParseException
Throws:
ParseException

PrimitiveArrayType

public final void PrimitiveArrayType()
                              throws ParseException
Throws:
ParseException

ReturnType

public final ReturnType ReturnType()
                            throws ParseException
Throws:
ParseException

Name

public final Name Name()
                throws ParseException
Throws:
ParseException

ThrowsList

public final ThrowsList ThrowsList()
                            throws ParseException
Throws:
ParseException

Expression

public final Expression Expression()
                            throws ParseException
Throws:
ParseException

AssignmentExpression

public final void AssignmentExpression()
                                throws ParseException
Throws:
ParseException

AssignmentOperator

public final void AssignmentOperator()
                              throws ParseException
Throws:
ParseException

TernaryExpression

public final void TernaryExpression()
                             throws ParseException
Throws:
ParseException

ConditionalOrExpression

public final void ConditionalOrExpression()
                                   throws ParseException
Throws:
ParseException

ConditionalAndExpression

public final void ConditionalAndExpression()
                                    throws ParseException
Throws:
ParseException

InclusiveOrExpression

public final void InclusiveOrExpression()
                                 throws ParseException
Throws:
ParseException

ExclusiveOrExpression

public final void ExclusiveOrExpression()
                                 throws ParseException
Throws:
ParseException

AndExpression

public final void AndExpression()
                         throws ParseException
Throws:
ParseException

EqualityExpression

public final void EqualityExpression()
                              throws ParseException
Throws:
ParseException

InstanceOfExpression

public final void InstanceOfExpression()
                                throws ParseException
Throws:
ParseException

RelationalExpression

public final void RelationalExpression()
                                throws ParseException
Throws:
ParseException

ShiftExpression

public final void ShiftExpression()
                           throws ParseException
Throws:
ParseException

AdditiveExpression

public final void AdditiveExpression()
                              throws ParseException
Throws:
ParseException

MultiplicativeExpression

public final void MultiplicativeExpression()
                                    throws ParseException
Throws:
ParseException

UnaryExpression

public final void UnaryExpression()
                           throws ParseException
Throws:
ParseException

PreIncrementExpression

public final void PreIncrementExpression()
                                  throws ParseException
Throws:
ParseException

PreDecrementExpression

public final void PreDecrementExpression()
                                  throws ParseException
Throws:
ParseException

UnaryExpressionNotPlusMinus

public final void UnaryExpressionNotPlusMinus()
                                       throws ParseException
Throws:
ParseException

CastLookahead

public final void CastLookahead()
                         throws ParseException
Throws:
ParseException

PostfixExpression

public final void PostfixExpression()
                             throws ParseException
Throws:
ParseException

CastExpression

public final void CastExpression()
                          throws ParseException
Throws:
ParseException

PrimaryExpression

public final Expression PrimaryExpression()
                                   throws ParseException
Throws:
ParseException

MemberSelector

public final void MemberSelector()
                          throws ParseException
Throws:
ParseException

PrimaryPrefix

public final void PrimaryPrefix()
                         throws ParseException
Throws:
ParseException

PrimarySuffix

public final void PrimarySuffix()
                         throws ParseException
Throws:
ParseException

Literal

public final void Literal()
                   throws ParseException
Throws:
ParseException

IntegerLiteral

public final int IntegerLiteral()
                         throws ParseException
Throws:
ParseException

Arguments

public final InvocationArgs Arguments()
                               throws ParseException
Throws:
ParseException

AllocationExpression

public final void AllocationExpression()
                                throws ParseException
Throws:
ParseException

ArrayDimsAndInits

public final void ArrayDimsAndInits()
                             throws ParseException
Throws:
ParseException

Statement

public final void Statement()
                     throws ParseException
Throws:
ParseException

AssertStatement

public final void AssertStatement()
                           throws ParseException
Throws:
ParseException

LabeledStatement

public final void LabeledStatement()
                            throws ParseException
Throws:
ParseException

Block

public final CodeBlock Block()
                      throws ParseException
Throws:
ParseException

BlockStatement

public final void BlockStatement()
                          throws ParseException
Throws:
ParseException

LocalVariableDeclaration

public final void LocalVariableDeclaration()
                                    throws ParseException
Throws:
ParseException

EmptyStatement

public final void EmptyStatement()
                          throws ParseException
Throws:
ParseException

StatementExpression

public final void StatementExpression()
                               throws ParseException
Throws:
ParseException

SwitchStatement

public final void SwitchStatement()
                           throws ParseException
Throws:
ParseException

SwitchLabel

public final void SwitchLabel()
                       throws ParseException
Throws:
ParseException

IfStatement

public final void IfStatement()
                       throws ParseException
Throws:
ParseException

WhileStatement

public final void WhileStatement()
                          throws ParseException
Throws:
ParseException

DoStatement

public final void DoStatement()
                       throws ParseException
Throws:
ParseException

ForStatement

public final void ForStatement()
                        throws ParseException
Throws:
ParseException

ForInit

public final void ForInit()
                   throws ParseException
Throws:
ParseException

StatementExpressionList

public final void StatementExpressionList()
                                   throws ParseException
Throws:
ParseException

ForUpdate

public final void ForUpdate()
                     throws ParseException
Throws:
ParseException

BreakStatement

public final void BreakStatement()
                          throws ParseException
Throws:
ParseException

ContinueStatement

public final void ContinueStatement()
                             throws ParseException
Throws:
ParseException

ReturnStatement

public final void ReturnStatement()
                           throws ParseException
Throws:
ParseException

ThrowStatement

public final void ThrowStatement()
                          throws ParseException
Throws:
ParseException

SynchronizedStatement

public final void SynchronizedStatement()
                                 throws ParseException
Throws:
ParseException

TryStatement

public final TryStatement TryStatement()
                                throws ParseException
Throws:
ParseException

CatchBlock

public final CatchBlock CatchBlock()
                            throws ParseException
Throws:
ParseException

FinallyBlock

public final FinallyBlock FinallyBlock()
                                throws ParseException
Throws:
ParseException

Annotation

public final void Annotation()
                      throws ParseException
Throws:
ParseException

NormalAnnotation

public final void NormalAnnotation()
                            throws ParseException
Throws:
ParseException

MarkerAnnotation

public final void MarkerAnnotation()
                            throws ParseException
Throws:
ParseException

SingleMemberAnnotation

public final void SingleMemberAnnotation()
                                  throws ParseException
Throws:
ParseException

MemberValuePairs

public final void MemberValuePairs()
                            throws ParseException
Throws:
ParseException

MemberValuePair

public final void MemberValuePair()
                           throws ParseException
Throws:
ParseException

MemberValue

public final void MemberValue()
                       throws ParseException
Throws:
ParseException

MemberValueArrayInitializer

public final void MemberValueArrayInitializer()
                                       throws ParseException
Throws:
ParseException

AnnotationTypeDeclaration

public final void AnnotationTypeDeclaration()
                                     throws ParseException
Throws:
ParseException

AnnotationTypeBody

public final void AnnotationTypeBody()
                              throws ParseException
Throws:
ParseException

AnnotationTypeMemberDeclaration

public final void AnnotationTypeMemberDeclaration()
                                           throws ParseException
Throws:
ParseException

DefaultValue

public final void DefaultValue()
                        throws ParseException
Throws:
ParseException