@malloydata/motly-ts-parser 0.0.1 → 0.0.2
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/build/parser.js +15 -3
- package/package.json +1 -1
package/build/parser.js
CHANGED
|
@@ -80,13 +80,25 @@ class Parser {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Like `skipWs`, but also eats commas. Used in statement-list
|
|
85
|
+
* contexts (top-level document and properties blocks) so commas
|
|
86
|
+
* can serve as optional separators between statements.
|
|
87
|
+
*/
|
|
88
|
+
skipWsAndCommas() {
|
|
89
|
+
this.skipWs();
|
|
90
|
+
while (this.peekChar() === ",") {
|
|
91
|
+
this.advance(1);
|
|
92
|
+
this.skipWs();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
83
95
|
// ── Statement Dispatch ──────────────────────────────────────────
|
|
84
96
|
parseStatements() {
|
|
85
97
|
const statements = [];
|
|
86
|
-
this.
|
|
98
|
+
this.skipWsAndCommas();
|
|
87
99
|
while (this.pos < this.input.length) {
|
|
88
100
|
statements.push(this.parseStatement());
|
|
89
|
-
this.
|
|
101
|
+
this.skipWsAndCommas();
|
|
90
102
|
}
|
|
91
103
|
return statements;
|
|
92
104
|
}
|
|
@@ -775,7 +787,7 @@ class Parser {
|
|
|
775
787
|
}
|
|
776
788
|
const stmts = [];
|
|
777
789
|
for (;;) {
|
|
778
|
-
this.
|
|
790
|
+
this.skipWsAndCommas();
|
|
779
791
|
if (this.eatChar("}"))
|
|
780
792
|
return stmts;
|
|
781
793
|
if (this.pos >= this.input.length) {
|