Purple  0.1
Standard Language Specification
Classes | Typedefs | Functions
tree.h File Reference

Function headers for abstract syntax tree parsing. More...

#include <stdlib.h>
#include "scan.h"
#include "translate/symbol_table.h"
#include "utils/logging.h"
Include dependency graph for tree.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ASTNode
 Component of the abstract syntax tree built during parsing. More...
 

Typedefs

typedef struct ASTNode ASTNode
 Component of the abstract syntax tree built during parsing. More...
 

Functions

ASTNodecreate_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...
 
ASTNodecreate_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...
 
ASTNodecreate_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...
 
ASTNodecreate_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...
 

Detailed Description

Function headers for abstract syntax tree parsing.

Author
Charles Averill
Date
09-Sep-2022

Typedef Documentation

◆ ASTNode

typedef struct ASTNode ASTNode

Component of the abstract syntax tree built during parsing.

Function Documentation

◆ add_position_info()

void add_position_info ( ASTNode dest,
position  p 
)

Add position information to an ASTNode.

Parameters
destDestination ASTNode pointer
pPosition information

◆ ast_debug_level_order()

void ast_debug_level_order ( ASTNode root,
LogLevel  log_level 
)

Print out an AST's level order traversal.

Parameters
rootRoot of AST
log_levelLog level to print at

◆ create_ast_identifier_leaf()

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.

Parameters
ttypeTokenType of the new AST Node
symbol_nameThe identifier for the provided Token information
Returns
ASTNode* The pointer to a new AST Leaf Node with the provided values

◆ create_ast_node()

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.

Parameters
ttypeTokenType of the new AST Node
leftLeft child subtree of the new AST Node
midMiddle child subtree of the new AST Node
rightRight child subtree of the new AST Node
typeType of the new AST Node
symbol_nameThe identifier for the provided Token information
Returns
ASTNode* The pointer to a new AST Node with the provided values

◆ create_ast_nonidentifier_leaf()

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.

Parameters
ttypeTokenType of the new AST Node
typeType of the new AST Node
Returns
ASTNode* The pointer to a new AST Leaf Node with the provided values

◆ create_unary_ast_node()

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.

Parameters
ttypeTokenType of the new AST Node
childThe AST Node's single child
typeType of the new AST Node
symbol_nameThe identifier for the provided Token information
Returns
ASTNode* The pointer to a new AST Unary Parent Node with the provided values