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

Allan Odgaard mailinglist at textmate.org
Fri Jan 6 00:11:38 UTC 2012


On 30/12/2011, at 19.58, Adam Strzelecki wrote:

> […] C grammar […] uses `include = '$base'` […] This works perfectly well for standalone C or C++ file

I think there might be a few edge-cases. For example using #if 0 / #else / #endif inside @implementation … @end and such.

Although this specific example is perhaps a slightly different issue than the self/base one (as what we want there is to include “current context’s rules”).

> […] when trying to embed C source into other language we get a problem […]
> 
> I can see two solutions here:
> (1) caller should be able to block/change $base […]
> (2) callee should be able to specify language grammars that are allowed to be base for it.
> 
> Or maybe there's already some undocumented solution?

I have not thought it through but I think we need to rewrite the current (Objective-)C(++) grammars to be injection based.

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.




More information about the textmate-dev mailing list