diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2025-10-29 20:22:19 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2025-10-29 20:22:19 -0700 |
| commit | c20434533887618820985cbb25081255475852f2 (patch) | |
| tree | 9285eb81051be8dfba245b5a1dace38aefcba1e4 /src/lib/core/lexer.ts | |
| parent | 8896b33a652563d90cb211a85dd2f7213f42e5d1 (diff) | |
references
Diffstat (limited to 'src/lib/core/lexer.ts')
| -rw-r--r-- | src/lib/core/lexer.ts | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/lib/core/lexer.ts b/src/lib/core/lexer.ts index 3315fb2..e9756bd 100644 --- a/src/lib/core/lexer.ts +++ b/src/lib/core/lexer.ts @@ -1,4 +1,4 @@ -import { LexerCtx, Token, TokenType } from "./common"; +import { LexerCtx, Token, TokenSubType, TokenType } from "./common"; export type BreakingToken = | TokenType.OPEN_PAREN @@ -16,7 +16,7 @@ export type IsWhitespace<T> = T extends `${TokenType.SPACE}` : false; export type ProcessNameCollection< - Cur extends LexerCtx, + Ctx extends LexerCtx, Tail extends string, _Token extends Token | null > = { @@ -24,16 +24,29 @@ export type ProcessNameCollection< nameCollection: ""; tokens: _Token extends null ? [ - ...Cur["tokens"], - ...(Cur["nameCollection"] extends "" + ...Ctx["tokens"], + ...(Ctx["nameCollection"] extends "" ? [] - : [Token<TokenType.UNIQUE_SYMBOL, Cur["nameCollection"]>]) + : [ + Token< + TokenType.NAME, + TokenSubType.REFERENCE, + Ctx["nameCollection"] + > + ]) ] : [ - ...Cur["tokens"], - ...(Cur["nameCollection"] extends "" + ...Ctx["tokens"], + ...(Ctx["nameCollection"] extends "" ? [_Token] - : [Token<TokenType.UNIQUE_SYMBOL, Cur["nameCollection"]>, _Token]) + : [ + Token< + TokenType.NAME, + TokenSubType.REFERENCE, + Ctx["nameCollection"] + >, + _Token + ]) ]; }; @@ -53,9 +66,7 @@ export type _Lex<Ctx extends LexerCtx> = nameCollection: `${Ctx["nameCollection"]}${Head}`; tokens: Ctx["tokens"]; }> - : // : Ctx["next"] extends `${infer Head}` - // ? _Lex<{ next: Head; tokens: Ctx["tokens"] }> - Ctx["tokens"]; + : Ctx["tokens"]; export type Lex<Raw extends string> = _Lex<{ next: `${Raw};`; |
