Commits

Anonymous committed e2b2ea3

use pirop for binary ops

  • Participants
  • Parent commits 75de862

Comments (0)

Files changed (4)

File src/builtins/say.pir

     .return ()
 .end
 
-.namespace []
-.sub 'min'
-    .param int a
-    .param int b
-    .local int c
-    c = a-b
-    .return (c)
-.end
-.namespace []
 .sub 'dup'
     .param int b
     .local int c
     c = 2*b
     .return (c)
 .end
-.namespace []
 .sub 'fact'
     .param int b
     .local int c
     c = sqrt b
     .return (c)
 .end
-.sub 'add'
-    .param int a
-    .param int b
-    .local int c
-    c = a+b
-    .return (c)
-.end
-.sub 'mul'
-    .param int a
-    .param int b
-    .local int c
-    c = a*b
-    .return (c)
-.end
-.sub 'rem'
-    .param int a
-    .param int b
-    .local int c
-    c = cmod a, b
-    .return (c)
-.end
-.sub 'div'
-    .param int a
-    .param int b
-    .local int c
-    c = div a, b
-    .return (c)
-.end
+
 .sub 'better'
     .param int a
     .param int b

File src/parser/actions.pm

 }
 
 method binary($/, $key) {
-  my $res := mkcall0( $key );
+  my $res := PAST::Op.new(:pirop( $key ));
   for $<value> {
     $res.push( $( $_ ));
   }

File src/parser/grammar.pg

 }
 
 rule binary {
-  |'the' 'remainder' 'of' 'the' 'quotient' 'between' <value> 'and' <value> {*} #= rem
-  |'the' 'difference' 'between' <value> 'and' <value> {*} #= min
+  |'the' 'remainder' 'of' 'the' 'quotient' 'between' <value> 'and' <value> {*} #= mod
+  |'the' 'difference' 'between' <value> 'and' <value> {*} #= sub
   |'the' 'sum' 'of' <value> 'and' <value> {*} #= add
   |'the' 'product' 'of' <value> 'and' <value> {*} #= mul
   |'the' 'quotient' 'between' <value> 'and' <value> {*} #= div
 
 DIR=File.join(File.dirname(__FILE__),'..')
 
-puts "1..#{45+1+1+26+1+11+1+100}"
+puts "1..#{45+1+1+26+1+11+1+99*2}"
 def with_prog(name)
   p str= %W[../../parrot z2.pir example/#{name}.spl].map{|x| File.join(DIR,x)}*" "
   IO.popen(str,'r+') do |io|