Skip to content

Instantly share code, notes, and snippets.

@FROGGS
Last active August 29, 2015 14: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 FROGGS/199ccc0d6412e6858217 to your computer and use it in GitHub Desktop.
Save FROGGS/199ccc0d6412e6858217 to your computer and use it in GitHub Desktop.
diff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp
index c570f57..253a648 100644
--- a/src/Perl6/Actions.nqp
+++ b/src/Perl6/Actions.nqp
@@ -4734,11 +4734,39 @@ class Perl6::Actions is HLL::Actions does STDActions {
method circumfix:sym<( )>($/) {
my $past := $<semilist>.ast;
+ my @args;
+ # look for any chained adverb pairs
+ if $<semilist><statement>[0]<EXPR> -> $EXPR {
+ my $*WAS_SKIPPED := 0;
+ try {
+ if $*FAKE_INFIX_FOUND {
+ hunt_loose_adverbs_in_arglist($EXPR, @args);
+ }
+ }
+ }
my $size := +$past.list;
if $size == 0 {
$past := QAST::Stmts.new( :node($/) );
$past.push(QAST::Op.new( :op('call'), :name('&infix:<,>')));
}
+ elsif +@args {
+ if $size == 1
+ && nqp::istype($past[0], QAST::Op) && $past[0].op eq 'callmethod' && $past[0].name eq 'new'
+ && nqp::istype($past[0][0], QAST::Var) && $past[0][0].name eq 'Pair' {
+ $past := QAST::Stmts.new( :node($/),
+ QAST::Op.new( :op('call'), :name('&infix:<,>'),
+ $past[0], |@args)
+ )
+ }
+ else {
+ for @args {
+ $past.push($_);
+ }
+ }
+ }
+ if +@args {
+ say($past.dump);
+ }
make $past;
}
diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp
index 364a539..920b645 100644
--- a/src/Perl6/Grammar.nqp
+++ b/src/Perl6/Grammar.nqp
@@ -3519,7 +3519,11 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token circumfix:sym<SEQ( )> { :dba('statement list') 'SEQ(' ~ ')' <sequence> }
- token circumfix:sym<( )> { :dba('parenthesized expression') '(' ~ ')' <semilist> }
+ token circumfix:sym<( )> {
+ :my $*FAKE_INFIX_FOUND := 0;
+ :dba('parenthesized expression')
+ '(' ~ ')' <semilist>
+ }
token circumfix:sym<[ ]> { :dba('array composer') '[' ~ ']' <semilist> }
token circumfix:sym<ang> {
:dba('quote words')
$ perl6-m -e 'say( (:a(2) :b(3) :c(4)) )'
- QAST::Stmts (:a(2) :b(3) :c(4))
- QAST::Op(call &infix:<,>)
- QAST::Op(callmethod new)
- QAST::Var(lexical Pair :decl())
- QAST::Want+{QAST::SpecialArg}
- QAST::WVal(Str)
- Ss
- QAST::SVal(a)
- QAST::Want+{QAST::SpecialArg} 2
- QAST::WVal(Int)
- Ii
- QAST::IVal(2)
- QAST::Want+{QAST::SpecialArg} 3
- QAST::WVal(Int)
- Ii
- QAST::IVal(3)
- QAST::Want+{QAST::SpecialArg} 4
- QAST::WVal(Int)
- Ii
- QAST::IVal(4)
- QAST::Op(callmethod new)
- QAST::Var(lexical Pair :decl())
- QAST::Want+{QAST::SpecialArg}
- QAST::WVal(Str)
- Ss
- QAST::SVal(b)
- QAST::Want+{QAST::SpecialArg} 3
- QAST::WVal(Int)
- Ii
- QAST::IVal(3)
- QAST::Op(callmethod new)
- QAST::Var(lexical Pair :decl())
- QAST::Want+{QAST::SpecialArg}
- QAST::WVal(Str)
- Ss
- QAST::SVal(c)
- QAST::Want+{QAST::SpecialArg} 4
- QAST::WVal(Int)
- Ii
- QAST::IVal(4)
"a" => 2 "b" => Mu "c" => Mu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment