-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinternals.c
54 lines (44 loc) · 1.11 KB
/
internals.c
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "libs/arg_table.h"
#include "libs/bin_buffer.h"
#include "libs/symbol_table.h"
#include "y.tab.h"
//#include "arch/"
/*
Useless code that will be deleted
*/
char* keywords [] = {"def", "alloc", "struct", "byte"};
int keyword_id [] = {DEF, ALLOC, STRUCT, BYTE}; //defined in the y.tab.h header file
//SYMBOL_TABLE local_table; //for identifiers
char* identifiers [4];
int identifier_index = 0;
void set_identifier(char* identifier_name)
{
identifiers [identifier_index] = strdup(identifier_name);
//identifier_index++;
}
void reset_identifiers()
{
identifier_index = 0;
}
void init_internals()
{
//init_symbol_table(&local_table);
}
int return_token(char* identifier)
{
for(int i = 0;i <= 3;i++)
{
//printf("To compare %s\n", identifier);
if(strcmp(keywords [i], identifier) == 0)
{
return keyword_id [i];
}
}
//if nothing
printf("Return IDENTIFIER %s\n", identifier);
set_identifier(identifier);
return IDENTIFIER;
}