-
Notifications
You must be signed in to change notification settings - Fork 0
/
psa.h
76 lines (66 loc) · 1.53 KB
/
psa.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: IFJ21 imperative language compiler
*
* Author: Stepan Bakaj <xbakaj00>
* Author: Radek Serejch <xserej00>
*
*/
#ifndef IFJ_BRATWURST2021_PSA_H
#define IFJ_BRATWURST2021_PSA_H
#include <stdbool.h>
#include "parser.h"
typedef bool psa_error_t;
psa_error_t psa (p_data_ptr_t data);
#define PSA_NO_ERR true
#define PSA_ERR false
/**
* @enum Rules used for parsing.
*/
typedef enum
{
OPERAND, // E -> i
NT_HASHTAG, // E -> #E
LBR_NT_RBR, // E -> (E)
NT_CONCAT_NT, // E -> E .. E
NT_PLUS_NT, // E -> E + E
NT_MINUS_NT, // E -> E - E
NT_MUL_NT, // E -> E * E
NT_DIV_NT, // E -> E / E
NT_IDIV_NT, // E -> E // E
NT_EQ_NT, // E -> E = E
NT_NEQ_NT, // E -> E ~= E
NT_LEQ_NT, // E -> E <= E
NT_GEQ_NT, // E -> E >= E
NT_LTN_NT, // E -> E < E
NT_GTN_NT, // E -> E > E
NOT_A_RULE // rule doesn't exist
} psa_rules_enum;
/**
* @enum Symbols used for precednece analysis.
*/
typedef enum
{
HASHTAG, // #
PLUS, // +
MINUS, // -
MUL, // *
DIV, // /
INT_DIV, // //
CONCAT, // ..
LESS_THAN, // <
GTR_THAN, // >
LESS_EQ, // <=
GTR_EQ, // >=
NOT_EQ, // ~=
EQ, // ==
LEFT_BRACKET, // (
RIGHT_BRACKET, // )
IDENTIFIER, // ID
INT_NUMBER, // int
DOUBLE_NUMBER, // double
STRN, // string
DOLLAR, // $
STOP, // stop symbol used when reducing
NON_TERM // non-terminal
} psa_table_symbol_enum;
#endif //IFJ_BRATWURST2021_PSA_H