From 725bcd5670a5d83c201fac147aedce01d9283d03 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 11 Aug 2018 14:44:42 -0400 Subject: Moved interpreter (REPL) code to stdlib. --- new-luxc/source/program.lux | 48 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'new-luxc/source/program.lux') 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 + (-> Text (Process a) (IO a))) + (do io.Monad [?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 - [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 console platform configuration))))) -- cgit v1.2.3