Skip Menu |
Report information
Id: 130273
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: rongshenmd [at]

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)

Date: Mon, 5 Dec 2016 22:57:47 -0800
To: perlbug-admin [...]
From: Rong Shen <rongshenmd [...]>
Subject: Fwd: [BUG] [REGEX] error : “Cannot find method 'ann' on object of type NQPMu”
Download (untitled) / with headers
text/plain 2.7k
Download (untitled) / with headers
text/html 22.1k

Message body is not shown because it is too large.

RT-Send-CC: perl6-compiler [...]
Download (untitled) / with headers
text/plain 1.6k
On Mon, 05 Dec 2016 22:58:27 -0800, wrote: Show quoted text
> ------------------------------------------------------------ > --------------------- > > Okay, I am still having trouble with perl6 grammar and action. I want to > find a pattern in a string, and as soon as it is is found, change the > pattern according to action, and return the modified string. > > my $test = "xx, 1-March-23, 23.feb.21, yy foo 12/january/2099 , > zzz";# want this result: xx, 010323, 230221, yy foo 120199 , zzz"; # > 2 digits for day, month, year > > grammar month { > regex TOP { <unit>+ } > regex unit { <before> <form1> <after> } > regex before { .*? } > regex after { .*? }
Both `before` and `after` happen to be the names of a couple of the standard rules (for doing lookahead and lookbehind), inherited from the base Grammar class. In theory overriding these as you have is fine enough (until you try to use the built-in ones and then get confused because yours took precedence, at least ;-)). In practice, part of the regex compiler treated the name `before` specially and then got very upset when it was not something of the form `<before some regex here>`. I've now made it more robust in and with that patch your grammar seems to work nicely. What needs a bit more discussion is whether we'd like to simply leave it at that and add a spectest to codify that overriding before/after this way is fine (I'm good with this), or treat those two names a bit more specially (but then where do we draw the line on which built-ins get such treatment?) Thanks, /jnthn

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

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at