-
-
Save zoffixznet/5beb5a8a9857640cd4c2011b3c6989a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub hunt_loose_adverbs_in_arglist($/, @past) { | |
# if we have a non-comma-separated list of adverbial pairs in an | |
# arglist or semiarglist, only the first will be passed as a named | |
# argument. | |
# Thus, we need to find chained adverbs. They show up on the parse | |
# tree as colonpair rules followed by a fake_infix. | |
# if nqp::getenvhash<COLONPAIR> eq 'trace' { say($/.dump) } | |
nqp::atkey(nqp::getenvhash(),'ZZ') && nqp::say('ZZ1: ' ~ $/.dump); | |
if +$/.list == 1 && nqp::istype($/[0].ast, QAST::Op) | |
&& $/[0].ast.op eq 'call' && $/[0].ast.name ne 'infix:<,>' { | |
nqp::die("these adverbs belong to a deeper-nested thing"); | |
} | |
if $<fake_infix> || $<colonpair> && +($/.list) == 0 && +($/.hash) == 1 { | |
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say('ZZ2.1'); | |
nqp::atkey(nqp::getenvhash(),'ZZ4') && nqp::say('ZZ4.1'); | |
if +($/.list) == 1 { | |
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say('ZZ2.2'); | |
hunt_loose_adverbs_in_arglist($/[0], @past); | |
} | |
nqp::atkey(nqp::getenvhash(),'ZZ4') && nqp::say('ZZ4.2'); | |
my $Pair := $*W.find_symbol(['Pair']); | |
nqp::atkey(nqp::getenvhash(),'ZZ4') && nqp::say('ZZ4.3'); | |
if $<colonpair> && istype($<colonpair>.ast.returns, $Pair) { | |
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say('ZZ2.3' ~ $<colonpair>.dump); | |
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say('ZZ2.3' ~ $<colonpair>.ast.dump); | |
unless nqp::atkey(nqp::getenvhash(),'ZZ3') { | |
if $*WAS_SKIPPED { | |
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say('ZZ2.4'); | |
nqp::push(@past, $<colonpair>.ast); | |
} else { | |
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say('ZZ2.5'); | |
$*WAS_SKIPPED := 1; | |
} | |
} | |
} | |
nqp::atkey(nqp::getenvhash(),'ZZ4') && nqp::say('ZZ4.4'); | |
} | |
elsif $<OPER>.Str eq ',' { | |
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say('ZZ2.6'); | |
my $*WAS_SKIPPED := 0; | |
for $/.list { | |
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say('ZZ2.7'); | |
hunt_loose_adverbs_in_arglist($_, @past); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZZ1: - 0: :w | |
- colonpair: :w | |
- identifier: w | |
- fake_infix: | |
- O: | |
- OPER: | |
- O: | |
- colonpair: :h<1> | |
- coloncircumfix: <1> | |
- circumfix: <1> | |
- nibble: 1 | |
- identifier: h | |
ZZ2.1 | |
ZZ4.1 | |
ZZ2.2 | |
ZZ1: - colonpair: :w | |
- identifier: w | |
ZZ2.1 | |
ZZ4.1 | |
ZZ4.2 | |
ZZ4.3 | |
ZZ2.3- identifier: w | |
ZZ2.3- QAST::Op(callmethod new) <wanted nosink> :statement_id<2> :w | |
- QAST::Var(lexical Pair) <wanted> :w | |
- QAST::Want <wanted> | |
- QAST::WVal(Str) | |
- Ss | |
- QAST::SVal(w) | |
- QAST::Op(p6bool) <wanted> | |
- QAST::IVal(1) | |
- QAST::WVal+{QAST::SpecialArg}(IntStr :named<h>) <wanted> 1 | |
ZZ4.4 | |
ZZ4.2 | |
ZZ4.3 | |
ZZ2.3- coloncircumfix: <1> | |
- circumfix: <1> | |
- nibble: 1 | |
- identifier: h | |
ZZ2.3- QAST::Op(callmethod new) <nosink> :h<1> | |
- QAST::Var(lexical Pair) <wanted> :h<1> | |
- QAST::Want | |
- QAST::WVal(Str) | |
- Ss | |
- QAST::SVal(h) | |
- QAST::WVal+{QAST::SpecialArg}(:named<h>) <wanted> 1 | |
ZZ4.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment