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

People
Owner: Nobody in particular
Requestors: cognominal [...] gmail.com
Cc:
AdminCc:

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



Subject:
Date: Fri, 18 Sep 2009 08:41:08 +0200
To: bug-regexp-grammars [...] rt.cpan.org
From: Stéphane Payrard <cognominal [...] gmail.com>
=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: [rt.cpan.org #49803]
Date: Tue, 22 Sep 2009 16:09:39 +1000
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
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