-
Notifications
You must be signed in to change notification settings - Fork 0
/
SymbolTable.h
60 lines (50 loc) · 1.37 KB
/
SymbolTable.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
#ifndef ANALIZADORLEXICO_HASHTABLE_H
#define ANALIZADORLEXICO_HASHTABLE_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
/* Function type. */
typedef double (*func_t) (double);
#define SYMBOL_TABLE_DEFAULT_SIZE 49
struct symrec{
char *name; /* name of symbol */
int type; /* type of symbol: either VAR or FNCT */
bool initialized;
union{
double var; /* value of a VAR */
func_t fnctptr; /* value of a FNCT */
} value;
};
typedef struct symrec symrec;
typedef struct _SymbolTable{
bool hasRegister;
struct symrec *registe;
bool hasLeft;
struct _SymbolTable *left;
bool hashRight;
struct _SymbolTable *right;
}SymbolTable;
/*
* Symbol table is a hash table with trees in each register
*
*
* HASH TABLE
* BUCKET -> Tree with lexemes
* BUCKET -> Tree with lexemes
* BUCKET -> Tree with lexemes
* BUCKET -> Tree with lexemes
* BUCKET -> Tree with lexemes
* BUCKET -> Tree with lexemes
* BUCKET -> Tree with lexemes
* ...
*
* */
SymbolTable *symbolTable;
SymbolTable* symbolTableCreate();
void symbolTableDestroy(SymbolTable *);
symrec* symbolTableAnalyze(SymbolTable *, char const *);
symrec* symbolTableInsert(SymbolTable *, char const *, int);//just for the load of keywords
void symbolTablePrint(SymbolTable *);
void symbolTablePrintType(SymbolTable *,int);
#endif //ANALIZADORLEXICO_HASHTABLE_H