diff --git a/compilers/opsc/src/Ops/Compiler/Actions.pm b/compilers/opsc/src/Ops/Compiler/Actions.pm index 82a39044ab..8b17641a95 100644 --- a/compilers/opsc/src/Ops/Compiler/Actions.pm +++ b/compilers/opsc/src/Ops/Compiler/Actions.pm @@ -633,12 +633,22 @@ method circumfix:sym<( )> ($/) { } method postcircumfix:sym<[ ]> ($/) { - make PAST::Var.new( - $.ast, - :scope('keyed'), - ); + make PAST::Var.new($.ast, :scope('keyed_int')); } +method postcircumfix:sym<( )> ($/) { + make $.ast; +} + +method arglist($/) { + my $past := PAST::Op.new( :pasttype('call'), :node($/) ); + + if ($) { + $past.push($_.ast) for $; + } + + make $past; +} # For casting we just set "returns" of EXPR. method prefix:sym<( )> ($/) { @@ -647,6 +657,16 @@ method prefix:sym<( )> ($/) { ); } +method postfix:sym«->» ($/) { + # ')> + make PAST::Var.new( ~$, :scope('keyed_arrow')); +} + +method postfix:sym«.» ($/) { + # ')> + make PAST::Var.new( ~$, :scope('keyed_dotty')); +} + # Helper method for generating PAST::Val with opsize method opsize () { make PAST::Val.new( diff --git a/compilers/opsc/src/Ops/Compiler/Grammar.pm b/compilers/opsc/src/Ops/Compiler/Grammar.pm index c0719fdf5f..e94a614af9 100644 --- a/compilers/opsc/src/Ops/Compiler/Grammar.pm +++ b/compilers/opsc/src/Ops/Compiler/Grammar.pm @@ -309,10 +309,15 @@ token postcircumfix:sym<[ ]> { } -#token postfix:sym«->» { ')> } -#token postfix:sym«.» { ')> } -token infix:sym«->» { ')> } -token infix:sym«.» { ')> } +token postcircumfix:sym<( )> { + '(' <.ws> ')' + +} + +token postfix:sym«->» { ')> } +token postfix:sym«.» { ')> } +#token infix:sym«->» { ')> } +#token infix:sym«.» { ')> } # XXX Check precedence token postfix:sym<--> { ')> } diff --git a/compilers/opsc/src/Ops/Op.pm b/compilers/opsc/src/Ops/Op.pm index 03e2d8ef32..f9fcff32d0 100644 --- a/compilers/opsc/src/Ops/Op.pm +++ b/compilers/opsc/src/Ops/Op.pm @@ -304,9 +304,15 @@ our multi method to_c(PAST::Var $var, %c) { } $res; } - elsif $var.scope eq 'keyed' { + elsif $var.scope eq 'keyed_int' { self.to_c($var[0], %c) ~ '[' ~ self.to_c($var[1], %c) ~ ']'; } + elsif $var.scope eq 'keyed_arrow' { + self.to_c($var[0], %c) ~ '->' ~ self.to_c($var[1], %c); + } + elsif $var.scope eq 'keyed_dotty' { + self.to_c($var[0], %c) ~ '.' ~ self.to_c($var[1], %c); + } elsif $var.scope eq 'register' { my $n := +$var.name; %c.access_arg( self.arg_type($n - 1), $n, %c);