-
Notifications
You must be signed in to change notification settings - Fork 10
/
meta.txt
38 lines (30 loc) · 828 Bytes
/
meta.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
35
36
37
38
.syntax meta
arg = '$' {'emit_token();'}
| .string {'emit(' $ ');'};
output = '{' *arg '}' {'emit_nl();'};
exp3 = .id {'meta_' $ '();'}
| .string {'read_literal(' $ ');'}
| '.id' {'read_id();'}
| '.number' {'read_number();'}
| '.string' {'read_string();'}
| '(' exp1 ')'
| '.e' {'test_flag = 1;'}
| '*' {'do {'}
exp3 {'} while (test_flag);'}
{'test_flag = 1;'};
exp2 = ( exp3 {'if (test_flag) {'}
| output {'if (1) {'} )
*( exp3 {'error_if_false();'}
| output )
{'}'};
exp1 = {'do {'} exp2
*( '|' {'if (test_flag) { break; }'} exp2 )
{'} while (0);'};
stat = .id {'void meta_' $ '(void)'}
{'{'}
'=' exp1 ';'
{'}'};
program = '.syntax' .id {'#include "support.h"'}
*stat
'.end';
.end