aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/target/ruby.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/target/ruby.lux47
1 files changed, 36 insertions, 11 deletions
diff --git a/stdlib/source/lux/target/ruby.lux b/stdlib/source/lux/target/ruby.lux
index e884d6c70..641cc8d2e 100644
--- a/stdlib/source/lux/target/ruby.lux
+++ b/stdlib/source/lux/target/ruby.lux
@@ -124,7 +124,8 @@
)
(template [<ruby_name> <lux_name>]
- [(def: #export <lux_name> (..global <ruby_name>))]
+ [(def: #export <lux_name>
+ (..global <ruby_name>))]
["@" latest_error]
["_" last_string_read]
@@ -135,11 +136,17 @@
["/" input_record_separator]
["\" output_record_separator]
["0" script_name]
- ["*" command_line_arguments]
["$" process_id]
["?" exit_status]
)
+ (template [<ruby_name> <lux_name>]
+ [(def: #export <lux_name>
+ (..local <ruby_name>))]
+
+ ["ARGV" command_line_arguments]
+ )
+
(def: #export nil
Literal
(:abstraction "nil"))
@@ -172,8 +179,9 @@
(-> <type> Literal)
(|>> <prep> <format> :abstraction))]
- [%.int int Int (<|)]
+ [%.int int Int (<|)]
[%.text string Text ..sanitize]
+ [(<|) symbol Text (format ":")]
)
(def: #export float
@@ -323,6 +331,13 @@
(..nest (:representation rescue)))))
(text.join_with text.new_line)))))
+ (def: #export (catch expectation body!)
+ (-> Expression Statement Statement)
+ (<| :abstraction
+ ..block
+ (format "catch(" (:representation expectation) ") do"
+ (..nest (:representation body!)))))
+
(def: #export (return value)
(-> Expression Statement)
(:abstraction (format "return " (:representation value) ..statement_suffix)))
@@ -360,8 +375,7 @@
(list\map (|>> :representation))
(text.join_with ..input_separator)
(text.enclose' "|"))
- " "
- (:representation body!))
+ (..nest (:representation body!)))
(text.enclose ["{" "}"])
(format "lambda "))]
(|> (case name
@@ -401,9 +415,14 @@
[">>" bit_shr]
)
- (def: #export (not subject)
- (-> Expression Computation)
- (:abstraction (format "(!" (:representation subject) ")")))
+ (template [<unary> <name>]
+ [(def: #export (<name> subject)
+ (-> Expression Computation)
+ (:abstraction (format "(" <unary> (:representation subject) ")")))]
+
+ ["!" not]
+ ["-" negate]
+ )
(def: #export (comment commentary on)
(All [brand] (-> Text (Code brand) (Code brand)))
@@ -448,11 +467,17 @@
<definitions>))]
[1
- [["print"]]]
+ [["print"]
+ ["require"]]]
[2
- []]
+ [["print"]]]
[3
- []]
+ [["print"]]]
)
+
+(def: #export throw/1
+ (-> Expression Statement)
+ (|>> (..apply/1 (..local "throw"))
+ ..statement))