-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymtab.h
49 lines (40 loc) · 1.18 KB
/
symtab.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
#ifndef SYMTAB_H
#define SYMTAB_H
#include "uthash.h"
#include "tree.h"
// Tipi di simboli
enum sym_type {
VARIABLE,
FUNCTION,
PARAMETER,
F_RETURN
};
// struttura del simbolo
struct symbol {
char *name; // chiave della hash table
enum TYPE type;
enum sym_type sym_type;
struct AstNode *pl;
int used_flag;
int array_flag;
int lineno;
char *line;
UT_hash_handle hh; //per rendere la struttura "hashable"
};
// lista di tabelle
struct symlist {
int scope;
struct symbol *symtab; // tabella dello scope corrente
struct symlist *next; // tabella successiva
};
// gestione delle tabelle
struct symlist* create_symtab(int scope, struct symlist *next);
struct symlist* delete_symtab(struct symlist *syml);
struct symbol* find_symtab(struct symlist *syml, char *name);
void print_symtab(struct symlist *syml);
void check_usage(struct symlist *syml);
// gestione dei singoli simboli
void insert_sym(struct symlist* syml, char *name, enum TYPE type, enum sym_type sym_type, struct AstNode *pl, int lineno, char *line);
struct symbol* find_sym(struct symlist* syml, char *name);
void remove_sym(struct symlist* syml, struct symbol *s);
#endif