-
Notifications
You must be signed in to change notification settings - Fork 1
/
define.lime
37 lines (29 loc) · 1010 Bytes
/
define.lime
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
%namespace JavanileDefine
%class GrammarParser
%start start_stmt
%token '{'
%token '}'
%token ';'
%token ','
start_stmt = loads_stmt
.
loads_stmt = define_stmt
| loads_stmt define_stmt
.
define_stmt = DEFINE concept { $this->define($2); }
| DEFINE concept '{' instruction_list '}' { $this->define($2, [], $4); }
| DEFINE concept WITH concept_list { $this->define($2, $4); }
| DEFINE concept WITH concept_list '{' instruction_list '}' { $this->define($2, $4, $6); }
.
concept_list = { $$ = []; } concept { $$[] = $2; }
| concept_list ',' concept { $1[] = $3; $$ = $1; }
.
concept = LITERAL
| ROUTE
.
instruction_list = { $$ = []; } instruction ';' { $$[] = $2; }
| instruction_list instruction ';' { $1[] = $2; $$ = $1; }
.
instruction = { $$ = []; } concept { $$[] = $2; }
| instruction concept { $1[] = $2; $$ = $1; }
.