From c127566abe5a6daa3bc05bf58fedb7acbf6434e1 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 6 Nov 2025 21:30:50 -0800 Subject: [PATCH] topNode.topNode --- src/compiler/compiler.ts | 2 +- src/parser/curlyTokenizer.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/compiler.ts b/src/compiler/compiler.ts index 5f482d1..b907055 100644 --- a/src/compiler/compiler.ts +++ b/src/compiler/compiler.ts @@ -786,7 +786,7 @@ export class Compiler { instructions.push(['PUSH', node]) } else { const [input, topNode] = node - let child = topNode.topNode.firstChild + let child = topNode.firstChild while (child) { instructions.push(...this.#compileNode(child, input)) child = child.nextSibling diff --git a/src/parser/curlyTokenizer.ts b/src/parser/curlyTokenizer.ts index bc8acf0..00e3ce1 100644 --- a/src/parser/curlyTokenizer.ts +++ b/src/parser/curlyTokenizer.ts @@ -1,13 +1,13 @@ import { parser } from '#parser/shrimp.ts' -import type { Tree } from '@lezer/common' +import type { SyntaxNode } from '@lezer/common' import { isIdentStart, isIdentChar } from './tokenizer' -// Turns a { curly string } into separate tokens for interpolation -export const tokenizeCurlyString = (value: string): (string | [string, Tree])[] => { +// Turns a { curly string } into strings and nodes for interpolation +export const tokenizeCurlyString = (value: string): (string | [string, SyntaxNode])[] => { let pos = 1 let start = 1 let char = value[pos] - const tokens: (string | [string, Tree])[] = [] + const tokens: (string | [string, SyntaxNode])[] = [] while (pos < value.length) { if (char === '$') { @@ -37,7 +37,7 @@ export const tokenizeCurlyString = (value: string): (string | [string, Tree])[] } const input = value.slice(start + 2, pos) // skip '$(' - tokens.push([input, parser.parse(input)]) + tokens.push([input, parser.parse(input).topNode]) start = ++pos // skip ')' } else { char = value[++pos] @@ -48,7 +48,7 @@ export const tokenizeCurlyString = (value: string): (string | [string, Tree])[] char = value[++pos] const input = value.slice(start + 1, pos) // skip '$' - tokens.push([input, parser.parse(input)]) + tokens.push([input, parser.parse(input).topNode]) start = pos-- // backtrack and start over } }