[TxMt] Re: Regexp generator for language grammars wanted

Hans-Jörg Bibiko bibiko at eva.mpg.de
Mon Sep 22 07:45:03 UTC 2008


On 22.09.2008, at 01:33, Luke Daley wrote:

>> the generator script will output something like this:
>>
>> NS(Array|Mutable(String|Array)|C(ell(Item)?|oder))
>
> For TM2, it would be nice to not have to do this pretty common step.
>
> Perhaps we could just specify a text file in the bundle with a word
> per line for a certain scope, and TM automagically reads the file and
> optimizes a regex and uses that. This would certainly make
> maintaining the word list easier.

Yes. This would be nice. I had a similar idea as well.
Why not having a given subfolder called 'ScopeLists' in 'Syntax' or  
whatever where one can put such lists as one word per line and these  
files are named according to the scopes (maybe also zipped) like  
'support.function.cappuccino.txt.gz'

Then there would be several options how to generate the regexp.
If one would read a tmLanguage file through the shell like tmSnippets  
while loading the bundles and the 'Optimize' script is inside TM's  
Support file then one could write

{name = 'support.function.cappuccino';
	match = '\b`"$TM_SUPPORT_PATH/optimize.rb" "$TM_BUNDLE_PATH/Syntaxes/ 
ScopeLists/support.function.cappuccino.txt.gz"`\b';
},

Of course, there're dozens of other possibilities to do that ;)

Furthermore, sometimes these lists can be generated automatically by  
grepping documentation/header/etc. files thus if the the user updates  
a Framework/library/etc. the tmLanguage would also be updated  
automatically (but this could be also a bit dangerous).

On the other hand this would also offers some other chances to write a  
language grammar.

Cheers,

--Hans




More information about the textmate mailing list