I have a language that is embedded by YAML for the general structure but scalars should be processed with the DSL. However, only when they are located at a specific position in the YAML file.
title: my title
a = b;
In the example above, I would like the existing YAML parser to parse the document and have the scalar at foo: parsed again.
I know how to determine the location in the file to determine what to parse again but I wonder what the best approach:
- create my own YAML + DSL single lexer / parser (current situation)
- create a new IFileElementType that overrides the doParseContents, basically replacing the YAML Scalar AST node with a more tokenized node with the DSL
- another way?
I need the DSL part to be aware of DSL parts in other parts of the document (and other documents).
The reason I want to move away from the current situation (a single lexer/parser) is that I end up with either:
- making the lexer aware of where it is in the document and determine the next state from there. That works but I don't feel a Lexer should have that responsibility
- parse every YAML Scalar as DSL which generates tokens where it's not supposed to be (the title: example above should be simple plain text)
Is there any example in the community repo that I'm missing or another example that I can use?