-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhashTable.h
104 lines (95 loc) · 1.55 KB
/
hashTable.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
93
94
95
96
97
98
99
100
101
102
103
104
/*
Group 1:
1. Anupam Aggarwal 2016A7PS0033P
2. Piyush Garg 2016A7PS0035P
3. Rijul Katiyar 2016A7PS0063P
4. Vidit Jain 2016A7PS0064P
*/
#include<stdbool.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#ifndef TOKEN
#define TOKEN 23
typedef enum{
EPS,
TK_MAIN,
TK_END,
TK_FUNID,
TK_SEM,
TK_INPUT,
TK_PARAMETER,
TK_LIST,
TK_SQL,
TK_SQR,
TK_OUTPUT,
TK_ID,
TK_INT,
TK_REAL,
TK_RECORD,
TK_RECORDID,
TK_COMMA,
TK_ENDRECORD,
TK_TYPE,
TK_COLON,
TK_FIELDID,
TK_GLOBAL,
TK_ASSIGNOP,
TK_DOT,
TK_CALL,
TK_WITH,
TK_PARAMETERS,
TK_WHILE,
TK_OP,
TK_CL,
TK_ENDWHILE,
TK_IF,
TK_THEN,
TK_ELSE,
TK_ENDIF,
TK_READ,
TK_WRITE,
TK_MUL,
TK_DIV,
TK_PLUS,
TK_MINUS,
TK_NUM,
TK_RNUM,
TK_NOT,
TK_AND,
TK_OR,
TK_LT,
TK_LE,
TK_EQ,
TK_GT,
TK_GE,
TK_NE,
TK_RETURN,
TK_ERROR, // For Unknown definition ERROR
TK_ERROR2, // for Length ERROR
TK_ERROR3 // for Unkown Symbol error
}tokenType;
extern char *tokenMap[];
#endif
struct node{
char* key;
tokenType token;
struct node* next;
};
typedef struct node* Node ;
struct list{
Node head;
};
typedef struct list* List;
struct hashTable
{
List rows;
int no_rows;
};
void hashInit(int no);
void addEntry(char* key,tokenType token);
int hashFunc(char* key,int no);
int lookup(char* key);
void printTable();
void printList(struct list ls);
extern struct hashTable* keywordTable;