Skip Menu |
Report information
Id: 125374
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: bri [at] abrij.org
Cc:
AdminCc:

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



From: bri <bri [...] abrij.org>
Subject: proto+multi regex rules NQYI
To: rakudobug [...] perl.org
Date: Sun, 7 Jun 2015 00:00:56 -0400
Download (untitled) / with headers
text/plain 1.3k
# I believe this is a known NYI but it is probably about time there was # an RT for it. # Rakudo's proto+multi grammar rules don't function as specced. They # should be equivalent to an '|' alternative. # These two grammars should produce identical results grammar g1 { proto token m {*} multi token m:sep<2> { '==' } multi token m:sep<1> { '=' } multi token m:sep<0> { '' } token TOP { d <m> foo } } grammar g2 { proto token m {*} multi token m:sep<0> { '' } multi token m:sep<1> { '=' } multi token m:sep<2> { '==' } token TOP { d <m> foo } } g1.parse('d==foo').say; # 「d==foo」 m => 「==」 g1.parse('d=foo').say; # 「d=foo」 m => 「=」 g1.parse('dfoo').say; # 「dfoo」 m => 「」 g2.parse('d==foo').say; # (Any) g2.parse('d=foo').say; # (Any) g2.parse('dfoo').say; # 「dfoo」 m => 「」 # Also this: perl6 -e 'grammar g { proto regex { f {*} g } }' ===SORRY!=== Error while compiling -e Proto regex body must be {*} (or <*> or <...>, which are deprecated) at -e:1 ------> grammar g { proto regex ⏏{ f {*} g } } ...where the design docs say: The proto calls into the subdispatcher when it sees a * that cannot be a quantifier and is the only thing in its block. Therefore you can put items before and after the subdispatch by putting the * into curlies: proto token foo { <prestuff> {*} <poststuff> }


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

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