-
Notifications
You must be signed in to change notification settings - Fork 11
/
expression.h
76 lines (65 loc) · 1.42 KB
/
expression.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
/**
* Project: Implementace překladače imperativního jazyka IFJ17.
*
* @brief Expression interface.
*
* @author Timotej Halás <xhalas10@stud.fit.vutbr.cz>
* @author Dominik Harmim <xharmi00@stud.fit.vutbr.cz>
*/
#ifndef _EXPRESSION_H
#define _EXPRESSION_H
#include "analysis.h"
/**
* @enum Rules used for parsing.
*/
typedef enum
{
NT_EQ_NT, /// E -> E = E
NT_NEQ_NT, /// E -> E <> E
NT_LEQ_NT, /// E -> E <= E
NT_LTN_NT, /// E -> E < E
NT_MEQ_NT, /// E -> E => E
NT_MTN_NT, /// E -> E > E
NT_PLUS_NT, /// E -> E + E
NT_MINUS_NT, /// E -> E - E
NT_IDIV_NT, /// E -> E \ E
NT_MUL_NT, /// E -> E * E
NT_DIV_NT, /// E -> E / E
LBR_NT_RBR, /// E -> (E)
OPERAND, /// E -> i
NOT_A_RULE /// rule doesn't exist
} Prec_rules_enum;
/**
* @enum Symbols used for precednece analysis.
*/
typedef enum
{
PLUS, /// +
MINUS, /// -
MUL, /// *
DIV, /// /
IDIV, /// \ /
EQ, /// =
NEQ, /// <>
LEQ, /// <=
LTN, /// <
MEQ, /// >=
MTN, /// >
LEFT_BRACKET, /// (
RIGHT_BRACKET, /// )
IDENTIFIER, /// ID
INT_NUMBER, /// int
DOUBLE_NUMBER, /// double
STRING, /// string
DOLLAR, /// $
STOP, /// stop symbol used when reducing
NON_TERM /// non-terminal
} Prec_table_symbol_enum;
/**
* Implementation of <expression> rule. Parses expressions.
*
* @param data Pointer to parser's internal data.
* @return Given exit code.
*/
int expression(PData* data);
#endif //_EXPRESSION_H