-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.h
65 lines (52 loc) · 1.49 KB
/
parser.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
60
61
62
63
64
65
/**
* @file parser.h
* @author Filip Sapak (xsapak05)
* @brief IFJ20 - parser function prototypes
*/
#ifndef PARSER_H
#define PARSER_H
#include "tokenlist.h"
#include "scanner.h"
#include "string.h"
#include "resources.h"
#include "error.h"
#include "symtable.h"
#define CHECK_TYPE(TOKENTYPE) if (Token->type != TOKENTYPE) { htabFree(localtab); errorExit(syntaxError,"parser: syntaxERR \n"); }
#define CHECK_EOF() if (Token == list.pTail) { return; } else { htabFree(localtab); errorExit(syntaxError, "No EOF\n"); }
#define TEST_EOF() if (Token == list.pTail) return;
#define TEST_TYPE(TOKENTYPE) if (Token->type == TOKENTYPE){ decisionFlag = 1; } else { decisionFlag = 0; }
#define DECIDE() if (decisionFlag) return;
#define SET_FLAG(flag) (flag = 1)
#define GET_NEXT(token) if (token->pNext == NULL) { htabFree(localtab); errorExit(syntaxError, "Function with no ending\n"); } else { TOKEN_MOVE_NEXT(token); }
Token_t *Token;
HTab_t* localtab;
int decisionFlag;
int functionParse;
void dataInit();
void parse();
void prog();
void exec();
void func();
void func_types();
void types_n();
void type();
void params();
void params_n();
void func_n();
void body();
void statement_n();
void statement();
void definition();
void assignment();
void ids();
void ids_n();
void expressions();
void expression_n();
void _if();
void _for();
void _call();
void _return();
void _call_param();
void _call_param_n();
void expression();
#endif // PARSER_H