aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/program.lux
blob: e7fa95c2d4a42daa3a4a4237b59ba9918b7b9223 (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
(;module:
  lux
  (lux (control monad)
       [io #- run]
       [cli #+ program: CLI Monad<CLI>])
  (luxc ["&" base]
        ["&;" parser]
        ["&;" compiler]
        (module (descriptor ["&;" type]))
        ))

(type: Compilation
  {#mode &;Mode
   #program &;Path
   #target &;Path})

(def: (marker tokens)
  (-> (List 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: compilation^
  (CLI Compilation)
  ($_ cli;seq
      mode^
      (tagged (list "-p" "--program"))
      (tagged (list "-t" "--target"))))

(program: ([command (cli;opt compilation^)]
           [sources (cli;some (tagged (list "-s" "--source")))])
  (case command
    #;None
    (io (log! "No REPL for you!"))

    (#;Some [mode program target])
    (exec (&compiler;compile-program mode program target sources)
      (io []))))