Skip Menu |

This queue is for tickets about the Regexp-Grammars CPAN distribution.

Report information
The Basics
Id: 49803
Status: open
Priority: 0/
Queue: Regexp-Grammars

Owner: Nobody in particular
Requestors: cognominal [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Date: Fri, 18 Sep 2009 08:41:08 +0200
To: bug-regexp-grammars [...]
From: Stéphane Payrard <cognominal [...]>
Download (untitled) / with headers
text/plain 1.2k
=pod Dear Damian, I have a problem with Regexp::Grammars. I have reduced it : it seems that a named subrule in a negative look-ahead does not work. In the following program, I expected $gram1 and $gram2 to have the same behavior but they don't. The json encoding of the parsings are respectively: { "" : "abab", "c" : [ "ab" ], "!" : -1 } { "" : "abab", "c" : [ "ab", "ab" ] } The second parsing is correct, but the first is not because the array should have two entries. I don't know the meaning of the key-value in the encoding of the fisrt parse : "!" : -1 Thanks for that (as usual) wonderful package. Having identified the problem, I guess I can work around it. So, no hurry, I can wait for a fix. Sorry, I have not yet the courage to look in your source code. =cut use strict; use feature ':5.10'; use Regexp::Grammars; use JSON::XS; my $gram1 = qr{ <debug: on> \A <[c]>+ \Z <token: c> ( (?! <b> ) a )+ b <token: b> b }xms; my $gram2 = qr{ <debug: on> \A <[c]>+ \Z <token: c> ( (?! b ) a )+ b }xms; my $json = JSON::XS->new->pretty(1); "abab" =~ $gram1 ; print $json->encode(\%/); "abab" =~ $gram2 ; print $json->encode(\%/); -- cognominal stef
Subject: Re: [ #49803]
Date: Tue, 22 Sep 2009 16:09:39 +1000
To: bug-Regexp-Grammars [...]
From: Damian Conway <damian [...]>
Download (untitled) / with headers
text/plain 502b
Hi Stephane, Thanks for the bug report. It's definitely a problem, and one that I hope will not be too hard to work around. For negative lookaheads, the solution is to replace: (?! <b> ) with: (?!(?!)| <b> ) The next release of Regexp::Grammars will do this automatically. Positive lookaheads seem more difficult and I do not yet have a solution for them. I'll keep working on it though, and hope that I can find a solution that's equally easy for Regexp::Grammars to automate. Damian

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to