Commits

Anonymous committed e2b2ea3

use pirop for binary ops

Comments (0)

Files changed (4)

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

src/parser/actions.pm

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

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|
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.