1. riffraff
  2. shakespeare-parrot

Commits

gabriele renzi  committed e05c49b

refatcor enter and exit to simplify pir

  • Participants
  • Parent commits 9759e87
  • Branches default

Comments (0)

Files changed (2)

File src/builtins/say.pir

View file
 
 
 .sub 'enter'
-    .param pmc args :slurpy
-    print "enter\n"
+    .param string char
+    print "enter: "
+    print char
+    print "\n"
     .return ()
 .end
-.sub 'exeunt'
-    .param pmc args :slurpy
-    print "exeunt\n"
+.sub 'exit'
+    .param string char
+    print "exit: "
+    print char
+    print "\n"
     .return ()
 .end
 .sub 'say2'

File src/parser/actions.pm

View file
 }
 
 method enters($/) {
-  my $res := PAST::Op.new(:name('enter'),:pasttype('call'),:node($/));
+  my $past := PAST::Stmts.new(:node($/));
+
   for $<charlist><character> {
+    my $res := PAST::Op.new(:name('enter'),:pasttype('call'),:node($/));
     $res.push( PAST::Val.new(:value($_), :returns('String'),:node($_)) );
+    $past.push($res);
   }
-  make $res;
+  make $past;
 }
 method exits($/) {
-  my $res := PAST::Op.new(:name('exeunt'),:pasttype('call'),:node($/));
-  if $<charlist> {
-    for $<charlist><character> {
-      $res.push( PAST::Val.new(:value($_), :returns('String'),:node($_)) );
-    }
+  my $past := PAST::Stmts.new(:node($/));
+
+  for $<charlist><character> {
+    my $res := PAST::Op.new(:name('exit'),:pasttype('call'),:node($/));
+    $res.push( PAST::Val.new(:value($_), :returns('String'),:node($_)) );
+    $past.push($res);
   }
-  make $res;
+  make $past;
 }
 
 method noun($/,$k) {