Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[cardinal]

* ARGS support
* AST generation for indexed variables works, but parsing doesn't


git-svn-id: https://svn.parrot.org/parrot/trunk/languages/cardinal@27508 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 5bd60ecf5244b43bd6d75f3ef0b606f2b265aa5f 1 parent 9e63e11
@tene tene authored
Showing with 27 additions and 5 deletions.
  1. +14 −3 cardinal.pir
  2. +13 −2 src/parser/actions.pm
View
17 cardinal.pir
@@ -68,13 +68,24 @@ to the cardinal compiler.
=cut
.sub 'main' :main
- .param pmc args
+ .param pmc args_str
$P0 = compreg 'cardinal'
- $P1 = $P0.'command_line'(args)
+ $P1 = $P0.'command_line'(args_str)
+
+ ## create ARGS global.
+ .local pmc args, iter
+ args = new 'CardinalArray'
+ iter = new 'Iterator', args_str
+ args_loop:
+ unless iter goto args_end
+ $P0 = shift iter
+ push args, $P0
+ goto args_loop
+ args_end:
+ set_hll_global 'ARGS', args
.include 'iterator.pasm'
- .local pmc iter
$P0 = get_hll_global ['cardinal'], '@?END_BLOCKS'
iter = new 'Iterator', $P0
iter = .ITERATE_FROM_END
View
15 src/parser/actions.pm
@@ -154,8 +154,19 @@ method member_variable($/) {
}
method indexed_variable($/) {
- make $( $<primary> );
- # XXX fix index
+ my $var := $( $<primary> );
+ my $args;
+ if $<args> {
+ $args := $( $<args>[0] );
+ }
+
+ my $past := PAST::Var.new( :scope('keyed'), :node($/) );
+ $past.push($var);
+ while $args[0] {
+ $past.push( $args.shift() );
+ }
+
+ make $past;
}
method variable($/, $key) {
Please sign in to comment.
Something went wrong with that request. Please try again.