-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken_term.h
58 lines (50 loc) · 1.43 KB
/
token_term.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
50
51
52
53
54
55
56
57
58
/**
* Implementace překladače imperativního jazyka IFJ22
*
* @file token_term.h
* @author Josef Kuchař ([email protected])
* @author Matej Sirovatka ([email protected])
* @author Tomáš Běhal ([email protected])
* @author Šimon Benčík ([email protected])
* @brief Declaration of token terminal functions
*/
#ifndef __TOKEN_TERM_H__
#define __TOKEN_TERM_H__
#include "token.h"
typedef struct token_term {
token_t value; // +
token_type_t result; // int
struct token_term* left; // 1
struct token_term* right; // 2
bool terminal; // false
} token_term_t;
/**
* @brief Creates new token_term_t with specified token and value of terminal
*
* @param token Token to be used
* @param is_term Value whether token_term_t is or isn't terminal
*
* @return new instance of token_term_t
*/
token_term_t* token_term_new(token_t value, bool terminal);
/**
* @brief Pretty prints token_term_t
*
* @param token Token to be printed
*/
void token_term_pprint(token_term_t token);
/**
* @brief Generates graphviz code from expression tree
*
* @param token Root token
* @param depth Current depth (starts at 0)
* @param side Current side (starts at 0)
*/
void token_graph_print(token_term_t* token, int depth, int side);
/**
* @brief Frees token_term_t and all its children
*
* @param root Root token
*/
void token_term_free(token_term_t* root);
#endif