[TxMt] Language grammar question - how does newline get inserted when you type "{\r}" ?

Allan Odgaard throw-away-1 at macromates.com
Sat Feb 18 05:48:30 UTC 2006


On 18/2/2006, at 6:20, Charilaos Skiadas wrote:

>> The current Io bundle does this. For the records though, the way  
>> it is achieved is by having the language grammar match empty  
>> parenthesis and have it assign a scope name to that construct (for  
>> example meta.empty-parenthesis.io).
> But the same effect with curly braces instead of parentheses does  
> not need any extra stuff like that, does it? How is that done, and  
> why can't we use the same for parens?

Ah no, the curly brace automation is hardcoded.

It could be changed to also be specified by overloading return -- I  
like that latter part of it. But having to put in all those language  
grammar rules, I'm not too fond of. One option is the talked about  
possibility of making a “base” language grammar for source code that  
all others include, but this is only of limited use, e.g. as  
mentioned on IRC yesterday, it would be nice to match Doxygen  
keywords and maybe Subversion magic words as well, but this happens  
in comments (well, the latter could likely be in strings), so each  
language would still need to have some knowledge about this (i.e.  
where to include the svn or Doxygen language grammar).

Adding to this, there is also the problem where a construct is both  
matched for behavior altering and for styling, or where it is matched  
simply to make the language parse correctly. For example LaTeX do  
parse { and }, although in this case it wouldn't conflict, because  
the potential base grammar would only match them, when nothing was in  
between.





More information about the textmate mailing list