Nested syntax templates
Opened this issue · 4 comments
bopjesvla commented
syntax helper2 = ctx => #`
syntax test2 = ctx => {
return #`1`
}`
helper2
syntax helper1 = ctx => #`(#`1`)`
syntax test1 = ctx => helper1
test1
Neither works.
disnet commented
The escape syntax for syntax templates is the same as normal templates:
#`a literal backtick \` and then we're done`
disnet commented
Oops. That's supposed to be the escape but looks like we have a bug:
syntax test = function (ctx) {
return #`let x = \`template string\`;`
}
test
throws:
/Users/tim/dev/sweet.js/node_modules/shift-parser/dist/tokenizer.js:731
throw this.createILLEGAL();
^
Error: [2:21]: Unexpected "`"
at JsError.Error (native)
at new JsError (/Users/tim/dev/sweet.js/node_modules/shift-parser/dist/tokenizer.js:161:81)
at Reader.createError (/Users/tim/dev/sweet.js/node_modules/shift-parser/dist/tokenizer.js:277:14)
at Reader.createILLEGAL (/Users/tim/dev/sweet.js/node_modules/shift-parser/dist/tokenizer.js:245:53)
at Reader.getEscapedIdentifier (/Users/tim/dev/sweet.js/node_modules/shift-parser/dist/tokenizer.js:731:24)
at Reader.scanIdentifier (/Users/tim/dev/sweet.js/node_modules/shift-parser/dist/tokenizer.js:795:63)
at Reader.advance (/Users/tim/dev/sweet.js/node_modules/shift-parser/dist/tokenizer.js:1437:25)
at Reader.advance (/Users/tim/dev/sweet.js/build/src/shift-reader.js:325:90)
at Reader.read (/Users/tim/dev/sweet.js/build/src/shift-reader.js:227:24)
at Reader.read (/Users/tim/dev/sweet.js/build/src/shift-reader.js:252:28)
bopjesvla commented
Yeah, I tried that too. I based the syntax for nested templates on the reader tests.
gabejohnson commented
This is still an issue. I have some ideas, but they involve changing our strategy for reading syntax templates. I'd also like to implement the ideas from #551 (comment) at the same time.