parrotcode: Untitled | |
Contents | Language Implementations | HQ9plus |
class HQ9plus::Grammar::Actions;
method TOP($/) { my $past := PAST::Block.new( :blocktype('declaration'), :node( $/ ), PAST::Op.new( :name('infix:='), :pasttype('copy'), PAST::Var.new( :name('hq9plus_code'), :viviself('String'), :isdecl(1), :scope('lexical') ), PAST::Val.new( :value(~$/) ) ), PAST::Op.new( :name('infix:='), :pasttype('copy'), PAST::Var.new( :name('hq9plus_accumulator'), :viviself('Integer'), :isdecl(1), :scope('lexical') ), PAST::Val.new( :value(0) ) ) ); for $<statement> { $past.push( $( $_ ) ); } make $past; }
method statement($/,$key) { my $past; if ( $key eq 'quine' ) { $past := PAST::Op.new( :name($key), :pasttype('call'), :node( $/ ), PAST::Var.new( :name('hq9plus_code'), :scope('lexical') ) ); } elsif ( $key eq 'plus' ) { $past := PAST::Op.new( :name('postfix:++'), :lvalue(1), PAST::Var.new( :name('hq9plus_accumulator'), :scope('lexical') ) ); } else { $past := PAST::Op.new( :name($key), :pasttype('call'), :node( $/ ) ); } make $past; }
# Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 100 # End: # vim: expandtab shiftwidth=4:
|