Permalink
Browse files

Add support for ${name} variables.

Stub in support for $array(index).
  • Loading branch information...
1 parent 20fc1e0 commit 91668b4b6418638e517bc9e141c0b695f079d0ae @coke coke committed Apr 14, 2010
Showing with 20 additions and 6 deletions.
  1. +15 −5 src/Partcl/Actions.pm
  2. +5 −1 src/Partcl/Grammar.pm
View
@@ -155,18 +155,28 @@ sub concat_atoms(@atoms) {
}
-method variable($/) {
- ## The beginning of each block sets up the C<lexpad> register
- ## to point to the current lexical scope -- this simply
- ## looks up the variable name in that lexpad and returns
- ## the corresponding value.
+## The beginning of each variable block sets up the C<lexpad> register
+## to point to the current lexical scope -- this simply
+## looks up the variable name in that lexpad and returns
+## the corresponding value.
+method variable:sym<scalar>($/) {
make PAST::Var.new( :scope<keyed>,
PAST::Var.new( :name<lexpad>, :scope<register> ),
~$<identifier>,
:node($/)
);
}
+method variable:sym<escaped>($/) {
+ make PAST::Var.new( :scope<keyed>,
+ PAST::Var.new( :name<lexpad>, :scope<register> ),
+ ~$<identifier>,
+ :node($/)
+ );
+}
+
+method variable:sym<array>($/) { make 'XXX'; }
+
method integer($/) {
if $<sign> eq '-' {
make -1 * $<int>.ast;
View
@@ -92,7 +92,11 @@ token list_atom:sym<\\> { <backslash> }
token list_atom:sym<chr> { <-[ \\ ]-space>+ }
token identifier { <ident> ** '::' }
-token variable { '$' <identifier> }
+
+proto token variable { <...> }
+token variable:sym<scalar> { '$' <identifier> }
+token variable:sym<array> { '$' <identifier> '(' <index=.bare> ')' }
+token variable:sym<escaped> { '$' '{' $<identifier>=(<-[ } ]>*) '}' }
rule integer { $<sign>=(<[+\-]>?)<int> }

0 comments on commit 91668b4

Please sign in to comment.