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. | |
| BlockNode * | addBlockNode (BlockNodeList *, BlockNode *) |
| Adds a BlockNode structure to a BlockNodeList structure. | |
| ExprNode * | addExprNode (ExprNodeList *, ExprNode *) |
| Adds an ExprNode structure to an ExprNodeList structure. | |
| FuncDefStmtNode * | addFuncDefStmtNode (FunctionTable *, FuncDefStmtNode *) |
| Adds a FuncDefStmtNode to a FunctionTable structure. | |
| IdentifierNode * | addIdentifierNode (IdentifierNodeList *, IdentifierNode *) |
| Adds an IdentifierNode structure to an IdentifierNodeList structure. | |
| StmtNode * | addStmtNode (StmtNodeList *, StmtNode *) |
| Adds a StmtNode to a StmtNodeList structure. | |
| AssignmentStmtNode * | createAssignmentStmtNode (IdentifierNode *, ExprNode *) |
| Creates an AssignmentStmtNode structure. | |
| BlockNode * | createBlockNode (StmtNodeList *) |
| Creates a BlockNode structure. | |
| BlockNodeList * | createBlockNodeList (void) |
| Creates a BlockNodeList structure. | |
| ConstantNode * | createBooleanConstantNode (int) |
| Creates a boolean type ConstantNode structure. | |
| CastExprNode * | createCastExprNode (ExprNode *, TypeNode *) |
| Creates a CastExprNode structure. | |
| CastStmtNode * | createCastStmtNode (IdentifierNode *, TypeNode *) |
| Creates a CastStmtNode structure. | |
| DeclarationStmtNode * | createDeclarationStmtNode (IdentifierNode *, IdentifierNode *, ExprNode *) |
| Creates a DeclarationStmtNode structure. | |
| ExprNode * | createExprNode (ExprType, void *) |
| Creates an ExprNode structure. | |
| ExprNodeList * | createExprNodeList (void) |
| Creates an ExprNodeList structure. | |
| ConstantNode * | createFloatConstantNode (float) |
| Creates a floating point decimal type ConstantNode structure. | |
| FuncCallExprNode * | createFuncCallExprNode (FuncDefStmtNode *, ExprNodeList *) |
| Creates a FuncCallExprNode structure. | |
| FuncDefStmtNode * | createFuncDefStmtNode (IdentifierNode *, IdentifierNode *, IdentifierNodeList *, BlockNode *) |
| Creates a FuncDefStmtNode structure. | |
| FunctionTable * | createFunctionTable (void) |
| Creates a FunctionTable structure. | |
| IdentifierNode * | createIdentifierNode (char *, const char *, unsigned int) |
| Creates an IdentifierNode structure. | |
| IdentifierNodeList * | createIdentifierNodeList (void) |
| Creates an IdentifierNodeList structure. | |
| IfThenElseStmtNode * | createIfThenElseStmtNode (BlockNode *, BlockNode *, ExprNodeList *, BlockNodeList *) |
| Creates an IfThenElseStmtNode structure. | |
| InputStmtNode * | createInputStmtNode (IdentifierNode *) |
| Creates an InputStmtNode structure. | |
| ConstantNode * | createIntegerConstantNode (int) |
| Creates an integer type ConstantNode structure. | |
| LoopStmtNode * | createLoopStmtNode (IdentifierNode *, IdentifierNode *, ExprNode *, ExprNode *, BlockNode *) |
| Creates a LoopStmtNode structure. | |
| MainNode * | createMainNode (BlockNode *, FunctionTable *) |
| Creates a MainNode structure. | |
| OpExprNode * | createOpExprNode (OpType, ExprNodeList *) |
| Creates an OpExprNode structure. | |
| PrintStmtNode * | createPrintStmtNode (ExprNodeList *, int) |
| Creates a PrintStmtNode structure. | |
| ReturnStmtNode * | createReturnStmtNode (ExprNode *) |
| Creates a ReturnStmtNode structure. | |
| StmtNode * | createStmtNode (StmtType, void *) |
| Creates a StmtNode structure. | |
| StmtNodeList * | createStmtNodeList (void) |
| Creates a StmtNodeList structure. | |
| ConstantNode * | createStringConstantNode (char *) |
| Creates a string type ConstantNode structure. | |
| SwitchStmtNode * | createSwitchStmtNode (ExprNodeList *, BlockNodeList *, BlockNode *) |
| Creates a SwitchStmtNode structure. | |
| TypeNode * | createTypeNode (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. | |
| FuncDefStmtNode * | lookupFuncDefStmtNode (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. | |
| BlockNode * | parseBlockNode (Token ***, FunctionTable *) |
| Parses a set of tokens into a BlockNode structure. | |
| ConstantNode * | parseConstantNode (Token ***) |
| Parses a set of tokens into a ConstantNode structure. | |
| ExprNode * | parseExprNode (Token ***, FunctionTable *) |
| Parses a set of tokens into an ExprNode structure. | |
| IdentifierNode * | parseIdentifierNode (Token ***) |
| Parses a set of tokens into an IdentifierNode structure. | |
| MainNode * | parseMainNode (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. | |
| StmtNode * | parseStmtNode (Token ***, FunctionTable *) |
| Parses a set of tokens into a StmtNode structure. | |
| TypeNode * | parseTypeNode (Token ***) |
| Parses a set of tokens into a TypeNode structure. | |
| int | peekToken (Token ***, TokenType) |
| Checks if the token pointed to by tokenp matches token. | |
| FunctionTable * | setupFunctionTable (Token **) |
| Sets up a FunctionTable structure filled with the prototypes of all declared functions. | |
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).
| enum ConstantType |
| enum ExprType |
Denotes the type of expression an ExprNode stores.
| 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.
| enum StmtType |
Denotes the type of statement a StmtNode stores.
| 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. |
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.
| 0 | The token does not match token. | |
| 1 | The token matches token. |
| [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.
| NULL | realloc was unable to allocate memory. |
| [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.
| NULL | realloc was unable to allocate memory. |
| [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.
| NULL | realloc was unable to allocate memory. |
| [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.
| NULL | realloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [in] | stmts | A pointer to the list of statements which comprise the block of code. |
| BlockNodeList* createBlockNodeList | ( | void | ) |
Creates a BlockNodeList structure.
| NULL | malloc was unable to allocate memory. |
| ConstantNode* createBooleanConstantNode | ( | int | data | ) |
Creates a boolean type ConstantNode structure.
0 if data equals 0 and 1 otherwise.| NULL | malloc was unable to allocate memory. |
| [in] | data | The constant boolean data. |
| CastExprNode* createCastExprNode | ( | ExprNode * | target, | |
| TypeNode * | newtype | |||
| ) |
Creates a CastExprNode structure.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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. |
Creates an ExprNode structure.
NULL | NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| ConstantNode* createFloatConstantNode | ( | float | data | ) |
Creates a floating point decimal type ConstantNode structure.
| NULL | malloc was unable to allocate memory. |
| [in] | data | The constant floating point decimal data. |
| FuncCallExprNode* createFuncCallExprNode | ( | FuncDefStmtNode * | def, | |
| ExprNodeList * | args | |||
| ) |
Creates a FuncCallExprNode structure.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| IdentifierNode* createIdentifierNode | ( | char * | image, | |
| const char * | fname, | |||
| unsigned int | line | |||
| ) |
Creates an IdentifierNode structure.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| IfThenElseStmtNode* createIfThenElseStmtNode | ( | BlockNode * | yes, | |
| BlockNode * | no, | |||
| ExprNodeList * | guards, | |||
| BlockNodeList * | blocks | |||
| ) |
Creates an IfThenElseStmtNode structure.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [in] | data | The constant integer data. |
| LoopStmtNode* createLoopStmtNode | ( | IdentifierNode * | name, | |
| IdentifierNode * | var, | |||
| ExprNode * | guard, | |||
| ExprNode * | update, | |||
| BlockNode * | body | |||
| ) |
Creates a LoopStmtNode structure.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [in] | value | A pointer to the value to return. |
Creates a StmtNode structure.
NULL | NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| ConstantNode* createStringConstantNode | ( | char * | data | ) |
Creates a string type ConstantNode structure.
| NULL | malloc was unable to allocate memory. |
| [in] | data | The constant character string data. |
| SwitchStmtNode* createSwitchStmtNode | ( | ExprNodeList * | guards, | |
| BlockNodeList * | blocks, | |||
| BlockNode * | def | |||
| ) |
Creates a SwitchStmtNode structure.
| NULL | malloc was unable to allocate memory. |
| [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.
| NULL | malloc was unable to allocate memory. |
| [in] | type | The type of value. |
| void deleteAssignmentStmtNode | ( | AssignmentStmtNode * | node | ) |
Deletes an AssignmentStmtNode structure.
| [in,out] | node | A pointer to the AssignmentStmtNode structure to be deleted. |
| void deleteBlockNode | ( | BlockNode * | node | ) |
Deletes a BlockNode structure.
| [in,out] | node | A pointer to the BlockNode structure to be deleted. |
| void deleteBlockNodeList | ( | BlockNodeList * | list | ) |
Deletes a BlockNodeList structure.
| [in,out] | list | A pointer to the BlockNodeList structure to delete. |
| void deleteCastExprNode | ( | CastExprNode * | node | ) |
Deletes a CastExprNode structure.
| [in,out] | node | A pointer to the CastExprNode structure to be deleted. |
| void deleteCastStmtNode | ( | CastStmtNode * | node | ) |
Deletes a CastStmtNode structure.
| [in,out] | node | A pointer to the CastStmtNode structure to be deleted. |
| void deleteConstantNode | ( | ConstantNode * | node | ) |
Deletes a ConstantNode structure.
| [in,out] | node | A pointer to the ConstantNode structure to be deleted. |
| void deleteDeclarationStmtNode | ( | DeclarationStmtNode * | node | ) |
Deletes a DeclarationStmtNode structure.
| [in,out] | node | A pointer to the DeclarationStmtNode structure to be deleted. |
| void deleteExprNode | ( | ExprNode * | node | ) |
Deletes an ExprNode structure.
| [in,out] | node | A pointer to the ExprNode structure to be deleted. |
| void deleteExprNodeList | ( | ExprNodeList * | list | ) |
Deletes an ExprNodeList structure.
| [in,out] | list | A pointer to the ExprNodeList structure to delete. |
| void deleteFuncCallExprNode | ( | FuncCallExprNode * | node | ) |
Deletes a FuncCallExprNode structure.
| [in,out] | node | A pointer to the FuncCallExprNode structure to be deleted. |
| void deleteFuncDefStmtNode | ( | FuncDefStmtNode * | node | ) |
Deletes a FuncDefStmtNode structure.
| [in,out] | node | A pointer to the FuncDefStmtNode structure to be deleted. |
| void deleteFunctionTable | ( | FunctionTable * | table | ) |
Deletes a FunctionTable structure.
| [in,out] | table | A pointer to the FunctionTable structure to delete. |
| void deleteIdentifierNode | ( | IdentifierNode * | node | ) |
Deletes an IdentifierNode structure.
| [in,out] | node | A pointer to the IdentifierNode structure to be deleted. |
| void deleteIdentifierNodeList | ( | IdentifierNodeList * | list | ) |
Deletes an IdentifierNodeList structure.
| [in,out] | list | A pointer to the IdentifierNodeList structure to delete. |
| void deleteIfThenElseStmtNode | ( | IfThenElseStmtNode * | node | ) |
Deletes a IfThenElseStmtNode structure.
| [in,out] | node | A pointer to the IfThenElseStmtNode structure to be deleted. |
| void deleteInputStmtNode | ( | InputStmtNode * | node | ) |
Deletes an InputStmtNode structure.
| [in,out] | node | A pointer to the InputStmtNode structure to be deleted. |
| void deleteLoopStmtNode | ( | LoopStmtNode * | node | ) |
Deletes a LoopStmtNode structure.
| [in,out] | node | A pointer to the LoopStmtNode structure to be deleted. |
| void deleteMainNode | ( | MainNode * | node | ) |
Deletes a MainNode structure.
| [in,out] | node | A pointer to the MainNode structure to be deleted. |
| void deleteOpExprNode | ( | OpExprNode * | node | ) |
Deletes an OpExprNode structure.
| [in,out] | node | A pointer to the OpExprNode structure to be deleted. |
| void deletePrintStmtNode | ( | PrintStmtNode * | node | ) |
Deletes a PrintStmtNode structure.
| [in,out] | node | A pointer to the PrintStmtNode structure to be deleted. |
| void deleteReturnStmtNode | ( | ReturnStmtNode * | node | ) |
Deletes a ReturnStmtNode structure.
| [in,out] | node | A pointer to the ReturnStmtNode structure to be deleted. |
| void deleteStmtNode | ( | StmtNode * | node | ) |
Deletes a StmtNode structure.
| [in,out] | node | A pointer to the StmtNode structure to be deleted. |
| void deleteStmtNodeList | ( | StmtNodeList * | list | ) |
Deletes a StmtNodeList structure.
| [in,out] | list | A pointer to the StmtNodeList structure to delete. |
| void deleteSwitchStmtNode | ( | SwitchStmtNode * | node | ) |
Deletes a SwitchStmtNode structure.
| [in,out] | node | A pointer to the SwitchStmtNode structure to be deleted. |
| void deleteTypeNode | ( | TypeNode * | node | ) |
Deletes a TypeNode structure.
| [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.
| [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.
| NULL | No such FuncDefStmtNode structure exists. |
| [in] | table | A pointer to the FunctionTable structure to search for name. |
| [in] | name | The name of the function to look up. |
Checks if the token after the one pointed to by tokenp matches token.
| 0 | The next token does not match token. | |
| 1 | The next token matches token. |
| [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.
| NULL | An error occurred during parsing. |
| [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.
| NULL | An error occurred during parsing. |
| ExprNode* parseExprNode | ( | Token *** | tokenp, | |
| FunctionTable * | functab | |||
| ) |
Parses a set of tokens into an ExprNode structure.
Parsing begins at the token pointed to by tokenp.
| NULL | An error occurred during parsing. |
| [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.
| NULL | An error occurred during parsing. |
| [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.
| NULL | An error occurred during parsing. |
| [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.
| NULL | An error occurred during parsing. |
| [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. |
Parses a set of tokens into a TypeNode structure.
Parsing begins at the token pointed to by tokenp.
| NULL | An error occurred during parsing. |
| [in,out] | tokenp | A pointer to the position of the next token to parse. |
Checks if the token pointed to by tokenp matches token.
| 0 | The token does not match token. | |
| 1 | The token matches token. |
| [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.
| NULL | An error occurred during setup. |
| [in] | tokens | A pointer to an array of tokens to scan for function prototypes. |
1.7.1