forked from coolsidd/Compiler-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar_structs.h
82 lines (78 loc) · 1.25 KB
/
grammar_structs.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
/* Header guard */
#ifndef GRAMMAR_STRUCT_H
#define GRAMMAR_STRUCT_H
/***************/
#include <stdio.h>
#include <string.h>
typedef enum { false, true } bool;
typedef enum { // list all the non terminals or terminals
arithmeticexpr,
assign_stmt,
assign_stmts,
decl_jagged,
decl_non_jagged,
decl_stmt,
decl_stmts,
declaration_type,
expr,
fact,
id_list,
index_list,
j2list,
j3list,
jagged2init,
jagged2list,
jagged3init,
jagged3list,
jagged_array,
list_of_identifiers,
main_program,
primitive_type,
range_list,
rect_array,
stmts,
term,
value_list,
var,
var_lhs,
AND,
ARRAY,
BOOLEAN,
COLON,
CONST,
CURLYCLOSE,
CURLYOPEN,
DECLARE,
DIV,
ELIPSIS,
EQUALS,
ID,
INTEGER,
JAGGED,
LIST,
LPAREN,
MINUS,
MULT,
OF,
OR,
PLUS,
PROGRAM,
R1,
REAL,
RPAREN,
SEMICOLON,
SIZE,
SQBC,
SQBO,
UNKNOWN,
VALUES,
VARIABLES,
} BaseSymbol;
typedef struct symbol { // symbol with info if it is terminal or not
bool is_terminal;
BaseSymbol s;
} Symbol;
Symbol toSymbol(char *enustr);
char *toStringSymbol(Symbol symb);
void printSymbol(Symbol symb);
#endif