aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/project.clj25
-rw-r--r--new-luxc/source/program.lux71
2 files changed, 96 insertions, 0 deletions
diff --git a/new-luxc/project.clj b/new-luxc/project.clj
new file mode 100644
index 000000000..4ecd372f5
--- /dev/null
+++ b/new-luxc/project.clj
@@ -0,0 +1,25 @@
+(defproject com.github.luxlang/new-luxc "0.6.0-SNAPSHOT"
+ :description "A re-written compiler for Lux."
+ :url "https://github.com/LuxLang/lux"
+ :license {:name "MIT License"
+ :url "https://opensource.org/licenses/MIT"}
+ :plugins [[com.github.luxlang/lein-luxc "0.6.0-SNAPSHOT"]]
+ :deploy-repositories [["releases" {:url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
+ :creds :gpg}]
+ ["snapshots" {:url "https://oss.sonatype.org/content/repositories/snapshots/"
+ :creds :gpg}]]
+ :pom-addition [:developers [:developer
+ [:name "Eduardo Julian"]
+ [:url "https://github.com/eduardoejp"]]]
+ :repositories [["snapshots" "https://oss.sonatype.org/content/repositories/snapshots/"]
+ ["releases" "https://oss.sonatype.org/service/local/staging/deploy/maven2/"]]
+ :scm {:name "git"
+ :url "https://github.com/LuxLang/lux.git"}
+
+ :dependencies []
+
+ :source-paths ["source"]
+ :test-paths ["test"]
+ :lux {:program {:jvm "program"}
+ :tests {:jvm "tests"}}
+ )
diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux
new file mode 100644
index 000000000..dbe875d12
--- /dev/null
+++ b/new-luxc/source/program.lux
@@ -0,0 +1,71 @@
+(;module:
+ lux
+ (lux (control monad)
+ [io #- run]
+ [cli #+ program: CLI Monad<CLI>]))
+
+(type: Path Text)
+
+(type: Platform
+ #JVM
+ #JS)
+
+(type: Mode
+ #Release
+ #Debug)
+
+(type: Compilation
+ {#mode Mode
+ #platform Platform
+ #program Path
+ #target Path})
+
+(type: Inputs
+ {#resources (List Path)
+ #sources (List Path)})
+
+(def: (marker tokens)
+ (-> Text (CLI Unit))
+ (cli;after (cli;option tokens)
+ (:: Monad<CLI> wrap [])))
+
+(def: (tagged tags)
+ (-> (List Text) (CLI Text))
+ (cli;after (cli;option tags)
+ cli;any))
+
+(def: mode^
+ (CLI Mode)
+ ($_ cli;alt
+ (marker (list "release"))
+ (marker (list "debug"))))
+
+(def: platform^
+ (CLI Platform)
+ ($_ cli;alt
+ (marker (list "jvm"))
+ (marker (list "js"))))
+
+(def: compilation^
+ (CLI Compilation)
+ ($_ cli;seq
+ mode^
+ platform^
+ (tagged (list "-p" "--program"))
+ (tagged (list "-t" "--target"))))
+
+(def: inputs^
+ (CLI Inputs)
+ ($_ cli;seq
+ (cli;some (tagged (list "-r" "--resource")))
+ (cli;some (tagged (list "-s" "--source")))))
+
+(program: ([[command [resources sources]]
+ (cli;seq (cli;opt compilation^)
+ inputs^)])
+ (case command
+ #;None
+ (io (log! "Hello, REPL!"))
+
+ (#;Some [mode platform program target])
+ (io (log! "Hello, compilation!"))))