Skip to content

Instantly share code, notes, and snippets.

@cognominal
Created August 11, 2015 00:10
Show Gist options
  • Select an option

  • Save cognominal/9067d157b484fb7703c7 to your computer and use it in GitHub Desktop.

Select an option

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

smls commented Aug 11, 2015

Copy link
Copy Markdown

Sure, why wouldn't it?

@raiph

raiph commented Aug 11, 2015

Copy link
Copy Markdown

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