From 1b110d177a8bc12776a6d24bd6d3f693abe5ba2a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 8 Nov 2021 22:20:54 -0400 Subject: Added the carriage return for better Windows compatibility. --- stdlib/source/library/lux/target/js.lux | 17 +++-- stdlib/source/library/lux/target/lua.lux | 31 +++++---- stdlib/source/library/lux/target/php.lux | 15 +++-- stdlib/source/library/lux/target/python.lux | 73 ++++++++++++---------- stdlib/source/library/lux/target/r.lux | 17 +++-- stdlib/source/library/lux/target/ruby.lux | 19 +++--- stdlib/source/library/lux/target/scheme.lux | 7 ++- .../lux/tool/compiler/language/lux/version.lux | 2 +- 8 files changed, 108 insertions(+), 73 deletions(-) (limited to 'stdlib/source') diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index b9307bf14..88ad9ff5e 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -23,9 +23,14 @@ (def: element (text.enclosed ["[" "]"])) +... Added the carriage return for better Windows compatibility. +(def: \n+ + Text + (format text.carriage_return text.new_line)) + (def: nested (-> Text Text) - (|>> (format text.new_line) + (|>> (format \n+) (text.replaced text.new_line (format text.new_line text.tab)))) (abstract: .public (Code brand) @@ -165,12 +170,12 @@ (def: .public (then pre post) (-> Statement Statement Statement) (:abstraction (format (:representation pre) - text.new_line + \n+ (:representation post)))) (def: block (-> Statement Text) - (let [close (format text.new_line "}")] + (let [close (format \n+ "}")] (|>> :representation ..nested (text.enclosed ["{" @@ -401,10 +406,10 @@ (list#each (.function (_ [when then]) (format (|> when (list#each (|>> :representation (text.enclosed ["case " ":"]))) - (text.interposed text.new_line)) + (text.interposed \n+)) (..nested (:representation then))))) - (text.interposed text.new_line)) - text.new_line + (text.interposed \n+)) + \n+ (case default {.#Some default} (format "default:" diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index 5389a8bc8..12885861e 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -27,10 +27,15 @@ [type abstract]]]) +... Added the carriage return for better Windows compatibility. +(def: \n+ + Text + (format text.carriage_return text.new_line)) + (def: nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (|>> (format text.new_line) + (|>> (format \n+) (text.replaced text.new_line nested_new_line)))) (def: input_separator ", ") @@ -248,7 +253,7 @@ (-> Statement Statement Statement) (:abstraction (format (:representation pre!) - text.new_line + \n+ (:representation post!)))) (def: locations @@ -275,29 +280,29 @@ (def: .public (if test then! else!) (-> Expression Statement Statement Statement) (:abstraction (format "if " (:representation test) - text.new_line "then" (..nested (:representation then!)) - text.new_line "else" (..nested (:representation else!)) - text.new_line "end"))) + \n+ "then" (..nested (:representation then!)) + \n+ "else" (..nested (:representation else!)) + \n+ "end"))) (def: .public (when test then!) (-> Expression Statement Statement) (:abstraction (format "if " (:representation test) - text.new_line "then" (..nested (:representation then!)) - text.new_line "end"))) + \n+ "then" (..nested (:representation then!)) + \n+ "end"))) (def: .public (while test body!) (-> Expression Statement Statement) (:abstraction (format "while " (:representation test) " do" (..nested (:representation body!)) - text.new_line "end"))) + \n+ "end"))) (def: .public (repeat until body!) (-> Expression Statement Statement) (:abstraction (format "repeat" (..nested (:representation body!)) - text.new_line "until " (:representation until)))) + \n+ "until " (:representation until)))) (def: .public (for_in vars source body!) (-> (List Var) Expression Statement Statement) @@ -307,7 +312,7 @@ (text.interposed ..input_separator)) " in " (:representation source) " do" (..nested (:representation body!)) - text.new_line "end"))) + \n+ "end"))) (def: .public (for_step var from to step body!) (-> Var Expression Expression Expression Statement @@ -318,7 +323,7 @@ ..input_separator (:representation to) ..input_separator (:representation step) " do" (..nested (:representation body!)) - text.new_line "end"))) + \n+ "end"))) (def: .public (return value) (-> Expression Statement) @@ -330,7 +335,7 @@ ..locations (text.enclosed ["(" ")"])) (..nested (:representation body!)) - text.new_line "end") + \n+ "end") (text.enclosed ["(" ")"]) :abstraction)) @@ -343,7 +348,7 @@ ..locations (text.enclosed ["(" ")"])) (..nested (:representation body!)) - text.new_line "end")))] + \n+ "end")))] [function "function"] [local_function "local function"] diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index e11745829..f02eafd89 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -29,15 +29,20 @@ (def: input_separator ", ") (def: statement_suffix ";") +... Added the carriage return for better Windows compatibility. +(def: \n+ + Text + (format text.carriage_return text.new_line)) + (def: nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (|>> (format text.new_line) + (|>> (format \n+) (text.replaced text.new_line nested_new_line)))) (def: block (-> Text Text) - (|>> ..nested (text.enclosed ["{" (format text.new_line "}")]))) + (|>> ..nested (text.enclosed ["{" (format \n+ "}")]))) (def: group (-> Text Text) @@ -450,7 +455,7 @@ (-> Statement Statement Statement) (:abstraction (format (:representation pre!) - text.new_line + \n+ (:representation post!)))) (def: .public (while test body!) @@ -490,10 +495,10 @@ (-> Statement (List Except) Statement) (:abstraction (format "try " (..block (:representation body!)) - text.new_line + \n+ (|> excepts (list#each catch) - (text.interposed text.new_line))))) + (text.interposed \n+))))) (template [ ] [(def: .public diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index ba17a92f0..79a15c682 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -1,31 +1,31 @@ (.using - [library - [lux {"-" Location Code Label not or and list if cond int comment exec try} - ["@" target] - ["[0]" ffi] - [abstract - [equivalence {"+" Equivalence}] - [hash {"+" Hash}] - ["[0]" enum]] - [control - [pipe {"+" new> case> cond>}] - [parser - ["<[0]>" code]]] - [data - ["[0]" text - ["%" format {"+" format}]] - [collection - ["[0]" list ("[1]#[0]" functor mix)]]] - [macro - [syntax {"+" syntax:}] - ["[0]" template] - ["[0]" code]] - [math - [number - ["n" nat] - ["f" frac]]] - [type - abstract]]]) + [library + [lux {"-" Location Code Label not or and list if cond int comment exec try} + ["@" target] + ["[0]" ffi] + [abstract + [equivalence {"+" Equivalence}] + [hash {"+" Hash}] + ["[0]" enum]] + [control + [pipe {"+" new> case> cond>}] + [parser + ["<[0]>" code]]] + [data + ["[0]" text + ["%" format {"+" format}]] + [collection + ["[0]" list ("[1]#[0]" functor mix)]]] + [macro + [syntax {"+" syntax:}] + ["[0]" template] + ["[0]" code]] + [math + [number + ["n" nat] + ["f" frac]]] + [type + abstract]]]) (def: expression (-> Text Text) @@ -37,14 +37,19 @@ (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))] (as_is)) +... Added the carriage return for better Windows compatibility. +(def: \n+ + Text + (format text.carriage_return text.new_line)) + (def: nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (for [@.old (|>> (format text.new_line) + (for [@.old (|>> (format \n+) (:as java/lang/String) (java/lang/String::replace (:as java/lang/CharSequence text.new_line) (:as java/lang/CharSequence nested_new_line)))] - (|>> (format text.new_line) + (|>> (format \n+) (text.replaced text.new_line nested_new_line))))) (abstract: .public (Code brand) @@ -340,7 +345,7 @@ (:abstraction (format "if " (:representation test) ":" (..nested (:representation then!)) - text.new_line "else:" + \n+ "else:" (..nested (:representation else!))))) (def: .public (when test then!) @@ -353,7 +358,7 @@ (-> (Statement Any) (Statement Any) (Statement Any)) (:abstraction (format (:representation pre!) - text.new_line + \n+ (:representation post!)))) (template [ <0>] @@ -372,7 +377,7 @@ (..nested (:representation body!)) (case else! {.#Some else!} - (format text.new_line "else:" + (format \n+ "else:" (..nested (:representation else!))) {.#None} @@ -405,7 +410,7 @@ (..nested (:representation body!)) (|> excepts (list#each (function (_ [classes exception catch!]) - (format text.new_line "except (" (text.interposed ", " (list#each ..code classes)) + (format \n+ "except (" (text.interposed ", " (list#each ..code classes)) ") as " (:representation exception) ":" (..nested (:representation catch!))))) text.together)))) @@ -445,7 +450,7 @@ (def: .public (comment commentary on) (All (_ brand) (-> Text (Code brand) (Code brand))) - (:abstraction (format "# " (..safe commentary) text.new_line + (:abstraction (format "# " (..safe commentary) \n+ (:representation on)))) ) diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index ca5d7ea31..f4c3588ce 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -70,24 +70,29 @@ (:abstraction (format "(" code ")"))) + ... Added the carriage return for better Windows compatibility. + (def: \n+ + Text + (format text.carriage_return text.new_line)) + (def: nested_new_line (format text.new_line text.tab)) (def: nested (-> Text Text) (|>> (text.replaced text.new_line ..nested_new_line) - (format ..nested_new_line))) + (format text.carriage_return ..nested_new_line))) (def: (_block expression) (-> Text Text) - (format "{" (nested expression) text.new_line "}")) + (format "{" (nested expression) \n+ "}")) (def: .public (block expression) (-> Expression Expression) (:abstraction (format "{" (..nested (:representation expression)) - text.new_line "}"))) + \n+ "}"))) (template [ ] [(def: .public @@ -173,7 +178,7 @@ (format func "(" (|> args (list#each ..code) - (text.interposed (format "," text.new_line)) + (text.interposed (format "," \n+)) ..nested) ")")))) @@ -258,7 +263,7 @@ (:abstraction (format "if(" (:representation test) ") {" (.._block (:representation then)) - text.new_line "}"))) + \n+ "}"))) (def: .public (cond clauses else) (-> (List [Expression Expression]) Expression Expression) @@ -381,6 +386,6 @@ (-> Expression Expression Expression) (:abstraction (format (:representation pre) - text.new_line + \n+ (:representation post)))) ) diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index 5eaaf8e1d..eb0f542ac 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -29,10 +29,15 @@ (def: input_separator ", ") (def: statement_suffix ";") +... Added the carriage return for better Windows compatibility. +(def: \n+ + Text + (format text.carriage_return text.new_line)) + (def: nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (|>> (format text.new_line) + (|>> (format \n+) (text.replaced text.new_line nested_new_line)))) (abstract: .public (Code brand) @@ -214,7 +219,7 @@ (def: (control_structure content) (-> Text Text) (format content - text.new_line "end" ..statement_suffix)) + \n+ "end" ..statement_suffix)) (def: .public (apply/* arguments block_lambda func) (-> (List Expression) (Maybe Expression) Expression Computation) @@ -259,7 +264,7 @@ (-> Statement Statement Statement) (:abstraction (format (:representation pre!) - text.new_line + \n+ (:representation post!)))) (def: .public (set vars value) @@ -276,7 +281,7 @@ ..control_structure (format "if " (:representation test) (..nested (:representation then!)) - text.new_line "else" + \n+ "else" (..nested (:representation else!))))) (template [ ] @@ -313,10 +318,10 @@ (format "begin" (..nested (:representation body!)) (|> rescues (list#each (.function (_ [classes exception rescue]) - (format text.new_line "rescue " (text.interposed ..input_separator classes) + (format \n+ "rescue " (text.interposed ..input_separator classes) " => " (:representation exception) (..nested (:representation rescue))))) - (text.interposed text.new_line))))) + (text.interposed \n+))))) (def: .public (catch expectation body!) (-> Expression Statement Statement) @@ -413,7 +418,7 @@ (def: .public (comment commentary on) (All (_ brand) (-> Text (Code brand) (Code brand))) - (:abstraction (format "# " (..safe commentary) text.new_line + (:abstraction (format "# " (..safe commentary) \n+ (:representation on)))) ) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index 0cfcfd9f1..f1ad798e7 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -21,6 +21,11 @@ [type abstract]]]) +... Added the carriage return for better Windows compatibility. +(def: \n+ + Text + (format text.carriage_return text.new_line)) + (def: nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] @@ -155,7 +160,7 @@ (def: form (-> (List (Code Any)) Code) - (.let [nested_new_line (format text.new_line text.tab)] + (.let [nested_new_line (format \n+ text.tab)] (|>> (case> {.#End} (:abstraction "()") diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/version.lux b/stdlib/source/library/lux/tool/compiler/language/lux/version.lux index 22c388a4c..c9ffff258 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/version.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/version.lux @@ -6,4 +6,4 @@ (def: .public version Version - 00,06,04) + 00,06,05) -- cgit v1.2.3