org.owasp.orizon.mirage.c.parser
Class CParser

java.lang.Object
  extended by org.owasp.orizon.mirage.c.parser.CParser
All Implemented Interfaces:
CConstants

public class CParser
extends java.lang.Object
implements CConstants


Field Summary
 CLexer token_source
          Generated Lexer.
 
Fields inherited from interface org.owasp.orizon.mirage.c.parser.CConstants
ABSTRACTDECLARATOR, ADDITIVEEXPRESSION, ANDEXPRESSION, ARGUMENTEXPRESSIONLIST, ASSIGNMENTEXPRESSION, ASSIGNMENTOPERATOR, AUTO, BREAK, CASE, CASTEXPRESSION, CHAR, CHARACTER_LITERAL, COMPOUNDSTATEMENT, CONDITIONALEXPRESSION, CONST, CONSTANT, CONSTANTEXPRESSION, CONTINUE, DECIMAL_LITERAL, DECLARATION, DECLARATIONLIST, DECLARATIONSPECIFIERS, DECLARATOR, DEFAULT, DFLT, DIGIT, DIRECTABSTRACTDECLARATOR, DIRECTDECLARATOR, DO, DOUBLE, ELSE, ENUM, ENUMERATOR, ENUMERATORLIST, ENUMSPECIFIER, EOF, EQUALITYEXPRESSION, EXCLUSIVEOREXPRESSION, EXPONENT, EXPRESSION, EXPRESSIONSTATEMENT, EXTERN, EXTERNALDECLARATION, FLOAT, FLOATING_POINT_LITERAL, FOR, FUNCTIONDEFINITION, GOTO, HEX_LITERAL, IDENTIFIER, IDENTIFIERLIST, IF, INCLUSIVEOREXPRESSION, INITDECLARATOR, INITDECLARATORLIST, INITIALIZER, INITIALIZERLIST, INT, INTEGER_LITERAL, ITERATIONSTATEMENT, JUMPSTATEMENT, LABELEDSTATEMENT, LETTER, LOGICALANDEXPRESSION, LOGICALOREXPRESSION, LONG, MULTIPLICATIVEEXPRESSION, nodeNames, OCTAL_LITERAL, PARAMETERDECLARATION, PARAMETERLIST, PARAMETERTYPELIST, POINTER, POSTFIXEXPRESSION, PREPROCESSOR_OUTPUT, PRIMARYEXPRESSION, REGISTER, RELATIONALEXPRESSION, RETURN, SELECTIONSTATEMENT, SHIFTEXPRESSION, SHORT, SIGNED, SIZEOF, SPECIFIERQUALIFIERLIST, STATEMENT, STATEMENTLIST, STATIC, STORAGECLASSSPECIFIER, STRING_LITERAL, STRUCT, STRUCTDECLARATION, STRUCTDECLARATIONLIST, STRUCTDECLARATOR, STRUCTDECLARATORLIST, STRUCTORUNION, STRUCTORUNIONSPECIFIER, SWITCH, tokenImage, TRANSLATIONUNIT, TYPEDEF, TYPEDEFNAME, TYPENAME, TYPEQUALIFIER, TYPEQUALIFIERLIST, TYPESPECIFIER, UNARYEXPRESSION, UNARYOPERATOR, UNION, UNSIGNED, VOID, VOLATILE, WHILE
 
Constructor Summary
CParser(CLexer tm)
          Constructor with generated Token Manager.
CParser(java.io.Reader stream)
           
 
Method Summary
 void AbstractDeclarator()
           
 void AdditiveExpression()
           
 void ANDExpression()
           
 void ArgumentExpressionList()
           
 void AssignmentExpression()
           
 void AssignmentOperator()
           
 void CastExpression()
           
 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 ConstantExpression()
           
 void Declaration()
           
 void DeclarationList()
           
 void DeclarationSpecifiers()
           
 void Declarator()
           
 void DirectAbstractDeclarator()
           
 void DirectDeclarator()
           
 void disable_tracing()
          Disable tracing.
 void enable_tracing()
          Enable tracing.
 void Enumerator()
           
 void EnumeratorList()
           
 void EnumSpecifier()
           
 void EqualityExpression()
           
 void ExclusiveORExpression()
           
 void Expression()
           
 void ExpressionStatement()
           
 void ExternalDeclaration()
           
 void FunctionDefinition()
           
 ParseException generateParseException()
           
 boolean getBuildTree()
           
 Token getNextToken()
          Get the next Token.
 Token getToken(int index)
          Get the specific Token.
 void IdentifierList()
           
 void InclusiveORExpression()
           
 void InitDeclarator()
           
 void InitDeclaratorList()
           
 void Initializer()
           
 void InitializerList()
           
 void IterationStatement()
           
 void JumpStatement()
           
 void LabeledStatement()
           
 void LogicalANDExpression()
           
 void LogicalORExpression()
           
static void main(java.lang.String[] args)
           
 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 ParameterDeclaration()
           
 void ParameterList()
           
 void ParameterTypeList()
           
 Node peekNode()
          Returns the node currently on the top of the stack.
 void Pointer()
           
 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 PrimaryExpression()
           
 void pushNode(Node n)
          push a node onto the top of the node stack
 void RelationalExpression()
           
 Node rootNode()
          Returns the root node of the AST.
 void SelectionStatement()
           
 void setBuildTree(boolean buildTree)
           
 void setInputSource(java.lang.String inputSource)
           
 void ShiftExpression()
           
 void SpecifierQualifierList()
           
 void Statement()
           
 void StatementList()
           
 void StorageClassSpecifier()
           
 void StructDeclaration()
           
 void StructDeclarationList()
           
 void StructDeclarator()
           
 void StructDeclaratorList()
           
 void StructOrUnion()
           
 void StructOrUnionSpecifier()
           
 void TranslationUnit()
           
 void TypedefName()
           
 void TypeName()
           
 void TypeQualifier()
           
 void TypeQualifierList()
           
 void TypeSpecifier()
           
 void UnaryExpression()
           
 void UnaryOperator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public CLexer token_source
Generated Lexer.

Constructor Detail

CParser

public CParser(java.io.Reader stream)

CParser

public CParser(CLexer tm)
Constructor with generated Token Manager.

Method Detail

main

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

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.


TranslationUnit

public final void TranslationUnit()
                           throws ParseException
Throws:
ParseException

ExternalDeclaration

public final void ExternalDeclaration()
                               throws ParseException
Throws:
ParseException

FunctionDefinition

public final void FunctionDefinition()
                              throws ParseException
Throws:
ParseException

Declaration

public final void Declaration()
                       throws ParseException
Throws:
ParseException

DeclarationList

public final void DeclarationList()
                           throws ParseException
Throws:
ParseException

DeclarationSpecifiers

public final void DeclarationSpecifiers()
                                 throws ParseException
Throws:
ParseException

StorageClassSpecifier

public final void StorageClassSpecifier()
                                 throws ParseException
Throws:
ParseException

TypeSpecifier

public final void TypeSpecifier()
                         throws ParseException
Throws:
ParseException

TypeQualifier

public final void TypeQualifier()
                         throws ParseException
Throws:
ParseException

StructOrUnionSpecifier

public final void StructOrUnionSpecifier()
                                  throws ParseException
Throws:
ParseException

StructOrUnion

public final void StructOrUnion()
                         throws ParseException
Throws:
ParseException

StructDeclarationList

public final void StructDeclarationList()
                                 throws ParseException
Throws:
ParseException

InitDeclaratorList

public final void InitDeclaratorList()
                              throws ParseException
Throws:
ParseException

InitDeclarator

public final void InitDeclarator()
                          throws ParseException
Throws:
ParseException

StructDeclaration

public final void StructDeclaration()
                             throws ParseException
Throws:
ParseException

SpecifierQualifierList

public final void SpecifierQualifierList()
                                  throws ParseException
Throws:
ParseException

StructDeclaratorList

public final void StructDeclaratorList()
                                throws ParseException
Throws:
ParseException

StructDeclarator

public final void StructDeclarator()
                            throws ParseException
Throws:
ParseException

EnumSpecifier

public final void EnumSpecifier()
                         throws ParseException
Throws:
ParseException

EnumeratorList

public final void EnumeratorList()
                          throws ParseException
Throws:
ParseException

Enumerator

public final void Enumerator()
                      throws ParseException
Throws:
ParseException

Declarator

public final void Declarator()
                      throws ParseException
Throws:
ParseException

DirectDeclarator

public final void DirectDeclarator()
                            throws ParseException
Throws:
ParseException

Pointer

public final void Pointer()
                   throws ParseException
Throws:
ParseException

TypeQualifierList

public final void TypeQualifierList()
                             throws ParseException
Throws:
ParseException

ParameterTypeList

public final void ParameterTypeList()
                             throws ParseException
Throws:
ParseException

ParameterList

public final void ParameterList()
                         throws ParseException
Throws:
ParseException

ParameterDeclaration

public final void ParameterDeclaration()
                                throws ParseException
Throws:
ParseException

IdentifierList

public final void IdentifierList()
                          throws ParseException
Throws:
ParseException

Initializer

public final void Initializer()
                       throws ParseException
Throws:
ParseException

InitializerList

public final void InitializerList()
                           throws ParseException
Throws:
ParseException

TypeName

public final void TypeName()
                    throws ParseException
Throws:
ParseException

AbstractDeclarator

public final void AbstractDeclarator()
                              throws ParseException
Throws:
ParseException

DirectAbstractDeclarator

public final void DirectAbstractDeclarator()
                                    throws ParseException
Throws:
ParseException

TypedefName

public final void TypedefName()
                       throws ParseException
Throws:
ParseException

Statement

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

StatementList

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

Expression

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

ConstantExpression

public final void ConstantExpression()
                              throws ParseException
Throws:
ParseException

LogicalORExpression

public final void LogicalORExpression()
                               throws ParseException
Throws:
ParseException

LogicalANDExpression

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

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

UnaryOperator

public final void UnaryOperator()
                         throws ParseException
Throws:
ParseException

PostfixExpression

public final void PostfixExpression()
                             throws ParseException
Throws:
ParseException

PrimaryExpression

public final void PrimaryExpression()
                             throws ParseException
Throws:
ParseException

ArgumentExpressionList

public final void ArgumentExpressionList()
                                  throws ParseException
Throws:
ParseException

Constant

public final void Constant()
                    throws ParseException
Throws:
ParseException