Hello TM developers,

I've just realized that posting to general TM list about this grammar problems 
wasn't wise idea to I've let myself to report to dev list here.

Since C grammar is intended to be the base for other grammars such as C++ or 
Obj-C it uses `include = '$base'` instead of `include = '$self'` for all 
recursive sub-block parsing to point back to original grammar (if possible). 
This works perfectly well for standalone C or C++ file, however when trying to 
embed C source into other language we get a problem, i.e. for Ruby grammar:

#!/usr/bin/env ruby
# trying to embed something into Ruby (using TM2 grammar)
variable = <<-C
/* we are parsed by C grammar here */
enum {
 /* ooops this comment isn't parsed anymore by C grammar but Ruby again! */
}
C

Problem is on '{' which starts new C block, that does `include = '$base'`. 
Unfortunately $base is Ruby here not C. Same if we change C into CPP in the 
example above, $base is still Ruby.

I can see two solutions here:
(1) caller should be able to block/change $base i.e. using some new keyword:

{ safeInclude = 'source.c'; }
or
{ base = 'source.c'; include = 'source.c'; }

(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?

Cheers,
-- 
Adam Strzelecki

_______________________________________________
textmate-dev mailing list
textmate-dev@lists.macromates.com
http://lists.macromates.com/listinfo/textmate-dev

Reply via email to