Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Scope changes to actions also.

Custom circumfixes generate action methods. Refactor this to also be
handled by mixins, so the changes are properly scoped.
  • Loading branch information...
commit 1cb742ae33f13ec86fab0e2324199b2e422d2750 1 parent 0faf6fa
@jnthn jnthn authored
Showing with 12 additions and 8 deletions.
  1. +12 −8 src/Perl6/Grammar.pm
View
20 src/Perl6/Grammar.pm
@@ -615,6 +615,7 @@ grammar Perl6::Grammar is HLL::Grammar {
token statement {
:my $*QSIGIL := '';
:my $*SCOPE := '';
+ :my $*ACTIONS := %*LANG<MAIN-actions>;
<!before <[\])}]> | $ >
<!!{ nqp::rebless($/.CURSOR, %*LANG<MAIN>) }>
[
@@ -2924,18 +2925,21 @@ grammar Perl6::Grammar is HLL::Grammar {
}
# This also becomes the current MAIN. Also place it in %?LANG.
- %*LANG<MAIN> := self;
+ %*LANG<MAIN> := self.WHAT;
$*W.install_lexical_symbol($*W.cur_lexpad(), '%?LANG', $*W.p6ize_recursive(%*LANG));
# May also need to add to the actions.
- # XXX Should be mixed in too.
if $category eq 'circumfix' {
- $*ACTIONS.HOW.add_method($*ACTIONS, $canname, sub ($self, $/) {
- make QAST::Op.new(
- :op('call'), :name('&' ~ $subname),
- $<EXPR>.ast
- );
- });
+ my role CircumfixAction[$meth, $subname] {
+ method ::($meth)($/) {
+ make QAST::Op.new(
+ :op('call'), :name('&' ~ $subname),
+ $<EXPR>.ast
+ );
+ }
+ };
+ %*LANG<MAIN-actions> := $*ACTIONS.HOW.mixin($*ACTIONS,
+ CircumfixAction.HOW.curry(CircumfixAction, $canname, $subname));
}
return 1;
Please sign in to comment.
Something went wrong with that request. Please try again.