-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrammar.js
40 lines (40 loc) · 1.1 KB
/
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
const base = require("./grammar/base");
const operation = require("./grammar/operation");
const closure = require("./grammar/closure");
module.exports = grammar({
name: "meson",
conflicts: ($) => [
[$._logic_unit, $.normal_command],
[$.variableunit, $._logic_unit],
[$.operatorunit, $._logic_unit],
[$.expression_statement],
[$.variableunit],
[$.pair, $.variableunit, $._logic_unit],
[$.operatorunit, $.variableunit, $._logic_unit],
[$.normal_command, $.variableunit, $._logic_unit],
[$.pair, $._logic_unit],
[$.listitem, $.expression_statement],
[$.list, $.variableunit],
[$._logic_unit],
],
extras: ($) => [$.comment, /\s/],
rules: {
//source_file: ($) => repeat($._command_invocation),
source_file: ($) => repeat($._unit),
_unit: ($) =>
seq(
choice(
$.expression_statement,
$.comment,
$.normal_command,
$.operatorunit,
$.if_condition,
$.foreach_command
)
),
...base,
...operation,
...closure,
comment: (_) => token(seq("#", /[^\n]+/)),
},
});