-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsem_parser.h
executable file
·65 lines (52 loc) · 1.17 KB
/
sem_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
63
64
65
/* Compilers Project Group 2
// Aditya Raisinghani 2011A7PS042P
// Utkarsh Verma 2011A7PS137P
// BITS Pilani, Pilani Campus
// Second semester 2014
*/
#ifndef SEMP
#define SEMP
typedef struct _sem
{
flag isLeaf;
token leafName;
char* leafValue; //ID.entry, or NUM/RNUM/STR.val
nonTerminal nontermValue;
} sem;
typedef struct _semset *sems;
struct _semset
{
sem sem_value;
sems nextSem;
};
typedef struct _semrule *semrule;
typedef struct _semrule **semRuleArray;
typedef semrule semantics;
struct _semrule
{
int ruleNum;
choice isMakeNode_Leaf_Direct;
nonTerminal nonterm_value; //LHS
sems semanticsSet; //RHS.nonterms or leaf.
//hasEmpty nullable; //if ===NULL
//semrule nextRule;
//char* nodename //maybe reqd later.AST nodename
};
typedef sem astData;
typedef struct _astTree *astTree;
struct _astTree
{
astTree sisterNode;
astTree parentNode;
astTree childNode;
// char* name;
int ruleNum;
astData element;
termData data;
};
semrule readAndDefineSemanticRule(FILE *fp);
char* readNonTerm(char* term, char* rule, int ptr);
sem readLeafTerm(char* rule, int ptr);
sems getRHSnodes(char* ruleString, int ptr, choice _ch);
semRuleArray returnSemanticRules();
#endif