-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser-common.h
91 lines (51 loc) · 1.5 KB
/
parser-common.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
/*
* common.h
*
* Created on: Oct 23, 2010
* Author: farhanhubble
*/
#ifndef COMMON_H_
#define COMMON_H_ 1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<assert.h>
#include<stdbool.h>
#endif /* COMMON_H_ */
struct prodList{ /* Structure for storing all productions of a symbol */
char *head;
char **productions;
char **first;
char *follow;
_Bool nullable;
int prodcount;
};
struct parseinfo{
int varcount;
int termcount;
char **variables;
char **terminals;
char ***actions;
};
int fileread(char**,const char*,int *);
void printRaw(char *,int);
struct prodList **makeGrammarTable(char *, int *, int*);
char **addRow(char **,int );
char *addSymbolToRow(char *,const char *);
struct prodList **incrementRows(struct prodList**,int );
char *preProcess(char **,int );
int genNullables(struct prodList**,int,char*);
int genFirst(struct prodList**,int,char*);
int genFollow(struct prodList**,int,char*);
_Bool isToken(char *,char *);
_Bool isNullable(char *,struct prodList**,int ,char *);
char *getNextSymbol(char *,int *);
_Bool isToken(char *,char *);
int indexOf(char *,struct prodList**,int );
char *addToSet(char *, char * , int *);
char *doUnion(char *, char *,int *);
int genParseTable(struct parseinfo *, struct prodList ** , int , char *);
int setAction(struct parseinfo *,char* , char *,char * );
int save(struct parseinfo );
char *removeFromSet(char* ,char *,int *);
char *clean(char *);