-
Notifications
You must be signed in to change notification settings - Fork 1
/
parser.h
38 lines (36 loc) · 1.64 KB
/
parser.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
/*
-=-=-=-=-=-=-=-=-=-=-=-=-=
BATCH 26
-=-=-=-=-=-=-=-=-=-=-=-=-=
AAYUSH AHUJA 2010A7PS023P
MAYANK GUPTA 2010A7PS022P
-=-=-=-=-=-=-=-=-=-=-=-=-=
parser.h
-=-=-=-=-=-=-=-=-=-=-=-=-=
*/
#ifndef PARSER_H_INCLUDED
#define PARSER_H_INCLUDED
void createParseTable(grammar G[], Table T[][60], sets S[], int Gno);
parseTree parseInputSourceCode(int file, Table T[][60], keywordTable kt, grammar G[], bool*error, sets Set[]);
void printParseTree(parseTree PT, FILE *outfile);
symbol toSym(char *a, keywordTable nt);//return Symbol for given string
int createGrammar(FILE * fp,grammar G[], keywordTable nt);//load grammar from text file
void createSets(FILE * fp,sets S[], keywordTable nt);
void addNt(keywordTable nt, char *keyword, symbol s);//recursively called to add non-terminal to non-terminal Table
void initNt(keywordTable nt);//initialize non-terminals table
void initTable(Table T[][60]);//initialize parser table with no rule
void addtoTable(symbol nt, symbol t, int ruleno, Table T[][60]);//insert rule in table
bool isTerminal(symbol s);//returns true if given symbol is terminal
void printTable(FILE *fp, Table T[][60]);//print parser table
parseTree createParseNode(symbol s,int lineno);
struct stackNode* createStackNode(parseTree tree);
Stack push(Stack S,parseTree tree);
Stack pop(Stack S);
void initSets(sets S[],grammar G[], int Gno);
void firstSets(sets S[], grammar G[],symbol s, int Gno);
void printFirst(sets S[]);
void followSets(sets S[], grammar G[],symbol s, int Gno);
void copyTree(parseTree A , parseTree B);
parseTree createAbstractSyntaxTree(parseTree T);
void printAST(parseTree A, FILE *outFile, int *totalAllocatedMemory);
#endif // PARSER_H_INCLUDED