diff options
author | Eduardo Julian | 2018-08-11 14:44:42 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-08-11 14:44:42 -0400 |
commit | 725bcd5670a5d83c201fac147aedce01d9283d03 (patch) | |
tree | 3942735ba1b19dee9b2ba5a0818f4a6be1cf3cfe /new-luxc/source/program.lux | |
parent | 0fe039a41571328a29b7a620643fc5e30e32b9a3 (diff) |
Moved interpreter (REPL) code to stdlib.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/program.lux | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux index 4e0925717..01b3a2eee 100644 --- a/new-luxc/source/program.lux +++ b/new-luxc/source/program.lux @@ -7,7 +7,7 @@ ["." promise (#+ Promise)] ["." task (#+ Task)]] [data - ["e" error] + ["." error] [text format]] ["." io (#+ IO Process io)] @@ -15,12 +15,13 @@ ["." instant]] [cli (#+ program:)] [world - ["." file (#+ File)]] + ["." file (#+ File)] + ["." console]] [compiler ["." cli] - ["." default (#+ Platform)]]] + ["." default (#+ Platform)]] + ["." interpreter]] [luxc - ## ["." repl] [lang ["." host/jvm] [translation @@ -28,19 +29,19 @@ ["." runtime] ["." expression]]]]]) -(def: (or-crash! failure-describer action) +(def: (or-crash! failure-description action) (All [a] - (-> Text (Task a) (Promise a))) - (do promise.Monad<Promise> + (-> Text (Process a) (IO a))) + (do io.Monad<IO> [?output action] (case ?output - (#e.Error error) + (#error.Error error) (exec (log! (format "\n" - failure-describer "\n" + failure-description "\n" error "\n")) - (io.run (io.exit +1))) + (io.exit +1)) - (#e.Success output) + (#error.Success output) (wrap output)))) (def: (timed action) @@ -65,17 +66,14 @@ (program: [{service cli.service}] (do io.Monad<IO> - [platform ..jvm-platform] - (wrap (: (Promise Any) - (case service - (#cli.Build [configuration program]) - (<| (or-crash! "Compilation failed:") - promise.future - ..timed - (default.compile platform configuration program)) - - (#cli.REPL configuration) - (undefined) - ## (<| (or-crash! "REPL failed:") - ## (repl.run sources target)) - ))))) + [platform ..jvm-platform + console (:: @ map error.assume console.open)] + (case service + (#cli.Compilation configuration) + (<| (or-crash! "Compilation failed:") + ..timed + (default.compile platform configuration)) + + (#cli.Interpretation configuration) + (<| (or-crash! "Interpretation failed:") + (interpreter.run io.Monad<Process> console platform configuration))))) |