From b14f95ca68887d9e6cea211b47e04e5ec00c05fa Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 13 Mar 2018 23:28:19 -0400 Subject: - Initial Ruby back-end implementation. --- .../luxc/lang/translation/ruby/primitive.jvm.lux | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 new-luxc/source/luxc/lang/translation/ruby/primitive.jvm.lux (limited to 'new-luxc/source/luxc/lang/translation/ruby/primitive.jvm.lux') diff --git a/new-luxc/source/luxc/lang/translation/ruby/primitive.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/primitive.jvm.lux new file mode 100644 index 000000000..15e68d8c6 --- /dev/null +++ b/new-luxc/source/luxc/lang/translation/ruby/primitive.jvm.lux @@ -0,0 +1,42 @@ +(.module: + lux + (lux (control pipe) + (data [number] + text/format) + [macro "meta/" Monad]) + (luxc (lang (host [ruby #+ Ruby Expression Statement])))) + +(def: #export translate-bool + (-> Bool (Meta Expression)) + (|>> %b meta/wrap)) + +(def: #export translate-int + (-> Int (Meta Expression)) + (|>> %i meta/wrap)) + +(def: #export translate-nat + (-> Nat (Meta Expression)) + (|>> (:! Int) %i meta/wrap)) + +(def: #export translate-deg + (-> Deg (Meta Expression)) + (|>> (:! Int) %i meta/wrap)) + +(def: #export translate-frac + (-> Frac (Meta Expression)) + (|>> (cond> [(f/= number.positive-infinity)] + [(new> "(1/0)")] + + [(f/= number.negative-infinity)] + [(new> "(-1/0)")] + + [(f/= number.not-a-number)] + [(new> "(0/0)")] + + ## else + [%f]) + meta/wrap)) + +(def: #export translate-text + (-> Text (Meta Expression)) + (|>> %t meta/wrap)) -- cgit v1.2.3