aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/r
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby.lux39
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/case.jvm.lux5
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/eval.jvm.lux21
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/expression.jvm.lux9
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/function.jvm.lux4
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/procedure.jvm.lux3
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux26
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux2
8 files changed, 62 insertions, 47 deletions
diff --git a/new-luxc/source/luxc/lang/translation/ruby.lux b/new-luxc/source/luxc/lang/translation/ruby.lux
index 8f00c0ecd..e405b2b4f 100644
--- a/new-luxc/source/luxc/lang/translation/ruby.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby.lux
@@ -18,6 +18,16 @@
(host [ruby #+ Ruby Expression Statement]))
[".C" io]))
+(do-template [<name>]
+ [(exception: #export (<name> {message Text})
+ message)]
+
+ [No-Active-Module-Buffer]
+ [Cannot-Execute]
+
+ [No-Anchor]
+ )
+
(host.import java/lang/Object)
(host.import java/lang/String
@@ -50,7 +60,7 @@
(io {#context ["" +0]
#anchor #.None
#interpreter (let [interpreter (ScriptingContainer::new [])]
- (function [code]
+ (function (_ code)
("lux try" (io (: Top (maybe.default [] (ScriptingContainer::runScriptlet [code] interpreter)))))))
#module-buffer #.None
#program-buffer (StringBuilder::new [])}))
@@ -59,7 +69,7 @@
(def: #export init-module-buffer
(Meta Unit)
- (function [compiler]
+ (function (_ compiler)
(#e.Success [(update@ #.host
(|>> (:! Host)
(set@ #module-buffer (#.Some (StringBuilder::new [])))
@@ -67,12 +77,9 @@
compiler)
[]])))
-(exception: #export No-Active-Module-Buffer)
-(exception: #export Cannot-Execute)
-
(def: #export (with-sub-context expr)
(All [a] (-> (Meta a) (Meta [Text a])))
- (function [compiler]
+ (function (_ compiler)
(let [old (:! Host (get@ #.host compiler))
[old-name old-sub] (get@ #context old)
new-name (format old-name "___" (%i (nat-to-int old-sub)))]
@@ -92,7 +99,7 @@
(def: #export context
(Meta Text)
- (function [compiler]
+ (function (_ compiler)
(#e.Success [compiler
(|> (get@ #.host compiler)
(:! Host)
@@ -102,7 +109,7 @@
(def: #export (with-anchor anchor expr)
(All [a] (-> Anchor (Meta a) (Meta a)))
- (function [compiler]
+ (function (_ compiler)
(let [old (:! Host (get@ #.host compiler))]
(case (expr (set@ #.host
(:! Void (set@ #anchor (#.Some anchor) old))
@@ -118,11 +125,9 @@
(#e.Error error)
(#e.Error error)))))
-(exception: #export No-Anchor)
-
(def: #export anchor
(Meta Anchor)
- (function [compiler]
+ (function (_ compiler)
(case (|> compiler (get@ #.host) (:! Host) (get@ #anchor))
(#.Some anchor)
(#e.Success [compiler anchor])
@@ -132,32 +137,30 @@
(def: #export module-buffer
(Meta StringBuilder)
- (function [compiler]
+ (function (_ compiler)
(case (|> compiler (get@ #.host) (:! Host) (get@ #module-buffer))
#.None
- ((lang.fail (No-Active-Module-Buffer "")) compiler)
+ ((lang.throw No-Active-Module-Buffer "") compiler)
(#.Some module-buffer)
(#e.Success [compiler module-buffer]))))
(def: #export program-buffer
(Meta StringBuilder)
- (function [compiler]
+ (function (_ compiler)
(#e.Success [compiler (|> compiler (get@ #.host) (:! Host) (get@ #program-buffer))])))
(def: (execute code)
(-> Expression (Meta Unit))
- (function [compiler]
+ (function (_ compiler)
(let [interpreter (|> compiler (get@ #.host) (:! Host) (get@ #interpreter))]
(case (interpreter code)
(#e.Error error)
- ((lang.fail (Cannot-Execute error)) compiler)
+ ((lang.throw Cannot-Execute error) compiler)
(#e.Success _)
(#e.Success [compiler []])))))
-(exception: #export Unknown-Member)
-
(def: #export variant-tag-field "_lux_tag")
(def: #export variant-flag-field "_lux_flag")
(def: #export variant-value-field "_lux_value")
diff --git a/new-luxc/source/luxc/lang/translation/ruby/case.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/case.jvm.lux
index 016038d03..7f951a9dc 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/case.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/case.jvm.lux
@@ -34,7 +34,7 @@
(Meta Expression))
(do macro.Monad<Meta>
[valueO (translate valueS)]
- (wrap (list/fold (function [[idx tail?] source]
+ (wrap (list/fold (function (_ [idx tail?] source)
(let [method (if tail?
runtimeT.product//right
runtimeT.product//left)]
@@ -86,7 +86,8 @@
Expression
(ruby.string "PM-ERROR"))
-(exception: #export Unrecognized-Path)
+(exception: #export (Unrecognized-Path {message Text})
+ message)
(def: (translate-pattern-matching' translate path)
(-> (-> ls.Synthesis (Meta Expression)) Code (Meta Expression))
diff --git a/new-luxc/source/luxc/lang/translation/ruby/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/eval.jvm.lux
index bce63ce9c..348e5bcf9 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/eval.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/eval.jvm.lux
@@ -11,6 +11,16 @@
(lang (host [ruby #+ Ruby Expression Statement])))
[//])
+(do-template [<name>]
+ [(exception: #export (<name> {message Text})
+ message)]
+
+ [Not-A-Variant]
+ [Unknown-Kind-Of-Host-Object]
+ [Null-Has-No-Lux-Representation]
+ [Cannot-Evaluate]
+ )
+
(host.import java/lang/Object
(toString [] String)
(getClass [] (Class Object)))
@@ -44,8 +54,6 @@
(recur (n/inc idx) (array.write idx lux-value output))))
(#e.Success output)))))
-(exception: #export Not-A-Variant)
-
(def: (variant lux-object host-object)
(-> (-> Object (Error Top)) RubyHash (Error Top))
(case [(RubyHash::get [(:! Object //.variant-tag-field)] host-object)
@@ -61,9 +69,6 @@
_
(ex.throw Not-A-Variant "")))
-(exception: #export Unknown-Kind-Of-Host-Object)
-(exception: #export Null-Has-No-Lux-Representation)
-
(def: (lux-object host-object)
(-> Object (Error Top))
(`` (cond (host.null? host-object)
@@ -94,11 +99,9 @@
(ex.throw Unknown-Kind-Of-Host-Object (format object-class " --- " text-representation)))
)))
-(exception: #export Cannot-Evaluate)
-
(def: #export (eval code)
(-> Expression (Meta Top))
- (function [compiler]
+ (function (_ compiler)
(let [interpreter (|> compiler (get@ #.host) (:! //.Host) (get@ #//.interpreter))]
(case (interpreter code)
(#e.Error error)
@@ -111,7 +114,7 @@
(case (lux-object (:! Object output))
(#e.Success parsed-output)
(exec ## (log! (format "eval #e.Success\n"
- ## "<< " code))
+ ## "<< " code))
(#e.Success [compiler parsed-output]))
(#e.Error error)
diff --git a/new-luxc/source/luxc/lang/translation/ruby/expression.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/expression.jvm.lux
index d0e42c22d..96728731d 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/expression.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/expression.jvm.lux
@@ -21,8 +21,13 @@
[".T" case]
[".T" procedure]))
-(exception: #export Invalid-Function-Syntax)
-(exception: #export Unrecognized-Synthesis)
+(do-template [<name>]
+ [(exception: #export (<name> {message Text})
+ message)]
+
+ [Invalid-Function-Syntax]
+ [Unrecognized-Synthesis]
+ )
(def: #export (translate synthesis)
(-> ls.Synthesis (Meta Expression))
diff --git a/new-luxc/source/luxc/lang/translation/ruby/function.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/function.jvm.lux
index ba349dedd..f5d64459d 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/function.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/function.jvm.lux
@@ -64,9 +64,9 @@
args-initsO+
(ruby.while! (ruby.bool true)
(ruby.return! bodyO))))
- (ruby.return! (let [recur (function [args] (ruby.call (list args) function-name))]
+ (ruby.return! (let [recur (function (_ args) (ruby.call (list args) function-name))]
(ruby.? (ruby.> arityO "num_args")
- (let [slice (function [from to]
+ (let [slice (function (_ from to)
(ruby.array-range from to "curried"))
arity-args (ruby.splat (slice (ruby.int 0) limitO))
output-func-args (ruby.splat (slice arityO "num_args"))]
diff --git a/new-luxc/source/luxc/lang/translation/ruby/procedure.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/procedure.jvm.lux
index e7121ac98..0bda70ad9 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/procedure.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/procedure.jvm.lux
@@ -12,7 +12,8 @@
(/ ["/." common]
["/." host]))
-(exception: #export Unknown-Procedure)
+(exception: #export (Unknown-Procedure {message Text})
+ message)
(def: procedures
/common.Bundle
diff --git a/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
index 0fc0029eb..39c1f561d 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
@@ -51,7 +51,7 @@
(-> Text Bundle Bundle)
(|> bundle
dict.entries
- (list/map (function [[key val]] [(format prefix " " key) val]))
+ (list/map (function (_ [key val]) [(format prefix " " key) val]))
(dict.from-list text.Hash<Text>)))
(def: (wrong-arity proc expected actual)
@@ -61,19 +61,19 @@
" Actual: " (|> actual nat-to-int %i)))
(syntax: (arity: [name s.local-symbol] [arity s.nat])
- (with-gensyms [g!proc g!name g!translate g!inputs]
+ (with-gensyms [g!_ g!proc g!name g!translate g!inputs]
(do @
[g!input+ (monad.seq @ (list.repeat arity (macro.gensym "input")))]
(wrap (list (` (def: #export ((~ (code.local-symbol name)) (~ g!proc))
(-> (-> (..Vector (~ (code.nat arity)) Expression) Expression)
(-> Text ..Proc))
- (function [(~ g!name)]
- (function [(~ g!translate) (~ g!inputs)]
+ (function ((~ g!_) (~ g!name))
+ (function ((~ g!_) (~ g!translate) (~ g!inputs))
(case (~ g!inputs)
(^ (list (~+ g!input+)))
(do macro.Monad<Meta>
[(~+ (|> g!input+
- (list/map (function [g!input]
+ (list/map (function (_ g!input)
(list g!input (` ((~ g!translate) (~ g!input))))))
list.concat))]
((~' wrap) ((~ g!proc) [(~+ g!input+)])))
@@ -88,8 +88,8 @@
(def: #export (variadic proc)
(-> Variadic (-> Text Proc))
- (function [proc-name]
- (function [translate inputsS]
+ (function (_ proc-name)
+ (function (_ translate inputsS)
(do macro.Monad<Meta>
[inputsI (monad.map @ translate inputsS)]
(wrap (proc inputsI))))))
@@ -112,7 +112,9 @@
Unary
valueO)
-(exception: #export Wrong-Syntax)
+(exception: #export (Wrong-Syntax {message Text})
+ message)
+
(def: #export (wrong-syntax procedure args)
(-> Text (List ls.Synthesis) Text)
(format "Procedure: " procedure "\n"
@@ -120,8 +122,8 @@
(def: lux//loop
(-> Text Proc)
- (function [proc-name]
- (function [translate inputsS]
+ (function (_ proc-name)
+ (function (_ translate inputsS)
(case (s.run inputsS ($_ p.seq s.nat (s.tuple (p.many s.any)) s.any))
(#e.Success [offset initsS+ bodyS])
(loopT.translate-loop translate offset initsS+ bodyS)
@@ -132,8 +134,8 @@
(def: lux//recur
(-> Text Proc)
- (function [proc-name]
- (function [translate inputsS]
+ (function (_ proc-name)
+ (function (_ translate inputsS)
(loopT.translate-recur translate inputsS))))
(def: lux-procs
diff --git a/new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux
index 190b9cf6a..9e6383ce4 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux
@@ -77,7 +77,7 @@
_
(` (let [(~' @) (~ runtime)
(~+ (|> (list.zip2 argsC+ argsLC+)
- (list/map (function [[left right]] (list left right)))
+ (list/map (function (_ [left right]) (list left right)))
list/join))]
(ruby.function! (~ runtime)
(list (~+ argsLC+))