forked from coolsidd/Compiler-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_tree.h
49 lines (43 loc) · 1.42 KB
/
parse_tree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
Group 36
2017B4A70495P Manan Soni
2017B4A70549P Siddharth Singh
2017B4A70636P Nayan Khanna
2017B4A70740P Aditya Tulsyan
*/
#ifndef __PARSE_TREE_H_
#define __PARSE_TREE_H_
#include <stdlib.h>
#include "grammar.h"
#include "tokenizer_structs.h"
#define KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
#define RESET "\033[0m"
typedef struct ____TYPE_EXPRESSION____ type_expression;
char * get_string_representation(type_expression * txp);
typedef struct parse_tree_node {
int num_children;
struct parse_tree_node *child;
struct parse_tree_node *last_child;
struct parse_tree_node *next;
struct parse_tree_node *parent;
type_expression* txp;
Token *tok;
int depth;
} Parse_tree_node;
Parse_tree_node *getNodeFromIndex(Parse_tree_node *p, int index);
Parse_tree_node *createParseTree(TokenStream *s, Grammar *g, int *maxline);
Parse_tree_node *recursiveParseNonterminal(Symbol symb, Token ** tstr, Grammar *g, int *maxline, int depth);
Parse_tree_node *new_parse_tree();
void free_parse_tree(Parse_tree_node *root);
void add_parsed_child(Parse_tree_node *root, Parse_tree_node *node);
void printLine(char* symb, bool t, char* typ, char* name, int line, int depth);
void printParseTree(Parse_tree_node *p, int d);
void traverseParseTree(Parse_tree_node *p, int height);
#endif