[SVN] Re: C based grammars broken for embedding (restricting $base reference)

Adam Strzelecki ono at java.pl
Mon Jan 16 17:54:23 UTC 2012

> So we have 4 “dummy” grammars which basically just assigns a root scope to the document (e.g. source.c++) and the C, C++, and Objective-C support is then injected into the scopes for where they should be active. This would fix embedding as well.

Okay I think I get it. Still I am not sure what makes injection more powerful than inclusion?

So we would have 4 dummy grammars for root scope (C, C++, Obj-C, Obj-C++), but also 3 extra grammars (C, C++, Obj-C) that do the real job and have proper injection scope selectors set. Right?

But then if Obj-C++ dummy grammar sets source.objc++ and all support grammars have source.objc++ injection selector assigned, then what would be the order of injection? How can we ensure C support grammar goes last?

Also it seems when I remove "include = 'source.c'" from Lua grammar and made it use injection from "meta.embedded.c" scope, seems that C grammar $base still refers to injector grammar (Lua). Would it be feasible to make $base to refer first grammar in inclusion chain, where any injection break such chain? This would fix C embedding straight ahead when using injection.

Moreover now if we use injection based C/C++/Obj-C support, can we embed (inject) some other grammar into C/C++? I.e.:

1. source.lua
2. meta.embedded.c <- C injection
3. string.quoted.double.c
4. meta.embedded.html <- HTML injection?

And then will C grammar rules will be injected only to 2,3 scope levels or 4 scope level (HTML) too, where HTML get injected?


More information about the textmate-dev mailing list