-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.txt
34 lines (27 loc) · 1.42 KB
/
bootstrap.txt
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
.syntax program
output = '{'
* ( '$' {'io.write(_input)'}
| .string {'io.write(' $ ')'})
'}' {'io.write("\\n")' };
primary = .id { $ '()' }
| .string {'_run.testSTR(' $ ')' }
| '.id' {'local _input = _run.parseID()' }
| '.number' {'local _input = _run.parseNUM()' }
| '.string' {'local _input = _run.parseSTR()' }
| '.empty' {'_switch = true' }
| '(' choice ')'
| '*' {'repeat -- repetition --' }
primary {'until not _switch -- repetition (end)'}
{'_switch = true' };
sequence = {'repeat -- sequence --' }
(primary {'if not _switch then break end'} | output)
* (primary {'if not _switch then error() end'} | output)
{'until true -- sequence (end)'};
choice = {'repeat -- choice --' }
sequence * ('|' {'if _switch then break end'} sequence)
{'until true -- choice (end)'};
rule = .id {'function ' $ '()'}
'=' choice ';' {'end -- (' $ ')' };
program = '.syntax' .id {'local _run = require("runtime")'}
* rule '.end' {$ '()' };
.end