@wdprlib/parser 2.0.6 → 2.0.7
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/index.cjs +21 -7
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -167,6 +167,14 @@ class Lexer {
|
|
|
167
167
|
}
|
|
168
168
|
return result;
|
|
169
169
|
}
|
|
170
|
+
lastNonWhitespaceTokenType() {
|
|
171
|
+
for (let i = this.state.tokens.length - 1;i >= 0; i--) {
|
|
172
|
+
const t = this.state.tokens[i];
|
|
173
|
+
if (t.type !== "WHITESPACE")
|
|
174
|
+
return t.type;
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
170
178
|
addToken(type, value) {
|
|
171
179
|
const startPos = import_ast.createPoint(this.state.line, this.state.column - value.length, this.state.pos - value.length);
|
|
172
180
|
const endPos = import_ast.createPoint(this.state.line, this.state.column, this.state.pos);
|
|
@@ -436,15 +444,21 @@ class Lexer {
|
|
|
436
444
|
return;
|
|
437
445
|
}
|
|
438
446
|
if (char === '"') {
|
|
439
|
-
|
|
440
|
-
|
|
447
|
+
const lastNonWs = this.lastNonWhitespaceTokenType();
|
|
448
|
+
if (lastNonWs === "EQUALS") {
|
|
449
|
+
let quoted = this.advance();
|
|
450
|
+
while (!this.isAtEnd() && this.current() !== '"' && this.current() !== `
|
|
441
451
|
`) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
452
|
+
quoted += this.advance();
|
|
453
|
+
}
|
|
454
|
+
if (this.current() === '"') {
|
|
455
|
+
quoted += this.advance();
|
|
456
|
+
}
|
|
457
|
+
this.addToken("QUOTED_STRING", quoted);
|
|
458
|
+
return;
|
|
446
459
|
}
|
|
447
|
-
this.
|
|
460
|
+
this.advance();
|
|
461
|
+
this.addToken("TEXT", '"');
|
|
448
462
|
return;
|
|
449
463
|
}
|
|
450
464
|
if (char === ":") {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -112,6 +112,14 @@ class Lexer {
|
|
|
112
112
|
}
|
|
113
113
|
return result;
|
|
114
114
|
}
|
|
115
|
+
lastNonWhitespaceTokenType() {
|
|
116
|
+
for (let i = this.state.tokens.length - 1;i >= 0; i--) {
|
|
117
|
+
const t = this.state.tokens[i];
|
|
118
|
+
if (t.type !== "WHITESPACE")
|
|
119
|
+
return t.type;
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
115
123
|
addToken(type, value) {
|
|
116
124
|
const startPos = createPoint(this.state.line, this.state.column - value.length, this.state.pos - value.length);
|
|
117
125
|
const endPos = createPoint(this.state.line, this.state.column, this.state.pos);
|
|
@@ -381,15 +389,21 @@ class Lexer {
|
|
|
381
389
|
return;
|
|
382
390
|
}
|
|
383
391
|
if (char === '"') {
|
|
384
|
-
|
|
385
|
-
|
|
392
|
+
const lastNonWs = this.lastNonWhitespaceTokenType();
|
|
393
|
+
if (lastNonWs === "EQUALS") {
|
|
394
|
+
let quoted = this.advance();
|
|
395
|
+
while (!this.isAtEnd() && this.current() !== '"' && this.current() !== `
|
|
386
396
|
`) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
397
|
+
quoted += this.advance();
|
|
398
|
+
}
|
|
399
|
+
if (this.current() === '"') {
|
|
400
|
+
quoted += this.advance();
|
|
401
|
+
}
|
|
402
|
+
this.addToken("QUOTED_STRING", quoted);
|
|
403
|
+
return;
|
|
391
404
|
}
|
|
392
|
-
this.
|
|
405
|
+
this.advance();
|
|
406
|
+
this.addToken("TEXT", '"');
|
|
393
407
|
return;
|
|
394
408
|
}
|
|
395
409
|
if (char === ":") {
|