[SVN] Perl qq(..) with multiline nested (..) within

Allan Odgaard allan at macromates.com
Sun Jun 5 14:02:33 UTC 2005


On Jun 5, 2005, at 14:41, Peter Traskalik wrote:

> there could be a built in functionality for "counting" the matching  
> "(" and ")"
> so with a given end = "\\)"; TextMate would not match any of the   
> "(...)" pairs
> in between if the amount of openings and closings is equal.

There is subexp calls in the regex, but that'll only work for single  
lines though.

> what do you think ?
> maybe i am on the wrong way at all? missing something ?

The proper solution is to define a rule that matches the parenthesis  
and includes itself in the patterns section. In 1.1b12 you still need  
an extra file for this to be possible (i.e. you can't include subsets  
of the current file).

Using an extra file it'd be something like:

{   name = "string.double-quoted.q.perl";
     begin = "\\Wq[qwx]*\\("; end = "\\)";
     patterns = ( include = "source.perl-qq"; );
}

And then the extra file would be:

{   name = "Quoted Perl string contents";
     scopeName = "source.perl-qq";
     patterns = (
         {
             begin = "\\("; end = "\\)";
             patterns = (
                 { include = "text.html"; },
                 { include = "source.sql"; },
                 { include = "source.perl-qq"; }
             );
         }
     );
);

Currently though I don't encourage using non-limited recursion, since  
the stack used for nesting depth is currently static, and will make  
TM abort given enough recursions. Something which _really_ should be  
fixed soon now...




More information about the textmate-dev mailing list