I have a question regarding grammar injections.
I have written a tree-sitter based grammar for my custom language that defines shader nodes for my 3D engine. For the glsl code sections I use simple single quote for a multiline block. I would like to make an injection for the code block for glsl but I do not undestand how.
First I have read this:
However there are still things I do not understand. Why does the regex need to be defined in the grammar of the inner language (In my case I don’t even need a regex since all my code blocks are GLSL code)? Wouldn’t it make more sense to define the grammar in the outer language because the regex might differ for among languages (Or maybe I got it wrong?).
The first link does not specify where the addInjectionPoint function needs to be called. From the second link I figured I might have to create a
To me it would make a lot more sense if there was some kind of simple method for injection on the node and let the grammar in the outer language define a different node for each of the different languages (e.g. callExpressionHTML or callExpressionPHP).
Another problem might be that the language-glsl package that provides the glsl grammar might be using text mate because it does not define type: tree-sitter in the cson file. Is that correct? Is it still possible to inject it into my tree-sitter grammar?
I did not yet upload the grammar to github but I can do this tomorrow if you want me to.