aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/target/python.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/target/python.lux')
-rw-r--r--stdlib/source/library/lux/target/python.lux73
1 files changed, 39 insertions, 34 deletions
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 [<keyword> <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))))
)