Commits

Anonymous committed 0f80dcc

refactor through mkstr

Comments (0)

Files changed (1)

src/parser/actions.pm

     ) 
 =cut 
     $past.push(
-      mkcall(
-       PAST::Val.new( :value($_<character>), :returns('String')),
-       'declare')
+      mkcall( mkstr($_<character>), 'declare')
     );
   }
   for $<act> {
   make $past;
 }
 
+sub mkstr($arg) {
+  return PAST::Val.new(:value(""~$arg));
+}
 sub mkcall($arg,$name) {
 return PAST::Op.new($arg, :name($name), :pasttype('call'));
 }
           :name('the_speaker'),
           :scope('package')
         ),
-        PAST::Val.new(
-          :value(""~$<character>), 
-        ),
-        :pasttype('bind'),
+        mkstr($<character>),
+        :pasttype('bind')
       )
     );
     for $<sentence> {
 
 method reference($/, $k) {
   if $k eq 'named_ref' {
-  make mkcall( PAST::Val.new(
-      :value($<character>), 
-      :returns('String')
-      ), 
-    'valueof');
+    make mkcall( mkstr($<character>), 'valueof');
   }
   elsif $k eq 'you_ref' {
-  make mkcall( mkcall0('find_other_name'), 'valueof');
+    make mkcall( mkcall0('find_other_name'), 'valueof');
   }
   else {
-  make mkcall( mkcall0('get_speaker_name'), 'valueof');
+    make mkcall( mkcall0('get_speaker_name'), 'valueof');
   }
 }
 
-method you_ref($/) {
-}
-
-method named_ref($/) {
-}
-
 method enters($/) {
   my $past := PAST::Stmts.new();
 
   for $<charlist><character> {
-    my $res := mkcall( PAST::Val.new(
-        :value($_), 
-        :returns('String'),
-        ),'enter' );
+    my $res := mkcall( mkstr($_),'enter');
     $past.push($res);
   }
   make $past;
 
   if $k eq 'list' {
     for $<charlist><character> {
-      my $res := mkcall( PAST::Val.new(
-          :value($_), 
-          :returns('String'),
-          ),'exit' );
+      my $res := mkcall( mkstr($_), 'exit');
       $past.push($res);
     }
   }
   make $past;
 }
 method exits($/) {
-  my $res := mkcall( PAST::Val.new(
-      :value($<character>), 
-      :returns('String'),
-      ),'exit' );
+  my $res := mkcall( mkstr($<character>), 'exit');
   make $res;
 }