diff --git a/src/Partcl/Actions.pm b/src/Partcl/Actions.pm index b20fa7d..bf0cadd 100644 --- a/src/Partcl/Actions.pm +++ b/src/Partcl/Actions.pm @@ -174,13 +174,21 @@ sub concat_atoms(@atoms) { ## the corresponding value. method variable:sym($/) { - if $ { - # Array access - my $variable := PAST::Var.new( :scope, - PAST::Var.new( :name, :scope ), - ~$ - ); + my $variable; + if $ { + $variable := PAST::Var.new( :scope, + PAST::Var.new( :name<%GLOBALS>, :scope ), + ~$ + ); + } else { + $variable := PAST::Var.new( :scope, + PAST::Var.new( :name, :scope ), + ~$ + ); + } + # Array access + if $ { make PAST::Op.new( :pasttype, PAST::Op.new( :pirop, PAST::Op.new( :pirop, $variable), @@ -197,10 +205,6 @@ method variable:sym($/) { } else { # Scalar - my $variable := PAST::Var.new( :scope, - PAST::Var.new( :name, :scope ), - ~$ - ); make PAST::Op.new( :pasttype, PAST::Op.new( :pirop, $variable), diff --git a/src/Partcl/Grammar.pm b/src/Partcl/Grammar.pm index 282e9d4..d4b8071 100644 --- a/src/Partcl/Grammar.pm +++ b/src/Partcl/Grammar.pm @@ -93,11 +93,11 @@ token list_atom:sym<\\> { } token list_atom:sym { <-[ \\ ]-space>+ } token colons { ':' ':'+ } -token identifier { <.colons>? ** <.colons> } +token identifier { ** <.colons> } proto token variable { <...> } # XXX The key here is wrong. It needs to do variable interpolation, and more. -token variable:sym { '$' [ '(' $=(<-[)]>+) ')' ]? } +token variable:sym { '$' $=<.colons>? [ '(' $=(<-[)]>+) ')' ]? } token variable:sym { '$' '{' $=(<-[ } ]>*) '}' } rule integer { $=(<[+\-]>?) }