tarsec 0.2.1 → 0.2.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/dist/parsers.js +17 -1
- package/package.json +2 -2
package/dist/parsers.js
CHANGED
|
@@ -168,7 +168,23 @@ export const quotedString = trace("quotedString", (input) => {
|
|
|
168
168
|
recordFailure(input, "a quoted string");
|
|
169
169
|
return failure(`expected a quote, got ${escape(input[0])}`, input);
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
let closeIdx = -1;
|
|
172
|
+
let searchFrom = 1;
|
|
173
|
+
while (true) {
|
|
174
|
+
const idx = input.indexOf(q, searchFrom);
|
|
175
|
+
if (idx === -1)
|
|
176
|
+
break;
|
|
177
|
+
// Count consecutive backslashes before the quote
|
|
178
|
+
let backslashes = 0;
|
|
179
|
+
for (let i = idx - 1; i >= 1 && input[i] === "\\"; i--)
|
|
180
|
+
backslashes++;
|
|
181
|
+
if (backslashes % 2 === 0) {
|
|
182
|
+
// Even number of backslashes (including 0) means the quote is unescaped
|
|
183
|
+
closeIdx = idx;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
searchFrom = idx + 1;
|
|
187
|
+
}
|
|
172
188
|
if (closeIdx === -1) {
|
|
173
189
|
recordFailure(input, "a quoted string");
|
|
174
190
|
return failure(`expected closing ${escape(q)}`, input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tarsec",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A parser combinator library for TypeScript, inspired by Parsec.",
|
|
5
5
|
"homepage": "https://github.com/egonSchiele/tarsec",
|
|
6
6
|
"scripts": {
|
|
@@ -38,4 +38,4 @@
|
|
|
38
38
|
"typescript": "^5.4.2",
|
|
39
39
|
"vitest": "^1.4.0"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|