-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.hpp
More file actions
51 lines (38 loc) · 1004 Bytes
/
parser.hpp
File metadata and controls
51 lines (38 loc) · 1004 Bytes
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
50
51
#pragma once
#include "lexer.hpp"
enum node_kind_t { NODE_OP = 41, NODE_VAL , NODE_VAR};
struct node_data_t {
enum node_kind_t k;
union {
enum operation_t op;
int val;
char *var;
} u;
char value = -1;
};
struct node_t {
node_t *left, *right;
node_data_t data;
bool isbracket = false;
node_t();
};
void print_n(node_t *node);
node_t *copy_node(node_t *copied_node);
void destroy_subtree(node_t *current);
struct syntax_tree_t {
node_t *root_ ;
int state_;
syntax_tree_t();
syntax_tree_t(lex_array_t &lex_array);
syntax_tree_t(node_t *new_root);
syntax_tree_t(const syntax_tree_t &other);
~syntax_tree_t();
void destroy_syntax_tree_t(node_t *node);
node_t *parse_expr (lex_array_t &lex_array);
node_t *parse_disjunct (lex_array_t &lex_array);
node_t *parse_conjunct (lex_array_t &lex_array);
node_t *parse_term (lex_array_t &lex_array);
node_t *copy_tree_root (node_t *root);
void show();
void print_node(node_t *root); //private
};