SQL language embedded in YAML

Hello CodeMirror!

I’m new around. I’m using CodeMirror through the React component [1] to render a YAML editor in my app. One of the fields in my YAML is a string that’s supposed to be parsed as a SQL query. I wonder if there’s a way to compose the YAML language and the SQL language such that the one particular field uses SQL highlighting and such.

I’ve read the Mixed-language docs [2], but they seem to talk about composing two LR languages. As far as I can tell, YAML (@codemirror/legacy-modes/mode/yaml) seems to be a “stream language”. Is it still possible to get the composition that I want somehow?


[1] React CodeMirror - CodeMirror component for React.
[2] CodeMirror Mixed-Language Parsing Example

Legacy/stream parsers won’t create a syntax tree, just a sequence of tokens, so you generally can’t use Lezer’s mixed parsing with them, because the ranges to parse don’t exist as nodes in the tree. Also, StreamParser isn’t set up for any kind of mixed parsing at all, at the moment.