From 72482573b97662b6b5910213b5f1bf21c685961c Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 14 Apr 2017 17:36:40 -0400 Subject: - Development of the new re-written compiler has officially begun! --- new-luxc/project.clj | 25 ++++++++++++++++ new-luxc/source/program.lux | 71 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 new-luxc/project.clj create mode 100644 new-luxc/source/program.lux (limited to 'new-luxc') 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])) + +(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 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!")))) -- cgit v1.2.3