# New Ticket Created by  Aleks-Daniel Jakimenko-Aleksejev 
# Please include the string:  [perl #130218]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=130218 >


Code:
grammar G {
  token TOP { <before> }
  token before { . }
}
say G.parse(‘f’)

Result:
===SORRY!===
Cannot find method 'ann' on object of type NQPMu


In other words, using <before> is a compile-time error. If we try the same 
thing with <after>, it may seem to work, but there is another issue with it:

Code:
grammar G {
  token TOP { <!after \d> }
  token after { . }
}
say G.parse(‘f’)

Result:
Too many positionals passed; expected 1 argument but got 2
  in regex after at -e line 3
  in regex TOP at -e line 2
  in block <unit> at -e line 5

So it is a run-time error, huh!

Obviously, both examples work if you name your tokens differently:

Code:
grammar G {
  token TOP { <!after \d> }
  token aftermath { . }
}
say G.parse(‘f’)

Result:
Nil


Code:
grammar G {
  token TOP { <beforehead> }
  token beforehead { . }
}
say G.parse(‘f’)

Result:
「f」
 beforehead => 「f」

Reply via email to