feelin 4.3.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.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +43 -0
  8. data/feelin.gemspec +22 -0
  9. data/lib/feelin/js/node_modules/.package-lock.json +67 -0
  10. data/lib/feelin/js/node_modules/@lezer/common/LICENSE +21 -0
  11. data/lib/feelin/js/node_modules/@lezer/common/README.md +14 -0
  12. data/lib/feelin/js/node_modules/@lezer/common/dist/index.cjs +2181 -0
  13. data/lib/feelin/js/node_modules/@lezer/common/dist/index.d.cts +1137 -0
  14. data/lib/feelin/js/node_modules/@lezer/common/dist/index.d.ts +1137 -0
  15. data/lib/feelin/js/node_modules/@lezer/common/dist/index.js +2168 -0
  16. data/lib/feelin/js/node_modules/@lezer/common/package.json +32 -0
  17. data/lib/feelin/js/node_modules/@lezer/highlight/LICENSE +21 -0
  18. data/lib/feelin/js/node_modules/@lezer/highlight/README.md +14 -0
  19. data/lib/feelin/js/node_modules/@lezer/highlight/dist/index.cjs +915 -0
  20. data/lib/feelin/js/node_modules/@lezer/highlight/dist/index.d.cts +621 -0
  21. data/lib/feelin/js/node_modules/@lezer/highlight/dist/index.d.ts +623 -0
  22. data/lib/feelin/js/node_modules/@lezer/highlight/dist/index.js +904 -0
  23. data/lib/feelin/js/node_modules/@lezer/highlight/package.json +31 -0
  24. data/lib/feelin/js/node_modules/@lezer/lr/LICENSE +21 -0
  25. data/lib/feelin/js/node_modules/@lezer/lr/README.md +25 -0
  26. data/lib/feelin/js/node_modules/@lezer/lr/dist/constants.d.ts +45 -0
  27. data/lib/feelin/js/node_modules/@lezer/lr/dist/constants.js +5 -0
  28. data/lib/feelin/js/node_modules/@lezer/lr/dist/index.cjs +1890 -0
  29. data/lib/feelin/js/node_modules/@lezer/lr/dist/index.d.cts +303 -0
  30. data/lib/feelin/js/node_modules/@lezer/lr/dist/index.d.ts +303 -0
  31. data/lib/feelin/js/node_modules/@lezer/lr/dist/index.js +1883 -0
  32. data/lib/feelin/js/node_modules/@lezer/lr/package.json +32 -0
  33. data/lib/feelin/js/node_modules/feelin/LICENSE +21 -0
  34. data/lib/feelin/js/node_modules/feelin/README.md +65 -0
  35. data/lib/feelin/js/node_modules/feelin/dist/builtins.d.ts +355 -0
  36. data/lib/feelin/js/node_modules/feelin/dist/index.cjs +2072 -0
  37. data/lib/feelin/js/node_modules/feelin/dist/index.cjs.map +1 -0
  38. data/lib/feelin/js/node_modules/feelin/dist/index.d.ts +3 -0
  39. data/lib/feelin/js/node_modules/feelin/dist/index.esm.js +2063 -0
  40. data/lib/feelin/js/node_modules/feelin/dist/index.esm.js.map +1 -0
  41. data/lib/feelin/js/node_modules/feelin/dist/interpreter.d.ts +26 -0
  42. data/lib/feelin/js/node_modules/feelin/dist/parser.d.ts +4 -0
  43. data/lib/feelin/js/node_modules/feelin/dist/temporal.d.ts +6 -0
  44. data/lib/feelin/js/node_modules/feelin/dist/types.d.ts +35 -0
  45. data/lib/feelin/js/node_modules/feelin/dist/utils.d.ts +12 -0
  46. data/lib/feelin/js/node_modules/feelin/package.json +63 -0
  47. data/lib/feelin/js/node_modules/lezer-feel/LICENSE +21 -0
  48. data/lib/feelin/js/node_modules/lezer-feel/README.md +94 -0
  49. data/lib/feelin/js/node_modules/lezer-feel/dist/index.cjs +1328 -0
  50. data/lib/feelin/js/node_modules/lezer-feel/dist/index.cjs.map +1 -0
  51. data/lib/feelin/js/node_modules/lezer-feel/dist/index.d.ts +32 -0
  52. data/lib/feelin/js/node_modules/lezer-feel/dist/index.js +1323 -0
  53. data/lib/feelin/js/node_modules/lezer-feel/dist/index.js.map +1 -0
  54. data/lib/feelin/js/node_modules/lezer-feel/package.json +61 -0
  55. data/lib/feelin/js/node_modules/luxon/LICENSE.md +7 -0
  56. data/lib/feelin/js/node_modules/luxon/README.md +55 -0
  57. data/lib/feelin/js/node_modules/luxon/build/amd/luxon.js +8623 -0
  58. data/lib/feelin/js/node_modules/luxon/build/amd/luxon.js.map +1 -0
  59. data/lib/feelin/js/node_modules/luxon/build/cjs-browser/luxon.js +8621 -0
  60. data/lib/feelin/js/node_modules/luxon/build/cjs-browser/luxon.js.map +1 -0
  61. data/lib/feelin/js/node_modules/luxon/build/es6/luxon.js +8011 -0
  62. data/lib/feelin/js/node_modules/luxon/build/es6/luxon.js.map +1 -0
  63. data/lib/feelin/js/node_modules/luxon/build/global/luxon.js +8626 -0
  64. data/lib/feelin/js/node_modules/luxon/build/global/luxon.js.map +1 -0
  65. data/lib/feelin/js/node_modules/luxon/build/global/luxon.min.js +1 -0
  66. data/lib/feelin/js/node_modules/luxon/build/global/luxon.min.js.map +1 -0
  67. data/lib/feelin/js/node_modules/luxon/build/node/luxon.js +7679 -0
  68. data/lib/feelin/js/node_modules/luxon/build/node/luxon.js.map +1 -0
  69. data/lib/feelin/js/node_modules/luxon/package.json +87 -0
  70. data/lib/feelin/js/node_modules/luxon/src/datetime.js +2566 -0
  71. data/lib/feelin/js/node_modules/luxon/src/duration.js +990 -0
  72. data/lib/feelin/js/node_modules/luxon/src/errors.js +61 -0
  73. data/lib/feelin/js/node_modules/luxon/src/impl/conversions.js +206 -0
  74. data/lib/feelin/js/node_modules/luxon/src/impl/diff.js +95 -0
  75. data/lib/feelin/js/node_modules/luxon/src/impl/digits.js +90 -0
  76. data/lib/feelin/js/node_modules/luxon/src/impl/english.js +233 -0
  77. data/lib/feelin/js/node_modules/luxon/src/impl/formats.js +176 -0
  78. data/lib/feelin/js/node_modules/luxon/src/impl/formatter.js +409 -0
  79. data/lib/feelin/js/node_modules/luxon/src/impl/invalid.js +14 -0
  80. data/lib/feelin/js/node_modules/luxon/src/impl/locale.js +554 -0
  81. data/lib/feelin/js/node_modules/luxon/src/impl/regexParser.js +335 -0
  82. data/lib/feelin/js/node_modules/luxon/src/impl/tokenParser.js +505 -0
  83. data/lib/feelin/js/node_modules/luxon/src/impl/util.js +316 -0
  84. data/lib/feelin/js/node_modules/luxon/src/impl/zoneUtil.js +34 -0
  85. data/lib/feelin/js/node_modules/luxon/src/info.js +205 -0
  86. data/lib/feelin/js/node_modules/luxon/src/interval.js +665 -0
  87. data/lib/feelin/js/node_modules/luxon/src/luxon.js +26 -0
  88. data/lib/feelin/js/node_modules/luxon/src/package.json +4 -0
  89. data/lib/feelin/js/node_modules/luxon/src/settings.js +180 -0
  90. data/lib/feelin/js/node_modules/luxon/src/zone.js +97 -0
  91. data/lib/feelin/js/node_modules/luxon/src/zones/IANAZone.js +231 -0
  92. data/lib/feelin/js/node_modules/luxon/src/zones/fixedOffsetZone.js +150 -0
  93. data/lib/feelin/js/node_modules/luxon/src/zones/invalidZone.js +53 -0
  94. data/lib/feelin/js/node_modules/luxon/src/zones/systemZone.js +61 -0
  95. data/lib/feelin/js/node_modules/min-dash/LICENSE +21 -0
  96. data/lib/feelin/js/node_modules/min-dash/README.md +38 -0
  97. data/lib/feelin/js/node_modules/min-dash/dist/array.d.ts +12 -0
  98. data/lib/feelin/js/node_modules/min-dash/dist/collection.d.ts +174 -0
  99. data/lib/feelin/js/node_modules/min-dash/dist/fn.d.ts +37 -0
  100. data/lib/feelin/js/node_modules/min-dash/dist/index.cjs +910 -0
  101. data/lib/feelin/js/node_modules/min-dash/dist/index.d.ts +5 -0
  102. data/lib/feelin/js/node_modules/min-dash/dist/index.esm.js +872 -0
  103. data/lib/feelin/js/node_modules/min-dash/dist/lang.d.ts +29 -0
  104. data/lib/feelin/js/node_modules/min-dash/dist/min-dash.js +916 -0
  105. data/lib/feelin/js/node_modules/min-dash/dist/min-dash.min.js +1 -0
  106. data/lib/feelin/js/node_modules/min-dash/dist/object.d.ts +112 -0
  107. data/lib/feelin/js/node_modules/min-dash/package.json +72 -0
  108. data/lib/feelin/js/package-lock.json +72 -0
  109. data/lib/feelin/js/package.json +5 -0
  110. data/lib/feelin/version.rb +3 -0
  111. data/lib/feelin.rb +63 -0
  112. data/spec/feelin/feelin_spec.rb +38 -0
  113. data/spec/spec_helper.rb +2 -0
  114. metadata +198 -0
@@ -0,0 +1,1137 @@
1
+ /**
2
+ The [`TreeFragment.applyChanges`](#common.TreeFragment^applyChanges)
3
+ method expects changed ranges in this format.
4
+ */
5
+ interface ChangedRange {
6
+ /**
7
+ The start of the change in the start document
8
+ */
9
+ fromA: number;
10
+ /**
11
+ The end of the change in the start document
12
+ */
13
+ toA: number;
14
+ /**
15
+ The start of the replacement in the new document
16
+ */
17
+ fromB: number;
18
+ /**
19
+ The end of the replacement in the new document
20
+ */
21
+ toB: number;
22
+ }
23
+ /**
24
+ Tree fragments are used during [incremental
25
+ parsing](#common.Parser.startParse) to track parts of old trees
26
+ that can be reused in a new parse. An array of fragments is used
27
+ to track regions of an old tree whose nodes might be reused in new
28
+ parses. Use the static
29
+ [`applyChanges`](#common.TreeFragment^applyChanges) method to
30
+ update fragments for document changes.
31
+ */
32
+ declare class TreeFragment {
33
+ /**
34
+ The start of the unchanged range pointed to by this fragment.
35
+ This refers to an offset in the _updated_ document (as opposed
36
+ to the original tree).
37
+ */
38
+ readonly from: number;
39
+ /**
40
+ The end of the unchanged range.
41
+ */
42
+ readonly to: number;
43
+ /**
44
+ The tree that this fragment is based on.
45
+ */
46
+ readonly tree: Tree;
47
+ /**
48
+ The offset between the fragment's tree and the document that
49
+ this fragment can be used against. Add this when going from
50
+ document to tree positions, subtract it to go from tree to
51
+ document positions.
52
+ */
53
+ readonly offset: number;
54
+ /**
55
+ Construct a tree fragment. You'll usually want to use
56
+ [`addTree`](#common.TreeFragment^addTree) and
57
+ [`applyChanges`](#common.TreeFragment^applyChanges) instead of
58
+ calling this directly.
59
+ */
60
+ constructor(
61
+ /**
62
+ The start of the unchanged range pointed to by this fragment.
63
+ This refers to an offset in the _updated_ document (as opposed
64
+ to the original tree).
65
+ */
66
+ from: number,
67
+ /**
68
+ The end of the unchanged range.
69
+ */
70
+ to: number,
71
+ /**
72
+ The tree that this fragment is based on.
73
+ */
74
+ tree: Tree,
75
+ /**
76
+ The offset between the fragment's tree and the document that
77
+ this fragment can be used against. Add this when going from
78
+ document to tree positions, subtract it to go from tree to
79
+ document positions.
80
+ */
81
+ offset: number, openStart?: boolean, openEnd?: boolean);
82
+ /**
83
+ Whether the start of the fragment represents the start of a
84
+ parse, or the end of a change. (In the second case, it may not
85
+ be safe to reuse some nodes at the start, depending on the
86
+ parsing algorithm.)
87
+ */
88
+ get openStart(): boolean;
89
+ /**
90
+ Whether the end of the fragment represents the end of a
91
+ full-document parse, or the start of a change.
92
+ */
93
+ get openEnd(): boolean;
94
+ /**
95
+ Create a set of fragments from a freshly parsed tree, or update
96
+ an existing set of fragments by replacing the ones that overlap
97
+ with a tree with content from the new tree. When `partial` is
98
+ true, the parse is treated as incomplete, and the resulting
99
+ fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
100
+ true.
101
+ */
102
+ static addTree(tree: Tree, fragments?: readonly TreeFragment[], partial?: boolean): readonly TreeFragment[];
103
+ /**
104
+ Apply a set of edits to an array of fragments, removing or
105
+ splitting fragments as necessary to remove edited ranges, and
106
+ adjusting offsets for fragments that moved.
107
+ */
108
+ static applyChanges(fragments: readonly TreeFragment[], changes: readonly ChangedRange[], minGap?: number): readonly TreeFragment[];
109
+ }
110
+ /**
111
+ Interface used to represent an in-progress parse, which can be
112
+ moved forward piece-by-piece.
113
+ */
114
+ interface PartialParse {
115
+ /**
116
+ Advance the parse state by some amount. Will return the finished
117
+ syntax tree when the parse completes.
118
+ */
119
+ advance(): Tree | null;
120
+ /**
121
+ The position up to which the document has been parsed. Note
122
+ that, in multi-pass parsers, this will stay back until the last
123
+ pass has moved past a given position.
124
+ */
125
+ readonly parsedPos: number;
126
+ /**
127
+ Tell the parse to not advance beyond the given position.
128
+ `advance` will return a tree when the parse has reached the
129
+ position. Note that, depending on the parser algorithm and the
130
+ state of the parse when `stopAt` was called, that tree may
131
+ contain nodes beyond the position. It is an error to call
132
+ `stopAt` with a higher position than it's [current
133
+ value](#common.PartialParse.stoppedAt).
134
+ */
135
+ stopAt(pos: number): void;
136
+ /**
137
+ Reports whether `stopAt` has been called on this parse.
138
+ */
139
+ readonly stoppedAt: number | null;
140
+ }
141
+ /**
142
+ A superclass that parsers should extend.
143
+ */
144
+ declare abstract class Parser {
145
+ /**
146
+ Start a parse for a single tree. This is the method concrete
147
+ parser implementations must implement. Called by `startParse`,
148
+ with the optional arguments resolved.
149
+ */
150
+ abstract createParse(input: Input, fragments: readonly TreeFragment[], ranges: readonly {
151
+ from: number;
152
+ to: number;
153
+ }[]): PartialParse;
154
+ /**
155
+ Start a parse, returning a [partial parse](#common.PartialParse)
156
+ object. [`fragments`](#common.TreeFragment) can be passed in to
157
+ make the parse incremental.
158
+
159
+ By default, the entire input is parsed. You can pass `ranges`,
160
+ which should be a sorted array of non-empty, non-overlapping
161
+ ranges, to parse only those ranges. The tree returned in that
162
+ case will start at `ranges[0].from`.
163
+ */
164
+ startParse(input: Input | string, fragments?: readonly TreeFragment[], ranges?: readonly {
165
+ from: number;
166
+ to: number;
167
+ }[]): PartialParse;
168
+ /**
169
+ Run a full parse, returning the resulting tree.
170
+ */
171
+ parse(input: Input | string, fragments?: readonly TreeFragment[], ranges?: readonly {
172
+ from: number;
173
+ to: number;
174
+ }[]): Tree;
175
+ }
176
+ /**
177
+ This is the interface parsers use to access the document. To run
178
+ Lezer directly on your own document data structure, you have to
179
+ write an implementation of it.
180
+ */
181
+ interface Input {
182
+ /**
183
+ The length of the document.
184
+ */
185
+ readonly length: number;
186
+ /**
187
+ Get the chunk after the given position. The returned string
188
+ should start at `from` and, if that isn't the end of the
189
+ document, may be of any length greater than zero.
190
+ */
191
+ chunk(from: number): string;
192
+ /**
193
+ Indicates whether the chunks already end at line breaks, so that
194
+ client code that wants to work by-line can avoid re-scanning
195
+ them for line breaks. When this is true, the result of `chunk()`
196
+ should either be a single line break, or the content between
197
+ `from` and the next line break.
198
+ */
199
+ readonly lineChunks: boolean;
200
+ /**
201
+ Read the part of the document between the given positions.
202
+ */
203
+ read(from: number, to: number): string;
204
+ }
205
+ /**
206
+ Parse wrapper functions are supported by some parsers to inject
207
+ additional parsing logic.
208
+ */
209
+ type ParseWrapper = (inner: PartialParse, input: Input, fragments: readonly TreeFragment[], ranges: readonly {
210
+ from: number;
211
+ to: number;
212
+ }[]) => PartialParse;
213
+
214
+ /**
215
+ The default maximum length of a `TreeBuffer` node.
216
+ */
217
+ declare const DefaultBufferLength = 1024;
218
+ /**
219
+ Each [node type](#common.NodeType) or [individual tree](#common.Tree)
220
+ can have metadata associated with it in props. Instances of this
221
+ class represent prop names.
222
+ */
223
+ declare class NodeProp<T> {
224
+ /**
225
+ Indicates whether this prop is stored per [node
226
+ type](#common.NodeType) or per [tree node](#common.Tree).
227
+ */
228
+ perNode: boolean;
229
+ /**
230
+ A method that deserializes a value of this prop from a string.
231
+ Can be used to allow a prop to be directly written in a grammar
232
+ file.
233
+ */
234
+ deserialize: (str: string) => T;
235
+ /**
236
+ Create a new node prop type.
237
+ */
238
+ constructor(config?: {
239
+ /**
240
+ The [deserialize](#common.NodeProp.deserialize) function to
241
+ use for this prop, used for example when directly providing
242
+ the prop from a grammar file. Defaults to a function that
243
+ raises an error.
244
+ */
245
+ deserialize?: (str: string) => T;
246
+ /**
247
+ By default, node props are stored in the [node
248
+ type](#common.NodeType). It can sometimes be useful to directly
249
+ store information (usually related to the parsing algorithm)
250
+ in [nodes](#common.Tree) themselves. Set this to true to enable
251
+ that for this prop.
252
+ */
253
+ perNode?: boolean;
254
+ });
255
+ /**
256
+ This is meant to be used with
257
+ [`NodeSet.extend`](#common.NodeSet.extend) or
258
+ [`LRParser.configure`](#lr.ParserConfig.props) to compute
259
+ prop values for each node type in the set. Takes a [match
260
+ object](#common.NodeType^match) or function that returns undefined
261
+ if the node type doesn't get this prop, and the prop's value if
262
+ it does.
263
+ */
264
+ add(match: {
265
+ [selector: string]: T;
266
+ } | ((type: NodeType) => T | undefined)): NodePropSource;
267
+ /**
268
+ Prop that is used to describe matching delimiters. For opening
269
+ delimiters, this holds an array of node names (written as a
270
+ space-separated string when declaring this prop in a grammar)
271
+ for the node types of closing delimiters that match it.
272
+ */
273
+ static closedBy: NodeProp<readonly string[]>;
274
+ /**
275
+ The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
276
+ attached to closing delimiters, holding an array of node names
277
+ of types of matching opening delimiters.
278
+ */
279
+ static openedBy: NodeProp<readonly string[]>;
280
+ /**
281
+ Used to assign node types to groups (for example, all node
282
+ types that represent an expression could be tagged with an
283
+ `"Expression"` group).
284
+ */
285
+ static group: NodeProp<readonly string[]>;
286
+ /**
287
+ Attached to nodes to indicate these should be
288
+ [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
289
+ in a bidirectional text isolate, so that direction-neutral
290
+ characters on their sides don't incorrectly get associated with
291
+ surrounding text. You'll generally want to set this for nodes
292
+ that contain arbitrary text, like strings and comments, and for
293
+ nodes that appear _inside_ arbitrary text, like HTML tags. When
294
+ not given a value, in a grammar declaration, defaults to
295
+ `"auto"`.
296
+ */
297
+ static isolate: NodeProp<"rtl" | "ltr" | "auto">;
298
+ /**
299
+ The hash of the [context](#lr.ContextTracker.constructor)
300
+ that the node was parsed in, if any. Used to limit reuse of
301
+ contextual nodes.
302
+ */
303
+ static contextHash: NodeProp<number>;
304
+ /**
305
+ The distance beyond the end of the node that the tokenizer
306
+ looked ahead for any of the tokens inside the node. (The LR
307
+ parser only stores this when it is larger than 25, for
308
+ efficiency reasons.)
309
+ */
310
+ static lookAhead: NodeProp<number>;
311
+ /**
312
+ This per-node prop is used to replace a given node, or part of a
313
+ node, with another tree. This is useful to include trees from
314
+ different languages in mixed-language parsers.
315
+ */
316
+ static mounted: NodeProp<MountedTree>;
317
+ }
318
+ /**
319
+ A mounted tree, which can be [stored](#common.NodeProp^mounted) on
320
+ a tree node to indicate that parts of its content are
321
+ represented by another tree.
322
+ */
323
+ declare class MountedTree {
324
+ /**
325
+ The inner tree.
326
+ */
327
+ readonly tree: Tree;
328
+ /**
329
+ If this is null, this tree replaces the entire node (it will
330
+ be included in the regular iteration instead of its host
331
+ node). If not, only the given ranges are considered to be
332
+ covered by this tree. This is used for trees that are mixed in
333
+ a way that isn't strictly hierarchical. Such mounted trees are
334
+ only entered by [`resolveInner`](#common.Tree.resolveInner)
335
+ and [`enter`](#common.SyntaxNode.enter).
336
+ */
337
+ readonly overlay: readonly {
338
+ from: number;
339
+ to: number;
340
+ }[] | null;
341
+ /**
342
+ The parser used to create this subtree.
343
+ */
344
+ readonly parser: Parser;
345
+ constructor(
346
+ /**
347
+ The inner tree.
348
+ */
349
+ tree: Tree,
350
+ /**
351
+ If this is null, this tree replaces the entire node (it will
352
+ be included in the regular iteration instead of its host
353
+ node). If not, only the given ranges are considered to be
354
+ covered by this tree. This is used for trees that are mixed in
355
+ a way that isn't strictly hierarchical. Such mounted trees are
356
+ only entered by [`resolveInner`](#common.Tree.resolveInner)
357
+ and [`enter`](#common.SyntaxNode.enter).
358
+ */
359
+ overlay: readonly {
360
+ from: number;
361
+ to: number;
362
+ }[] | null,
363
+ /**
364
+ The parser used to create this subtree.
365
+ */
366
+ parser: Parser);
367
+ }
368
+ /**
369
+ Type returned by [`NodeProp.add`](#common.NodeProp.add). Describes
370
+ whether a prop should be added to a given node type in a node set,
371
+ and what value it should have.
372
+ */
373
+ type NodePropSource = (type: NodeType) => null | [NodeProp<any>, any];
374
+ /**
375
+ Each node in a syntax tree has a node type associated with it.
376
+ */
377
+ declare class NodeType {
378
+ /**
379
+ The name of the node type. Not necessarily unique, but if the
380
+ grammar was written properly, different node types with the
381
+ same name within a node set should play the same semantic
382
+ role.
383
+ */
384
+ readonly name: string;
385
+ /**
386
+ The id of this node in its set. Corresponds to the term ids
387
+ used in the parser.
388
+ */
389
+ readonly id: number;
390
+ /**
391
+ Define a node type.
392
+ */
393
+ static define(spec: {
394
+ /**
395
+ The ID of the node type. When this type is used in a
396
+ [set](#common.NodeSet), the ID must correspond to its index in
397
+ the type array.
398
+ */
399
+ id: number;
400
+ /**
401
+ The name of the node type. Leave empty to define an anonymous
402
+ node.
403
+ */
404
+ name?: string;
405
+ /**
406
+ [Node props](#common.NodeProp) to assign to the type. The value
407
+ given for any given prop should correspond to the prop's type.
408
+ */
409
+ props?: readonly ([NodeProp<any>, any] | NodePropSource)[];
410
+ /**
411
+ Whether this is a [top node](#common.NodeType.isTop).
412
+ */
413
+ top?: boolean;
414
+ /**
415
+ Whether this node counts as an [error
416
+ node](#common.NodeType.isError).
417
+ */
418
+ error?: boolean;
419
+ /**
420
+ Whether this node is a [skipped](#common.NodeType.isSkipped)
421
+ node.
422
+ */
423
+ skipped?: boolean;
424
+ }): NodeType;
425
+ /**
426
+ Retrieves a node prop for this type. Will return `undefined` if
427
+ the prop isn't present on this node.
428
+ */
429
+ prop<T>(prop: NodeProp<T>): T | undefined;
430
+ /**
431
+ True when this is the top node of a grammar.
432
+ */
433
+ get isTop(): boolean;
434
+ /**
435
+ True when this node is produced by a skip rule.
436
+ */
437
+ get isSkipped(): boolean;
438
+ /**
439
+ Indicates whether this is an error node.
440
+ */
441
+ get isError(): boolean;
442
+ /**
443
+ When true, this node type doesn't correspond to a user-declared
444
+ named node, for example because it is used to cache repetition.
445
+ */
446
+ get isAnonymous(): boolean;
447
+ /**
448
+ Returns true when this node's name or one of its
449
+ [groups](#common.NodeProp^group) matches the given string.
450
+ */
451
+ is(name: string | number): boolean;
452
+ /**
453
+ An empty dummy node type to use when no actual type is available.
454
+ */
455
+ static none: NodeType;
456
+ /**
457
+ Create a function from node types to arbitrary values by
458
+ specifying an object whose property names are node or
459
+ [group](#common.NodeProp^group) names. Often useful with
460
+ [`NodeProp.add`](#common.NodeProp.add). You can put multiple
461
+ names, separated by spaces, in a single property name to map
462
+ multiple node names to a single value.
463
+ */
464
+ static match<T>(map: {
465
+ [selector: string]: T;
466
+ }): (node: NodeType) => T | undefined;
467
+ }
468
+ /**
469
+ A node set holds a collection of node types. It is used to
470
+ compactly represent trees by storing their type ids, rather than a
471
+ full pointer to the type object, in a numeric array. Each parser
472
+ [has](#lr.LRParser.nodeSet) a node set, and [tree
473
+ buffers](#common.TreeBuffer) can only store collections of nodes
474
+ from the same set. A set can have a maximum of 2**16 (65536) node
475
+ types in it, so that the ids fit into 16-bit typed array slots.
476
+ */
477
+ declare class NodeSet {
478
+ /**
479
+ The node types in this set, by id.
480
+ */
481
+ readonly types: readonly NodeType[];
482
+ /**
483
+ Create a set with the given types. The `id` property of each
484
+ type should correspond to its position within the array.
485
+ */
486
+ constructor(
487
+ /**
488
+ The node types in this set, by id.
489
+ */
490
+ types: readonly NodeType[]);
491
+ /**
492
+ Create a copy of this set with some node properties added. The
493
+ arguments to this method can be created with
494
+ [`NodeProp.add`](#common.NodeProp.add).
495
+ */
496
+ extend(...props: NodePropSource[]): NodeSet;
497
+ }
498
+ /**
499
+ Options that control iteration. Can be combined with the `|`
500
+ operator to enable multiple ones.
501
+ */
502
+ declare enum IterMode {
503
+ /**
504
+ When enabled, iteration will only visit [`Tree`](#common.Tree)
505
+ objects, not nodes packed into
506
+ [`TreeBuffer`](#common.TreeBuffer)s.
507
+ */
508
+ ExcludeBuffers = 1,
509
+ /**
510
+ Enable this to make iteration include anonymous nodes (such as
511
+ the nodes that wrap repeated grammar constructs into a balanced
512
+ tree).
513
+ */
514
+ IncludeAnonymous = 2,
515
+ /**
516
+ By default, regular [mounted](#common.NodeProp^mounted) nodes
517
+ replace their base node in iteration. Enable this to ignore them
518
+ instead.
519
+ */
520
+ IgnoreMounts = 4,
521
+ /**
522
+ This option only applies in
523
+ [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
524
+ library to not enter mounted overlays if one covers the given
525
+ position.
526
+ */
527
+ IgnoreOverlays = 8
528
+ }
529
+ /**
530
+ A piece of syntax tree. There are two ways to approach these
531
+ trees: the way they are actually stored in memory, and the
532
+ convenient way.
533
+
534
+ Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
535
+ objects. By packing detail information into `TreeBuffer` leaf
536
+ nodes, the representation is made a lot more memory-efficient.
537
+
538
+ However, when you want to actually work with tree nodes, this
539
+ representation is very awkward, so most client code will want to
540
+ use the [`TreeCursor`](#common.TreeCursor) or
541
+ [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
542
+ a view on some part of this data structure, and can be used to
543
+ move around to adjacent nodes.
544
+ */
545
+ declare class Tree {
546
+ /**
547
+ The type of the top node.
548
+ */
549
+ readonly type: NodeType;
550
+ /**
551
+ This node's child nodes.
552
+ */
553
+ readonly children: readonly (Tree | TreeBuffer)[];
554
+ /**
555
+ The positions (offsets relative to the start of this tree) of
556
+ the children.
557
+ */
558
+ readonly positions: readonly number[];
559
+ /**
560
+ The total length of this tree
561
+ */
562
+ readonly length: number;
563
+ /**
564
+ Construct a new tree. See also [`Tree.build`](#common.Tree^build).
565
+ */
566
+ constructor(
567
+ /**
568
+ The type of the top node.
569
+ */
570
+ type: NodeType,
571
+ /**
572
+ This node's child nodes.
573
+ */
574
+ children: readonly (Tree | TreeBuffer)[],
575
+ /**
576
+ The positions (offsets relative to the start of this tree) of
577
+ the children.
578
+ */
579
+ positions: readonly number[],
580
+ /**
581
+ The total length of this tree
582
+ */
583
+ length: number,
584
+ /**
585
+ Per-node [node props](#common.NodeProp) to associate with this node.
586
+ */
587
+ props?: readonly [NodeProp<any> | number, any][]);
588
+ /**
589
+ The empty tree
590
+ */
591
+ static empty: Tree;
592
+ /**
593
+ Get a [tree cursor](#common.TreeCursor) positioned at the top of
594
+ the tree. Mode can be used to [control](#common.IterMode) which
595
+ nodes the cursor visits.
596
+ */
597
+ cursor(mode?: IterMode): TreeCursor;
598
+ /**
599
+ Get a [tree cursor](#common.TreeCursor) pointing into this tree
600
+ at the given position and side (see
601
+ [`moveTo`](#common.TreeCursor.moveTo).
602
+ */
603
+ cursorAt(pos: number, side?: -1 | 0 | 1, mode?: IterMode): TreeCursor;
604
+ /**
605
+ Get a [syntax node](#common.SyntaxNode) object for the top of the
606
+ tree.
607
+ */
608
+ get topNode(): SyntaxNode;
609
+ /**
610
+ Get the [syntax node](#common.SyntaxNode) at the given position.
611
+ If `side` is -1, this will move into nodes that end at the
612
+ position. If 1, it'll move into nodes that start at the
613
+ position. With 0, it'll only enter nodes that cover the position
614
+ from both sides.
615
+
616
+ Note that this will not enter
617
+ [overlays](#common.MountedTree.overlay), and you often want
618
+ [`resolveInner`](#common.Tree.resolveInner) instead.
619
+ */
620
+ resolve(pos: number, side?: -1 | 0 | 1): SyntaxNode;
621
+ /**
622
+ Like [`resolve`](#common.Tree.resolve), but will enter
623
+ [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
624
+ pointing into the innermost overlaid tree at the given position
625
+ (with parent links going through all parent structure, including
626
+ the host trees).
627
+ */
628
+ resolveInner(pos: number, side?: -1 | 0 | 1): SyntaxNode;
629
+ /**
630
+ In some situations, it can be useful to iterate through all
631
+ nodes around a position, including those in overlays that don't
632
+ directly cover the position. This method gives you an iterator
633
+ that will produce all nodes, from small to big, around the given
634
+ position.
635
+ */
636
+ resolveStack(pos: number, side?: -1 | 0 | 1): NodeIterator;
637
+ /**
638
+ Iterate over the tree and its children, calling `enter` for any
639
+ node that touches the `from`/`to` region (if given) before
640
+ running over such a node's children, and `leave` (if given) when
641
+ leaving the node. When `enter` returns `false`, that node will
642
+ not have its children iterated over (or `leave` called).
643
+ */
644
+ iterate(spec: {
645
+ enter(node: SyntaxNodeRef): boolean | void;
646
+ leave?(node: SyntaxNodeRef): void;
647
+ from?: number;
648
+ to?: number;
649
+ mode?: IterMode;
650
+ }): void;
651
+ /**
652
+ Get the value of the given [node prop](#common.NodeProp) for this
653
+ node. Works with both per-node and per-type props.
654
+ */
655
+ prop<T>(prop: NodeProp<T>): T | undefined;
656
+ /**
657
+ Returns the node's [per-node props](#common.NodeProp.perNode) in a
658
+ format that can be passed to the [`Tree`](#common.Tree)
659
+ constructor.
660
+ */
661
+ get propValues(): readonly [NodeProp<any> | number, any][];
662
+ /**
663
+ Balance the direct children of this tree, producing a copy of
664
+ which may have children grouped into subtrees with type
665
+ [`NodeType.none`](#common.NodeType^none).
666
+ */
667
+ balance(config?: {
668
+ /**
669
+ Function to create the newly balanced subtrees.
670
+ */
671
+ makeTree?: (children: readonly (Tree | TreeBuffer)[], positions: readonly number[], length: number) => Tree;
672
+ }): Tree;
673
+ /**
674
+ Build a tree from a postfix-ordered buffer of node information,
675
+ or a cursor over such a buffer.
676
+ */
677
+ static build(data: BuildData): Tree;
678
+ }
679
+ /**
680
+ Represents a sequence of nodes.
681
+ */
682
+ type NodeIterator = {
683
+ node: SyntaxNode;
684
+ next: NodeIterator | null;
685
+ };
686
+ type BuildData = {
687
+ /**
688
+ The buffer or buffer cursor to read the node data from.
689
+
690
+ When this is an array, it should contain four values for every
691
+ node in the tree.
692
+
693
+ - The first holds the node's type, as a node ID pointing into
694
+ the given `NodeSet`.
695
+ - The second holds the node's start offset.
696
+ - The third the end offset.
697
+ - The fourth the amount of space taken up in the array by this
698
+ node and its children. Since there's four values per node,
699
+ this is the total number of nodes inside this node (children
700
+ and transitive children) plus one for the node itself, times
701
+ four.
702
+
703
+ Parent nodes should appear _after_ child nodes in the array. As
704
+ an example, a node of type 10 spanning positions 0 to 4, with
705
+ two children, of type 11 and 12, might look like this:
706
+
707
+ [11, 0, 1, 4, 12, 2, 4, 4, 10, 0, 4, 12]
708
+ */
709
+ buffer: BufferCursor | readonly number[];
710
+ /**
711
+ The node types to use.
712
+ */
713
+ nodeSet: NodeSet;
714
+ /**
715
+ The id of the top node type.
716
+ */
717
+ topID: number;
718
+ /**
719
+ The position the tree should start at. Defaults to 0.
720
+ */
721
+ start?: number;
722
+ /**
723
+ The position in the buffer where the function should stop
724
+ reading. Defaults to 0.
725
+ */
726
+ bufferStart?: number;
727
+ /**
728
+ The length of the wrapping node. The end offset of the last
729
+ child is used when not provided.
730
+ */
731
+ length?: number;
732
+ /**
733
+ The maximum buffer length to use. Defaults to
734
+ [`DefaultBufferLength`](#common.DefaultBufferLength).
735
+ */
736
+ maxBufferLength?: number;
737
+ /**
738
+ An optional array holding reused nodes that the buffer can refer
739
+ to.
740
+ */
741
+ reused?: readonly Tree[];
742
+ /**
743
+ The first node type that indicates repeat constructs in this
744
+ grammar.
745
+ */
746
+ minRepeatType?: number;
747
+ };
748
+ /**
749
+ This is used by `Tree.build` as an abstraction for iterating over
750
+ a tree buffer. A cursor initially points at the very last element
751
+ in the buffer. Every time `next()` is called it moves on to the
752
+ previous one.
753
+ */
754
+ interface BufferCursor {
755
+ /**
756
+ The current buffer position (four times the number of nodes
757
+ remaining).
758
+ */
759
+ pos: number;
760
+ /**
761
+ The node ID of the next node in the buffer.
762
+ */
763
+ id: number;
764
+ /**
765
+ The start position of the next node in the buffer.
766
+ */
767
+ start: number;
768
+ /**
769
+ The end position of the next node.
770
+ */
771
+ end: number;
772
+ /**
773
+ The size of the next node (the number of nodes inside, counting
774
+ the node itself, times 4).
775
+ */
776
+ size: number;
777
+ /**
778
+ Moves `this.pos` down by 4.
779
+ */
780
+ next(): void;
781
+ /**
782
+ Create a copy of this cursor.
783
+ */
784
+ fork(): BufferCursor;
785
+ }
786
+ /**
787
+ Tree buffers contain (type, start, end, endIndex) quads for each
788
+ node. In such a buffer, nodes are stored in prefix order (parents
789
+ before children, with the endIndex of the parent indicating which
790
+ children belong to it).
791
+ */
792
+ declare class TreeBuffer {
793
+ /**
794
+ The buffer's content.
795
+ */
796
+ readonly buffer: Uint16Array;
797
+ /**
798
+ The total length of the group of nodes in the buffer.
799
+ */
800
+ readonly length: number;
801
+ /**
802
+ The node set used in this buffer.
803
+ */
804
+ readonly set: NodeSet;
805
+ /**
806
+ Create a tree buffer.
807
+ */
808
+ constructor(
809
+ /**
810
+ The buffer's content.
811
+ */
812
+ buffer: Uint16Array,
813
+ /**
814
+ The total length of the group of nodes in the buffer.
815
+ */
816
+ length: number,
817
+ /**
818
+ The node set used in this buffer.
819
+ */
820
+ set: NodeSet);
821
+ }
822
+ /**
823
+ The set of properties provided by both [`SyntaxNode`](#common.SyntaxNode)
824
+ and [`TreeCursor`](#common.TreeCursor). Note that, if you need
825
+ an object that is guaranteed to stay stable in the future, you
826
+ need to use the [`node`](#common.SyntaxNodeRef.node) accessor.
827
+ */
828
+ interface SyntaxNodeRef {
829
+ /**
830
+ The start position of the node.
831
+ */
832
+ readonly from: number;
833
+ /**
834
+ The end position of the node.
835
+ */
836
+ readonly to: number;
837
+ /**
838
+ The type of the node.
839
+ */
840
+ readonly type: NodeType;
841
+ /**
842
+ The name of the node (`.type.name`).
843
+ */
844
+ readonly name: string;
845
+ /**
846
+ Get the [tree](#common.Tree) that represents the current node,
847
+ if any. Will return null when the node is in a [tree
848
+ buffer](#common.TreeBuffer).
849
+ */
850
+ readonly tree: Tree | null;
851
+ /**
852
+ Retrieve a stable [syntax node](#common.SyntaxNode) at this
853
+ position.
854
+ */
855
+ readonly node: SyntaxNode;
856
+ /**
857
+ Test whether the node matches a given context—a sequence of
858
+ direct parent nodes. Empty strings in the context array act as
859
+ wildcards, other strings must match the ancestor node's name.
860
+ */
861
+ matchContext(context: readonly string[]): boolean;
862
+ }
863
+ /**
864
+ A syntax node provides an immutable pointer to a given node in a
865
+ tree. When iterating over large amounts of nodes, you may want to
866
+ use a mutable [cursor](#common.TreeCursor) instead, which is more
867
+ efficient.
868
+ */
869
+ interface SyntaxNode extends SyntaxNodeRef {
870
+ /**
871
+ The node's parent node, if any.
872
+ */
873
+ parent: SyntaxNode | null;
874
+ /**
875
+ The first child, if the node has children.
876
+ */
877
+ firstChild: SyntaxNode | null;
878
+ /**
879
+ The node's last child, if available.
880
+ */
881
+ lastChild: SyntaxNode | null;
882
+ /**
883
+ The first child that ends after `pos`.
884
+ */
885
+ childAfter(pos: number): SyntaxNode | null;
886
+ /**
887
+ The last child that starts before `pos`.
888
+ */
889
+ childBefore(pos: number): SyntaxNode | null;
890
+ /**
891
+ Enter the child at the given position. If side is -1 the child
892
+ may end at that position, when 1 it may start there.
893
+
894
+ This will by default enter
895
+ [overlaid](#common.MountedTree.overlay)
896
+ [mounted](#common.NodeProp^mounted) trees. You can set
897
+ `overlays` to false to disable that.
898
+
899
+ Similarly, when `buffers` is false this will not enter
900
+ [buffers](#common.TreeBuffer), only [nodes](#common.Tree) (which
901
+ is mostly useful when looking for props, which cannot exist on
902
+ buffer-allocated nodes).
903
+ */
904
+ enter(pos: number, side: -1 | 0 | 1, mode?: IterMode): SyntaxNode | null;
905
+ /**
906
+ This node's next sibling, if any.
907
+ */
908
+ nextSibling: SyntaxNode | null;
909
+ /**
910
+ This node's previous sibling.
911
+ */
912
+ prevSibling: SyntaxNode | null;
913
+ /**
914
+ A [tree cursor](#common.TreeCursor) starting at this node.
915
+ */
916
+ cursor(mode?: IterMode): TreeCursor;
917
+ /**
918
+ Find the node around, before (if `side` is -1), or after (`side`
919
+ is 1) the given position. Will look in parent nodes if the
920
+ position is outside this node.
921
+ */
922
+ resolve(pos: number, side?: -1 | 0 | 1): SyntaxNode;
923
+ /**
924
+ Similar to `resolve`, but enter
925
+ [overlaid](#common.MountedTree.overlay) nodes.
926
+ */
927
+ resolveInner(pos: number, side?: -1 | 0 | 1): SyntaxNode;
928
+ /**
929
+ Move the position to the innermost node before `pos` that looks
930
+ like it is unfinished (meaning it ends in an error node or has a
931
+ child ending in an error node right at its end).
932
+ */
933
+ enterUnfinishedNodesBefore(pos: number): SyntaxNode;
934
+ /**
935
+ Get a [tree](#common.Tree) for this node. Will allocate one if it
936
+ points into a buffer.
937
+ */
938
+ toTree(): Tree;
939
+ /**
940
+ Get the first child of the given type (which may be a [node
941
+ name](#common.NodeType.name) or a [group
942
+ name](#common.NodeProp^group)). If `before` is non-null, only
943
+ return children that occur somewhere after a node with that name
944
+ or group. If `after` is non-null, only return children that
945
+ occur somewhere before a node with that name or group.
946
+ */
947
+ getChild(type: string | number, before?: string | number | null, after?: string | number | null): SyntaxNode | null;
948
+ /**
949
+ Like [`getChild`](#common.SyntaxNode.getChild), but return all
950
+ matching children, not just the first.
951
+ */
952
+ getChildren(type: string | number, before?: string | number | null, after?: string | number | null): SyntaxNode[];
953
+ }
954
+ /**
955
+ A tree cursor object focuses on a given node in a syntax tree, and
956
+ allows you to move to adjacent nodes.
957
+ */
958
+ declare class TreeCursor implements SyntaxNodeRef {
959
+ /**
960
+ The node's type.
961
+ */
962
+ type: NodeType;
963
+ /**
964
+ Shorthand for `.type.name`.
965
+ */
966
+ get name(): string;
967
+ /**
968
+ The start source offset of this node.
969
+ */
970
+ from: number;
971
+ /**
972
+ The end source offset.
973
+ */
974
+ to: number;
975
+ private stack;
976
+ private bufferNode;
977
+ private yieldNode;
978
+ private yieldBuf;
979
+ /**
980
+ Move the cursor to this node's first child. When this returns
981
+ false, the node has no child, and the cursor has not been moved.
982
+ */
983
+ firstChild(): boolean;
984
+ /**
985
+ Move the cursor to this node's last child.
986
+ */
987
+ lastChild(): boolean;
988
+ /**
989
+ Move the cursor to the first child that ends after `pos`.
990
+ */
991
+ childAfter(pos: number): boolean;
992
+ /**
993
+ Move to the last child that starts before `pos`.
994
+ */
995
+ childBefore(pos: number): boolean;
996
+ /**
997
+ Move the cursor to the child around `pos`. If side is -1 the
998
+ child may end at that position, when 1 it may start there. This
999
+ will also enter [overlaid](#common.MountedTree.overlay)
1000
+ [mounted](#common.NodeProp^mounted) trees unless `overlays` is
1001
+ set to false.
1002
+ */
1003
+ enter(pos: number, side: -1 | 0 | 1, mode?: IterMode): boolean;
1004
+ /**
1005
+ Move to the node's parent node, if this isn't the top node.
1006
+ */
1007
+ parent(): boolean;
1008
+ /**
1009
+ Move to this node's next sibling, if any.
1010
+ */
1011
+ nextSibling(): boolean;
1012
+ /**
1013
+ Move to this node's previous sibling, if any.
1014
+ */
1015
+ prevSibling(): boolean;
1016
+ private atLastNode;
1017
+ private move;
1018
+ /**
1019
+ Move to the next node in a
1020
+ [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
1021
+ traversal, going from a node to its first child or, if the
1022
+ current node is empty or `enter` is false, its next sibling or
1023
+ the next sibling of the first parent node that has one.
1024
+ */
1025
+ next(enter?: boolean): boolean;
1026
+ /**
1027
+ Move to the next node in a last-to-first pre-order traversal. A
1028
+ node is followed by its last child or, if it has none, its
1029
+ previous sibling or the previous sibling of the first parent
1030
+ node that has one.
1031
+ */
1032
+ prev(enter?: boolean): boolean;
1033
+ /**
1034
+ Move the cursor to the innermost node that covers `pos`. If
1035
+ `side` is -1, it will enter nodes that end at `pos`. If it is 1,
1036
+ it will enter nodes that start at `pos`.
1037
+ */
1038
+ moveTo(pos: number, side?: -1 | 0 | 1): this;
1039
+ /**
1040
+ Get a [syntax node](#common.SyntaxNode) at the cursor's current
1041
+ position.
1042
+ */
1043
+ get node(): SyntaxNode;
1044
+ /**
1045
+ Get the [tree](#common.Tree) that represents the current node, if
1046
+ any. Will return null when the node is in a [tree
1047
+ buffer](#common.TreeBuffer).
1048
+ */
1049
+ get tree(): Tree | null;
1050
+ /**
1051
+ Iterate over the current node and all its descendants, calling
1052
+ `enter` when entering a node and `leave`, if given, when leaving
1053
+ one. When `enter` returns `false`, any children of that node are
1054
+ skipped, and `leave` isn't called for it.
1055
+ */
1056
+ iterate(enter: (node: SyntaxNodeRef) => boolean | void, leave?: (node: SyntaxNodeRef) => void): void;
1057
+ /**
1058
+ Test whether the current node matches a given context—a sequence
1059
+ of direct parent node names. Empty strings in the context array
1060
+ are treated as wildcards.
1061
+ */
1062
+ matchContext(context: readonly string[]): boolean;
1063
+ }
1064
+ /**
1065
+ Provides a way to associate values with pieces of trees. As long
1066
+ as that part of the tree is reused, the associated values can be
1067
+ retrieved from an updated tree.
1068
+ */
1069
+ declare class NodeWeakMap<T> {
1070
+ private map;
1071
+ private setBuffer;
1072
+ private getBuffer;
1073
+ /**
1074
+ Set the value for this syntax node.
1075
+ */
1076
+ set(node: SyntaxNode, value: T): void;
1077
+ /**
1078
+ Retrieve value for this syntax node, if it exists in the map.
1079
+ */
1080
+ get(node: SyntaxNode): T | undefined;
1081
+ /**
1082
+ Set the value for the node that a cursor currently points to.
1083
+ */
1084
+ cursorSet(cursor: TreeCursor, value: T): void;
1085
+ /**
1086
+ Retrieve the value for the node that a cursor currently points
1087
+ to.
1088
+ */
1089
+ cursorGet(cursor: TreeCursor): T | undefined;
1090
+ }
1091
+
1092
+ /**
1093
+ Objects returned by the function passed to
1094
+ [`parseMixed`](#common.parseMixed) should conform to this
1095
+ interface.
1096
+ */
1097
+ interface NestedParse {
1098
+ /**
1099
+ The parser to use for the inner region.
1100
+ */
1101
+ parser: Parser;
1102
+ /**
1103
+ When this property is not given, the entire node is parsed with
1104
+ this parser, and it is [mounted](#common.NodeProp^mounted) as a
1105
+ non-overlay node, replacing its host node in tree iteration.
1106
+
1107
+ When an array of ranges is given, only those ranges are parsed,
1108
+ and the tree is mounted as an
1109
+ [overlay](#common.MountedTree.overlay).
1110
+
1111
+ When a function is given, that function will be called for
1112
+ descendant nodes of the target node, not including child nodes
1113
+ that are covered by another nested parse, to determine the
1114
+ overlay ranges. When it returns true, the entire descendant is
1115
+ included, otherwise just the range given. The mixed parser will
1116
+ optimize range-finding in reused nodes, which means it's a good
1117
+ idea to use a function here when the target node is expected to
1118
+ have a large, deep structure.
1119
+ */
1120
+ overlay?: readonly {
1121
+ from: number;
1122
+ to: number;
1123
+ }[] | ((node: SyntaxNodeRef) => {
1124
+ from: number;
1125
+ to: number;
1126
+ } | boolean);
1127
+ }
1128
+ /**
1129
+ Create a parse wrapper that, after the inner parse completes,
1130
+ scans its tree for mixed language regions with the `nest`
1131
+ function, runs the resulting [inner parses](#common.NestedParse),
1132
+ and then [mounts](#common.NodeProp^mounted) their results onto the
1133
+ tree.
1134
+ */
1135
+ declare function parseMixed(nest: (node: SyntaxNodeRef, input: Input) => NestedParse | null): ParseWrapper;
1136
+
1137
+ export { BufferCursor, ChangedRange, DefaultBufferLength, Input, IterMode, MountedTree, NestedParse, NodeIterator, NodeProp, NodePropSource, NodeSet, NodeType, NodeWeakMap, ParseWrapper, Parser, PartialParse, SyntaxNode, SyntaxNodeRef, Tree, TreeBuffer, TreeCursor, TreeFragment, parseMixed };