Data Structures | Enumerations | Functions

parser.h File Reference

Structures and functions for parsing tokens into a parse tree. More...

Data Structures

struct  AssignmentStmtNode
 Stores an assignment statement. More...
struct  BlockNode
 Stores a a block of code. More...
struct  BlockNodeList
 Stores a list of blocks of code. More...
struct  CastExprNode
 Stores a cast expression. More...
struct  CastStmtNode
 Stores a cast statement. More...
union  ConstantData
 Stores the data associated with a ConstantNode structure. More...
struct  ConstantNode
 Stores a constant value. More...
struct  DeclarationStmtNode
 Stores a declaration statement. More...
struct  ExprNode
 Stores an expression. More...
struct  ExprNodeList
 Stores a list of expressions. More...
struct  FuncCallExprNode
 Stores a function call expression. More...
struct  FuncDefStmtNode
 Stores a function definition statement. More...
struct  FunctionTable
 Stores the contents of the function table. More...
struct  IdentifierNode
 Stores an identifier. More...
struct  IdentifierNodeList
 Stores a list of identifiers. More...
struct  IfThenElseStmtNode
 Stores an if/then/else statement. More...
struct  InputStmtNode
 Stores an input statement. More...
struct  LoopStmtNode
 Stores a loop statement. More...
struct  MainNode
 Stores the main block of code a program executes. More...
struct  OpExprNode
 Stores an operation expression. More...
struct  PrintStmtNode
 Stores a print statement. More...
struct  ReturnStmtNode
 Stores a return statement. More...
struct  StmtNode
 Stores a statement. More...
struct  StmtNodeList
 Stores a list of statements. More...
struct  SwitchStmtNode
 Stores a switch statement. More...
struct  TypeNode
 Stores a variable type. More...

Enumerations

enum  ConstantType {
  CT_INTEGER, CT_FLOAT, CT_BOOLEAN, CT_STRING,
  CT_NIL
}
 

Denotes the type of a constant.

More...
enum  ExprType {
  ET_CAST, ET_CONSTANT, ET_IDENTIFIER, ET_FUNCCALL,
  ET_OP, ET_IMPVAR
}
 

Denotes the type of expression an ExprNode stores.

More...
enum  OpType {
  OP_ADD, OP_SUB, OP_MULT, OP_DIV,
  OP_MOD, OP_MAX, OP_MIN, OP_AND,
  OP_OR, OP_XOR, OP_NOT, OP_EQ,
  OP_NEQ, OP_CAT
}
 

Denotes the type of operation an OpExprNode performs.

More...
enum  StmtType {
  ST_CAST, ST_PRINT, ST_INPUT, ST_ASSIGNMENT,
  ST_DECLARATION, ST_IFTHENELSE, ST_SWITCH, ST_BREAK,
  ST_RETURN, ST_LOOP, ST_FUNCDEF, ST_EXPR
}
 

Denotes the type of statement a StmtNode stores.

More...

Functions

int acceptToken (Token ***, TokenType)
 Checks if the token pointed to by tokenp matches token and if it does, advances the token pointer to the next token in the array.
BlockNodeaddBlockNode (BlockNodeList *, BlockNode *)
 Adds a BlockNode structure to a BlockNodeList structure.
ExprNodeaddExprNode (ExprNodeList *, ExprNode *)
 Adds an ExprNode structure to an ExprNodeList structure.
FuncDefStmtNodeaddFuncDefStmtNode (FunctionTable *, FuncDefStmtNode *)
 Adds a FuncDefStmtNode to a FunctionTable structure.
IdentifierNodeaddIdentifierNode (IdentifierNodeList *, IdentifierNode *)
 Adds an IdentifierNode structure to an IdentifierNodeList structure.
StmtNodeaddStmtNode (StmtNodeList *, StmtNode *)
 Adds a StmtNode to a StmtNodeList structure.
AssignmentStmtNodecreateAssignmentStmtNode (IdentifierNode *, ExprNode *)
 Creates an AssignmentStmtNode structure.
BlockNodecreateBlockNode (StmtNodeList *)
 Creates a BlockNode structure.
BlockNodeListcreateBlockNodeList (void)
 Creates a BlockNodeList structure.
ConstantNodecreateBooleanConstantNode (int)
 Creates a boolean type ConstantNode structure.
CastExprNodecreateCastExprNode (ExprNode *, TypeNode *)
 Creates a CastExprNode structure.
CastStmtNodecreateCastStmtNode (IdentifierNode *, TypeNode *)
 Creates a CastStmtNode structure.
DeclarationStmtNodecreateDeclarationStmtNode (IdentifierNode *, IdentifierNode *, ExprNode *)
 Creates a DeclarationStmtNode structure.
ExprNodecreateExprNode (ExprType, void *)
 Creates an ExprNode structure.
ExprNodeListcreateExprNodeList (void)
 Creates an ExprNodeList structure.
ConstantNodecreateFloatConstantNode (float)
 Creates a floating point decimal type ConstantNode structure.
FuncCallExprNodecreateFuncCallExprNode (FuncDefStmtNode *, ExprNodeList *)
 Creates a FuncCallExprNode structure.
FuncDefStmtNodecreateFuncDefStmtNode (IdentifierNode *, IdentifierNode *, IdentifierNodeList *, BlockNode *)
 Creates a FuncDefStmtNode structure.
FunctionTablecreateFunctionTable (void)
 Creates a FunctionTable structure.
IdentifierNodecreateIdentifierNode (char *, const char *, unsigned int)
 Creates an IdentifierNode structure.
IdentifierNodeListcreateIdentifierNodeList (void)
 Creates an IdentifierNodeList structure.
IfThenElseStmtNodecreateIfThenElseStmtNode (BlockNode *, BlockNode *, ExprNodeList *, BlockNodeList *)
 Creates an IfThenElseStmtNode structure.
InputStmtNodecreateInputStmtNode (IdentifierNode *)
 Creates an InputStmtNode structure.
ConstantNodecreateIntegerConstantNode (int)
 Creates an integer type ConstantNode structure.
LoopStmtNodecreateLoopStmtNode (IdentifierNode *, IdentifierNode *, ExprNode *, ExprNode *, BlockNode *)
 Creates a LoopStmtNode structure.
MainNodecreateMainNode (BlockNode *, FunctionTable *)
 Creates a MainNode structure.
OpExprNodecreateOpExprNode (OpType, ExprNodeList *)
 Creates an OpExprNode structure.
PrintStmtNodecreatePrintStmtNode (ExprNodeList *, int)
 Creates a PrintStmtNode structure.
ReturnStmtNodecreateReturnStmtNode (ExprNode *)
 Creates a ReturnStmtNode structure.
StmtNodecreateStmtNode (StmtType, void *)
 Creates a StmtNode structure.
StmtNodeListcreateStmtNodeList (void)
 Creates a StmtNodeList structure.
ConstantNodecreateStringConstantNode (char *)
 Creates a string type ConstantNode structure.
SwitchStmtNodecreateSwitchStmtNode (ExprNodeList *, BlockNodeList *, BlockNode *)
 Creates a SwitchStmtNode structure.
TypeNodecreateTypeNode (ConstantType)
 Creates a TypeNode structure.
void deleteAssignmentStmtNode (AssignmentStmtNode *)
 Deletes an AssignmentStmtNode structure.
void deleteBlockNode (BlockNode *)
 Deletes a BlockNode structure.
void deleteBlockNodeList (BlockNodeList *)
 Deletes a BlockNodeList structure.
void deleteCastExprNode (CastExprNode *)
 Deletes a CastExprNode structure.
void deleteCastStmtNode (CastStmtNode *)
 Deletes a CastStmtNode structure.
void deleteConstantNode (ConstantNode *)
 Deletes a ConstantNode structure.
void deleteDeclarationStmtNode (DeclarationStmtNode *)
 Deletes a DeclarationStmtNode structure.
void deleteExprNode (ExprNode *)
 Deletes an ExprNode structure.
void deleteExprNodeList (ExprNodeList *)
 Deletes an ExprNodeList structure.
void deleteFuncCallExprNode (FuncCallExprNode *)
 Deletes a FuncCallExprNode structure.
void deleteFuncDefStmtNode (FuncDefStmtNode *)
 Deletes a FuncDefStmtNode structure.
void deleteFunctionTable (FunctionTable *)
 Deletes a FunctionTable structure.
void deleteIdentifierNode (IdentifierNode *)
 Deletes an IdentifierNode structure.
void deleteIdentifierNodeList (IdentifierNodeList *)
 Deletes an IdentifierNodeList structure.
void deleteIfThenElseStmtNode (IfThenElseStmtNode *)
 Deletes a IfThenElseStmtNode structure.
void deleteInputStmtNode (InputStmtNode *)
 Deletes an InputStmtNode structure.
void deleteLoopStmtNode (LoopStmtNode *)
 Deletes a LoopStmtNode structure.
void deleteMainNode (MainNode *)
 Deletes a MainNode structure.
void deleteOpExprNode (OpExprNode *)
 Deletes an OpExprNode structure.
void deletePrintStmtNode (PrintStmtNode *)
 Deletes a PrintStmtNode structure.
void deleteReturnStmtNode (ReturnStmtNode *)
 Deletes a ReturnStmtNode structure.
void deleteStmtNode (StmtNode *)
 Deletes a StmtNode structure.
void deleteStmtNodeList (StmtNodeList *)
 Deletes a StmtNodeList structure.
void deleteSwitchStmtNode (SwitchStmtNode *)
 Deletes a SwitchStmtNode structure.
void deleteTypeNode (TypeNode *)
 Deletes a TypeNode structure.
void error (const char *, Token **)
 Prints an error message of the form "LINE: INFO before: NEXT.\n", where LINE is the line the next token appears on, INFO is info and NEXT is the image of the next token.
FuncDefStmtNodelookupFuncDefStmtNode (FunctionTable *, const char *)
 Looks up a function definition by its name.
int nextToken (Token ***, TokenType)
 Checks if the token after the one pointed to by tokenp matches token.
BlockNodeparseBlockNode (Token ***, FunctionTable *)
 Parses a set of tokens into a BlockNode structure.
ConstantNodeparseConstantNode (Token ***)
 Parses a set of tokens into a ConstantNode structure.
ExprNodeparseExprNode (Token ***, FunctionTable *)
 Parses a set of tokens into an ExprNode structure.
IdentifierNodeparseIdentifierNode (Token ***)
 Parses a set of tokens into an IdentifierNode structure.
MainNodeparseMainNode (Token **, FunctionTable *)
 Parses tokens into a MainNode structure, an intermediary form to be passed along to a later stage of processing such as, for example, an interpreter.
StmtNodeparseStmtNode (Token ***, FunctionTable *)
 Parses a set of tokens into a StmtNode structure.
TypeNodeparseTypeNode (Token ***)
 Parses a set of tokens into a TypeNode structure.
int peekToken (Token ***, TokenType)
 Checks if the token pointed to by tokenp matches token.
FunctionTablesetupFunctionTable (Token **)
 Sets up a FunctionTable structure filled with the prototypes of all declared functions.

Detailed Description

Structures and functions for parsing tokens into a parse tree.

The parser reads through a series of tokens (generated by the tokenizer) and adds semantic meaning to them by forming them into a parse tree which can, in turn, be passed on to later processes (such as an interpreter).

Author:
Justin J. Meza
Date:
2010

Enumeration Type Documentation

Denotes the type of a constant.

Enumerator:
CT_INTEGER 

An integer value.

CT_FLOAT 

A floating point decimal value.

CT_BOOLEAN 

A true/false value.

CT_STRING 

A character string value.

CT_NIL 

Represents no value.

enum ExprType

Denotes the type of expression an ExprNode stores.

Enumerator:
ET_CAST 

A CastExprNode structure.

ET_CONSTANT 

A ConstantNode structure.

ET_IDENTIFIER 

An IdentifierNode structure.

ET_FUNCCALL 

A FuncCallExprNode structure.

ET_OP 

An OpExprNode structure.

ET_IMPVAR 

An implicit variable (no structure is needed for this type of expression).

enum OpType

Denotes the type of operation an OpExprNode performs.

Enumerator:
OP_ADD 

Addition.

OP_SUB 

Subtraction.

OP_MULT 

Multiplication.

OP_DIV 

Division.

OP_MOD 

Modulo.

OP_MAX 

Maximum.

OP_MIN 

Minimum.

OP_AND 

Logical AND.

OP_OR 

Logical OR.

OP_XOR 

Logical XOR.

OP_NOT 

Logical NOT.

OP_EQ 

Equality.

OP_NEQ 

Inequality.

OP_CAT 

String concatenation.

enum StmtType

Denotes the type of statement a StmtNode stores.

Enumerator:
ST_CAST 

A CastStmtNode structure.

ST_PRINT 

A PrintStmtNode structure.

ST_INPUT 

An InputStmtNode structure.

ST_ASSIGNMENT 

An AssignmentStmtNode structure.

ST_DECLARATION 

A DeclarationStmtNode structure.

ST_IFTHENELSE 

An IfThenElseStmtNode structure.

ST_SWITCH 

A SwitchStmtNode structure.

ST_BREAK 

A break statement (no structure is needed for this type of statement).

ST_RETURN 

A ReturnStmtNode structure.

ST_LOOP 

A LoopStmtNode structure.

ST_FUNCDEF 

A FuncDefStmtNode structure.

ST_EXPR 

An ExprNode structure.


Function Documentation

int acceptToken ( Token ***  tokenp,
TokenType  token 
)

Checks if the token pointed to by tokenp matches token and if it does, advances the token pointer to the next token in the array.

Note:
Unlike peekToken(Token ***, TokenType) and nextToken(Token ***, TokenType), this function does modify tokenp.
Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
If the token pointed to by tokenp does not match token, tokenp will point to the same token as when the function was called.
If the token pointed to by tokenp matches token, tokenp will point to the next token after the one matched.
Return values:
0 The token does not match token.
1 The token matches token.
See also:
peekToken(Token ***, TokenType)
nextToken(Token ***, TokenType)
Parameters:
[in,out] tokenp A pointer to the position of the next token to parse in an array of Token structures.
[in] token The type of token to match.
BlockNode* addBlockNode ( BlockNodeList list,
BlockNode node 
)

Adds a BlockNode structure to a BlockNodeList structure.

Precondition:
list was created by createBlockNodeList(void).
node was created by createBlockNode(StmtNodeList *).
Postcondition:
node will be added on to the end of list and the size of list will be updated accordingly.
Returns:
A pointer to the added BlockNode structure (will be the same as node).
Return values:
NULL realloc was unable to allocate memory.
Parameters:
[in,out] list A pointer to the BlockNodeList structure to add node to.
[in] node A pointer to the BlockNode structure to add to list.
ExprNode* addExprNode ( ExprNodeList list,
ExprNode node 
)

Adds an ExprNode structure to an ExprNodeList structure.

Precondition:
list was created by createExprNodeList(void).
node was created by createExprNode(ExprType, void *).
Postcondition:
node will be added on to the end of list and the size of list will be updated accordingly.
Returns:
A pointer to the added ExprNode structure (will be the same as node).
Return values:
NULL realloc was unable to allocate memory.
Parameters:
[in,out] list A pointer to the ExprNodeList structure to add node to.
[in] node A pointer to the ExprNode structure to add to list.
FuncDefStmtNode* addFuncDefStmtNode ( FunctionTable table,
FuncDefStmtNode node 
)

Adds a FuncDefStmtNode to a FunctionTable structure.

Precondition:
table was created by createFunctionTable(void).
node was created by createFuncDefStmtNode(IdentifierNode *, IdentifierNode *, IdentifierNodeList *, BlockNode *).
Postcondition:
node will be added on to the end of table and the size of table will be updated accordingly.
Returns:
A pointer to the added FuncDefStmtNode structure (will be the same as node).
Return values:
NULL realloc was unable to allocate memory.
See also:
lookupFuncDefStmtNode(FunctionTable *, const char *)
Parameters:
[in,out] table A pointer to the FunctionTable structure to add node to.
[in] node A pointer to the FuncDefStmtNode structure to add to table.
IdentifierNode* addIdentifierNode ( IdentifierNodeList list,
IdentifierNode node 
)

Adds an IdentifierNode structure to an IdentifierNodeList structure.

Precondition:
list was created by createIdentifierNodeList(void).
node was created by createIdentifierNode(char *, const char *, unsigned int).
Postcondition:
node will be added on to the end of list and the size of list will be updated accordingly.
Returns:
A pointer to the added IdentifierNode structure (will be the same as node).
Return values:
NULL realloc was unable to allocate memory.
Parameters:
[in,out] list A pointer to the IdentifierNodeList structure to add node to.
[in] node A pointer to the IdentifierNode structure to add to list.
StmtNode* addStmtNode ( StmtNodeList list,
StmtNode node 
)

Adds a StmtNode to a StmtNodeList structure.

Precondition:
list was created by createStmtNodeList(void).
node was created by createStmtNode(StmtType, void *).
Postcondition:
node will be added on to the end of list and the size of list will be updated accordingly.
Returns:
A pointer to the added StmtNode (will be the same as node).
Return values:
NULL malloc was unable to allocate memory.
Parameters:
[in,out] list A pointer to the StmtNodeList structure to add node to.
[in] node A pointer to the StmtNode structure to add to list.
AssignmentStmtNode* createAssignmentStmtNode ( IdentifierNode target,
ExprNode expr 
)

Creates an AssignmentStmtNode structure.

Precondition:
target was created by createIdentifierNode(char *, const char *, unsigned int).
expr was created by createExprNode(ExprType, void *).
Returns:
A pointer to an AssignmentStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteAssignmentStmtNode(AssignmentStmtNode *)
Parameters:
[in] target A pointer to the name of the variable to store the evaluated contents of a expr into.
[in] expr A pointer to the expression to evaluate and store in target.
BlockNode* createBlockNode ( StmtNodeList stmts  ) 

Creates a BlockNode structure.

Precondition:
stmts was created by createStmtNodeList(void) and contains contents added by addStmtNode(StmtNodeList *, StmtNode *).
Returns:
A pointer to a BlockNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteBlockNode(BlockNode *)
Parameters:
[in] stmts A pointer to the list of statements which comprise the block of code.
BlockNodeList* createBlockNodeList ( void   ) 

Creates a BlockNodeList structure.

Returns:
A pointer to a BlockNodeList structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteBlockNodeList(BlockNodeList *)
ConstantNode* createBooleanConstantNode ( int  data  ) 

Creates a boolean type ConstantNode structure.

Returns:
A pointer to a boolean type ConstantNode structure with value 0 if data equals 0 and 1 otherwise.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteConstantNode(ConstantNode *)
Parameters:
[in] data The constant boolean data.
CastExprNode* createCastExprNode ( ExprNode target,
TypeNode newtype 
)

Creates a CastExprNode structure.

Precondition:
target was created by createExprNode(ExprType, void *).
newtype was created by createTypeNode(ConstantType).
Returns:
A pointer to a CastExprNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteCastExprNode(CastExprNode *)
Parameters:
[in] target A pointer to the expression to cast.
[in] newtype A pointer to the type to cast the copy of target to.
CastStmtNode* createCastStmtNode ( IdentifierNode target,
TypeNode newtype 
)

Creates a CastStmtNode structure.

Precondition:
target was created by createIdentifierNode(char *, const char *, unsigned int).
newtype was created by createTypeNode(ConstantType).
Returns:
A pointer to a CastStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteCastStmtNode(CastStmtNode *)
Parameters:
[in] target A pointer to the name of the variable whose type is to be changed to newtype.
[in] newtype A pointer to the type to change target to.
DeclarationStmtNode* createDeclarationStmtNode ( IdentifierNode scope,
IdentifierNode target,
ExprNode expr 
)

Creates a DeclarationStmtNode structure.

Precondition:
scope was created by createIdentifierNode(char *, const char *, unsigned int).
target was created by createIdentifierNode(char *, const char *, unsigned int).
expr was created by createExprNode(ExprType, void *).
Returns:
A pointer to a DeclarationStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteDeclarationStmtNode(DeclarationStmtNode *)
Parameters:
[in] scope A pointer to the scope to create the variable in.
[in] target A pointer to the name of the variable to create.
[in] expr An optional pointer to the expression to initialize target to.
ExprNode* createExprNode ( ExprType  type,
void *  expr 
)

Creates an ExprNode structure.

Precondition:
expr contains a structure created corresponding to type:
Returns:
A pointer to an ExprNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteExprNode(ExprNode *)
Parameters:
[in] type The type of expression stored in expr.
[in] expr A pointer to the particular expression structure.
ExprNodeList* createExprNodeList ( void   ) 

Creates an ExprNodeList structure.

Returns:
A pointer to an ExprNodeList structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteExprNodeList(ExprNodeList *)
ConstantNode* createFloatConstantNode ( float  data  ) 

Creates a floating point decimal type ConstantNode structure.

Returns:
A pointer to a floating point decimal type ConstantNode storing the desired value.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteConstantNode(ConstantNode *)
Parameters:
[in] data The constant floating point decimal data.
FuncCallExprNode* createFuncCallExprNode ( FuncDefStmtNode def,
ExprNodeList args 
)

Creates a FuncCallExprNode structure.

Precondition:
def was created by createFuncDefStmtNode(IdentifierNode *, IdentifierNode *, IdentifierNodeList *, BlockNode *).
args was created by createExprNodeList(void) and contains items added by addExprNode(ExprNodeList *, ExprNode *).
Returns:
A pointer to a FuncCallExprNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteFuncCallExprNode(FuncCallExprNode *)
Parameters:
[in] def A pointer to the function definition to call.
[in] args A pointer to an ExprNodeList structure of arguments to be supplied to the function defined by def.
FuncDefStmtNode* createFuncDefStmtNode ( IdentifierNode scope,
IdentifierNode name,
IdentifierNodeList args,
BlockNode body 
)

Creates a FuncDefStmtNode structure.

Precondition:
scope was created by createIdentifierNode(char *, const char *, unsigned int).
name was created by createIdentifierNode(char *, const char *, unsigned int).
args was created by createIdentifierNodeList(void) and contains items added by addIdentifierNode(IdentifierNodeList *, IdentifierNode *).
body was created by createBlockNode(StmtNodeList *).
Returns:
A pointer to a FuncDefStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteFuncDefStmtNode(FuncDefStmtNode *)
Parameters:
[in] scope A pointer to the scope to define the function in.
[in] name A pointer to the name of the function.
[in] args A pointer to an array of the names of the arguments of the function.
[in] body A pointer to the block of code defined by the function.
FunctionTable* createFunctionTable ( void   ) 

Creates a FunctionTable structure.

Returns:
A pointer to a FunctionTable structure with no elements.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteFunctionTable(FunctionTable *)
IdentifierNode* createIdentifierNode ( char *  image,
const char *  fname,
unsigned int  line 
)

Creates an IdentifierNode structure.

Note:
image is copied for use within the structure so it must be freed by the caller.
Returns:
A pointer to an IdentifierNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteIdentifierNode(IdentifierNode *)
Parameters:
[in] image An array of characters that name the identifier.
[in] fname A pointer to the name of the file containing the identifier.
[in] line The line number from the source file that the identifier occurred on.
IdentifierNodeList* createIdentifierNodeList ( void   ) 

Creates an IdentifierNodeList structure.

Returns:
A pointer to a IdentifierNodeList structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteIdentifierNodeList(IdentifierNodeList *)
IfThenElseStmtNode* createIfThenElseStmtNode ( BlockNode yes,
BlockNode no,
ExprNodeList guards,
BlockNodeList blocks 
)

Creates an IfThenElseStmtNode structure.

Precondition:
yes was created by createBlockNode(StmtNodeList *).
no was created by createBlockNode(StmtNodeList *).
guards was created by createExprNodeList(void) and contains items added by addExprNode(ExprNodeList *, ExprNode *).
blocks was created by createBlockNodeList(void) and contains items added by addBlockNode(BlockNodeList *, BlockNode *).
Returns:
A pointer to a IfThenElseStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteIfThenElseStmtNode(IfThenElseStmtNode *)
Parameters:
[in] yes A pointer to the block of code to execute if the implicit variable casts to false.
[in] no A pointer to the block of code to execute if the implicit variable casts to false and the evaluations of all of the guards cast to false.
[in] guards A pointer to the expressions to test if the implicit variable casts to false.
[in] blocks A pointer to the respective blocks of code to execute if one of the evaluated guards casts to true.
InputStmtNode* createInputStmtNode ( IdentifierNode target  ) 

Creates an InputStmtNode structure.

Precondition:
target was created by createIdentifierNode(char *, const char *, unsigned int).
Returns:
A pointer to an InputStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteInputStmtNode(InputStmtNode *)
Parameters:
[in] target A pointer to the name of the variable to store the input in.
ConstantNode* createIntegerConstantNode ( int  data  ) 

Creates an integer type ConstantNode structure.

Returns:
A pointer to an integer type ConstantNode storing the desired value.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteConstantNode(ConstantNode *)
Parameters:
[in] data The constant integer data.
LoopStmtNode* createLoopStmtNode ( IdentifierNode name,
IdentifierNode var,
ExprNode guard,
ExprNode update,
BlockNode body 
)

Creates a LoopStmtNode structure.

Precondition:
name was created by createIdentifierNode(char *, const char *, unsigned int).
var was created by createIdentifierNode(char *, const char *, unsigned int).
guard was created by createExprNode(ExprType, void *).
update was created by createExprNode(ExprType, void *).
body was created by createBlockNode(StmtNodeList *).
Returns:
A pointer to a LoopStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteLoopStmtNode(LoopStmtNode *)
Parameters:
[in] name A pointer to the name of the loop.
[in] var A pointer to the name of the variable to be updated by update.
[in] guard A pointer to the expression to determine if the loop will continue.
[in] update A pointer to the expression to evaluate to update var.
[in] body A pointer to the block of code to be executed with each iteration of the loop.
MainNode* createMainNode ( BlockNode block,
FunctionTable functab 
)

Creates a MainNode structure.

Precondition:
block was created by createBlockNode(StmtNodeList *).
functab was created by createFunctionTable(void) and contains items added by addFuncDefStmtNode(FunctionTable *, FuncDefStmtNode *).
Returns:
A pointer to a MainNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteMainNode(MainNode *)
Parameters:
[in] block A pointer to the block of code to execute first.
[in] functab A pointer to the function table associated with this block of code.
OpExprNode* createOpExprNode ( OpType  type,
ExprNodeList args 
)

Creates an OpExprNode structure.

Precondition:
args was created by createExprNodeList(void) and contains items added by addExprNode(ExprNodeList *, ExprNode *).
Returns:
A pointer to an OpExprNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteOpExprNode(OpExprNode *)
Parameters:
[in] type The type of operation to perform on args.
[in] args A pointer to the arguments to perform the operation on.
PrintStmtNode* createPrintStmtNode ( ExprNodeList args,
int  nonl 
)

Creates a PrintStmtNode structure.

Precondition:
args was created by createExprNodeList(void) and contains items added by addExprNode(ExprNodeList *, ExprNode *).
Returns:
A pointer to a PrintStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deletePrintStmtNode(PrintStmtNode *)
Parameters:
[in] args A pointer to the list of expressions to evaluate and print.
[in] nonl Denotes an ending newline should be surpressed if not 0 and printed if 0.
ReturnStmtNode* createReturnStmtNode ( ExprNode value  ) 

Creates a ReturnStmtNode structure.

Precondition:
value was created by createExprNode(ExprType, void *).
Returns:
A pointer to a ReturnStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteReturnStmtNode(ReturnStmtNode *)
Parameters:
[in] value A pointer to the value to return.
StmtNode* createStmtNode ( StmtType  type,
void *  stmt 
)

Creates a StmtNode structure.

Precondition:
stmt contains a structure created corresponding to type:
Returns:
A pointer to a StmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteStmtNode(StmtNode *)
Parameters:
[in] type The type of statement stored in node.
[in] stmt A pointer to the particular statement structure.
StmtNodeList* createStmtNodeList ( void   ) 

Creates a StmtNodeList structure.

Returns:
A pointer to a StmtNodeList structure with no elements.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteStmtNodeList(StmtNodeList *)
ConstantNode* createStringConstantNode ( char *  data  ) 

Creates a string type ConstantNode structure.

Returns:
A pointer to a string type ConstantNode storing the desired value.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteConstantNode(ConstantNode *)
Parameters:
[in] data The constant character string data.
SwitchStmtNode* createSwitchStmtNode ( ExprNodeList guards,
BlockNodeList blocks,
BlockNode def 
)

Creates a SwitchStmtNode structure.

Precondition:
guards was created by createExprNodeList(void) and contains items added by addExprNode(ExprNodeList *, ExprNode *).
blocks was created by createBlockNodeList(void) and contains items added by addBlockNode(BlockNodeList *, BlockNode *).
def was created by createBlockNode(StmtNodeList *).
Returns:
A pointer to a SwitchStmtNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteSwitchStmtNode(SwitchStmtNode *)
Parameters:
[in] guards A pointer to the expressions to evaluate and compare to the implicit variable.
[in] blocks A pointer to the respective blocks of code to execute if one of the guards matches the implicit variable.
[in] def A pointer to the default block of code to execute if none of the guards match the implicit variable.
TypeNode* createTypeNode ( ConstantType  type  ) 

Creates a TypeNode structure.

Returns:
A pointer to a TypeNode structure with the desired properties.
Return values:
NULL malloc was unable to allocate memory.
See also:
deleteTypeNode(TypeNode *)
Parameters:
[in] type The type of value.
void deleteAssignmentStmtNode ( AssignmentStmtNode node  ) 

Deletes an AssignmentStmtNode structure.

Precondition:
node was created by createAssignmentStmtNode(IdentifierNode *, ExprNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createAssignmentStmtNode(IdentifierNode *, ExprNode *)
Parameters:
[in,out] node A pointer to the AssignmentStmtNode structure to be deleted.
void deleteBlockNode ( BlockNode node  ) 

Deletes a BlockNode structure.

Precondition:
node was created by createBlockNode(StmtNodeList *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createBlockNode(StmtNodeList *)
Parameters:
[in,out] node A pointer to the BlockNode structure to be deleted.
void deleteBlockNodeList ( BlockNodeList list  ) 

Deletes a BlockNodeList structure.

Precondition:
list was created by createBlockNodeList(void) and contains items added by addBlockNode(BlockNodeList *, BlockNode *).
Postcondition:
The memory at list and any of its associated members will be freed.
See also:
createBlockNodeList(void)
Parameters:
[in,out] list A pointer to the BlockNodeList structure to delete.
void deleteCastExprNode ( CastExprNode node  ) 

Deletes a CastExprNode structure.

Precondition:
node was created by createCastExprNode(ExprNode *, TypeNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createCastExprNode(ExprNode *, TypeNode *)
Parameters:
[in,out] node A pointer to the CastExprNode structure to be deleted.
void deleteCastStmtNode ( CastStmtNode node  ) 

Deletes a CastStmtNode structure.

Precondition:
node was created by createCastStmtNode(IdentifierNode *, TypeNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createCastStmtNode(IdentifierNode *, TypeNode *)
Parameters:
[in,out] node A pointer to the CastStmtNode structure to be deleted.
void deleteConstantNode ( ConstantNode node  ) 

Deletes a ConstantNode structure.

Precondition:
node was created by either createBooleanConstantNode(int), createIntegerConstantNode(int), createFloatConstantNode(float), or createStringConstantNode(char *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createBooleanConstantNode(int)
createIntegerConstantNode(int)
createFloatConstantNode(float)
createStringConstantNode(char *)
Parameters:
[in,out] node A pointer to the ConstantNode structure to be deleted.
void deleteDeclarationStmtNode ( DeclarationStmtNode node  ) 

Deletes a DeclarationStmtNode structure.

Precondition:
node was created by createDeclarationStmtNode(IdentifierNode *, IdentifierNode *, ExprNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createDeclarationStmtNode(IdentifierNode *, IdentifierNode *, ExprNode *)
Parameters:
[in,out] node A pointer to the DeclarationStmtNode structure to be deleted.
void deleteExprNode ( ExprNode node  ) 

Deletes an ExprNode structure.

Precondition:
node was created by createExprNode(ExprType, void *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createExprNode(ExprType, void *)
Parameters:
[in,out] node A pointer to the ExprNode structure to be deleted.
void deleteExprNodeList ( ExprNodeList list  ) 

Deletes an ExprNodeList structure.

Precondition:
list was created by createExprNodeList(void) and contains items added by addExprNode(ExprNodeList *, ExprNode *).
Postcondition:
The memory at list and any of its associated members will be freed.
See also:
createExprNodeList(void)
Parameters:
[in,out] list A pointer to the ExprNodeList structure to delete.
void deleteFuncCallExprNode ( FuncCallExprNode node  ) 

Deletes a FuncCallExprNode structure.

Precondition:
node was created by createFuncCallExprNode(FuncDefStmtNode *, ExprNodeList *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createFuncCallExprNode(FuncDefStmtNode *, ExprNodeList *)
Parameters:
[in,out] node A pointer to the FuncCallExprNode structure to be deleted.
void deleteFuncDefStmtNode ( FuncDefStmtNode node  ) 

Deletes a FuncDefStmtNode structure.

Precondition:
node was created by createFuncDefStmtNode(IdentifierNode *, IdentifierNode *, IdentifierNodeList *, BlockNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createFuncDefStmtNode(IdentifierNode *, IdentifierNode *, IdentifierNodeList *, BlockNode *)
Parameters:
[in,out] node A pointer to the FuncDefStmtNode structure to be deleted.
void deleteFunctionTable ( FunctionTable table  ) 

Deletes a FunctionTable structure.

Precondition:
table was created by createFunctionTable(void).
Postcondition:
The memory of the function table and any of its associated members will be freed.
See also:
createFunctionTable(void)
Parameters:
[in,out] table A pointer to the FunctionTable structure to delete.
void deleteIdentifierNode ( IdentifierNode node  ) 

Deletes an IdentifierNode structure.

Precondition:
node was created by createIdentifierNode(char *, const char *, unsigned int).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createIdentifierNode(char *, const char *, unsigned int)
Parameters:
[in,out] node A pointer to the IdentifierNode structure to be deleted.
void deleteIdentifierNodeList ( IdentifierNodeList list  ) 

Deletes an IdentifierNodeList structure.

Precondition:
list was created by createIdentifierNodeList(void) and contains items added by addIdentifierNode(IdentifierNodeList *, IdentifierNode *).
Postcondition:
The memory at list and any of its associated members will be freed.
See also:
createIdentifierNodeList(void)
Parameters:
[in,out] list A pointer to the IdentifierNodeList structure to delete.
void deleteIfThenElseStmtNode ( IfThenElseStmtNode node  ) 

Deletes a IfThenElseStmtNode structure.

Precondition:
node was created by createIfThenElseStmtNode(BlockNode *, BlockNode *, ExprNodeList *, BlockNodeList *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createIfThenElseStmtNode(BlockNode *, BlockNode *, ExprNodeList *, BlockNodeList *)
Parameters:
[in,out] node A pointer to the IfThenElseStmtNode structure to be deleted.
void deleteInputStmtNode ( InputStmtNode node  ) 

Deletes an InputStmtNode structure.

Precondition:
node was created by createInputStmtNode(IdentifierNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createInputStmtNode(IdentifierNode *)
Parameters:
[in,out] node A pointer to the InputStmtNode structure to be deleted.
void deleteLoopStmtNode ( LoopStmtNode node  ) 

Deletes a LoopStmtNode structure.

Precondition:
node was created by createLoopStmtNode(IdentifierNode *, IdentifierNode *, ExprNode *, ExprNode *, BlockNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createLoopStmtNode(IdentifierNode *, IdentifierNode *, ExprNode *, ExprNode *, BlockNode *)
Parameters:
[in,out] node A pointer to the LoopStmtNode structure to be deleted.
void deleteMainNode ( MainNode node  ) 

Deletes a MainNode structure.

Precondition:
node was created by createMainNode(BlockNode *, FunctionTable *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createMainNode(BlockNode *, FunctionTable *)
Parameters:
[in,out] node A pointer to the MainNode structure to be deleted.
void deleteOpExprNode ( OpExprNode node  ) 

Deletes an OpExprNode structure.

Precondition:
node was created by createOpExprNode(OpType, ExprNodeList *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createOpExprNode(OpType, ExprNodeList *)
Parameters:
[in,out] node A pointer to the OpExprNode structure to be deleted.
void deletePrintStmtNode ( PrintStmtNode node  ) 

Deletes a PrintStmtNode structure.

Precondition:
node was created by createPrintStmtNode(ExprNodeList *, int).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createPrintStmtNode(ExprNodeList *, int)
Parameters:
[in,out] node A pointer to the PrintStmtNode structure to be deleted.
void deleteReturnStmtNode ( ReturnStmtNode node  ) 

Deletes a ReturnStmtNode structure.

Precondition:
node was created by createReturnStmtNode(ExprNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createReturnStmtNode(ExprNode *)
Parameters:
[in,out] node A pointer to the ReturnStmtNode structure to be deleted.
void deleteStmtNode ( StmtNode node  ) 

Deletes a StmtNode structure.

Precondition:
node was created by createStmtNode(StmtType, void *).
Postcondition:
The memory at stmt and any of its associated members will be freed.
See also:
createStmtNode(StmtType, void *)
Parameters:
[in,out] node A pointer to the StmtNode structure to be deleted.
void deleteStmtNodeList ( StmtNodeList list  ) 

Deletes a StmtNodeList structure.

Precondition:
list was created by createStmtNodeList(void) and contains items added by addStmtNode(StmtNodeList *, StmtNode *).
Postcondition:
The memory at list and any of its associated members will be freed.
See also:
createStmtNodeList(void)
Parameters:
[in,out] list A pointer to the StmtNodeList structure to delete.
void deleteSwitchStmtNode ( SwitchStmtNode node  ) 

Deletes a SwitchStmtNode structure.

Precondition:
node was created by createSwitchStmtNode(ExprNodeList *, BlockNodeList *, BlockNode *).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createSwitchStmtNode(ExprNodeList *, BlockNodeList *, BlockNode *)
Parameters:
[in,out] node A pointer to the SwitchStmtNode structure to be deleted.
void deleteTypeNode ( TypeNode node  ) 

Deletes a TypeNode structure.

Precondition:
node was created by createTypeNode(ConstantType).
Postcondition:
The memory at node and any of its associated members will be freed.
See also:
createTypeNode(ConstantType)
Parameters:
[in,out] node A pointer to the TypeNode structure to be deleted.
void error ( const char *  info,
Token **  tokens 
)

Prints an error message of the form "LINE: INFO before: NEXT.\n", where LINE is the line the next token appears on, INFO is info and NEXT is the image of the next token.

Precondition:
tokens was created by tokenizeLexemes(Lexeme **).
Parameters:
[in] info The array of characters to print.
[in] tokens A pointer to an array of tokens to parse.
FuncDefStmtNode* lookupFuncDefStmtNode ( FunctionTable table,
const char *  name 
)

Looks up a function definition by its name.

Precondition:
table was created by createFunctionTable(void) and contains items added by addFuncDefStmtNode(FunctionTable *, FuncDefStmtNode *).
Returns:
A pointer to the FuncDefStmtNode structure named name.
Return values:
NULL No such FuncDefStmtNode structure exists.
See also:
addFuncDefStmtNode(FunctionTable *, FuncDefStmtNode *)
Parameters:
[in] table A pointer to the FunctionTable structure to search for name.
[in] name The name of the function to look up.
int nextToken ( Token ***  tokenp,
TokenType  token 
)

Checks if the token after the one pointed to by tokenp matches token.

Note:
Unlike acceptToken(Token ***, TokenType), this function does not modify tokenp.
Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
tokenp will point to the same token as when the function was called.
Return values:
0 The next token does not match token.
1 The next token matches token.
See also:
acceptToken(Token ***, TokenType)
peekToken(Token ***, TokenType)
Parameters:
[in] tokenp A pointer to the position of the next token to parse in an array of Token structures.
[in] token The type of token to match.
BlockNode* parseBlockNode ( Token ***  tokenp,
FunctionTable functab 
)

Parses a set of tokens into a BlockNode structure.

Parsing begins at the token pointed to by tokenp.

Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
tokenp will point to the next unparsed token in the array.
Returns:
A pointer to the generated BlockNode structure.
Return values:
NULL An error occurred during parsing.
See also:
parseConstantNode(Token ***)
parseTypeNode(Token ***)
parseIdentifierNode(Token ***)
parseExprNode(Token ***, FunctionTable *)
parseStmtNode(Token ***, FunctionTable *)
parseMainNode(Token **, FunctionTable *)
Parameters:
[in,out] tokenp A pointer to the position of the next token to parse.
[in,out] functab A pointer to the table of defined functions.
ConstantNode* parseConstantNode ( Token ***  tokenp  ) 

Parses a set of tokens into a ConstantNode structure.

Parsing begins at the token pointed to by tokenp.

Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
tokenp will point to the next unparsed token in the array.
Returns:
A pointer to the generated ConstantNode structure.
Return values:
NULL An error occurred during parsing.
See also:
parseTypeNode(Token ***)
parseIdentifierNode(Token ***)
parseExprNode(Token ***, FunctionTable *)
parseStmtNode(Token ***, FunctionTable *)
parseBlockNode(Token ***, FunctionTable *)
parseMainNode(Token **, FunctionTable *)
ExprNode* parseExprNode ( Token ***  tokenp,
FunctionTable functab 
)

Parses a set of tokens into an ExprNode structure.

Parsing begins at the token pointed to by tokenp.

Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
tokenp will point to the next unparsed token in the array.
Returns:
A pointer to the generated ExprNode structure.
Return values:
NULL An error occurred during parsing.
See also:
parseConstantNode(Token ***)
parseTypeNode(Token ***)
parseIdentifierNode(Token ***)
parseStmtNode(Token ***, FunctionTable *)
parseBlockNode(Token ***, FunctionTable *)
parseMainNode(Token **, FunctionTable *)
Parameters:
[in,out] tokenp A pointer to the position of the next token to parse.
[in,out] functab A pointer to the table of defined functions.
IdentifierNode* parseIdentifierNode ( Token ***  tokenp  ) 

Parses a set of tokens into an IdentifierNode structure.

Parsing begins at the token pointed to by tokenp.

Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
tokenp will point to the next unparsed token in the array.
Returns:
A pointer to the generated ExprNode structure.
Return values:
NULL An error occurred during parsing.
See also:
parseConstantNode(Token ***)
parseTypeNode(Token ***)
parseExprNode(Token ***, FunctionTable *)
parseStmtNode(Token ***, FunctionTable *)
parseBlockNode(Token ***, FunctionTable *)
parseMainNode(Token **, FunctionTable *)
Parameters:
[in,out] tokenp A pointer to the position of the next token to parse.
MainNode* parseMainNode ( Token **  tokens,
FunctionTable functab 
)

Parses tokens into a MainNode structure, an intermediary form to be passed along to a later stage of processing such as, for example, an interpreter.

Precondition:
tokens was created by tokenizeLexemes(Lexeme **).
functab was created by setupFunctionTable(Token **).
Returns:
A pointer to the generated MainNode structure.
Return values:
NULL An error occurred during parsing.
See also:
parseConstantNode(Token ***)
parseTypeNode(Token ***)
parseIdentifierNode(Token ***)
parseExprNode(Token ***, FunctionTable *)
parseStmtNode(Token ***, FunctionTable *)
parseBlockNode(Token ***, FunctionTable *)
Parameters:
[in] tokens A pointer to an array of tokens to parse.
[in,out] functab A pointer to a table of function prototypes.
StmtNode* parseStmtNode ( Token ***  tokenp,
FunctionTable functab 
)

Parses a set of tokens into a StmtNode structure.

Parsing begins at the token pointed to by tokenp.

Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
tokenp will point to the next unparsed token in the array.
Returns:
A pointer to the generated StmtNode structure.
Return values:
NULL An error occurred during parsing.
See also:
parseConstantNode(Token ***)
parseTypeNode(Token ***)
parseIdentifierNode(Token ***)
parseExprNode(Token ***, FunctionTable *)
parseBlockNode(Token ***, FunctionTable *)
parseMainNode(Token **, FunctionTable *)

Note:
The 1.2 specification only allows constant values for OMG guards thus this function explicitly checks for them.

Parameters:
[in,out] tokenp A pointer to the position of the next token to parse.
[in,out] functab A pointer to the table of defined functions.
TypeNode* parseTypeNode ( Token ***  tokenp  ) 

Parses a set of tokens into a TypeNode structure.

Parsing begins at the token pointed to by tokenp.

Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
tokenp will point to the next unparsed token in the array.
Returns:
A pointer to the generated ExprNode structure.
Return values:
NULL An error occurred during parsing.
See also:
parseConstantNode(Token ***)
parseIdentifierNode(Token ***)
parseExprNode(Token ***, FunctionTable *)
parseStmtNode(Token ***, FunctionTable *)
parseBlockNode(Token ***, FunctionTable *)
parseMainNode(Token **, FunctionTable *)
Parameters:
[in,out] tokenp A pointer to the position of the next token to parse.
int peekToken ( Token ***  tokenp,
TokenType  token 
)

Checks if the token pointed to by tokenp matches token.

Note:
Unlike acceptToken(Token ***, TokenType), this function does not modify tokenp.
Precondition:
tokenp points to a position in an array of tokens created by tokenizeLexemes(Lexeme **).
Postcondition:
tokenp will point to the same token as when the function was called.
Return values:
0 The token does not match token.
1 The token matches token.
See also:
acceptToken(Token ***, TokenType)
nextToken(Token ***, TokenType)
Parameters:
[in] tokenp A pointer to the position of the next token to parse in an array of Token structures.
[in] token The type of token to match.
FunctionTable* setupFunctionTable ( Token **  tokens  ) 

Sets up a FunctionTable structure filled with the prototypes of all declared functions.

This structure is then passed as an argument to parseMainNode(Token **, FunctionTable *) so that functions may be called before their definition as well as recursively.

Precondition:
tokens was created by tokenizeLexemes(Lexeme **).
Returns:
A pointer to the generated FunctionTable structure.
Return values:
NULL An error occurred during setup.
Parameters:
[in] tokens A pointer to an array of tokens to scan for function prototypes.
 All Data Structures Files Functions Variables Enumerations Enumerator Defines