-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrules
More file actions
170 lines (167 loc) · 8.88 KB
/
rules
File metadata and controls
170 lines (167 loc) · 8.88 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include "rules.h"
typedef enum { rule_block,rule_statement,rule_def,rule_include,rule_separator,rule_assignment,rule_funccall,rule_funcdec,rule_funcsign,rule_funcarguments,rule_argdec,rule_argument,rule_argname,rule_conditional,rule_condition,rule_declaration,rule_jump,rule_label,rule_expression,rule_chain,rule_math,rule_variable,rule_forloop,rule_whileloop,rule_dowhile,rule_enum,rule_enumcase,rule_struct,rule_decblock,rule_return,rule_interface,rule_intblock, num_grammar_rules } grammar_rules;
grammar_rule language_rules[num_grammar_rules] = {
[rule_block] = {{
{{ SYMRULE(statement,stat), SYMRULE(block,scope), },2},{{ SYMRULE(statement,stat), },1},
},2, sem_rule_scope},
[rule_statement] = {{
{{ SYMRULE(interface,interf), },1},
{{ SYMRULE(enum,enum), },1},
{{ SYMRULE(def,def), },1},
{{ SYMRULE(struct,struct), },1},
{{ SYMRULE(include,inc), },1},
{{ SYMRULE(dowhile,dowhile), TOKEN(SEMICOLON), },2},
{{ SYMRULE(funcdec,func), },1},
{{ TOKEN(LBRACE), SYMRULE(block,scope), TOKEN(RBRACE), },3},{{ TOKEN(LBRACE), TOKEN(RBRACE), },2},
{{ SYMRULE(forloop,for), },1},
{{ SYMRULE(whileloop,while), },1},
{{ SYMRULE(conditional,cond), },1},
{{ SYMRULE(jump,jmp), TOKEN(SEMICOLON), },2},
{{ SYMRULE(label,label), },1},
{{ SYMRULE(return,ret), TOKEN(SEMICOLON), },2},
{{ SYMRULE(assignment,assign), TOKEN(SEMICOLON), },2},
{{ SYMRULE(declaration,dec), TOKEN(SEMICOLON), },2},
{{ SYMRULE(funccall,call), TOKEN(SEMICOLON), },2},
},18, 0},
[rule_def] = {{
{{ LITERAL("defer"), SYMRULE(statement,exp), },2},
},1, sem_rule_def},
[rule_include] = {{
{{ LITTOK(SYMBOL,"@"), LITERAL("includeC"), TOKEN(LPAREN), SYMCHECK(CONST,inc), TOKEN(RPAREN), },5},
},1, sem_rule_inc},
[rule_separator] = {{
{{ TOKEN(SEMICOLON), },1},
{{ TOKEN(NEWLINE), },1},
},2, 0},
[rule_assignment] = {{
{{ SYMCHECK(IDENTIFIER,var), LITTOK(OPERATOR,"="), SYMRULE(expression,exp), },3},
},1, sem_rule_assign},
[rule_funccall] = {{
{{ SYMCHECK(IDENTIFIER,func), TOKEN(LPAREN), SYMRULE(argument,args), TOKEN(RPAREN), },4},{{ SYMCHECK(IDENTIFIER,func), TOKEN(LPAREN), TOKEN(RPAREN), },3},
},2, sem_rule_call},
[rule_funcdec] = {{
{{ SYMRULE(funcsign,func), TOKEN(LBRACE), SYMRULE(block,scope), TOKEN(RBRACE), },4},{{ SYMRULE(funcsign,func), TOKEN(LBRACE), TOKEN(RBRACE), },3},
},2, sem_rule_func},
[rule_funcsign] = {{
{{ SYMDEC(IDENTIFIER,type), SYMDEC(IDENTIFIER,name), SYMRULE(funcarguments,param), },3},{{ SYMDEC(IDENTIFIER,name), SYMRULE(funcarguments,param), },2},{{ SYMDEC(IDENTIFIER,type), SYMDEC(IDENTIFIER,name), },2},{{ SYMDEC(IDENTIFIER,name), },1},
},4, sem_rule_func},
[rule_funcarguments] = {{
{{ TOKEN(LPAREN), SYMRULE(argdec,param), TOKEN(RPAREN), },3},{{ TOKEN(LPAREN), TOKEN(RPAREN), },2},
},2, 0},
[rule_argdec] = {{
{{ SYMDEC(IDENTIFIER,type), SYMDEC(IDENTIFIER,name), TOKEN(COMMA), SYMRULE(argdec,param), },4},
{{ SYMDEC(IDENTIFIER,type), SYMDEC(IDENTIFIER,name), },2},
},2, sem_rule_param},
[rule_argument] = {{
{{ RULE(argname), SYMRULE(expression,exp), TOKEN(COMMA), SYMRULE(argument,args), },4},{{ SYMRULE(expression,exp), TOKEN(COMMA), SYMRULE(argument,args), },3},
{{ RULE(argname), SYMRULE(expression,exp), },2},{{ SYMRULE(expression,exp), },1},
},4, sem_rule_args},
[rule_argname] = {{
{{ TOKEN(IDENTIFIER), TOKEN(COLON), },2},
},1, 0},
[rule_conditional] = {{
{{ LITERAL("if"), SYMRULE(condition,cond), TOKEN(LBRACE), SYMRULE(block,scope), TOKEN(RBRACE), },5},{{ LITERAL("if"), SYMRULE(condition,cond), TOKEN(LBRACE), TOKEN(RBRACE), },4},
},2, sem_rule_cond},
[rule_condition] = {{
{{ TOKEN(LPAREN), SYMRULE(expression,cond), TOKEN(RPAREN), },3},
{{ SYMRULE(expression,cond), },1},
},2, 0},
[rule_declaration] = {{
{{ SYMDEC(IDENTIFIER,type), SYMDEC(IDENTIFIER,name), LITTOK(OPERATOR,"="), SYMRULE(expression,exp), },4},
{{ SYMDEC(IDENTIFIER,type), SYMDEC(IDENTIFIER,name), },2},
},2, sem_rule_dec},
[rule_jump] = {{
{{ LITERAL("goto"), SYMCHECK(IDENTIFIER,jmp), },2},
},1, sem_rule_jmp},
[rule_label] = {{
{{ SYMDEC(IDENTIFIER,name), TOKEN(COLON), },2},
},1, sem_rule_label},
[rule_expression] = {{
{{ SYMRULE(funccall,exp), },1},
{{ SYMRULE(chain,exp), },1},
{{ TOKEN(LPAREN), SYMRULE(expression,exp), TOKEN(RPAREN), },3},
{{ SYMRULE(math,exp), },1},
},4, 0},
[rule_chain] = {{
{{ SYMRULE(variable,var), SYMCHECK(DOT,op), SYMRULE(funccall,exp), },3},
{{ SYMRULE(variable,var), SYMCHECK(DOT,op), SYMCHECK(IDENTIFIER,exp), },3},
},2, sem_rule_var},
[rule_math] = {{
{{ SYMCHECK(CONST,val), SYMCHECK(OPERATOR,op), SYMRULE(expression,exp), },3},
{{ SYMRULE(variable,var), SYMCHECK(OPERATOR,op), SYMRULE(expression,exp), },3},
{{ SYMCHECK(CONST,val), },1},
{{ SYMRULE(variable,var), },1},
},4, sem_rule_exp},
[rule_variable] = {{
{{ SYMCHECK(IDENTIFIER,var), SYMCHECK(LBRACKET,op), SYMRULE(math,exp), TOKEN(RBRACKET), },4},
{{ SYMCHECK(IDENTIFIER,var), },1},
},2, sem_rule_var},
[rule_forloop] = {{
{{ LITERAL("for"), TOKEN(LPAREN), SYMRULE(declaration,dec), TOKEN(SEMICOLON), SYMRULE(condition,cond), TOKEN(SEMICOLON), SYMRULE(assignment,assign), TOKEN(RPAREN), TOKEN(LBRACE), SYMRULE(block,scope), TOKEN(RBRACE), },11},{{ LITERAL("for"), TOKEN(LPAREN), SYMRULE(declaration,dec), TOKEN(SEMICOLON), SYMRULE(condition,cond), TOKEN(SEMICOLON), SYMRULE(assignment,assign), TOKEN(RPAREN), TOKEN(LBRACE), TOKEN(RBRACE), },10},
},2, sem_rule_for},
[rule_whileloop] = {{
{{ LITERAL("while"), SYMRULE(condition,cond), TOKEN(LBRACE), SYMRULE(block,scope), TOKEN(RBRACE), },5},{{ LITERAL("while"), SYMRULE(condition,cond), TOKEN(LBRACE), TOKEN(RBRACE), },4},
},2, sem_rule_while},
[rule_dowhile] = {{
{{ LITERAL("do"), TOKEN(LBRACE), SYMRULE(block,scope), TOKEN(RBRACE), LITERAL("while"), SYMRULE(condition,cond), },6},{{ LITERAL("do"), TOKEN(LBRACE), TOKEN(RBRACE), LITERAL("while"), SYMRULE(condition,cond), },5},
},2, sem_rule_dowhile},
[rule_enum] = {{
{{ LITERAL("enum"), SYMDEC(IDENTIFIER,name), TOKEN(LBRACE), SYMRULE(enumcase,enum_case), TOKEN(RBRACE), },5},{{ LITERAL("enum"), SYMDEC(IDENTIFIER,name), TOKEN(LBRACE), TOKEN(RBRACE), },4},
},2, sem_rule_enum},
[rule_enumcase] = {{
{{ SYMDEC(IDENTIFIER,name), TOKEN(COMMA), SYMRULE(enumcase,enum_case), },3},{{ SYMDEC(IDENTIFIER,name), TOKEN(COMMA), },2},
{{ SYMDEC(IDENTIFIER,name), },1},
},3, sem_rule_enum_case},
[rule_struct] = {{
{{ LITERAL("struct"), SYMDEC(IDENTIFIER,name), TOKEN(LBRACE), SYMRULE(decblock,scope), TOKEN(RBRACE), },5},{{ LITERAL("struct"), SYMDEC(IDENTIFIER,name), TOKEN(LBRACE), TOKEN(RBRACE), },4},
{{ LITERAL("struct"), SYMDEC(IDENTIFIER,name), TOKEN(COLON), SYMDEC(IDENTIFIER,parent), TOKEN(LBRACE), SYMRULE(decblock,scope), TOKEN(RBRACE), },7},{{ LITERAL("struct"), SYMDEC(IDENTIFIER,name), TOKEN(COLON), TOKEN(LBRACE), SYMRULE(decblock,scope), TOKEN(RBRACE), },6},{{ LITERAL("struct"), SYMDEC(IDENTIFIER,name), TOKEN(COLON), SYMDEC(IDENTIFIER,parent), TOKEN(LBRACE), TOKEN(RBRACE), },6},{{ LITERAL("struct"), SYMDEC(IDENTIFIER,name), TOKEN(COLON), TOKEN(LBRACE), TOKEN(RBRACE), },5},
},6, sem_rule_struct},
[rule_decblock] = {{
{{ SYMRULE(declaration,dec), TOKEN(SEMICOLON), SYMRULE(decblock,scope), },3},{{ SYMRULE(declaration,dec), TOKEN(SEMICOLON), },2},
{{ SYMRULE(funcdec,func), SYMRULE(decblock,scope), },2},{{ SYMRULE(funcdec,func), },1},
},4, sem_rule_scope},
[rule_return] = {{
{{ LITERAL("return"), SYMRULE(expression,exp), },2},
},1, sem_rule_ret},
[rule_interface] = {{
{{ LITERAL("interface"), SYMDEC(IDENTIFIER,name), TOKEN(LBRACE), SYMRULE(intblock,scope), TOKEN(RBRACE), },5},{{ LITERAL("interface"), SYMDEC(IDENTIFIER,name), TOKEN(LBRACE), TOKEN(RBRACE), },4},
},2, sem_rule_interf},
[rule_intblock] = {{
{{ SYMRULE(declaration,dec), TOKEN(SEMICOLON), SYMRULE(intblock,scope), },3},{{ SYMRULE(declaration,dec), TOKEN(SEMICOLON), },2},
{{ SYMRULE(funcsign,func), TOKEN(SEMICOLON), SYMRULE(intblock,scope), },3},{{ SYMRULE(funcsign,func), TOKEN(SEMICOLON), },2},
},4, sem_rule_scope},
};
char* rule_names[num_grammar_rules] = {
[rule_block] = "block",
[rule_statement] = "statement",
[rule_def] = "def",
[rule_include] = "include",
[rule_separator] = "separator",
[rule_assignment] = "assignment",
[rule_funccall] = "funccall",
[rule_funcdec] = "funcdec",
[rule_funcsign] = "funcsign",
[rule_funcarguments] = "funcarguments",
[rule_argdec] = "argdec",
[rule_argument] = "argument",
[rule_argname] = "argname",
[rule_conditional] = "conditional",
[rule_condition] = "condition",
[rule_declaration] = "declaration",
[rule_jump] = "jump",
[rule_label] = "label",
[rule_expression] = "expression",
[rule_chain] = "chain",
[rule_math] = "math",
[rule_variable] = "variable",
[rule_forloop] = "forloop",
[rule_whileloop] = "whileloop",
[rule_dowhile] = "dowhile",
[rule_enum] = "enum",
[rule_enumcase] = "enumcase",
[rule_struct] = "struct",
[rule_decblock] = "decblock",
[rule_return] = "return",
[rule_interface] = "interface",
[rule_intblock] = "intblock",
};