@lezer/common 1.0.2 → 1.0.3
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/LICENSE +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.js +6 -3
- package/dist/parse.d.ts +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (C) 2018 by Marijn Haverbeke <
|
|
3
|
+
Copyright (C) 2018 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.cjs
CHANGED
|
@@ -347,15 +347,16 @@ class Tree {
|
|
|
347
347
|
/// not have its children iterated over (or `leave` called).
|
|
348
348
|
iterate(spec) {
|
|
349
349
|
let { enter, leave, from = 0, to = this.length } = spec;
|
|
350
|
-
|
|
350
|
+
let mode = spec.mode || 0, anon = (mode & exports.IterMode.IncludeAnonymous) > 0;
|
|
351
|
+
for (let c = this.cursor(mode | exports.IterMode.IncludeAnonymous);;) {
|
|
351
352
|
let entered = false;
|
|
352
|
-
if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
|
|
353
|
+
if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
|
|
353
354
|
if (c.firstChild())
|
|
354
355
|
continue;
|
|
355
356
|
entered = true;
|
|
356
357
|
}
|
|
357
358
|
for (;;) {
|
|
358
|
-
if (entered && leave && !c.type.isAnonymous)
|
|
359
|
+
if (entered && leave && (anon || !c.type.isAnonymous))
|
|
359
360
|
leave(c);
|
|
360
361
|
if (c.nextSibling())
|
|
361
362
|
break;
|
|
@@ -1442,6 +1443,8 @@ class InnerParse {
|
|
|
1442
1443
|
this.overlay = overlay;
|
|
1443
1444
|
this.target = target;
|
|
1444
1445
|
this.ranges = ranges;
|
|
1446
|
+
if (!ranges.length || ranges.some(r => r.from >= r.to))
|
|
1447
|
+
throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(ranges));
|
|
1445
1448
|
}
|
|
1446
1449
|
}
|
|
1447
1450
|
class ActiveOverlay {
|
package/dist/index.js
CHANGED
|
@@ -343,15 +343,16 @@ class Tree {
|
|
|
343
343
|
/// not have its children iterated over (or `leave` called).
|
|
344
344
|
iterate(spec) {
|
|
345
345
|
let { enter, leave, from = 0, to = this.length } = spec;
|
|
346
|
-
|
|
346
|
+
let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
|
|
347
|
+
for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {
|
|
347
348
|
let entered = false;
|
|
348
|
-
if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
|
|
349
|
+
if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
|
|
349
350
|
if (c.firstChild())
|
|
350
351
|
continue;
|
|
351
352
|
entered = true;
|
|
352
353
|
}
|
|
353
354
|
for (;;) {
|
|
354
|
-
if (entered && leave && !c.type.isAnonymous)
|
|
355
|
+
if (entered && leave && (anon || !c.type.isAnonymous))
|
|
355
356
|
leave(c);
|
|
356
357
|
if (c.nextSibling())
|
|
357
358
|
break;
|
|
@@ -1438,6 +1439,8 @@ class InnerParse {
|
|
|
1438
1439
|
this.overlay = overlay;
|
|
1439
1440
|
this.target = target;
|
|
1440
1441
|
this.ranges = ranges;
|
|
1442
|
+
if (!ranges.length || ranges.some(r => r.from >= r.to))
|
|
1443
|
+
throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(ranges));
|
|
1441
1444
|
}
|
|
1442
1445
|
}
|
|
1443
1446
|
class ActiveOverlay {
|
package/dist/parse.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare class TreeFragment {
|
|
|
13
13
|
constructor(from: number, to: number, tree: Tree, offset: number, openStart?: boolean, openEnd?: boolean);
|
|
14
14
|
get openStart(): boolean;
|
|
15
15
|
get openEnd(): boolean;
|
|
16
|
-
static addTree(tree: Tree, fragments?: readonly TreeFragment[], partial?: boolean): TreeFragment[];
|
|
16
|
+
static addTree(tree: Tree, fragments?: readonly TreeFragment[], partial?: boolean): readonly TreeFragment[];
|
|
17
17
|
static applyChanges(fragments: readonly TreeFragment[], changes: readonly ChangedRange[], minGap?: number): readonly TreeFragment[];
|
|
18
18
|
}
|
|
19
19
|
export interface PartialParse {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lezer/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Syntax tree data structure and parser interfaces for the lezer parser",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"module": "dist/index.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
|
-
"author": "Marijn Haverbeke <
|
|
13
|
+
"author": "Marijn Haverbeke <marijn@haverbeke.berlin>",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"ist": "^1.1.1",
|