Function headers for abstract syntax tree parsing.
More...
#include <stdlib.h>
#include "scan.h"
#include "translate/symbol_table.h"
#include "utils/logging.h"
Go to the source code of this file.
|
struct | ASTNode |
| Component of the abstract syntax tree built during parsing. More...
|
|
|
ASTNode * | create_ast_node (TokenType ttype, ASTNode *left, ASTNode *mid, ASTNode *right, Type type, char *symbol_name) |
| Constructs a new AST Node with the provided values. More...
|
|
void | add_position_info (ASTNode *dest, position p) |
| Add position information to an ASTNode. More...
|
|
ASTNode * | create_ast_nonidentifier_leaf (TokenType ttype, Type type) |
| Constructs a new AST Leaf Node with the provided values for a token that is not an identifier. More...
|
|
ASTNode * | create_ast_identifier_leaf (TokenType ttype, char *symbol_name) |
| Constructs a new AST Leaf Node with the provided values for a token that is an identifier. More...
|
|
ASTNode * | create_unary_ast_node (TokenType ttype, ASTNode *child, Type type, char *symbol_name) |
| Constructs a new AST Unary Parent Node with the provided values. More...
|
|
void | ast_debug_level_order (ASTNode *root, LogLevel log_level) |
| Print out an AST's level order traversal. More...
|
|
void | free_ast_node (ASTNode *root) |
|
Function headers for abstract syntax tree parsing.
- Author
- Charles Averill
- Date
- 09-Sep-2022
◆ PRINT_ASTNODE
#define PRINT_ASTNODE |
( |
|
node | ) |
|
Value: printf("ASTNode Information\n-------------------\n"); \
printf(
"TokenType: %s\nLeft: %d\nMiddle: %d\nRight: %d\n",
tokenStrings[node->ttype], \
(int)node->left, (int)node->mid, (int)node->right); \
printf("Is RValue: %s\n", node->is_rvalue ? "true" : "false"); \
printf("# of Func Call Args: %llu\n", node->num_args); \
printf("Value (int): %lld\n", node->value.number_value); \
printf("Value (str): %s\n", node->value.symbol_name);
static char * tokenStrings[]
Token string equivalents.
Definition: scan.h:96
◆ ASTNode
Component of the abstract syntax tree built during parsing.
◆ add_position_info()
Add position information to an ASTNode.
- Parameters
-
dest | Destination ASTNode pointer |
p | Position information |
◆ ast_debug_level_order()
Print out an AST's level order traversal.
- Parameters
-
root | Root of AST |
log_level | Log level to print at |
◆ create_ast_identifier_leaf()
Constructs a new AST Leaf Node with the provided values for a token that is an identifier.
- Parameters
-
ttype | TokenType of the new AST Node |
symbol_name | The identifier for the provided Token information |
- Returns
- ASTNode* The pointer to a new AST Leaf Node with the provided values
◆ create_ast_node()
Constructs a new AST Node with the provided values.
- Parameters
-
ttype | TokenType of the new AST Node |
left | Left child subtree of the new AST Node |
mid | Middle child subtree of the new AST Node |
right | Right child subtree of the new AST Node |
type | Type of the new AST Node |
symbol_name | The identifier for the provided Token information |
- Returns
- ASTNode* The pointer to a new AST Node with the provided values
◆ create_ast_nonidentifier_leaf()
Constructs a new AST Leaf Node with the provided values for a token that is not an identifier.
- Parameters
-
ttype | TokenType of the new AST Node |
type | Type of the new AST Node |
- Returns
- ASTNode* The pointer to a new AST Leaf Node with the provided values
◆ create_unary_ast_node()
Constructs a new AST Unary Parent Node with the provided values.
- Parameters
-
ttype | TokenType of the new AST Node |
child | The AST Node's single child |
type | Type of the new AST Node |
symbol_name | The identifier for the provided Token information |
- Returns
- ASTNode* The pointer to a new AST Unary Parent Node with the provided values
◆ free_ast_node()
void free_ast_node |
( |
ASTNode * |
root | ) |
|