Skip to content

Commit 41cebbd

Browse files
committed
fix
1 parent e04318a commit 41cebbd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/parser/parser_lib.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { assertGreater } from "@std/assert/greater";
22
import { MemoizationCacheResult, memoize } from "@std/cache/memoize";
33
import { ArrayResult, ArrayResultError } from "../array_result.ts";
4+
import { assert } from "@std/assert/assert";
5+
import { assertNotEquals } from "@std/assert/not-equals";
46

57
type ParserResult<T> = ArrayResult<Readonly<{ value: T; length: number }>>;
68
type InnerParser<T> = (input: number) => ParserResult<T>;
@@ -226,13 +228,13 @@ function generateError(
226228
length = 0;
227229
} else {
228230
const sourceString = currentSource.slice(position);
229-
const [token] = sourceString.match(/\S*/)!;
231+
const [token] = sourceString.match(/^\S*/)!;
230232
if (token === "") {
231233
if (/^\r?\n/.test(sourceString)) {
232234
source = "newline";
233235
length = 0;
234236
} else {
235-
const [token] = sourceString.match(/\s+?(?=\r?\n|$)/)!;
237+
const [token] = sourceString.match(/^\s+?(?=\S|\r?\n|$)/)!;
236238
source = "space";
237239
length = token.length;
238240
}

0 commit comments

Comments
 (0)