-
Notifications
You must be signed in to change notification settings - Fork 1
/
parser.defs.h
83 lines (73 loc) · 2.69 KB
/
parser.defs.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
82
83
#ifndef PARSER_DEFS_H
#define PARSER_DEFS_H
/* Non Terminals Defines */
#define TI_PROGRAMA 0xCAF0
#define TI_BLOCO 0xCAF1
#define TI_BLOCO_RETURN 0xCAF2
#define TI_COMANDO 0xCAF3
#define TI_COMANDORET 0xCAF4
#define TI_EXP 0xCAF5
#define TI_CHAMADADEFUNCAO 0xCAF6
#define TI_LISTADENOMES 0xCAF7
#define TI_LISTAEXP 0xCAF8
#define TI_COMANDO_LIST 0xCAF9
#define TI_TERM_ELSEIF 0xCAFA
#define TI_LABEL 0xCAFB
/* Check if it is a block */
#define IS_BLOCK(X) ((X == TI_BLOCO) || (X == TI_BLOCO_RETURN))
/* Extra Non Terminals */
#define TI_BLOCO_COMANDO 0xCAFC
#define TI_ASSIGN 0xCAFE
#define TI_WHILE 0XCAFF
#define TI_FOR 0XCB00
#define TI_FOR_INC 0xCB01
#define TI_IF_ELSE 0xCB02
#define TI_IF 0xCB03
#define TI_FUNCTION_PARAM 0xCB04
#define TI_FUNCTION 0xCB05
#define TI_LOCAL_DEFINE 0xCB06
#define TI_LOCAL_ASSIGN 0xCB07
#define TI_LIST_ELSEIF 0xCB08
#define TI_RETURN_EXPLIST 0xCB09
#define TI_RETURN 0xCB0A
/* Expressions */
#define IS_CALL_FUNCTION(X) ((X == TI_CALL_FUNCTION) || (X == TI_CALL_FUNCTION_PAR))
#define IS_NUMBER(X) (X == T_NUMBER)
#define IS_NAME(X) (X == T_NAME)
#define IS_NIL(X) (X == T_NIL)
#define IS_EXPRESSION(X) (((X >= 0xCB0B) && (X <= 0xCB24)) || IS_CALL_FUNCTION(X) || IS_NUMBER(X) || IS_NAME(X) || IS_NIL(X))
/* Unary Operands */
#define IS_UNARY_OPERAND(X) ((X >= 0xCB0B) && (X <= 0xCB0D))
#define TI_UMINUS 0xCB0B
#define TI_NOT 0xCB0C
#define TI_BIT_NOT 0xCB0D
/* Binary Operands */
#define IS_BINARY_OPERAND(X) ((X >= 0xCB0E) && (X <= 0xCB20))
#define TI_PLUS 0xCB0E
#define TI_MINUS 0xCB0F
#define TI_TIMES 0xCB10
#define TI_DIV 0xCB11
#define TI_FLOOR 0xCB12
#define TI_MOD 0xCB14
#define TI_BIT_AND 0xCB15
#define TI_BIT_OR 0xCB16
#define TI_BIT_N_XOR 0xCB17
#define TI_BIT_LSH 0xCB18
#define TI_BIT_RSH 0xCB19
#define TI_CONCAT 0xCB1A
#define TI_LT 0xCB1B
#define TI_LTEQ 0xCB1C
#define TI_GT 0xCB1D
#define TI_GTEQ 0xCB1E
#define TI_EQ 0xCB1F
#define TI_NEQ 0xCB20
/* Short-circuit evaluation for 'and' and 'or' */
#define IS_SHORT_CIRCUIT_OP(X) ((X >= 0xCB21) && (X <= 0xCB22))
#define TI_AND 0xCB21
#define TI_OR 0xCB22
/* Call of functions */
#define TI_CALL_FUNCTION_PAR 0xCB23
#define TI_CALL_FUNCTION 0xCB24
/* Empty non terminal */
#define TI_EMPTY 0xCB25
#endif