Repository navigation
Expand file tree
/
Copy pathexpParse.h
More file actions
77 lines (57 loc) · 1.64 KB
/
Copy pathexpParse.h
File metadata and controls
77 lines (57 loc) · 1.64 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
/**
* @file expParse.h
* @author Jakub Vlk (xvlkja07@stud.fit.vutbr.cz)
* @brief expression parser
* Implementation IFJ22 compiler
*/
#ifndef STACK_EXPPARSE_H
#define STACK_EXPPARSE_H
#include "LLtable.h"
#include "common.h"
#include "lex.h"
#include "semanticActions.h"
#include "stack.h"
// for gouping operation in precendece table
typedef enum {
indexOpPlusMinus = 0,
indexOpMulDiv,
indexId,
indexOpConcat,
indexLpar,
indexRpar,
indexCmp,
indexDollar,
indexCount
} precedenceTableIndex;
typedef enum {
precL = lexTypeCount + 1,// <
precR, // >
precEq, // =
precE, // nogo
dollar,
precendenceTypeCount
} precendenceType;
extern bool isExpInIf;
extern int leftparc;
extern char *precTypeString[];
extern precendenceType precedenceTable[indexCount][indexCount];
rule *derivateTopStack(genericStack *sTokens);
typedef enum {
exp = precendenceTypeCount + 1
} notTerminaltype;
typedef struct {
int type;
token_t *tokenData;
} expParserType;
precedenceTableIndex indexInPrecTable(lexType t);
#define precSymb(x, y) precedenceTable[indexInPrecTable((x)->type)][indexInPrecTable((y)->type)]
// converts precedenc symbol to readeable form
#define precSymbString(a) precTypeString[((int) a % (int) lexTypeCount) - 1]
expParserType *stackTopTerminal(genericStack *s);
unsigned findFirst(genericStack *s, int searchSymb);
// praser for expresions
void expAnal(bool isInIf);
void printExpParserType(void *data);
char *generatePrintExpParsertype(expParserType *data);
unsigned stackTopTerminalIndex(genericStack *s);
#endif//STACK_EXPPARSE_H