aboutsummaryrefslogtreecommitdiff
path: root/luxc/src/lux.clj
blob: 4f73f79e0ee78c0b7843edbb9f57b436638f0315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
;;  Copyright (c) Eduardo Julian. All rights reserved.
;;  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
;;  If a copy of the MPL was not distributed with this file,
;;  You can obtain one at http://mozilla.org/MPL/2.0/.

(ns lux
  (:gen-class)
  (:require [lux.base :as & :refer [|let |do return fail return* fail* |case]]
            [lux.compiler.base :as &compiler-base]
            [lux.compiler :as &compiler]
            [lux.repl :as &repl]
            [clojure.string :as string]
            :reload-all)
  (:import (java.io File)))

(def unit-separator (str (char 31)))

(defn ^:private process-dirs
  "(-> Text (List Text))"
  [resources-dirs]
  (-> resources-dirs
      (string/replace unit-separator "\n")
      string/split-lines
      &/->list))

(defn -main [& args]
  (|case (&/->list args)
    (&/$Cons "release" (&/$Cons program-module (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil))))))
    (time (&compiler/compile-program &/$Release program-module (process-dirs resources-dirs) (process-dirs source-dirs) target-dir))

    (&/$Cons "debug" (&/$Cons program-module (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil))))))
    (time (&compiler/compile-program &/$Debug program-module (process-dirs resources-dirs) (process-dirs source-dirs) target-dir))

    (&/$Cons "repl" (&/$Cons source-dirs (&/$Nil)))
    (&repl/repl (process-dirs source-dirs))

    _
    (println "Can't understand command.")))

(comment
  (-main "release" "tests"
         "/home/eduardoejp/workspace/projects/lux-stdlib/resources"
         (str "/home/eduardoejp/workspace/projects/lux-stdlib/source" unit-separator
              "/home/eduardoejp/workspace/projects/lux-stdlib/test")
         "/home/eduardoejp/workspace/projects/lux/target/jvm")

  (-main "release" "tests"
         "/home/eduardoejp/workspace/projects/lux-stdlib/resources"
         (str "/home/eduardoejp/workspace/projects/lux-stdlib/source" unit-separator
              "/home/eduardoejp/workspace/projects/lux-stdlib/test")
         "/home/eduardoejp/workspace/projects/lux-stdlib/target/jvm")
  )