[NTG-context] Off-topic: Struggles with LPEG grammar
Taco Hoekwater
taco at elvenkind.com
Mon Dec 21 13:50:41 CET 2020
> On 21 Dec 2020, at 13:46, Taco Hoekwater <taco at elvenkind.com> wrote:
>
>
>
>> On 21 Dec 2020, at 13:16, Mojca Miklavec <mojca.miklavec.lists at gmail.com> wrote:
>>
>> My only explanation would be that perhaps "^1" is so greedy that the
>> rest of the pattern doesn't get found. But I don't want to believe
>> that explanation.
>
> Which (of course) means that that is exactly what happens ;)
>
> The ones that match are
>
> ababbb (a (ba+bb) b) => r4 r1(r3(r5 r4) r2(r5 r5)) r5
> abbbab (a (bb+ba) b) => r4 r1(r2(r5 r5) r3(r5 r4)) r5
>
> With the ^1, in the “bb” cases the first “b” eats all three “b”s:
>
> ababbb fails the r5 at the end
Sorry, that was wrong, it fails at the second r5 in the r2 as well, for the same
reason as below.
>
> abbbab fails the first r2 already (since the second r5 therein never happens)
>
> Best wishes,
> Taco
More information about the ntg-context
mailing list