-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar_parser.h
61 lines (47 loc) · 1.11 KB
/
grammar_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
/*
=======================================================================================================
PPL ASSIGNMENT 1 2020
GROUP NUMBER 14
RUSHIKESH ZAWAR 2017B1A70977P
SHREY SHAH 2017B2A71038P
ABHIMANYU SETHI 2017B3A70637P
PRANALI SANCHETI 2017B3A70736P
=======================================================================================================
*/#ifndef GRAMMARPARSER_H
#define GRAMMARPARSER_H
#include<stdbool.h>
#include<stdio.h>
#include "lexer.h"
#define MAX_RHSLEN 1000
#define MAXRULES 61
#define LEX_MAX_LEN 100
typedef enum
{
#include "nonTerminals.txt"
} nonterminal;
typedef struct{
union
{
token_name t;
nonterminal nt;
};
bool is_terminal;
} symbol;
typedef struct rhsnode
{
symbol* sym;
struct rhsnode *next;
} rhsnode;
typedef struct rhsnode *rhsnode_ptr;
typedef struct
{
nonterminal lhs;
rhsnode_ptr head;
rhsnode_ptr tail;
} cell;
cell grammar[MAXRULES];
symbol* sym_get(char str[]);
int search_exists(char* lexeme);
void insert_at_end(rhsnode_ptr *ptr_tail, symbol* sym);
void readGrammar(FILE *fptr, cell grammar[]);
#endif