org.owasp.orizon.mirage.php.parser
Class PhpParser

java.lang.Object
  extended by org.owasp.orizon.mirage.php.parser.PhpParser
All Implemented Interfaces:
PhpConstants

public class PhpParser
extends java.lang.Object
implements PhpConstants


Field Summary
 PhpLexer token_source
          Generated Lexer.
 
Fields inherited from interface org.owasp.orizon.mirage.php.parser.PhpConstants
ABSTRACT, ADDITIVEEXPRESSION, AND, ARGUMENTEXPRESSIONLIST, ARRAY, ARRAYLITERAL, AS, ASSIGNMENTEXPRESSION, ASSIGNMENTOPERATOR, BITWISEANDEXPRESSION, BITWISEOREXPRESSION, BITWISEXOREXPRESSION, BREAK, CASE, CASTEXPRESSION, CATCH, CLASS, CLASSDECLARATION, CLASSINSTANTIATION, CLASSMEMBERS, CLONE, COMPOUNDSTATEMENT, CONDITIONALEXPRESSION, CONST, CONSTANT, CONTINUE, DECIMAL_LITERAL, DEFAULT, DEFINE, DEFINESTATEMENT, DFLT, DIGIT, DIGIT1, DO, DOLLAR, DOLLAR1, DOUBLE_STRING_LITERAL, DOUBLE_STRING_LITERAL_END, DOUBLE_STRING_LITERAL_START, DOUBLESTRINGLITERAL, DSL_COMPLEX_VAR, DSL_COMPLEX_VAR_END, DSL_COMPLEX_VAR_START, DSL_CV_TEXT, DSL_SIMPLE_STRING_VAR_END, DSL_SIMPLE_VAR, DSL_SIMPLE_VAR_END, DSL_SIMPLE_VAR_START, DSL_SIMPLE_VAR_WASNT, DSL_SPECIAL, ECHO, ECHOSTATEMENT, ELSE, ELSEIF, EMBEDDEDHTML, ENDOFSTATEMENT, EOF, EQUALITYEXPRESSION, EXPONENT, EXPRESSION, EXPRESSIONSTATEMENT, EXTENDS, FINAL, FLOATING_POINT_LITERAL, FOR, FOREACH, FUNCTION, GLOBAL, HD1, HD2, HEREDOC, HEREDOC_START, HEREDOC1, HEREDOC2, HEX_LITERAL, HTML, HTML_OTHER, HTML_STATE, HTMLBLOCK, IDENTIFIER, IF, IMPLEMENTS, INCLUDE_FULL, INCLUDE_ONCE, INCLUDESTATEMENT, INCLUDESTATEMENTEX, INSTANCEOF, INSTANCEOFEXPRESSION, INTEGER_LITERAL, INTERFACE, INTERFACEDECLARATION, INTERFACEMEMBER, INTERFACEMEMBERS, ITERATIONSTATEMENT, JUMPSTATEMENT, LABELEDSTATEMENT, LETTER, LETTER1, LOGICAL_AND_EXPRESSION, LOGICAL_OR_EXPRESSION, LOGICALTEXTANDEXPRESSION, LOGICALTEXTOREXPRESSION, LOGICALTEXTXOREXPRESSION, MEMBERDECLARATION, MULTIPLICATIVEEXPRESSION, NEW, nodeNames, NOT, NUMERAL_COMMENT, OCTAL_LITERAL, OR, PARAMETER, PARAMETERLIST, PHP_BEGIN, PHP_END, PHP_EXPR, PHPPAGE, POSTFIXEXPRESSION, POSTFIXINCDECEXPRESSION, PREDEFINED_CONSTANT, PREFIXINCDECEXPRESSION, PRIMARYEXPRESSION, PRINT, PRIVATE, PROTECTED, PUBLIC, RELATIONALEXPRESSION, REQUIRE, REQUIRE_ONCE, RETURN, RETURNSTATEMENT, SELECTIONSTATEMENT, SEMICOLON, SHIFTEXPRESSION, SINGLE_STRING_LITERAL, SINGLE_STRING_LITERAL_END, SINGLE_STRING_LITERAL_START, SLASH_SLASH_COMMENT, SLASH_STAR_COMMENT, SSL_SPECIAL, STATEMENT, STATIC, STRINGLITERAL, SWITCH, TEXT, THROW, THROWSTATEMENT, tokenImage, TRY, TRYBLOCK, UNARYEXPRESSION, VAR, VAR_NAME, VAR_NAME_STATE, VARIABLE, VARTYPE, VISIBILITY, WHILE, XOR
 
Constructor Summary
PhpParser(PhpLexer tm)
          Constructor with generated Token Manager.
PhpParser(java.io.Reader stream)
           
 
Method Summary
 void AdditiveExpression()
           
 void ArgumentExpressionList()
           
 void ArrayLiteral()
           
 void AssignmentExpression()
           
 void AssignmentOperator()
           
 void BitwiseAndExpression()
           
 void BitwiseOrExpression()
           
 void BitwiseXorExpression()
           
 void CastExpression()
           
 void ClassDeclaration()
           
 void ClassInstantiation()
           
 void ClassMembers()
           
 void clearNodeScope()
           
 void closeNodeScope(Node n, boolean condition)
          A conditional node is constructed if its condition is true.
 void closeNodeScope(Node n, int num)
           
 void CompoundStatement()
           
 void ConditionalExpression()
           
 void Constant()
           
 void DefineStatement()
           
 void disable_tracing()
          Disable tracing.
 void DoubleStringLiteral()
           
 void EchoStatement()
           
 void EmbeddedHtml()
           
 void enable_tracing()
          Enable tracing.
 void EndOfStatement()
           
 void EqualityExpression()
           
 void Expression()
           
 void ExpressionStatement()
           
 ParseException generateParseException()
           
 boolean getBuildTree()
           
 Token getNextToken()
          Get the next Token.
 Token getToken(int index)
          Get the specific Token.
 void HtmlBlock()
           
 void IncludeStatement()
           
 void IncludeStatementEx()
           
 void InstanceOfExpression()
           
 void InterfaceDeclaration()
           
 void InterfaceMember()
           
 void InterfaceMembers()
           
 void IterationStatement()
           
 void JumpStatement()
           
 void LabeledStatement()
           
 void Logical_And_Expression()
           
 void Logical_Or_Expression()
           
 void LogicalTextAndExpression()
           
 void LogicalTextOrExpression()
           
 void LogicalTextXorExpression()
           
 void MemberDeclaration()
           
 void MultiplicativeExpression()
           
 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 openNodeScope(Node n)
           
 void Parameter()
           
 void ParameterList()
           
 Node peekNode()
          Returns the node currently on the top of the stack.
 void PhpPage()
           
 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 PostfixIncDecExpression()
           
 void PrefixIncDecExpression()
           
 void PrimaryExpression()
           
 void pushNode(Node n)
          push a node onto the top of the node stack
 void RelationalExpression()
           
 void ReturnStatement()
           
 Node rootNode()
          Returns the root node of the AST.
 void SelectionStatement()
           
 void setBuildTree(boolean buildTree)
           
 void setInputSource(java.lang.String inputSource)
           
 void ShiftExpression()
           
 void Statement()
           
 void StringLiteral()
           
 void ThrowStatement()
           
 void TryBlock()
           
 void UnaryExpression()
           
 void Variable()
           
 void Visibility()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public PhpLexer token_source
Generated Lexer.

Constructor Detail

PhpParser

public PhpParser(java.io.Reader stream)

PhpParser

public PhpParser(PhpLexer tm)
Constructor with generated Token Manager.

Method Detail

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.


PhpPage

public final void PhpPage()
                   throws ParseException
Throws:
ParseException

HtmlBlock

public final void HtmlBlock()
                     throws ParseException
Throws:
ParseException

Statement

public final void Statement()
                     throws ParseException
Throws:
ParseException

ThrowStatement

public final void ThrowStatement()
                          throws ParseException
Throws:
ParseException

TryBlock

public final void TryBlock()
                    throws ParseException
Throws:
ParseException

EndOfStatement

public final void EndOfStatement()
                          throws ParseException
Throws:
ParseException

EmbeddedHtml

public final void EmbeddedHtml()
                        throws ParseException
Throws:
ParseException

DefineStatement

public final void DefineStatement()
                           throws ParseException
Throws:
ParseException

LabeledStatement

public final void LabeledStatement()
                            throws ParseException
Throws:
ParseException

ExpressionStatement

public final void ExpressionStatement()
                               throws ParseException
Throws:
ParseException

CompoundStatement

public final void CompoundStatement()
                             throws ParseException
Throws:
ParseException

SelectionStatement

public final void SelectionStatement()
                              throws ParseException
Throws:
ParseException

IterationStatement

public final void IterationStatement()
                              throws ParseException
Throws:
ParseException

JumpStatement

public final void JumpStatement()
                         throws ParseException
Throws:
ParseException

ParameterList

public final void ParameterList()
                         throws ParseException
Throws:
ParseException

Parameter

public final void Parameter()
                     throws ParseException
Throws:
ParseException

ClassDeclaration

public final void ClassDeclaration()
                            throws ParseException
Throws:
ParseException

ClassMembers

public final void ClassMembers()
                        throws ParseException
Throws:
ParseException

MemberDeclaration

public final void MemberDeclaration()
                             throws ParseException
Throws:
ParseException

InterfaceDeclaration

public final void InterfaceDeclaration()
                                throws ParseException
Throws:
ParseException

InterfaceMembers

public final void InterfaceMembers()
                            throws ParseException
Throws:
ParseException

InterfaceMember

public final void InterfaceMember()
                           throws ParseException
Throws:
ParseException

IncludeStatement

public final void IncludeStatement()
                            throws ParseException
Throws:
ParseException

IncludeStatementEx

public final void IncludeStatementEx()
                              throws ParseException
Throws:
ParseException

ReturnStatement

public final void ReturnStatement()
                           throws ParseException
Throws:
ParseException

EchoStatement

public final void EchoStatement()
                         throws ParseException
Throws:
ParseException

Expression

public final void Expression()
                      throws ParseException
Throws:
ParseException

LogicalTextOrExpression

public final void LogicalTextOrExpression()
                                   throws ParseException
Throws:
ParseException

LogicalTextXorExpression

public final void LogicalTextXorExpression()
                                    throws ParseException
Throws:
ParseException

LogicalTextAndExpression

public final void LogicalTextAndExpression()
                                    throws ParseException
Throws:
ParseException

AssignmentExpression

public final void AssignmentExpression()
                                throws ParseException
Throws:
ParseException

AssignmentOperator

public final void AssignmentOperator()
                              throws ParseException
Throws:
ParseException

ConditionalExpression

public final void ConditionalExpression()
                                 throws ParseException
Throws:
ParseException

Logical_Or_Expression

public final void Logical_Or_Expression()
                                 throws ParseException
Throws:
ParseException

Logical_And_Expression

public final void Logical_And_Expression()
                                  throws ParseException
Throws:
ParseException

BitwiseOrExpression

public final void BitwiseOrExpression()
                               throws ParseException
Throws:
ParseException

BitwiseXorExpression

public final void BitwiseXorExpression()
                                throws ParseException
Throws:
ParseException

BitwiseAndExpression

public final void BitwiseAndExpression()
                                throws ParseException
Throws:
ParseException

EqualityExpression

public final void EqualityExpression()
                              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

CastExpression

public final void CastExpression()
                          throws ParseException
Throws:
ParseException

UnaryExpression

public final void UnaryExpression()
                           throws ParseException
Throws:
ParseException

PrefixIncDecExpression

public final void PrefixIncDecExpression()
                                  throws ParseException
Throws:
ParseException

PostfixIncDecExpression

public final void PostfixIncDecExpression()
                                   throws ParseException
Throws:
ParseException

InstanceOfExpression

public final void InstanceOfExpression()
                                throws ParseException
Throws:
ParseException

PostfixExpression

public final void PostfixExpression()
                             throws ParseException
Throws:
ParseException

PrimaryExpression

public final void PrimaryExpression()
                             throws ParseException
Throws:
ParseException

ArrayLiteral

public final void ArrayLiteral()
                        throws ParseException
Throws:
ParseException

ClassInstantiation

public final void ClassInstantiation()
                              throws ParseException
Throws:
ParseException

Variable

public final void Variable()
                    throws ParseException
Throws:
ParseException

ArgumentExpressionList

public final void ArgumentExpressionList()
                                  throws ParseException
Throws:
ParseException

Constant

public final void Constant()
                    throws ParseException
Throws:
ParseException

StringLiteral

public final void StringLiteral()
                         throws ParseException
Throws:
ParseException

DoubleStringLiteral

public final void DoubleStringLiteral()
                               throws ParseException
Throws:
ParseException

Visibility

public final void Visibility()
                      throws ParseException
Throws:
ParseException