-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymtable.h
92 lines (76 loc) · 1.77 KB
/
symtable.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
/**
* IFJ Project 2020: Team 008, variant II
*
* @file symtable.h
*
* @brief Header file for symtable.c
*
*
* @author Martin Kneslík <[email protected]>
* @author Adriana Jurkechová <[email protected]>
* @author Karel Norek <[email protected]>
* @author Petr Salaba <[email protected]>
*/
#ifndef __SYMTABLE_H__
#define __SYMTABLE_H__
#include <string.h>
#include <stdbool.h>
#include "str.h"
#include "error.h"
// SYMTABLE
#define MAX_SYMSIZE 101
typedef enum
{
tINT,
tFLOAT64,
tSTRING,
tNONE,
tMULTIPLE
} DataType;
typedef char *tKey;
typedef struct tSymtableData
{
//func
bool defined;
bool typesSet;
string argumentTypes;
string returnTypes;
//var
DataType type;
//generation
int scopeId;
} * tSymtableData;
typedef struct tSymtableItem
{
tKey key;
tSymtableData data;
struct tSymtableItem *ptrnext;
} tSymtableItem;
typedef tSymtableItem *tSymtable[MAX_SYMSIZE];
extern int symtableSIZE;
typedef struct tSymStackItem
{
tSymtable symtable;
struct tSymStackItem *next;
} tSymStackItem;
typedef struct
{
tSymStackItem *top;
int scopeCount;
} tSymStack;
int hashCode(tKey key);
void symtableInit(tSymtable *ptrht);
tSymtableItem *symtableSearch(tSymtable *ptrht, tKey key);
tSymtableData symtableInsert(tSymtable *ptrht, tKey key);
tSymtableData symtableRead(tSymtable *ptrht, tKey key);
tSymtableData symtableReadStack(tSymStack *ptrht, tKey key);
void symtableDelete(tSymtable *ptrht, tKey key);
void symtableClearAll(tSymtable *ptrht);
//SYMSTACK
void symStackInit(tSymStack *symStack);
void symStackDispose(tSymStack *symStack);
unsigned symStackSize(tSymStack *symStack);
bool symStackEmpty(tSymStack *symStack);
bool symStackPush(tSymStack *symStack);
bool symStackPop(tSymStack *symStack);
#endif // __SYMTABLE_H__