@willbooster/tree-sitter-haskell 8.0.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/grammar/decl.js +37 -40
- package/grammar/externals.js +1 -0
- package/grammar/literal.js +1 -0
- package/package.json +1 -1
- package/tree-sitter-haskell.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar/decl.js
CHANGED
|
@@ -5,6 +5,8 @@ const {
|
|
|
5
5
|
layout,
|
|
6
6
|
} = require('./util.js')
|
|
7
7
|
|
|
8
|
+
const foreignMacro = /[A-Z][A-Za-z_0-9]*/
|
|
9
|
+
|
|
8
10
|
const binding = ($, pattern) => prec('bind', seq(
|
|
9
11
|
choice(
|
|
10
12
|
field('pattern', pattern),
|
|
@@ -17,10 +19,6 @@ const binding = ($, pattern) => prec('bind', seq(
|
|
|
17
19
|
|
|
18
20
|
module.exports = {
|
|
19
21
|
|
|
20
|
-
// ------------------------------------------------------------------------
|
|
21
|
-
// fixity
|
|
22
|
-
// ------------------------------------------------------------------------
|
|
23
|
-
|
|
24
22
|
_fun_arrow_prec: _ => seq('-', '1'),
|
|
25
23
|
|
|
26
24
|
// GHC.Types special decl
|
|
@@ -39,10 +37,6 @@ module.exports = {
|
|
|
39
37
|
),
|
|
40
38
|
),
|
|
41
39
|
|
|
42
|
-
// ------------------------------------------------------------------------
|
|
43
|
-
// signature
|
|
44
|
-
// ------------------------------------------------------------------------
|
|
45
|
-
|
|
46
40
|
_con_binding_list: $ => sep2(',', field('name', $._con)),
|
|
47
41
|
|
|
48
42
|
_var_binding_list: $ => sep2(',', field('name', $._var)),
|
|
@@ -55,10 +49,6 @@ module.exports = {
|
|
|
55
49
|
$._type_annotation,
|
|
56
50
|
),
|
|
57
51
|
|
|
58
|
-
// ------------------------------------------------------------------------
|
|
59
|
-
// function and pattern bind
|
|
60
|
-
// ------------------------------------------------------------------------
|
|
61
|
-
|
|
62
52
|
_simple_bind_match: $ => seq('=', field('expression', $._exp)),
|
|
63
53
|
|
|
64
54
|
_bind_match: $ => seq(
|
|
@@ -91,14 +81,6 @@ module.exports = {
|
|
|
91
81
|
$._function_head_parens,
|
|
92
82
|
),
|
|
93
83
|
|
|
94
|
-
/**
|
|
95
|
-
* The difference between a `function` with an `infix` head and a `bind` with `pat_infix` is that the former is for
|
|
96
|
-
* _declaring_ a `varop` and the latter uses a `conop` to pattern match on the rhs expression.
|
|
97
|
-
* The former may not have a type annotation, while the latter may.
|
|
98
|
-
*
|
|
99
|
-
* > a <> b = undefined
|
|
100
|
-
* > h : t :: [Int] = undefined
|
|
101
|
-
*/
|
|
102
84
|
_function_head_infix: $ => seq(
|
|
103
85
|
field('left_operand', $.pattern),
|
|
104
86
|
optional($._cond_no_section_op),
|
|
@@ -118,10 +100,6 @@ module.exports = {
|
|
|
118
100
|
|
|
119
101
|
_binding_name_parens: $ => parens($, choice($._var, $._binding_name_parens)),
|
|
120
102
|
|
|
121
|
-
/**
|
|
122
|
-
* The `implicit_variable` here is for:
|
|
123
|
-
* g = let ?par = Impy 5 in f
|
|
124
|
-
*/
|
|
125
103
|
bind: $ => binding($, $._pat),
|
|
126
104
|
|
|
127
105
|
_module_bind: $ => binding($, $._binding_pat),
|
|
@@ -147,48 +125,67 @@ module.exports = {
|
|
|
147
125
|
|
|
148
126
|
_where_binds: $ => seq($._where, optional(field('binds', $.local_binds))),
|
|
149
127
|
|
|
150
|
-
|
|
151
|
-
// foreign
|
|
152
|
-
// ------------------------------------------------------------------------
|
|
153
|
-
|
|
154
|
-
calling_convention: _ => token(choice(
|
|
128
|
+
_foreign_calling_keyword: _ => token(choice(
|
|
155
129
|
'ccall',
|
|
156
130
|
'stdcall',
|
|
157
131
|
'capi',
|
|
158
132
|
'prim',
|
|
159
133
|
'javascript',
|
|
160
|
-
/[A-Z_]+/, // It's common in GHC to use a cpp #define for this
|
|
161
134
|
)),
|
|
162
135
|
|
|
163
|
-
|
|
136
|
+
_foreign_safety_keyword: _ => token(choice(
|
|
164
137
|
'unsafe',
|
|
165
138
|
'safe',
|
|
166
139
|
'interruptible',
|
|
167
140
|
)),
|
|
168
141
|
|
|
142
|
+
_foreign_macro: _ => token(prec(-1, foreignMacro)),
|
|
143
|
+
|
|
144
|
+
_foreign_underscore_identifier: _ => token(/_[A-Za-z_0-9]+/),
|
|
145
|
+
|
|
146
|
+
_foreign_calling_convention: $ => choice(
|
|
147
|
+
alias('_', $.calling_convention),
|
|
148
|
+
alias($._foreign_calling_keyword, $.calling_convention),
|
|
149
|
+
alias($._foreign_macro, $.calling_convention),
|
|
150
|
+
alias($._foreign_underscore_identifier, $.calling_convention),
|
|
151
|
+
),
|
|
152
|
+
|
|
153
|
+
_foreign_safety: $ => choice(
|
|
154
|
+
alias('_', $.safety),
|
|
155
|
+
alias($._foreign_safety_keyword, $.safety),
|
|
156
|
+
alias($._foreign_macro, $.safety),
|
|
157
|
+
alias($._foreign_underscore_identifier, $.safety),
|
|
158
|
+
),
|
|
159
|
+
|
|
160
|
+
_foreign_underscore_signature: $ => seq(
|
|
161
|
+
field('name', alias($._foreign_underscore_identifier, $.variable)),
|
|
162
|
+
$._type_annotation,
|
|
163
|
+
),
|
|
164
|
+
|
|
165
|
+
_foreign_signature: $ => choice(
|
|
166
|
+
$.signature,
|
|
167
|
+
alias($._foreign_underscore_signature, $.signature),
|
|
168
|
+
),
|
|
169
|
+
|
|
169
170
|
entity: $ => $.string,
|
|
170
171
|
|
|
171
172
|
foreign_import: $ => seq(
|
|
172
173
|
'foreign',
|
|
173
174
|
'import',
|
|
174
|
-
field('calling_convention', $.
|
|
175
|
-
optional(field('safety', $.
|
|
175
|
+
field('calling_convention', $._foreign_calling_convention),
|
|
176
|
+
optional(field('safety', $._foreign_safety)),
|
|
176
177
|
optional(field('entity', $.entity)),
|
|
177
|
-
field('signature', $.
|
|
178
|
+
field('signature', $._foreign_signature),
|
|
178
179
|
),
|
|
179
180
|
|
|
180
181
|
foreign_export: $ => seq(
|
|
181
182
|
'foreign',
|
|
182
183
|
'export',
|
|
183
|
-
field('calling_convention', $.
|
|
184
|
+
field('calling_convention', $._foreign_calling_convention),
|
|
184
185
|
optional(field('entity', $.entity)),
|
|
185
|
-
field('signature', $.
|
|
186
|
+
field('signature', $._foreign_signature),
|
|
186
187
|
),
|
|
187
188
|
|
|
188
|
-
// ------------------------------------------------------------------------
|
|
189
|
-
// default
|
|
190
|
-
// ------------------------------------------------------------------------
|
|
191
|
-
|
|
192
189
|
default_types: $ => seq('default', parens($, optional(sep1(',', field('type', $._ktype))))),
|
|
193
190
|
|
|
194
191
|
}
|
package/grammar/externals.js
CHANGED
|
@@ -170,6 +170,7 @@ module.exports = {
|
|
|
170
170
|
$._consym,
|
|
171
171
|
|
|
172
172
|
$._unboxed_label_start,
|
|
173
|
+
$._sized_integer,
|
|
173
174
|
|
|
174
175
|
// The newline is used as a dummy symbol that is emitted whenever the scanner has to update its state even though
|
|
175
176
|
// the current position must be parsed by the grammar.
|
package/grammar/literal.js
CHANGED
package/package.json
CHANGED
package/tree-sitter-haskell.wasm
CHANGED
|
Binary file
|