From 5427ac7ec52ffcd3731f2cde030d79a0f1feb2d3 Mon Sep 17 00:00:00 2001 From: Roberto Simonetti Date: Thu, 1 Feb 2024 14:12:22 +0100 Subject: [PATCH] Tools(extract): log tokenizer error (#113) --- packages/qwik-speak/tools/core/parser.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/qwik-speak/tools/core/parser.ts b/packages/qwik-speak/tools/core/parser.ts index 5d97273..84bbaa1 100644 --- a/packages/qwik-speak/tools/core/parser.ts +++ b/packages/qwik-speak/tools/core/parser.ts @@ -385,8 +385,18 @@ export function parseSequenceExpressions(code: string, alias: string): CallExpre const indexes = findIndexes(code, alias); + let tokens: Token[] = []; for (const i of indexes) { - const tokens = tokenize(code, i); + try { + tokens = tokenize(code, i); + } catch (ex: any) { + // Report tokenizer + console.error(ex); + console.error('\n\x1b[31mQwik Speak Tokenizer error\x1b[0m\n%s', + code.substring(i, i + 100) + ' [...]' + + '\n'); + } + if (tokens.length > 0) { try { const callExpression = parse(tokens, code, alias);