Skip Menu |
 

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

Report information
The Basics
Id: 123860
Status: rejected
Priority: 0/
Queue: Regexp-Grammars

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

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



Subject: This program doesn’t stop running
Date: Mon, 11 Dec 2017 11:12:57 +0200
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Alexander Karelas <alex.karelas [...] gmail.com>
Download (untitled) / with headers
text/plain 692b
Which means i cannot use regexes inside require blocks, i think? But thats bad because how else can i say: i want this word to match one of these regexes but also not match one of those regexes? I see no other way to do it Show quoted text
> #!/usr/bin/env perl > > use v5.16; > use warnings; > use lib 'local/lib/perl5'; > > use Regexp::Grammars; > use Test::More; > use DDP; > use Data::Dumper; > > my $grammar = qr/ > > \A <item> \z > > <token: item> > (\S+) > <require: (?{ no Regexp::Grammars; $CAPTURE != m!! })> > > /; > > my $matches = 'Peter' =~ $grammar; > > my $struct = { > matches => $matches, > hashref => \%/, > errors => \@!, > }; > > p $struct;
Subject: Re: [rt.cpan.org #123860] This program doesn’t stop running
Date: Tue, 12 Dec 2017 12:09:19 +1100
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Download (untitled) / with headers
text/plain 949b
Hi Alexander. First of all, unless I've misunderstood your intent, I'm fairly sure you need: <require: (?{ no Regexp::Grammars; $CAPTURE !~ m!! })> That is: !~ instead of != Second, if that's the case, there's seems to be no point in doing a negative match against an empty regex, since an empty regex is special-cased to rematch the previous successful regex (which would either be in one of the module's you loaded--most likely inside Regexp::Grammars itself--or else a null match, if there was in fact no preceding successful match). Neither of those is a desirable outcome as far as I can see. I'd have expected you to want to write something like: <require: (?{ no Regexp::Grammars; $CAPTURE !~ m!Paul! })> ...which works perfectly well in my own testing. But perhaps I have misunderstood your intentions, in which case I'd be happy to have them explained to me and to help you achieve your goals with Regexp::Grammars. Damian
Subject: Re: [rt.cpan.org #123860] This program doesn’t stop running
Date: Tue, 12 Dec 2017 07:54:31 +0200
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Alexander Karelas <alex.karelas [...] gmail.com>
Download (untitled) / with headers
text/plain 1.3k
Indeed that works, but I thought that sibce empty regex doesnt work, that means a regex is not supposed to be there and evil things might happen in complex situations. Is that not the case? Sent from my iPhone Show quoted text
> On 12 Dec 2017, at 3:10 AM, damian@conway.org via RT <bug-Regexp-Grammars@rt.cpan.org> wrote: > > <URL: https://rt.cpan.org/Ticket/Display.html?id=123860 > > > Hi Alexander. > > First of all, unless I've misunderstood your intent, I'm fairly sure you > need: > > <require: (?{ no Regexp::Grammars; $CAPTURE !~ m!! })> > > That is: !~ instead of != > > Second, if that's the case, there's seems to be no point in doing a > negative match against an empty regex, since an empty regex is > special-cased to rematch the previous successful regex (which would > either be in one of the module's you loaded--most likely inside > Regexp::Grammars itself--or else a null match, if there was in fact no > preceding successful match). Neither of those is a desirable outcome as > far as I can see. > > I'd have expected you to want to write something like: > > <require: (?{ no Regexp::Grammars; $CAPTURE !~ m!Paul! })> > > ...which works perfectly well in my own testing. > > But perhaps I have misunderstood your intentions, in which case > I'd be happy to have them explained to me and to help you achieve > your goals with Regexp::Grammars. > > Damian >
Subject: Re: [rt.cpan.org #123860] This program doesn’t stop running
Date: Tue, 12 Dec 2017 18:35:21 +1100
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Download (untitled) / with headers
text/plain 728b
Show quoted text
> Indeed that works, but I thought that since empty regex doesnt work, > that means a regex is not supposed to be there and evil things might > happen in complex situations. Is that not the case?
Evil things might indeed happen in complex situations. They often do. And nested regex matches certainly qualify as "complex situations". :-) In practical terms, a <require:...> is probably not the right tool here. You will probably do better with a preliminary negative look-ahead on the regex you want not to match. Like so: my $grammar = qr/ \A <item> \z <token: item> *(?! Paul | Joh?n | Ringo+ | [George] \b ) # None of these allowed* (\S++) /; Hope this helps, Damian


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.