Skip to content

Instantly share code, notes, and snippets.

@cognominal
Created August 11, 2015 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cognominal/9067d157b484fb7703c7 to your computer and use it in GitHub Desktop.
Save cognominal/9067d157b484fb7703c7 to your computer and use it in GitHub Desktop.
should the .a action method should be called knowing the match is in an assertion that does not contribute to the TOP match
grammar A {
token TOP { a <?before <a> > }
token a { a }
}
class A-actions {
method TOP($/) { say('yea') }
method a($/) { say('oops') }
}
A.parse('aa', :actions(A-actions));
@smls
Copy link

smls commented Aug 11, 2015

Sure, why wouldn't it?

@raiph
Copy link

raiph commented Aug 11, 2015

SO5 says "Action methods are invoked as soon as the corresponding rule has a successful match, regardless of if the match occurs in a zero-width match". It sounds to me like that covers the case you mention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment