"Double quoted strings" #35
|
|
@ -867,7 +867,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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user