It seems there is no way to have parts of a capture scoped by calls to $self or #repository elements, which means that complex captures get to have many capture elements.
It would be handy if there was a code for language grammar capture numbering, so that these are more resilient and self-healing when the regexp underlying their definition changes.
What I would suggest for TM2 is something like a code for "next group" so instead of explicitly numbering all matches, only non- sequential elements are explicitly numbered, and all others are self numbering. A nice code would be "#". A nice twist would be if this supported skipping elements when suffixed with an addition "#++" or "# +n"
Then, if we change a match from, say: match = '(a)(b)(c)'; To say: match = '(a)(a1)(b)(c)';
Then the numbering, instead of manually being recoded from this: 1 = { name = 'a'; }; 2 = { name = 'b'; }; 3 = { name = 'c'; }; to this: 1 = { name = 'a'; }; 2 = { name = 'a1'; }; 3 = { name = 'b'; }; 4 = { name = 'c'; };
Could simply stay as this (where # is a code for "next sequential number" 1 = { name = 'a'; }; # = { name = 'a1'; }; # = { name = 'b'; }; # = { name = 'c'; };
In the more complex case,
1 = { name = 'a'; }; # = { name = 'a1'; }; #+1 = { name = 'b'; }; //skips a group # = { name = 'c'; };
On Aug 7, 2007, at 6:52 PM, Timothy Bates wrote:
It seems there is no way to have parts of a capture scoped by calls to $self or #repository elements, which means that complex captures get to have many capture elements.
It would be handy if there was a code for language grammar capture numbering, so that these are more resilient and self-healing when the regexp underlying their definition changes.
What I would suggest for TM2 is something like a code for "next group" so instead of explicitly numbering all matches, only non- sequential elements are explicitly numbered, and all others are self numbering. A nice code would be "#". A nice twist would be if this supported skipping elements when suffixed with an addition "#+ +" or "#+n"
The simple flaw in this is that the captures are a dictionary, and each dictionary key must be unique. It's not possible to have a single character like that. Now it could happen where you use this notation and then TextMate translates it into the actual numbers when it saves it. However try hitting enter inside a capture dictionary, a new capture set will be created with the next sequential number, basically the same thing already built in. :)
On 8 Aug 2007, at 00:52, Timothy Bates wrote:
It would be handy if there was a code for language grammar capture numbering, so that these are more resilient and self-healing when the regexp underlying their definition changes.
I believe the plan for TM2 is to use the named captures functionality of Oniguruma, so you can instead give captured groups identifiers of your choice and then use those identifiers to refer to them for naming.