Skip Menu |
 

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

Report information
The Basics
Id: 85159
Status: resolved
Priority: 0/
Queue: Regexp-Grammars

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

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



Subject: Internal error: this shouldn't happen
Date: Thu, 09 May 2013 21:29:21 +0400
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Arseny Krasikov <nyaapa [...] gmail.com>
Download (untitled) / with headers
text/plain 136b
have this on <token: BIT> 1 | 0 v5.16.3 use 5.014; fedora 18 Regexp::Grammars version 1.026 -- Kindest Regards, Arseny Krasikov
Subject: Re: [rt.cpan.org #85159] Internal error: this shouldn't happen
Date: Fri, 10 May 2013 07:29:16 +1000
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Download (untitled) / with headers
text/plain 119b
Show quoted text
> <token: BIT> > 1 | 0
Definitely a bug. Workaround is: <token: BIT> 1 | [0] Will be fixed ASAP. Damian
Subject: Re: [rt.cpan.org #85159] Internal error: this shouldn't happen
Date: Fri, 10 May 2013 07:45:07 +1000
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Bug fixed. New version uploaded to CPAN. Thanks again! Damian
Resolved.
Subject: Re: [rt.cpan.org #85159] Internal error: this shouldn't happen
Date: Fri, 10 May 2013 04:37:30 +0400
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Arseny Krasikov <nyaapa [...] gmail.com>
Download (untitled) / with headers
text/plain 517b
On 10.05.2013 01:46, damian@conway.org via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=85159 > > > Bug fixed. New version uploaded to CPAN. > > Thanks again! > > Damian >
Thanks you for great module :) I have a question, i cant hardcode rules directly at code, so i need to add some rules from variables via interpolation. How can i do it in legit way? I didn't find a good solution, but only a hack... Also, topic http://www.perlmonks.org/?node_id=1032842 -- Kindest Regards, Arseny Krasikov
Subject: Re: [rt.cpan.org #85159] Internal error: this shouldn't happen
Date: Fri, 10 May 2013 13:55:28 +1000
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Download (untitled) / with headers
text/plain 798b
Show quoted text
> I have a question, i cant hardcode rules directly at code, so i need to > add some rules from variables via interpolation. How can i do it in > legit way? I didn't find a good solution, but only a hack...
I usually do it as in the code below. It seems to work fine. Damian -----cut----------cut----------cut----------cut----------cut----------cut----------cut----- my $rules = q{ <rule: List> \( <[Item]>* % , \) <token: Item> [^(),]++ | <List> }; my $grammar = do { use re 'eval'; use Regexp::Grammars; qr{ ^ <List> $ $rules }xms; }; while (my $line = <DATA>) { if ($line =~ $grammar) { use Data::Dumper 'Dumper'; warn Dumper( \%/ ); } else { say 'failed'; } } __DATA__ (1,2,3,(4,5,6),7)
Subject: Re: [rt.cpan.org #85159] Internal error: this shouldn't happen
Date: Fri, 10 May 2013 13:44:43 +0400
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Arseny Krasikov <nyaapa [...] gmail.com>
Download (untitled) / with headers
text/plain 1.1k
On 10.05.2013 08:01, damian@conway.org via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=85159 > >
>> I have a question, i cant hardcode rules directly at code, so i need to >> add some rules from variables via interpolation. How can i do it in >> legit way? I didn't find a good solution, but only a hack...
> I usually do it as in the code below. > It seems to work fine. > > Damian
yes, your example works fine, but if you put all query in scalar and write qr{$rules}xims;, for example, that doesn't work, and in this situation one doesn't know whats wrong -- rules or constructor :) http://pastebin.com/0K7C0iLz And example of massive regexps(one regexp for one rule) that doesn't work. In $grammar->{W} dump you can see that it searches for ^ K $, but this is wrong. http://pastebin.com/XuA02uPf This is simplified example of my abnf-validator. --cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut--cut-- Script output A win B win C win D win E win F win G win H win I win J win K win L win M fail N fail O fail P fail Q fail R fail S fail T fail U fail V fail W fail X fail Y fail Z fail -- Kindest Regards, Arseny Krasikov
Subject: Re: [rt.cpan.org #85159] Internal error: this shouldn't happen
Date: Fri, 10 May 2013 20:12:17 +1000
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Download (untitled) / with headers
text/plain 775b
Show quoted text
> yes, your example works fine, but if you put all query in scalar and > write qr{$rules}xims;, for example, that doesn't work,
That's because you're tripping an optimization in Perl itself. If an interpolated variable is the *only* thing in a qr, Perl doesn't bother to call any qr overload. Arguably, a bug. The workaround is to include at least one whitespace. For example, this works: my $rules = q{ ^ <data_terminate> $ <token: data_terminate> (?: \.\x0D\x0A ) }; my $grammar = do { use re 'eval'; use Regexp::Grammars; qr{ $rules}xims; }; if ( ".\x0D\x0A" =~ $grammar) { use Data::Dumper 'Dumper'; warn Dumper( \%/ ); } else { say 'failed'; } Damian
Subject: Re: [rt.cpan.org #85159] Internal error: this shouldn't happen
Date: Fri, 10 May 2013 15:05:04 +0400
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Arseny Krasikov <nyaapa [...] gmail.com>
Download (untitled) / with headers
text/plain 361b
On 10.05.2013 14:13, damian@conway.org via RT wrote: Show quoted text
> That's because you're tripping an optimization in Perl itself. > If an interpolated variable is the*only* thing in a qr, Perl > doesn't bother to call any qr overload. Arguably, a bug.
Yep i know about this and understand ploblem :) but what about second example? -- Kindest Regards, Arseny Krasikov
Subject: Re: [rt.cpan.org #85159] Internal error: this shouldn't happen
Date: Sat, 11 May 2013 06:02:37 +1000
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Download (untitled) / with headers
text/plain 308b
Show quoted text
> but what about second example?
That took a little longer to track down. It was a subtle bug in the module's caching of post-translated regexes. I've patched it and uploaded a new release, under which your second example now works correctly. Many thanks for pointing out these annoying problems! 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.