[TxMt] Re: Use begin marker of a scope to end the previous one
Édouard Gilbert
edouard.gilbert at gmail.com
Thu Mar 19 19:10:55 UTC 2009
Le 19 mars 09 à 19:00, Allan Odgaard a écrit :
> On 16 Mar 2009, at 11:01, Édouard Gilbert wrote:
>
>> [...]
>> Watch out for grammar bugs, however. It’s easy to make TM crash if
>> you write things like:
>>
>> begin = '(?=a)'
>> end = '(?=b)'
>>
>> because neither expression consume a character. [...]
>
> For the records, you’d need to make it:
>
> begin = '(?=a)'
> end = '(?=a)'
>
> Here, if the ‘patterns’ active between begin/end do not consume
> anything, we have the infinite loop. In your example the parser would
> have advanced to “just before b”, so the same rule would not be
> applicable at the same position.
Actually, I ran into the problem with both look-ahead and look behind,
as in
begin = '(?<=a)'
end = '(?=b)'
so I didn’t thought of that. It might help with some trouble I have on
a grammar. Cheers.
While we’re discussing language grammars, I was wondering if we could
hope some lexer-like capabilities in TM2.0 — I to have regexes
everywhere in my grammars, they make anything barely readable.
And, on quite but not that much unrelated matters, what would be the
better way to match something like:
a
> I can apply set of rule A
b
> I can apply set of rule B
c
My current is
begin = 'a'
end = '(?<=c)'
patterns= (
{ begin = '(?<=a)'
end = 'b'
patterns = ( A )
begin = '(?<=b)'
end = 'c'
patterns = ( B )
}
but the restrictions on look-ahead bug me.
begin = '(?=a)'
end = 'c'
patterns= (
{ begin = 'a'
end = '(?=b)'
patterns = ( A )
begin = 'b'
end = '(?=c)'
patterns = ( B )
}
might be a better solution. Or is there a efficient and elegant
solution I didn't think of?
Édouard GILBERT
edouard.gilbert at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ?douard Gilbert.vcf
Type: text/directory
Size: 578 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20090319/8181641c/attachment.vcf>
-------------- next part --------------
More information about the textmate
mailing list