Purple  0.1
Standard Language Specification
tree.h
Go to the documentation of this file.
1
8#ifndef TREE_H
9#define TREE_H
10
11#include <stdlib.h>
12
13#include "scan.h"
15#include "utils/logging.h"
16
20typedef struct ASTNode {
24 struct ASTNode* left;
26 struct ASTNode* mid;
28 struct ASTNode* right;
36 char filename[256];
42 union {
49
50ASTNode* create_ast_node(TokenType ttype, ASTNode* left, ASTNode* mid, ASTNode* right, Type type,
51 char* symbol_name);
54ASTNode* create_ast_identifier_leaf(TokenType ttype, char* symbol_name);
55ASTNode* create_unary_ast_node(TokenType ttype, ASTNode* child, Type type, char* symbol_name);
56void ast_debug_level_order(ASTNode* root, LogLevel log_level);
57
58#endif /* TREE_H */
#define MAX_IDENTIFIER_LENGTH
Definition: identifier.h:12
Function headers, ANSI defines, and enums for raising internal warnings and errors.
LogLevel
Severity levels of logging statements emitted by the compiler.
Definition: logging.h:35
NumberType
Types of numbers supported by Purple.
Definition: number.h:17
Lexical Scanner function headers.
#define number_literal_type
Number literals can have a max value of 2^63 - 1 and a min value of -2^63.
Definition: scan.h:187
TokenType
Types of scannable tokens.
Definition: scan.h:20
Component of the abstract syntax tree built during parsing.
Definition: tree.h:20
char symbol_name[MAX_IDENTIFIER_LENGTH]
Definition: tree.h:46
NumberType number_type
Definition: tree.h:30
bool is_char_arithmetic
Definition: tree.h:34
NumberType largest_number_type
Definition: tree.h:32
union ASTNode::@2 value
struct ASTNode * left
Definition: tree.h:24
char filename[256]
Definition: tree.h:36
struct ASTNode * right
Definition: tree.h:28
int char_number
Definition: tree.h:40
TokenType ttype
The TokenType of the given token.
Definition: tree.h:22
number_literal_type number_value
Definition: tree.h:44
struct ASTNode * mid
Definition: tree.h:26
int line_number
Definition: tree.h:38
Container for type data.
Definition: type.h:18
Structure containing information about a Token's position in the input.
Definition: scan.h:197
Function headers and definitions for the global and local symbol tables.
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.
Definition: tree.c:108
void ast_debug_level_order(ASTNode *root, LogLevel log_level)
Print out an AST's level order traversal.
Definition: tree.c:191
void add_position_info(ASTNode *dest, position p)
Add position information to an ASTNode.
Definition: tree.c:94
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.
Definition: tree.c:120
struct ASTNode ASTNode
Component of the abstract syntax tree built during parsing.
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.
Definition: tree.c:134
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.
Definition: tree.c:26