Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: felix [...] bioinf.uni-leipzig.de
Cc:
AdminCc:

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



Subject: Fwd: Errors using <MATCH=[rule]>+ construct
Date: Mon, 5 Sep 2016 13:15:21 +0200
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Felix Kuehnl <felix [...] bioinf.uni-leipzig.de>
Download (untitled) / with headers
text/plain 1.9k
Hi, I am getting error messages and parsing errors using the <MATCH=[Rule]>+ syntax within my grammar rules. I just started using this really cool module, so I might just use it in a wrong way, but since it fails on a documented example, I think I encountered a bug. Under section "Defining a named grammar", a grammar for a list is given like this (slightly modified to leave out the inheritance feature): use v5.12; use warnings; my $test_grammar = do { use Regexp::Grammars; qr{ <List> <rule: List> <MATCH=[Item]>+ % <Separator> <rule: Item> \S++ <token: Separator> \s* , \s* }xms; }; die "Parsing error" unless "asd" =~ $test_grammar; Executing the code above with Regexp::Grammars 1.045 gives the following output: warn | Repeated subrule <MATCH=[Item]>+ | at /homes/brauerei2/felix/bin/regexp_grammar line 73 | will only capture its final match | (Did you mean <[MATCH=[Item]]>+ instead?) | warn | Possible failed attempt to specify a subrule call: | <MATCH=[Item]> | near /homes/brauerei2/felix/bin/regexp_grammar line 72 | (If you meant to match literally, use: \<MATCH=[Item]>) | and the program dies with error "Parsing error". The problem is the construct <MATCH=[Item]>+ of the List rule. Changing it into: <rule: List> # <MATCH=[Item]>+ % <Separator> # does not work <[Item]>+ % <Separator> <MATCH=(?{ $MATCH{Item} })> . . . fixes the issue and does what I think the original example is supposed to do: directly return the list of matched Items instead of a result hash containing this list under key 'Item'. Now it would be really nice to have the <MATCH=[Item]>+ shortcut, and since it is also officially documented, I wondered why it isn't working? Thanks for your help! Regards, Felix
Subject: Re: [rt.cpan.org #117520] Fwd: Errors using <MATCH=[rule]>+ construct
Date: Tue, 6 Sep 2016 07:33:29 +1000
To: bug-Regexp-Grammars [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Download (untitled) / with headers
text/plain 524b
Hi Felix, The problem is a documentation bug. The rule: <rule: List> <MATCH=[Item]>+ % <Separator> should be: <rule: List> <[MATCH=Item]>+ % <Separator> That is: the [...] goes around the entire subrule invocation (including any relabelling). Or, to look at it another way, there are scalar subrule calls <...> and list subrule calls <[...]> Sorry for the confusion. I've corrected the example in the documentation for the next release. Very much appreciated! 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.