-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgrammar.js
More file actions
57 lines (56 loc) · 1.67 KB
/
Copy pathgrammar.js
File metadata and controls
57 lines (56 loc) · 1.67 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const bindings = require("./grammar/term-");
const types = require("./grammar/types");
const useClause = require("./grammar/use-clause");
const identifiers = require("./grammar/identifier");
const reserved = require("./grammar/reserved");
const watch = require("./grammar/watch");
const externals = require("./grammar/externals");
const conflicts = require("./grammar/conflicts");
module.exports = grammar({
name: "unison",
precedences: ($) => [
["_expression", "identifier"],
["term_definition", "_expression"],
["keyword", "_expression"],
["function_application", "operator"], // `myFn a b + c` is equivalent to `((myFn a) b) + c`
["_infix_op_application", "_prefix_function_application"],
["literal_function", "function_application"],
["_boolean_exp", "literal_function"],
["constructor_or_variable_pattern", "_lhs"],
],
conflicts,
externals,
extras: ($) => [/\\?\s/, $.comment],
rules: {
unison: ($) =>
choice(
seq(repeat($._top_item), $.namespace_pragma, repeat($._top_item)),
repeat($._top_item),
),
...reserved,
_top_item: ($) =>
choice(
$.watch_expression,
$.test_watch_expression,
$.type_declaration,
alias($.documented_binding, $.term_declaration),
alias($.binding, $.term_declaration),
$.fold,
$.documented_use_clause,
$.use_clause,
alias($.effect_declaration, $.ability_declaration),
),
namespace_pragma: ($) =>
prec.right(
seq(
$.kw_namespace,
alias($._identifier, $.namespace),
),
),
...bindings,
...types,
...useClause,
...identifiers,
...watch,
},
});