From 1e6fabf95416fb9d905c9f4c9703637a54a153dd Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 17 Oct 2025 18:34:57 -0700 Subject: [PATCH] feat(tokenizer): use canShift to emit AssignableIdentifier vs Identifier --- src/parser/tokenizer.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/parser/tokenizer.ts b/src/parser/tokenizer.ts index 1d3c708..9bed8b0 100644 --- a/src/parser/tokenizer.ts +++ b/src/parser/tokenizer.ts @@ -1,5 +1,5 @@ import { ExternalTokenizer, InputStream, Stack } from '@lezer/lr' -import { Identifier, Word, IdentifierBeforeDot } from './shrimp.terms' +import { Identifier, AssignableIdentifier, Word, IdentifierBeforeDot } from './shrimp.terms' import type { Scope } from './scopeTracker' // The only chars that can't be words are whitespace, apostrophes, closing parens, and EOF. @@ -66,7 +66,16 @@ export const tokenizer = new ExternalTokenizer( } input.advance(pos) - input.acceptToken(isValidIdentifier ? Identifier : Word) + if (isValidIdentifier) { + // Use canShift to decide which identifier type + if (stack.canShift(AssignableIdentifier)) { + input.acceptToken(AssignableIdentifier) + } else { + input.acceptToken(Identifier) + } + } else { + input.acceptToken(Word) + } }, { contextual: true } )