I have a custom syntax for a simple preprocessing language where each line may contain a prefix. Prefixed lines are escapes into an embedded language that I can handle with an “embed” directive.
It works great, as long as I hardcode what the prefixes are in my syntax file. I just write some contexts that look for the pre-defined prefixes at the beginning of lines, and all is good.
But the language has a directive to change the prefixes. What I really want is instead of having to say:
- match '^#:'
# handle embedded context
I’d like to say:
- match '^{{my_prefix}}'
# handle embedded context
where my_prefix could change dynamically as I parsed directives that changed the prefix. Is such a thing possible? I see that I can define variables statically, or that I can use YAML Macros to be able to reuse a syntax file with different hardcoded prefixes, but I don’t see anything other than capture variables that would allow me to parse something from the file and use it in subsequent matches. I don’t think capture variables help me here, though, because I would imagine that they could be overwritten when I embed another syntax (which I don’t control).
Thanks.