-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.h
62 lines (50 loc) · 1.53 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* GROUP 48:
PUNEET ANAND 2016B4A70487P
MAYANK JASORIA 2016B1A70703P
SHUBHAM TIWARI 2016B4A70935P
VIBHAV OSWAL 2016B4A70594P */
#ifndef _PARSER
#define _PARSER
#include "parserDef.h"
#define PRINT_FORMAT "%-15s:%-15s:%-25s:%-25s:%-25s:%-25s:%-20s"
/* NOTE: Function return types may need to be changed. Check and update as necessary */
/**
* Initializes the parser for use in future
* @param filename The file which contains the grammar rules
* that the parser should use for parsing
*/
void parserInit(char* filename);
/**
* Computes the first and follow sets for all non terminals
* the grammar rules
*/
void ComputeFirstAndFollowSets();
/**
* Creates the parse table using the grammar rules, and first and follow sets
*/
void createParseTable();
/**
* Parses the input source code and generates the parse tree.
* Also, reports any syntactical errors which are identified
* during the process
* @param testcaseFile The source code file
*/
void parseInputSourceCode(char *testcaseFile);
/**
* Writes the inorder traversal of the parse tree to a given file
* @param PT The root of the generated parse tree
*/
void printParseTree(Tree PT);
/**
* Computes and returns the size of the Parse Tree
*/
static inline int getParseTreeSize() {
return numNodes * (sizeof(treeNode) + sizeof(token));
}
/**
* Returns the number of nodes of the parse tree
*/
static inline int getParseTreeNumNodes() {
return numNodes;
}
#endif