The first lit_str token always starts with a backtick, whereas the last lit_str always ends with one. If there are no intermediate interpolated blocks, the entire node really is just a single lit_str.
After encountering a backtick, I manually parse each string segment before/between/after interploated blocks. There was some trickery because this essentially bypasses most of the context and the tokenizer behind it which has to be advanced manually.
In the end this was a lot less work than I expected. That is until we encounter the edge-cases and bugs.
I finally decided to tackle this.
The AST remained surprisingly simple, a string template literal now looks like this:
The first
lit_str
token always starts with a backtick, whereas the lastlit_str
always ends with one. If there are no intermediate interpolated blocks, the entire node really is just a singlelit_str
.After encountering a backtick, I manually parse each string segment before/between/after interploated blocks. There was some trickery because this essentially bypasses most of the context and the tokenizer behind it which has to be advanced manually.
In the end this was a lot less work than I expected. That is until we encounter the edge-cases and bugs.
Closes #46.