@lezer/common 1.5.2 → 1.5.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lezer/common
2
2
 
3
- [ [**WEBSITE**](http://lezer.codemirror.net) | [**ISSUES**](https://github.com/lezer-parser/lezer/issues) | [**FORUM**](https://discuss.codemirror.net/c/lezer) | [**CHANGELOG**](https://github.com/lezer-parser/common/blob/master/CHANGELOG.md) ]
3
+ [ [**WEBSITE**](http://lezer.codemirror.net) | [**ISSUES**](https://code.haverbeke.berlin/lezer/lezer/issues) | [**FORUM**](https://discuss.codemirror.net/c/lezer) | [**CHANGELOG**](https://code.haverbeke.berlin/lezer/common/src/branch/main/CHANGELOG.md) ]
4
4
 
5
5
  [Lezer](https://lezer.codemirror.net/) is an incremental parser system
6
6
  intended for use in an editor or similar system.
package/dist/index.cjs CHANGED
@@ -1328,13 +1328,16 @@ function buildTree(data) {
1328
1328
  cursor.next();
1329
1329
  let localChildren = [], localPositions = [];
1330
1330
  let localInRepeat = id >= minRepeatType ? id : -1;
1331
- let lastGroup = 0, lastEnd = end;
1331
+ let lastGroup = 0, lastEnd = end, groupLookAhead = lookAheadAtStart;
1332
1332
  while (cursor.pos > endPos) {
1333
1333
  if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
1334
1334
  if (cursor.end <= lastEnd - maxBufferLength) {
1335
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1335
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, groupLookAhead, contextAtStart);
1336
1336
  lastGroup = localChildren.length;
1337
1337
  lastEnd = cursor.end;
1338
+ // The buffer is read backwards, so the current look-ahead is
1339
+ // the one recorded after the next group's end.
1340
+ groupLookAhead = lookAhead;
1338
1341
  }
1339
1342
  cursor.next();
1340
1343
  }
@@ -1346,7 +1349,7 @@ function buildTree(data) {
1346
1349
  }
1347
1350
  }
1348
1351
  if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
1349
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1352
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, groupLookAhead, contextAtStart);
1350
1353
  localChildren.reverse();
1351
1354
  localPositions.reverse();
1352
1355
  if (localInRepeat > -1 && lastGroup > 0) {
@@ -1399,7 +1402,7 @@ function buildTree(data) {
1399
1402
  if (!lastI && last.type == type && last.length == length)
1400
1403
  return last;
1401
1404
  if (lookAheadProp = last.prop(NodeProp.lookAhead))
1402
- lookAhead = positions[lastI] + last.length + lookAheadProp;
1405
+ lookAhead = positions[lastI] + last.length + lookAheadProp - length;
1403
1406
  }
1404
1407
  return makeTree(type, children, positions, length, lookAhead, contextHash);
1405
1408
  };
@@ -2025,14 +2028,14 @@ class StructureCursor {
2025
2028
  constructor(root, offset) {
2026
2029
  this.offset = offset;
2027
2030
  this.done = false;
2028
- this.cursor = root.cursor(exports.IterMode.IncludeAnonymous | exports.IterMode.IgnoreMounts);
2031
+ this.cursor = root.cursor(exports.IterMode.IncludeAnonymous | exports.IterMode.IgnoreMounts | exports.IterMode.ExcludeBuffers);
2029
2032
  }
2030
2033
  // Move to the first node (in pre-order) that starts at or after `pos`.
2031
2034
  moveTo(pos) {
2032
2035
  let { cursor } = this, p = pos - this.offset;
2033
2036
  while (!this.done && cursor.from < p) {
2034
- if (cursor.to >= pos && cursor.enter(p, 1, exports.IterMode.IgnoreOverlays | exports.IterMode.ExcludeBuffers)) ;
2035
- else if (cursor.to <= pos) {
2037
+ if (cursor.to >= p && cursor.enter(p, 1, exports.IterMode.IncludeAnonymous | exports.IterMode.IgnoreOverlays | exports.IterMode.ExcludeBuffers)) ;
2038
+ else if (cursor.to <= p) {
2036
2039
  if (!cursor.next(false))
2037
2040
  this.done = true;
2038
2041
  // Moved to next node
package/dist/index.d.cts CHANGED
@@ -1171,4 +1171,4 @@ tree.
1171
1171
  */
1172
1172
  declare function parseMixed(nest: (node: SyntaxNodeRef, input: Input) => NestedParse | null): ParseWrapper;
1173
1173
 
1174
- export { type BufferCursor, type ChangedRange, DefaultBufferLength, type Input, IterMode, MountedTree, type NestedParse, type NodeIterator, NodeProp, type NodePropSource, NodeSet, NodeType, NodeWeakMap, type ParseWrapper, Parser, type PartialParse, type SyntaxNode, type SyntaxNodeRef, Tree, TreeBuffer, TreeCursor, TreeFragment, parseMixed };
1174
+ export { BufferCursor, ChangedRange, DefaultBufferLength, Input, IterMode, MountedTree, NestedParse, NodeIterator, NodeProp, NodePropSource, NodeSet, NodeType, NodeWeakMap, ParseWrapper, Parser, PartialParse, SyntaxNode, SyntaxNodeRef, Tree, TreeBuffer, TreeCursor, TreeFragment, parseMixed };
package/dist/index.d.ts CHANGED
@@ -1171,4 +1171,4 @@ tree.
1171
1171
  */
1172
1172
  declare function parseMixed(nest: (node: SyntaxNodeRef, input: Input) => NestedParse | null): ParseWrapper;
1173
1173
 
1174
- export { type BufferCursor, type ChangedRange, DefaultBufferLength, type Input, IterMode, MountedTree, type NestedParse, type NodeIterator, NodeProp, type NodePropSource, NodeSet, NodeType, NodeWeakMap, type ParseWrapper, Parser, type PartialParse, type SyntaxNode, type SyntaxNodeRef, Tree, TreeBuffer, TreeCursor, TreeFragment, parseMixed };
1174
+ export { BufferCursor, ChangedRange, DefaultBufferLength, Input, IterMode, MountedTree, NestedParse, NodeIterator, NodeProp, NodePropSource, NodeSet, NodeType, NodeWeakMap, ParseWrapper, Parser, PartialParse, SyntaxNode, SyntaxNodeRef, Tree, TreeBuffer, TreeCursor, TreeFragment, parseMixed };
package/dist/index.js CHANGED
@@ -1326,13 +1326,16 @@ function buildTree(data) {
1326
1326
  cursor.next();
1327
1327
  let localChildren = [], localPositions = [];
1328
1328
  let localInRepeat = id >= minRepeatType ? id : -1;
1329
- let lastGroup = 0, lastEnd = end;
1329
+ let lastGroup = 0, lastEnd = end, groupLookAhead = lookAheadAtStart;
1330
1330
  while (cursor.pos > endPos) {
1331
1331
  if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
1332
1332
  if (cursor.end <= lastEnd - maxBufferLength) {
1333
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1333
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, groupLookAhead, contextAtStart);
1334
1334
  lastGroup = localChildren.length;
1335
1335
  lastEnd = cursor.end;
1336
+ // The buffer is read backwards, so the current look-ahead is
1337
+ // the one recorded after the next group's end.
1338
+ groupLookAhead = lookAhead;
1336
1339
  }
1337
1340
  cursor.next();
1338
1341
  }
@@ -1344,7 +1347,7 @@ function buildTree(data) {
1344
1347
  }
1345
1348
  }
1346
1349
  if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
1347
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1350
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, groupLookAhead, contextAtStart);
1348
1351
  localChildren.reverse();
1349
1352
  localPositions.reverse();
1350
1353
  if (localInRepeat > -1 && lastGroup > 0) {
@@ -1397,7 +1400,7 @@ function buildTree(data) {
1397
1400
  if (!lastI && last.type == type && last.length == length)
1398
1401
  return last;
1399
1402
  if (lookAheadProp = last.prop(NodeProp.lookAhead))
1400
- lookAhead = positions[lastI] + last.length + lookAheadProp;
1403
+ lookAhead = positions[lastI] + last.length + lookAheadProp - length;
1401
1404
  }
1402
1405
  return makeTree(type, children, positions, length, lookAhead, contextHash);
1403
1406
  };
@@ -2023,14 +2026,14 @@ class StructureCursor {
2023
2026
  constructor(root, offset) {
2024
2027
  this.offset = offset;
2025
2028
  this.done = false;
2026
- this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
2029
+ this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts | IterMode.ExcludeBuffers);
2027
2030
  }
2028
2031
  // Move to the first node (in pre-order) that starts at or after `pos`.
2029
2032
  moveTo(pos) {
2030
2033
  let { cursor } = this, p = pos - this.offset;
2031
2034
  while (!this.done && cursor.from < p) {
2032
- if (cursor.to >= pos && cursor.enter(p, 1, IterMode.IgnoreOverlays | IterMode.ExcludeBuffers)) ;
2033
- else if (cursor.to <= pos) {
2035
+ if (cursor.to >= p && cursor.enter(p, 1, IterMode.IncludeAnonymous | IterMode.IgnoreOverlays | IterMode.ExcludeBuffers)) ;
2036
+ else if (cursor.to <= p) {
2034
2037
  if (!cursor.next(false))
2035
2038
  this.done = true;
2036
2039
  // Moved to next node
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lezer/common",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "Syntax tree data structure and parser interfaces for the lezer parser",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",
@@ -21,8 +21,8 @@
21
21
  },
22
22
  "files": ["dist"],
23
23
  "repository": {
24
- "type" : "git",
25
- "url" : "https://github.com/lezer-parser/common.git"
24
+ "type": "git",
25
+ "url": "git+https://code.haverbeke.berlin/lezer/common.git"
26
26
  },
27
27
  "scripts": {
28
28
  "watch": "node build.js --watch",