@ifc-lite/parser 4.3.2 → 5.0.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/dist/attribute-helpers.d.ts +38 -4
- package/dist/attribute-helpers.d.ts.map +1 -1
- package/dist/attribute-helpers.js +71 -4
- package/dist/attribute-helpers.js.map +1 -1
- package/dist/columnar-parser-attributes.d.ts.map +1 -1
- package/dist/columnar-parser-attributes.js +35 -5
- package/dist/columnar-parser-attributes.js.map +1 -1
- package/dist/columnar-parser-indexes.d.ts.map +1 -1
- package/dist/columnar-parser-indexes.js +14 -2
- package/dist/columnar-parser-indexes.js.map +1 -1
- package/dist/columnar-parser-relationships.d.ts.map +1 -1
- package/dist/columnar-parser-relationships.js +6 -1
- package/dist/columnar-parser-relationships.js.map +1 -1
- package/dist/columnar-parser.d.ts +3 -1
- package/dist/columnar-parser.d.ts.map +1 -1
- package/dist/columnar-parser.js +16 -25
- package/dist/columnar-parser.js.map +1 -1
- package/dist/compact-entity-index-transport.d.ts +23 -0
- package/dist/compact-entity-index-transport.d.ts.map +1 -0
- package/dist/compact-entity-index-transport.js +28 -0
- package/dist/compact-entity-index-transport.js.map +1 -0
- package/dist/compact-entity-index.d.ts +0 -10
- package/dist/compact-entity-index.d.ts.map +1 -1
- package/dist/compact-entity-index.js +31 -24
- package/dist/compact-entity-index.js.map +1 -1
- package/dist/data-store-transport.d.ts +2 -12
- package/dist/data-store-transport.d.ts.map +1 -1
- package/dist/data-store-transport.js +7 -20
- package/dist/data-store-transport.js.map +1 -1
- package/dist/entity-extractor.d.ts.map +1 -1
- package/dist/entity-extractor.js +101 -6
- package/dist/entity-extractor.js.map +1 -1
- package/dist/entity-refs-from-index.d.ts.map +1 -1
- package/dist/entity-refs-from-index.js +12 -2
- package/dist/entity-refs-from-index.js.map +1 -1
- package/dist/entity-scanner.d.ts +63 -0
- package/dist/entity-scanner.d.ts.map +1 -1
- package/dist/entity-scanner.js +79 -2
- package/dist/entity-scanner.js.map +1 -1
- package/dist/express-id.d.ts +47 -0
- package/dist/express-id.d.ts.map +1 -0
- package/dist/express-id.js +57 -0
- package/dist/express-id.js.map +1 -0
- package/dist/generated/entities.d.ts +1 -1
- package/dist/generated/entities.d.ts.map +1 -1
- package/dist/generated/schema-registry.js +146 -146
- package/dist/generated/schema-registry.js.map +1 -1
- package/dist/georef-epset.d.ts +25 -0
- package/dist/georef-epset.d.ts.map +1 -0
- package/dist/georef-epset.js +214 -0
- package/dist/georef-epset.js.map +1 -0
- package/dist/georef-extractor.d.ts.map +1 -1
- package/dist/georef-extractor.js +38 -175
- package/dist/georef-extractor.js.map +1 -1
- package/dist/georef-map-conversion.d.ts +29 -0
- package/dist/georef-map-conversion.d.ts.map +1 -0
- package/dist/georef-map-conversion.js +75 -0
- package/dist/georef-map-conversion.js.map +1 -0
- package/dist/ifc-schema.d.ts +4 -2
- package/dist/ifc-schema.d.ts.map +1 -1
- package/dist/ifc-schema.js +15 -5
- package/dist/ifc-schema.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/material-extractor.d.ts +2 -17
- package/dist/material-extractor.d.ts.map +1 -1
- package/dist/material-extractor.js +12 -37
- package/dist/material-extractor.js.map +1 -1
- package/dist/material-layer-reader.d.ts +45 -0
- package/dist/material-layer-reader.d.ts.map +1 -0
- package/dist/material-layer-reader.js +63 -0
- package/dist/material-layer-reader.js.map +1 -0
- package/dist/material-resolver.d.ts.map +1 -1
- package/dist/material-resolver.js +14 -14
- package/dist/material-resolver.js.map +1 -1
- package/dist/measure-unit-scale.d.ts +41 -0
- package/dist/measure-unit-scale.d.ts.map +1 -0
- package/dist/measure-unit-scale.js +53 -0
- package/dist/measure-unit-scale.js.map +1 -0
- package/dist/on-demand-extractors.d.ts +3 -19
- package/dist/on-demand-extractors.d.ts.map +1 -1
- package/dist/on-demand-extractors.js +54 -264
- package/dist/on-demand-extractors.js.map +1 -1
- package/dist/owning-project.d.ts +54 -0
- package/dist/owning-project.d.ts.map +1 -0
- package/dist/owning-project.js +76 -0
- package/dist/owning-project.js.map +1 -0
- package/dist/parser.worker.d.ts +14 -0
- package/dist/parser.worker.d.ts.map +1 -1
- package/dist/parser.worker.js +2 -0
- package/dist/parser.worker.js.map +1 -1
- package/dist/project-units-symbols.d.ts +33 -0
- package/dist/project-units-symbols.d.ts.map +1 -0
- package/dist/project-units-symbols.js +265 -0
- package/dist/project-units-symbols.js.map +1 -0
- package/dist/project-units.d.ts +11 -19
- package/dist/project-units.d.ts.map +1 -1
- package/dist/project-units.js +9 -267
- package/dist/project-units.js.map +1 -1
- package/dist/property-set-merge.d.ts +65 -8
- package/dist/property-set-merge.d.ts.map +1 -1
- package/dist/property-set-merge.js +130 -29
- package/dist/property-set-merge.js.map +1 -1
- package/dist/property-value-parser.d.ts +55 -0
- package/dist/property-value-parser.d.ts.map +1 -0
- package/dist/property-value-parser.js +277 -0
- package/dist/property-value-parser.js.map +1 -0
- package/dist/quantity-collect.d.ts +42 -3
- package/dist/quantity-collect.d.ts.map +1 -1
- package/dist/quantity-collect.js +114 -7
- package/dist/quantity-collect.js.map +1 -1
- package/dist/query-backend-maps.d.ts +5 -8
- package/dist/query-backend-maps.d.ts.map +1 -1
- package/dist/query-backend-maps.js +155 -15
- package/dist/query-backend-maps.js.map +1 -1
- package/dist/relationship-extractor.d.ts.map +1 -1
- package/dist/relationship-extractor.js +18 -0
- package/dist/relationship-extractor.js.map +1 -1
- package/dist/scan-entities-balanced.d.ts +38 -0
- package/dist/scan-entities-balanced.d.ts.map +1 -0
- package/dist/scan-entities-balanced.js +258 -0
- package/dist/scan-entities-balanced.js.map +1 -0
- package/dist/scan-worker-inline.d.ts +17 -11
- package/dist/scan-worker-inline.d.ts.map +1 -1
- package/dist/scan-worker-inline.js +9 -235
- package/dist/scan-worker-inline.js.map +1 -1
- package/dist/scan-worker-source.d.ts +9 -0
- package/dist/scan-worker-source.d.ts.map +1 -0
- package/dist/scan-worker-source.js +383 -0
- package/dist/scan-worker-source.js.map +1 -0
- package/dist/spatial-hierarchy-builder.js +3 -3
- package/dist/spatial-hierarchy-builder.js.map +1 -1
- package/dist/step-lexing.d.ts +2 -0
- package/dist/step-lexing.d.ts.map +1 -1
- package/dist/step-lexing.js +116 -18
- package/dist/step-lexing.js.map +1 -1
- package/dist/step-trivia.d.ts +60 -0
- package/dist/step-trivia.d.ts.map +1 -0
- package/dist/step-trivia.js +63 -0
- package/dist/step-trivia.js.map +1 -0
- package/dist/tokenizer.d.ts +20 -21
- package/dist/tokenizer.d.ts.map +1 -1
- package/dist/tokenizer.js +164 -203
- package/dist/tokenizer.js.map +1 -1
- package/dist/unit-extractor.d.ts +43 -1
- package/dist/unit-extractor.d.ts.map +1 -1
- package/dist/unit-extractor.js +63 -4
- package/dist/unit-extractor.js.map +1 -1
- package/dist/worker-parser.d.ts +11 -1
- package/dist/worker-parser.d.ts.map +1 -1
- package/dist/worker-parser.js +16 -2
- package/dist/worker-parser.js.map +1 -1
- package/package.json +6 -6
package/dist/step-lexing.js
CHANGED
|
@@ -19,6 +19,8 @@ const SLASH = 0x2f; // '/'
|
|
|
19
19
|
const STAR = 0x2a; // '*'
|
|
20
20
|
const NEWLINE = 0x0a; // '\n'
|
|
21
21
|
const QUOTE = 0x27; // '\''
|
|
22
|
+
const LPAREN = 0x28; // '('
|
|
23
|
+
const RPAREN = 0x29; // ')'
|
|
22
24
|
// Whether a comment opens at `pos`.
|
|
23
25
|
export function opensComment(buf, pos, len) {
|
|
24
26
|
return buf[pos] === SLASH && pos + 1 < len && buf[pos + 1] === STAR;
|
|
@@ -41,21 +43,6 @@ export function opensComment(buf, pos, len) {
|
|
|
41
43
|
// string literal. Callers skip literals with skipStringLiteral first, which is
|
|
42
44
|
// what keeps a /* inside a HEADER description from opening a comment.
|
|
43
45
|
//
|
|
44
|
-
// Known, shared with the Rust EntityScanner, and deliberately NOT fixed here:
|
|
45
|
-
// ISO 10303-21 allows a comment anywhere whitespace is allowed, and none of the
|
|
46
|
-
// scanners treat one as trivia *within* a record. Two shapes, both pre-existing
|
|
47
|
-
// and both unchanged by this file:
|
|
48
|
-
//
|
|
49
|
-
// #1 /* note */ = IFCWALL(); header: fails the '=' check, no record
|
|
50
|
-
// #1=IFCWALL('a', /* n; */ $); body: ends early at the ';' in the comment
|
|
51
|
-
//
|
|
52
|
-
// That is true of scanEntities, of scanEntitiesFast, of the worker scanner, and
|
|
53
|
-
// of the Rust side, whose next_entity wants '=' straight after the digits and
|
|
54
|
-
// whose find_entity_end jumps to the next quote or semicolon with memchr2.
|
|
55
|
-
// Correcting it on the TypeScript side alone would put the JS fallback and the
|
|
56
|
-
// wasm scan at odds on well-formed files, so it wants one change across all
|
|
57
|
-
// four loops rather than a partial one here. Separate defect.
|
|
58
|
-
//
|
|
59
46
|
// The literal skip above is a smaller version of the same tension and is worth
|
|
60
47
|
// naming rather than hiding. Rust has no literal skip outside a record, so on a
|
|
61
48
|
// malformed file carrying an unpaired quote in DATA the two now disagree: this
|
|
@@ -71,8 +58,10 @@ export function skipComment(buf, pos, len) {
|
|
|
71
58
|
}
|
|
72
59
|
return -1;
|
|
73
60
|
}
|
|
74
|
-
// Index just past the closing quote of the literal opening at `pos`, or
|
|
75
|
-
// when it never closes
|
|
61
|
+
// Index just past the closing quote of the literal opening at `pos`, or -1
|
|
62
|
+
// when it never closes -- the same signal `skipComment` gives, not the old
|
|
63
|
+
// `len` return that read as "closed at the last byte". A doubled '' is an
|
|
64
|
+
// escaped quote and stays inside.
|
|
76
65
|
//
|
|
77
66
|
// Scanners consume a literal whole so nothing inside it can be mistaken for
|
|
78
67
|
// syntax. Without this, a HEADER description reading `'rev /* pending'` opens a
|
|
@@ -92,7 +81,7 @@ export function skipStringLiteral(buf, pos, len) {
|
|
|
92
81
|
}
|
|
93
82
|
p++;
|
|
94
83
|
}
|
|
95
|
-
return
|
|
84
|
+
return -1;
|
|
96
85
|
}
|
|
97
86
|
// Skip a string literal or a comment starting at `pos`. Callers test
|
|
98
87
|
// `opensLiteralOrComment` first, so this is only reached on a byte that starts
|
|
@@ -100,6 +89,9 @@ export function skipStringLiteral(buf, pos, len) {
|
|
|
100
89
|
export function skipLexical(buf, pos, len) {
|
|
101
90
|
if (buf[pos] === QUOTE) {
|
|
102
91
|
const next = skipStringLiteral(buf, pos, len);
|
|
92
|
+
if (next < 0) {
|
|
93
|
+
return { next: len, lines: countNewlines(buf, pos, len), stop: true };
|
|
94
|
+
}
|
|
103
95
|
return { next, lines: countNewlines(buf, pos, next), stop: false };
|
|
104
96
|
}
|
|
105
97
|
const next = skipComment(buf, pos, len);
|
|
@@ -112,6 +104,59 @@ export function skipLexical(buf, pos, len) {
|
|
|
112
104
|
export function opensLiteralOrComment(buf, pos, len) {
|
|
113
105
|
return buf[pos] === QUOTE || opensComment(buf, pos, len);
|
|
114
106
|
}
|
|
107
|
+
// ASCII whitespace per ISO 10303-21. Not /\s/: that also matches U+00A0 and the
|
|
108
|
+
// other Unicode space separators, which the byte scanners and the Rust half do
|
|
109
|
+
// not treat as whitespace.
|
|
110
|
+
//
|
|
111
|
+
// The full six-byte set (space, tab, LF, CR, form feed 0x0c, vertical tab
|
|
112
|
+
// 0x0b) matches `isAsciiSpace` below, which this file's header-string scanner
|
|
113
|
+
// already used for the same six bytes -- and matches `is_step_space` in
|
|
114
|
+
// `rust/export/src/source_header.rs`, which spells the set out for the same
|
|
115
|
+
// reason this one now does: a stdlib "ASCII whitespace" helper is not
|
|
116
|
+
// trustworthy here. Rust's `u8::is_ascii_whitespace` follows the WhatWG
|
|
117
|
+
// definition and excludes vertical tab, so reaching for it on either side
|
|
118
|
+
// reintroduces the exact FF/VT divergence issue #3733 reported (dropped
|
|
119
|
+
// entity on a leading form feed) rather than closing it.
|
|
120
|
+
function isSpaceByte(b) {
|
|
121
|
+
return (b === 0x20 || b === 0x09 || b === 0x0d || b === NEWLINE || b === 0x0c || b === 0x0b);
|
|
122
|
+
}
|
|
123
|
+
// Skip STEP trivia from `pos`: whitespace, comments, and any run of the two.
|
|
124
|
+
//
|
|
125
|
+
// ISO 10303-21 allows a comment ANYWHERE whitespace is allowed, which includes
|
|
126
|
+
// inside a record -- between an instance name and its '=', between the '=' and
|
|
127
|
+
// the type name, and between the type name and its '('. A scanner that skips
|
|
128
|
+
// only whitespace at those points reads `#1 /* was #7 */ = IFCWALL(...)` as no
|
|
129
|
+
// record at all. This is the one home for that rule on the byte side; the
|
|
130
|
+
// matching Rust half is `skip_step_trivia` in rust/core/src/parser/lexical.rs
|
|
131
|
+
// and the two are changed together.
|
|
132
|
+
//
|
|
133
|
+
// Callers hold to the composition order the rest of this file uses: a string
|
|
134
|
+
// literal is consumed whole first, so a '/*' inside one is text; a comment is
|
|
135
|
+
// consumed whole here, so a quote inside one is text and cannot open a literal.
|
|
136
|
+
//
|
|
137
|
+
// `stop` is true when a comment opens and never closes. Everything from there
|
|
138
|
+
// to end of input is inside it, so there is nothing left to find -- the same
|
|
139
|
+
// answer `skipLexical` gives, and the same answer Rust's `skip_step_comment`
|
|
140
|
+
// gives by refusing.
|
|
141
|
+
export function skipTrivia(buf, pos, len) {
|
|
142
|
+
let p = pos;
|
|
143
|
+
let lines = 0;
|
|
144
|
+
for (;;) {
|
|
145
|
+
while (p < len && isSpaceByte(buf[p])) {
|
|
146
|
+
if (buf[p] === NEWLINE)
|
|
147
|
+
lines++;
|
|
148
|
+
p++;
|
|
149
|
+
}
|
|
150
|
+
if (!opensComment(buf, p, len))
|
|
151
|
+
return { next: p, lines, stop: false };
|
|
152
|
+
const end = skipComment(buf, p, len);
|
|
153
|
+
if (end < 0) {
|
|
154
|
+
return { next: len, lines: lines + countNewlines(buf, p, len), stop: true };
|
|
155
|
+
}
|
|
156
|
+
lines += countNewlines(buf, p, end);
|
|
157
|
+
p = end;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
115
160
|
// Newlines in [from, to), so a skipped region does not desync line numbers.
|
|
116
161
|
export function countNewlines(buf, from, to) {
|
|
117
162
|
let n = 0;
|
|
@@ -121,6 +166,59 @@ export function countNewlines(buf, from, to) {
|
|
|
121
166
|
}
|
|
122
167
|
return n;
|
|
123
168
|
}
|
|
169
|
+
// Byte length of the record that starts at `startOffset` and whose argument
|
|
170
|
+
// list opens at `pos`: the span up to and including the ')' balancing that '(',
|
|
171
|
+
// or 0 when the input runs out first.
|
|
172
|
+
//
|
|
173
|
+
// A string literal is jumped over by skipStringLiteral above rather than
|
|
174
|
+
// counted, so the '(' in 'Storey (Level 1)' is text and not depth, and STEP's
|
|
175
|
+
// doubled-quote escape ('') stays inside the literal instead of closing it.
|
|
176
|
+
// Sharing that helper is what keeps the escape rule in one place: an
|
|
177
|
+
// open-coded `inString` flag here would be a second copy of it, free to drift
|
|
178
|
+
// from the one every other scanner in this file uses.
|
|
179
|
+
//
|
|
180
|
+
// A comment is jumped over for the same reason, in the same order: the literal
|
|
181
|
+
// test comes first, so a '/*' inside a value is text; the comment is then taken
|
|
182
|
+
// whole, so a '(' or a quote inside it is text. Without that, the comment in
|
|
183
|
+
// `#1=IFCWALL('a', /* see IFCWALL( */ $);` opened a paren depth that never
|
|
184
|
+
// closed and the record came back with length 0.
|
|
185
|
+
export function findEntityLength(buf, pos, startOffset) {
|
|
186
|
+
const len = buf.length;
|
|
187
|
+
let depth = 0;
|
|
188
|
+
while (pos < len) {
|
|
189
|
+
const char = buf[pos];
|
|
190
|
+
if (char === QUOTE) {
|
|
191
|
+
// Returns `-1` on an unterminated literal (see skipStringLiteral's own
|
|
192
|
+
// doc): no balancing ')' can follow, same 0 as running off the end.
|
|
193
|
+
const next = skipStringLiteral(buf, pos, len);
|
|
194
|
+
if (next < 0)
|
|
195
|
+
return 0;
|
|
196
|
+
pos = next;
|
|
197
|
+
}
|
|
198
|
+
else if (opensComment(buf, pos, len)) {
|
|
199
|
+
const end = skipComment(buf, pos, len);
|
|
200
|
+
// Unterminated: the rest of the input is inside the comment, so no
|
|
201
|
+
// balancing ')' can follow. Same 0 as running off the end.
|
|
202
|
+
if (end < 0)
|
|
203
|
+
return 0;
|
|
204
|
+
pos = end;
|
|
205
|
+
}
|
|
206
|
+
else if (char === LPAREN) {
|
|
207
|
+
depth++;
|
|
208
|
+
pos++;
|
|
209
|
+
}
|
|
210
|
+
else if (char === RPAREN) {
|
|
211
|
+
depth--;
|
|
212
|
+
pos++;
|
|
213
|
+
if (depth === 0)
|
|
214
|
+
return pos - startOffset;
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
pos++;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return 0; // no matching ')'
|
|
221
|
+
}
|
|
124
222
|
// ---------------------------------------------------------------------------
|
|
125
223
|
// The same rule over a decoded string.
|
|
126
224
|
//
|
package/dist/step-lexing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-lexing.js","sourceRoot":"","sources":["../src/step-lexing.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,6EAA6E;AAC7E,2EAA2E;AAC3E,+EAA+E;AAC/E,gDAAgD;AAChD,EAAE;AACF,uEAAuE;AACvE,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;AAC/E,qDAAqD;AACrD,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,oEAAoE;AAEpE,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,MAAM;AAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,MAAM;AACzB,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,OAAO;AAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO;AAE3B,oCAAoC;AACpC,MAAM,UAAU,YAAY,CAAC,GAAe,EAAE,GAAW,EAAE,GAAW;IACpE,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;AACtE,CAAC;AA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
|
3
|
+
* non-nesting `/* ... */` comments, in any order, ANYWHERE whitespace is
|
|
4
|
+
* legal in a record — including between a type name and its `(`.
|
|
5
|
+
*
|
|
6
|
+
* String-side counterpart to `skipTrivia` in `step-lexing.ts`, for callers
|
|
7
|
+
* that already hold a decoded record as a JS string and build a regex around
|
|
8
|
+
* it (entity/typed-value extraction and rewriting), rather than scanning raw
|
|
9
|
+
* bytes. Both mirror `skip_step_trivia` in `rust/core/src/parser/lexical.rs`.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately ASCII-only (`[ \t\n\r\x0b\x0c]`, matching `is_step_space` /
|
|
12
|
+
* `isSpaceByte` in `step-lexing.ts`) rather than `\s`, which also matches
|
|
13
|
+
* U+00A0 and other Unicode space separators Rust's byte scanner does not
|
|
14
|
+
* treat as whitespace — the exact TS/Rust divergence class issue #3733
|
|
15
|
+
* fixed for the byte scanners; a new trivia matcher should not reintroduce
|
|
16
|
+
* it under a different name.
|
|
17
|
+
*
|
|
18
|
+
* ## Why each alternative is shaped the way it is
|
|
19
|
+
*
|
|
20
|
+
* The outer `(?:A|B)*` must have exactly ONE way to partition any input into
|
|
21
|
+
* iterations. Where it has more than one, a failing suffix makes the engine
|
|
22
|
+
* enumerate them, which is exponential in the length of the trivia run. Both
|
|
23
|
+
* alternatives below are written to keep that count at one, and BOTH shapes
|
|
24
|
+
* have been measured — the two axes fail independently, so neither is
|
|
25
|
+
* theoretical:
|
|
26
|
+
*
|
|
27
|
+
* - The comment body is `(?:[^*]|\*(?!/))*`, NOT a lazy `[\s\S]*?`. A lazy
|
|
28
|
+
* body looks unambiguous locally, but when the overall pattern fails past
|
|
29
|
+
* a comment the engine retries it against every later `*/`, so one comment
|
|
30
|
+
* can absorb the ones after it and the two alternatives start overlapping
|
|
31
|
+
* on the same span. Requiring every `*` in the body to not be followed by
|
|
32
|
+
* `/` gives the body exactly one maximal extent, so a comment can never
|
|
33
|
+
* swallow the next one.
|
|
34
|
+
* - The whitespace alternative is a SINGLE-CHARACTER class, NOT `[...]+`.
|
|
35
|
+
* This is the counter-intuitive half: `+` looks like it collapses a run
|
|
36
|
+
* into one iteration, but the outer `*` can still split an n-character run
|
|
37
|
+
* into any composition of `+` matches (2^(n-1) of them) and walks all of
|
|
38
|
+
* them on failure — the textbook `(?:A+|B)*` blowup. A single-character
|
|
39
|
+
* class has exactly one partition: n iterations of one character each.
|
|
40
|
+
*
|
|
41
|
+
* Both hazards are pinned by `packages/parser/test/step-trivia-redos.test.ts`,
|
|
42
|
+
* one case per axis, and the test comment there carries the measurements.
|
|
43
|
+
* Change either alternative only with that test in front of you.
|
|
44
|
+
*
|
|
45
|
+
* ## Relation to the byte scanners
|
|
46
|
+
*
|
|
47
|
+
* The comment body also brings this pattern into line with
|
|
48
|
+
* `skip_step_trivia`, which stops a comment at its FIRST `*/`. A lazy body
|
|
49
|
+
* did not: on backtracking it would accept `/* a */ */` as one comment,
|
|
50
|
+
* where Rust reads a comment followed by junk and refuses the record. The
|
|
51
|
+
* shared vector "reject: comments do not nest, so the trailing `*/` is junk"
|
|
52
|
+
* in `rust/core/tests/fixtures/type_paren_trivia_vectors.json` pins that
|
|
53
|
+
* agreement, so this is a deliberate narrowing, not an accident.
|
|
54
|
+
*
|
|
55
|
+
* An unpaired, unterminated `/*` still fails to match rather than hanging:
|
|
56
|
+
* the body runs out of input, backtracking is O(1) per position, and the
|
|
57
|
+
* required `\*/` after it never appears.
|
|
58
|
+
*/
|
|
59
|
+
export declare const STEP_TRIVIA = "(?:[ \\t\\n\\r\\x0b\\x0c]|/\\*(?:[^*]|\\*(?!/))*\\*/)*";
|
|
60
|
+
//# sourceMappingURL=step-trivia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-trivia.d.ts","sourceRoot":"","sources":["../src/step-trivia.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,eAAO,MAAM,WAAW,2DAA2D,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* Regex source for ISO 10303-21 "trivia": a run of ASCII whitespace and
|
|
6
|
+
* non-nesting `/* ... */` comments, in any order, ANYWHERE whitespace is
|
|
7
|
+
* legal in a record — including between a type name and its `(`.
|
|
8
|
+
*
|
|
9
|
+
* String-side counterpart to `skipTrivia` in `step-lexing.ts`, for callers
|
|
10
|
+
* that already hold a decoded record as a JS string and build a regex around
|
|
11
|
+
* it (entity/typed-value extraction and rewriting), rather than scanning raw
|
|
12
|
+
* bytes. Both mirror `skip_step_trivia` in `rust/core/src/parser/lexical.rs`.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately ASCII-only (`[ \t\n\r\x0b\x0c]`, matching `is_step_space` /
|
|
15
|
+
* `isSpaceByte` in `step-lexing.ts`) rather than `\s`, which also matches
|
|
16
|
+
* U+00A0 and other Unicode space separators Rust's byte scanner does not
|
|
17
|
+
* treat as whitespace — the exact TS/Rust divergence class issue #3733
|
|
18
|
+
* fixed for the byte scanners; a new trivia matcher should not reintroduce
|
|
19
|
+
* it under a different name.
|
|
20
|
+
*
|
|
21
|
+
* ## Why each alternative is shaped the way it is
|
|
22
|
+
*
|
|
23
|
+
* The outer `(?:A|B)*` must have exactly ONE way to partition any input into
|
|
24
|
+
* iterations. Where it has more than one, a failing suffix makes the engine
|
|
25
|
+
* enumerate them, which is exponential in the length of the trivia run. Both
|
|
26
|
+
* alternatives below are written to keep that count at one, and BOTH shapes
|
|
27
|
+
* have been measured — the two axes fail independently, so neither is
|
|
28
|
+
* theoretical:
|
|
29
|
+
*
|
|
30
|
+
* - The comment body is `(?:[^*]|\*(?!/))*`, NOT a lazy `[\s\S]*?`. A lazy
|
|
31
|
+
* body looks unambiguous locally, but when the overall pattern fails past
|
|
32
|
+
* a comment the engine retries it against every later `*/`, so one comment
|
|
33
|
+
* can absorb the ones after it and the two alternatives start overlapping
|
|
34
|
+
* on the same span. Requiring every `*` in the body to not be followed by
|
|
35
|
+
* `/` gives the body exactly one maximal extent, so a comment can never
|
|
36
|
+
* swallow the next one.
|
|
37
|
+
* - The whitespace alternative is a SINGLE-CHARACTER class, NOT `[...]+`.
|
|
38
|
+
* This is the counter-intuitive half: `+` looks like it collapses a run
|
|
39
|
+
* into one iteration, but the outer `*` can still split an n-character run
|
|
40
|
+
* into any composition of `+` matches (2^(n-1) of them) and walks all of
|
|
41
|
+
* them on failure — the textbook `(?:A+|B)*` blowup. A single-character
|
|
42
|
+
* class has exactly one partition: n iterations of one character each.
|
|
43
|
+
*
|
|
44
|
+
* Both hazards are pinned by `packages/parser/test/step-trivia-redos.test.ts`,
|
|
45
|
+
* one case per axis, and the test comment there carries the measurements.
|
|
46
|
+
* Change either alternative only with that test in front of you.
|
|
47
|
+
*
|
|
48
|
+
* ## Relation to the byte scanners
|
|
49
|
+
*
|
|
50
|
+
* The comment body also brings this pattern into line with
|
|
51
|
+
* `skip_step_trivia`, which stops a comment at its FIRST `*/`. A lazy body
|
|
52
|
+
* did not: on backtracking it would accept `/* a */ */` as one comment,
|
|
53
|
+
* where Rust reads a comment followed by junk and refuses the record. The
|
|
54
|
+
* shared vector "reject: comments do not nest, so the trailing `*/` is junk"
|
|
55
|
+
* in `rust/core/tests/fixtures/type_paren_trivia_vectors.json` pins that
|
|
56
|
+
* agreement, so this is a deliberate narrowing, not an accident.
|
|
57
|
+
*
|
|
58
|
+
* An unpaired, unterminated `/*` still fails to match rather than hanging:
|
|
59
|
+
* the body runs out of input, backtracking is O(1) per position, and the
|
|
60
|
+
* required `\*/` after it never appears.
|
|
61
|
+
*/
|
|
62
|
+
export const STEP_TRIVIA = '(?:[ \\t\\n\\r\\x0b\\x0c]|/\\*(?:[^*]|\\*(?!/))*\\*/)*';
|
|
63
|
+
//# sourceMappingURL=step-trivia.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-trivia.js","sourceRoot":"","sources":["../src/step-trivia.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,wDAAwD,CAAC"}
|
package/dist/tokenizer.d.ts
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
|
+
import { type ScannedEntityRef } from './scan-entities-balanced.js';
|
|
1
2
|
export declare class StepTokenizer {
|
|
2
3
|
private buffer;
|
|
3
|
-
private
|
|
4
|
-
private
|
|
4
|
+
private oversizedIds;
|
|
5
|
+
private malformedRecords;
|
|
5
6
|
constructor(buffer: Uint8Array);
|
|
7
|
+
/** Records the last scan refused for an out-of-contract express id
|
|
8
|
+
* (express-id.ts, #3395). Reset per scan; the caller reports it. */
|
|
9
|
+
get oversizedIdCount(): number;
|
|
10
|
+
/** 0 or 1: whether the last `scanEntitiesFast`/`scanEntities` run stopped
|
|
11
|
+
* early on an unclosed `'` string, an unclosed block comment, or a
|
|
12
|
+
* declaration cut off before its own '(' -- never a count of how many,
|
|
13
|
+
* since the scan has no reliable way to resume past the first one it
|
|
14
|
+
* hits. Reset at the start of every scan; the caller reports it. */
|
|
15
|
+
get malformedRecordCount(): number;
|
|
6
16
|
/**
|
|
7
17
|
* Scan for all entity declarations (#EXPRESS_ID = TYPE(...))
|
|
8
|
-
* Returns entity references without parsing full content
|
|
18
|
+
* Returns entity references without parsing full content.
|
|
19
|
+
*
|
|
20
|
+
* Closes each record on the ')' balancing its argument list. The scan itself
|
|
21
|
+
* lives in `scan-entities-balanced.ts`; only the refusal count comes back
|
|
22
|
+
* here, and it comes back in a `finally` so an abandoned generator still
|
|
23
|
+
* reports what it refused.
|
|
9
24
|
*/
|
|
10
|
-
scanEntities(): Generator<
|
|
11
|
-
expressId: number;
|
|
12
|
-
type: string;
|
|
13
|
-
offset: number;
|
|
14
|
-
length: number;
|
|
15
|
-
line: number;
|
|
16
|
-
}>;
|
|
25
|
+
scanEntities(): Generator<ScannedEntityRef>;
|
|
17
26
|
/**
|
|
18
27
|
* FAST scan - skips to semicolon instead of matching parentheses
|
|
19
28
|
* ~5-10x faster for large files, yields length=0 (calculate on-demand)
|
|
20
29
|
*/
|
|
21
|
-
scanEntitiesFast(): Generator<
|
|
22
|
-
expressId: number;
|
|
23
|
-
type: string;
|
|
24
|
-
offset: number;
|
|
25
|
-
length: number;
|
|
26
|
-
line: number;
|
|
27
|
-
}>;
|
|
28
|
-
private readExpressId;
|
|
29
|
-
private readTypeName;
|
|
30
|
-
private skipWhitespace;
|
|
31
|
-
private findEntityLength;
|
|
30
|
+
scanEntitiesFast(): Generator<ScannedEntityRef>;
|
|
32
31
|
}
|
|
33
32
|
//# sourceMappingURL=tokenizer.d.ts.map
|
package/dist/tokenizer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAUA,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAUxF,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,gBAAgB,CAAa;gBAEzB,MAAM,EAAE,UAAU;IAI9B;yEACqE;IACrE,IAAI,gBAAgB,IAAI,MAAM,CAA8B;IAE5D;;;;yEAIqE;IACrE,IAAI,oBAAoB,IAAI,MAAM,CAAkC;IAEpE;;;;;;;;OAQG;IACF,YAAY,IAAI,SAAS,CAAC,gBAAgB,CAAC;IAY5C;;;OAGG;IACF,gBAAgB,IAAI,SAAS,CAAC,gBAAgB,CAAC;CAqQjD"}
|