forked from metthal/IFJ-Projekt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexpr.h
81 lines (71 loc) · 1.61 KB
/
expr.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Project name:
* Implementace interpretu imperativního jazyka IFJ13.
*
* Codename:
* INI: Ni Interpreter
*
* Description:
* https://wis.fit.vutbr.cz/FIT/st/course-files-st.php/course/IFJ-IT/projects/ifj2013.pdf
*
* Project's GitHub repository:
* https://github.com/metthal/IFJ-Projekt
*
* Team:
* Marek Milkovič (xmilko01)
* Lukáš Vrabec (xvrabe07)
* Ján Spišiak (xspisi03)
* Ivan Ševčík (xsevci50)
* Marek Bertovič (xberto00)
*/
/**
* @file expr.h
* @brief Declares interface of the bottom-up parser
**/
#ifndef EXPR_H
#define EXPR_H
#include "parser.h"
#include "vector.h"
#include "token.h"
/**
* Defines type of the token located on the bottom-up parser stack
**/
typedef enum
{
Terminal, ///< Terminal token
NonTerminal ///< Non-terminal token
} ExprTokenType;
typedef enum
{
NonConst,
Const
} ExprTokenSubtype;
/**
* Expression token used in bottom-up parsing
**/
typedef struct
{
union
{
Token *token;
int64_t offset;
};
ExprTokenType type;
ExprTokenSubtype subtype;
} ExprToken;
void initExpr();
void deinitExpr();
int64_t expr(int64_t resultOffset, uint32_t *maxStackPosUsed);
void initExprToken(ExprToken *token);
void deleteExprToken(ExprToken *token);
void copyExprToken(const ExprToken *src, ExprToken *dest);
typedef ExprToken* ExprTokenVectorIterator;
typedef const ExprToken* ConstExprTokenVectorIterator;
#define VECTOR_STRUCT_ITEM
#define VECTOR_ITEM ExprToken
#define VECTOR_ITERATOR ExprTokenVectorIterator
#include "vector_template.h"
#undef VECTOR_ITERATOR
#undef VECTOR_ITEM
#undef VECTOR_STRUCT_ITEM
#endif