Skip Menu |

This queue is for tickets about the Parse-RecDescent CPAN distribution.

Report information
The Basics
Id: 123495
Status: open
Priority: 0/
Queue: Parse-RecDescent

People
Owner: jtbraun [...] CPAN.org
Requestors: PUGLET [...] cpan.org
Cc: greg [...] foletta.org
AdminCc:

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



CC: greg [...] foletta.org
Subject: Autostub and Matchrule
Hi, I've tried to search for information before posting this, but couldn't find any. It appears that if I'm using a matchrule in conjunction with autostubbing, the dynamic matchrule doesn't get autostubbed? Here's an example of what I'm doing: my $parser = new Parse::RecDescent(q{ <autostub> startrule: config_line(s) { $item{'config_line(s)'} } | unrecognised { $item{unrecognised} } config_line: <rulevar: local $type_re = defined $arg[0] ? qr{$arg[0]} : qr{[-\w]+}> config_line: 'set' m{$type_re} <matchrule:$item{__PATTERN1__}> config_line[ $item{__PATTERN1__} ](s?) ... }); If I run this with the input 'set blah blah', I get the error: Unknown starting rule (Parse::RecDescent::namespace000001::blah) called Is this known or expected behaviour?
I'd have to go look more closely, but I suspect that <autostub> only generates stubs during grammar parsing. For your example to work, the <matchrule> directive would have to re-generate the parser (or at least the stub rule) if it doesn't exist in the current parser namespace. I wouldn't be surprised if that weren't covered. I'd have to look if the matchrule logic is generated in the parser, or if it's part of the runtime. If the former, it would certainly be possible to change the generated code if <autostub> is in effect to add this behavior. If the latter, doing rule existence checks will slow down all matchrule use, as you'll always have to do the check, or condition it on <autostub> having been present at parsing time. On Fri Nov 03 01:51:27 2017, PUGLET wrote: Show quoted text
> Hi, > > I've tried to search for information before posting this, but couldn't > find any. > > It appears that if I'm using a matchrule in conjunction with > autostubbing, the dynamic matchrule doesn't get autostubbed? > > Here's an example of what I'm doing: > > my $parser = new Parse::RecDescent(q{ > <autostub> > startrule: > config_line(s) { $item{'config_line(s)'} } | > unrecognised { $item{unrecognised} } > > config_line: <rulevar: local $type_re = defined $arg[0] ? qr{$arg[0]} > : qr{[-\w]+}> > config_line: 'set' m{$type_re} <matchrule:$item{__PATTERN1__}> > config_line[ $item{__PATTERN1__} ](s?) > > ... > }); > > If I run this with the input 'set blah blah', I get the error: > > Unknown starting rule (Parse::RecDescent::namespace000001::blah) > called > > Is this known or expected behaviour?