Hi Yary, I'm not sure whether this is really the reason, but sum is the name of a built-in function (see https://docs.perl6.org/routine/sum). It seems that the compiler interprets your token as a subroutine call of that builtin.
HTH, Laurent. 2018-08-12 9:28 GMT+02:00 yary <[email protected]>: > If I call a token "sum", this example gives an error. If I call it > "something-else", it doesn't. I didn't expect an error in either case. > What's going on? > > ~~ actions-test.p6 ~~ > grammar A { > rule TOP { <something-else> } > token something-else { <int>+ % '+' } > token int { \d+ } > } > > grammar B { > rule TOP { <sum> } > token sum { <int>+ % '+' } > token int { \d+ } > } > > class An-Action { > } > > say A.parse('5',actions => An-Action.new); # OK > say B.parse('5',actions => An-Action.new); # hopes, dashed > > __END__ > > The B.parse says "Too many positionals passed; expected 1 argument but got > 2 > in regex sum at action-test.p6 line 9 > in regex TOP at action-test.p6 line 8 > in block <unit> at action-test.p6 line 17" > > perl6 -v > This is Rakudo Star version 2018.06 built on MoarVM version 2018.06 > > > -y >
