-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtables.h
45 lines (36 loc) · 1.01 KB
/
tables.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
#ifndef _TABLES_H_
#define _TABLES_H_
#include "types.h"
#include "lex_value.h"
#define SIZE_OF_INT 4
struct entry {
int line;
enum natures nature;
enum types type;
struct val value;
char shift[12];
char *scope;
};
struct table {
struct entry **entries;
int num_entries;
char *scope;
};
struct table_stack{
struct table *top;
struct table_stack *next;
};
// Entries
struct entry new_entry(int line, enum natures nature, enum types type, struct val value);
// Tables
struct table *new_table();
void add_entry(struct table *table, struct entry *entry);
struct entry *search_table(struct table *table, char *label);
void free_table(struct table *table);
// Stack
struct table_stack *new_table_stack();
void push_table(struct table_stack **table_stack, struct table *new_table);
void pop_table(struct table_stack *table_stack);
struct entry *search_table_stack(struct table_stack *table_stack, char *label);
void free_table_stack(struct table_stack *table_stack);
#endif //_TABLES_H_