-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathanalysis.h
59 lines (42 loc) · 1.46 KB
/
analysis.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
59
/**
* Project: Implementace překladače imperativního jazyka IFJ17.
*
* @brief Syntactical and semantical analysis interface.
*
* @author Timotej Halás <xhalas10@stud.fit.vutbr.cz>
* @author Matej Karas <xkaras34@stud.fit.vutbr.cz>
* @author Dominik Harmim <xharmi00@stud.fit.vutbr.cz>
*/
#ifndef _ANALYSIS_H
#define _ANALYSIS_H
#include <stdbool.h>
#include "symtable.h"
#include "scanner.h"
#define GENERATE_CODE(_callback, ...) \
if (!_callback(__VA_ARGS__)) return ERROR_INTERNAL
/**
* @struct Parser's internal data representation.
*/
typedef struct
{
Sym_table global_table; /// Global symbol table
Sym_table local_table; /// Local symbol table
Token token; /// Token
TData* current_id; /// ID of currently processed function
TData* lhs_id; /// ID of left-hand-side variable
TData* rhs_id; /// ID of right-hand-side function (expression?)
unsigned param_index; /// Index of currently checked param
int label_index; /// Index for generating unique labels.
int label_deep; /// Deep of labes.
bool in_function; /// Defines if the parser is in function
bool in_declaration; /// Defines if param rule should add or check it's params
bool in_while_or_if; /// Defines if the parser is in construction while, if or then
bool non_declared_function; /// Function that has been only defined
} PData;
/**
* Starts syntactic and semantic anlysis.
*
* @return Appropriate error code.
*/
int analyse();
#endif //_ANALYSIS_H