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

(type: Compilation
  {#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: compilation^
  (CLI Compilation)
  ($_ cli;seq
      (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 [program target])
    (exec (&compiler;compile-program program target sources)
      (io []))))