-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.js
41 lines (38 loc) · 923 Bytes
/
grammar.js
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
module.exports = grammar({
name: 'corpus',
extras: _ => ['\r'],
externals: $ => [$.header_delimiter, $.delimiter],
rules: {
source_file: $ => repeat($.test_block),
test_block: $ =>
seq(
repeat('\n'),
$.header,
$.code,
$.delimiter,
optional('\n'),
$.syntax_tree,
),
header: $ =>
seq(
$.header_delimiter,
'\n',
$.header_text,
repeat1('\n'),
repeat(seq($.attribute, '\n')),
$.header_delimiter,
optional('\n'),
),
header_text: _ => /.+/,
attribute: $ =>
choice(
':skip',
':error',
':fail-fast',
seq(':language', '(', alias(/[^)]*/, $.language), ')'),
seq(':platform', '(', alias(/[^)]*/, $.platform), ')'),
),
code: _ => repeat1(seq(/[^\n]*/, '\n')),
syntax_tree: _ => repeat1(seq(/[^\n]*/, '\n')),
},
});