-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdef.h
158 lines (148 loc) · 2.37 KB
/
def.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef UNTITLED_DEF_H
#define UNTITLED_DEF_H
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define MODULE 258
#define ID 259
#define LBRACE 260
#define RBRACE 261
#define COLON 262
#define SEMICOLON 263
#define COMMA 264
#define CHAR 265
#define INT 266
#define REAL 267
#define STRING 268
#define BOOL 269
#define VOID 270
#define VAR 271
#define CONST 272
#define BEGIn 273
#define END 274
#define IF 275
#define THEN 276
#define ELSE 277
#define ELSEIF 278
#define WHILE 279
#define DO 280
#define RETURN 281
#define READ 282
#define WRITE 283
#define AND 284
#define OR 285
#define NOT 286
#define ASSIGN 287
#define LE 288
#define GE 289
#define LT 290
#define GT 291
#define EQ 292
#define NEQ 293
#define PLUS 294
#define MINUS 295
#define AST 296
#define FRAC 297
#define INTCONST 298
#define REALCONST 299
#define CHARCONST 300
#define STRCONST 301
#define BOOLCONST 302
#define ERROR 303
#define RETURNNULL 304
char* telaFileName;
/*Elenco dei non terminali*/
typedef enum {
NPROGRAM,
NMODULE_DECL,
NOPT_PARAM_LIST,
NPARAM_LIST,
NPARAM_DECL,
NTYPE,
NOPT_VAR_SECT,
NDECL_LIST,
NDECL,
NID_LIST,
NOPT_CONST_SECT, //10
NCONST_LIST,
NCONST_DECL,
NOPT_MODULE_LIST,
NMODULE_BODY,
NSTAT_LIST,
NSTAT,
NASSIGN_STAT,
NIF_STAT,
NOPT_ELSEIF_STAT_LIST,
NOPT_ELSE_STAT, //20
NWHILE_STAT,
NRETURN_STAT,
NOPT_EXPR,
NREAD_STAT,
NWRITE_STAT,
NEXPR_LIST,
NEXPR,
NEXPR1,
NBOOLOP,
NBOOL_TERM,
NRELOP,
NREL_TERM,
NREL_TERM1,
NLOW_BINOP,
NLOW_TERM,
NLOW_TERM1,
NHIGH_BINOP,
NFACTOR,
NUNARYOP,
NCONSTANT,
NMODULE_CALL,
NOPT_EXPR_LIST,
NCOND_EXPR,
NOPT_ELSEIF_EXPR_LIST
} Nonterminal;
/*Elenco dei tipi di nodo (che devono conservare dati)*/
typedef enum {
T_CHAR,
T_INT,
T_REAL,
T_STRING,
T_BOOL,
T_VOID,
T_CHARCONST,
T_INTCONST,
T_REALCONST,
T_STRCONST,
T_BOOLCONST,
T_ID,
T_NONTERMINAL,
T_AST,
T_FRAC,
T_MINUS,
T_PLUS,
T_NOT,
T_LE,
T_GE,
T_LT,
T_GT,
T_EQ,
T_NEQ,
T_AND,
T_OR,
T_RETURNULL
} Typenode;
/*Definizione della union del Lexval*/
typedef union {
int ival;
float rval;
char *sval;
} Lexval;
/*Definizione della struttura di un nodo*/
typedef struct structNode {
Typenode type;
Lexval value;
struct structNode *child, *brother;
} Node;
typedef Node *Pnode; /*Definisco il tipo Pnode per semplicità*/
/*Metodi usati dal lexer.lex -> NON TOCCARE*/
char *strcpy(char*, const char*), *newstring(char*);
#endif