fix: parens can't be in words
This commit is contained in:
parent
07a42d9767
commit
e1859c1bda
|
|
@ -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', () => {
|
test('assignment', () => {
|
||||||
expect('x = 5').toMatchTokens(
|
expect('x = 5').toMatchTokens(
|
||||||
{ type: 'Identifier', value: 'x' },
|
{ type: 'Identifier', value: 'x' },
|
||||||
|
|
|
||||||
|
|
@ -507,6 +507,7 @@ const isWordChar = (ch: number): boolean => {
|
||||||
!isWhitespace(ch) &&
|
!isWhitespace(ch) &&
|
||||||
ch !== 10 /* \n */ &&
|
ch !== 10 /* \n */ &&
|
||||||
ch !== 59 /* ; */ &&
|
ch !== 59 /* ; */ &&
|
||||||
|
ch !== 40 /* ( */ &&
|
||||||
ch !== 41 /* ) */ &&
|
ch !== 41 /* ) */ &&
|
||||||
ch !== 93 /* ] */ &&
|
ch !== 93 /* ] */ &&
|
||||||
ch !== -1 /* EOF */
|
ch !== -1 /* EOF */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user