-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparserDef.h
93 lines (79 loc) · 1.61 KB
/
parserDef.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
/*
Group 1:
1. Anupam Aggarwal 2016A7PS0033P
2. Piyush Garg 2016A7PS0035P
3. Rijul Katiyar 2016A7PS0063P
4. Vidit Jain 2016A7PS0064P
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lexerDef.h"
typedef struct tk_node * TK_NODE;
typedef struct tk_node tk_node;
typedef struct grammar * GRAMMAR;
typedef struct grammar grammar;
typedef struct rule * RULE;
typedef struct rule rule;
typedef struct firstfollow * FirstFollow;
typedef struct firstfollow firstfollow;
typedef struct followds * FOLLOWDS;
typedef struct followds followds;
typedef struct followind * FOLLOWIND;
typedef struct followind followind;
typedef int * parsetable;
typedef parsetable * PARSETABLE;
typedef struct tree_node * TREE_NODE;
typedef struct tree_node tree_node;
typedef struct hashT *Hashtable;
typedef enum {T, NT} ntt;
struct tk_node {
ntt type;
int info;
TK_NODE next;
};
struct rule {
int key;
TK_NODE start;
};
struct followind {
TK_NODE tk;
int index;
};
struct followds {
FOLLOWIND f;
int size;
};
struct grammar {
FOLLOWDS follow;
RULE nonterminals;
int* terminals;
int nonterminal_count;
int terminal_count;
int rules;
};
struct firstfollow {
// first 0th column eps, rest terminals as in grammar
int** first;
// follow 0th column $, rest terminals as in grammar
int** follow;
};
typedef union {
TOKENINFO tk;
int index;
} node_info;
struct tree_node {
ntt type;
node_info tk_info;
int parent_index;
TREE_NODE child;
TREE_NODE next;
int rule_index;
};
struct hashT {
char *name;
int value;
int index;
};
extern int invalid_prog;
#include "parser.h"