-
Hey guys, Basically, the syntax should be similar to template strings in JavaScript, although I want to use different quotes and don't need tag functions. Within the embedded expressions, it should then be possible to use other expressions from my grammar. So the following strings should be possible:
My first attempt at a corresponding grammar looked like this, but then I failed because of the terminal symbols...
Could someone help me how I can fix/define a grammar for template strings? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @JanikNex . You'll probably want to look into using multi-mode lexing to handle this one, since template strings are not regular. There's a test we put together some time ago that verifies multi-mode lexing behavior, but it also serves as a good example of how you can push/pop state to change what tokens are acceptable. In your case it would probably make sense to push/pop based on the |
Beta Was this translation helpful? Give feedback.
-
In addition to what @montymxb said, we have an unfinished guide on multi-mode lexing that uses template strings as an example. See here for a preview. |
Beta Was this translation helpful? Give feedback.
In addition to what @montymxb said, we have an unfinished guide on multi-mode lexing that uses template strings as an example. See here for a preview.