I’m learning how to write syntax definitions. I’m creating a syntax definition for a language that has two filetypes: source code (.wbs), and HTML with sourcecode embedded (.wbt). I’ve written the syntax for the source code and it works pretty well; now I’m trying to figure out the syntax definition for HTML with source embedded.
Here is my issue:
My sourcecode syntax does some fancy stack work to detect matched and unmatched keywords. For example, “else” will be identified as
keyword.control.conditional
if it’s within an “if” statement, but is otherwise identified as invalid.unmatched
.
With my template syntax, I push the source syntax at <%
and pop it off at %>
, but this means the source’s stack is deleted and starts over at every embedded statement. This leads to keywords incorrectly being identified as invalid.unmatched
, since the stack was not preserved. I need to preserve the source’s stack between these embedded statements – sort of like juggling two distinct stacks (HTML and my source). Is this possible? How would you approach this problem?