From e1859c1bda8e1b31a542ca96c187f77f149acb95 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath <2+defunkt@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:25:33 -0800 Subject: [PATCH] fix: parens can't be in words --- src/parser/tests/tokens.test.ts | 20 ++++++++++++++++++++ src/parser/tokenizer2.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/src/parser/tests/tokens.test.ts b/src/parser/tests/tokens.test.ts index f3613f7..b166570 100644 --- a/src/parser/tests/tokens.test.ts +++ b/src/parser/tests/tokens.test.ts @@ -425,6 +425,26 @@ f ) }) + test('function call w/ parens', () => { + expect('echo(bold hello world)').toMatchTokens( + { type: 'Identifier', value: 'echo' }, + { type: 'OpenParen' }, + { type: 'Identifier', value: 'bold' }, + { type: 'Identifier', value: 'hello' }, + { type: 'Identifier', value: 'world' }, + { type: 'CloseParen' }, + ) + + expect('echo (bold hello world)').toMatchTokens( + { type: 'Identifier', value: 'echo' }, + { type: 'OpenParen' }, + { type: 'Identifier', value: 'bold' }, + { type: 'Identifier', value: 'hello' }, + { type: 'Identifier', value: 'world' }, + { type: 'CloseParen' }, + ) + }) + test('assignment', () => { expect('x = 5').toMatchTokens( { type: 'Identifier', value: 'x' }, diff --git a/src/parser/tokenizer2.ts b/src/parser/tokenizer2.ts index c3e891b..dacaaca 100644 --- a/src/parser/tokenizer2.ts +++ b/src/parser/tokenizer2.ts @@ -507,6 +507,7 @@ const isWordChar = (ch: number): boolean => { !isWhitespace(ch) && ch !== 10 /* \n */ && ch !== 59 /* ; */ && + ch !== 40 /* ( */ && ch !== 41 /* ) */ && ch !== 93 /* ] */ && ch !== -1 /* EOF */