develooper Front page | perl.perl6.users | Postings from August 2018

Special token names, or my mistake

Thread Next
From:
yary
Date:
August 12, 2018 07:28
Subject:
Special token names, or my mistake
Message ID:
CAG2CFAYHNkRMFFFB_qxPA=qpgtdKoKFrBCcuSYwC-ZRvNP7m9Q@mail.gmail.com
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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About