aboutsummaryrefslogtreecommitdiffstats
path: root/alv/copilot.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-04-20 16:25:39 +0000
committers-ol <s-ol@users.noreply.github.com>2020-04-20 16:45:45 +0000
commit22fa7e3786ff4d5035c6827ed59c3bcf2e49ae53 (patch)
treef54ada7db6958c6b92064b13fff8294336111b64 /alv/copilot.moon
parentadd wxLua alv-wx (diff)
downloadalive-22fa7e3786ff4d5035c6827ed59c3bcf2e49ae53.tar.gz
alive-22fa7e3786ff4d5035c6827ed59c3bcf2e49ae53.zip
export and export* to create alive modules
See #16
Diffstat (limited to 'alv/copilot.moon')
-rw-r--r--alv/copilot.moon17
1 files changed, 2 insertions, 15 deletions
diff --git a/alv/copilot.moon b/alv/copilot.moon
index 3d1523e..e5868bb 100644
--- a/alv/copilot.moon
+++ b/alv/copilot.moon
@@ -6,13 +6,7 @@ lfs = require 'lfs'
import Scope from require 'alv.scope'
import Registry from require 'alv.registry'
import Error from require 'alv.error'
-import program from require 'alv.parsing'
-globals = Scope.from_table require 'alv.builtin'
-
-slurp = (file) ->
- file = io.open file, 'r'
- with file\read '*all'
- file\close!
+import loadfile from require 'alv.load'
spit = (file, str) ->
file = io.open file, 'w'
@@ -59,14 +53,7 @@ class Copilot
eval: =>
@registry\begin_eval!
- ok, ast = Error.try "parsing '#{@file}'", program\match, slurp @file
- if not (ok and ast)
- L\print ast or Error 'syntax', "failed to parse"
- @registry\rollback_eval!
- return
-
- scope = Scope globals
- ok, root = Error.try "evaluating '#{@file}'", ast\eval, scope, @registry
+ ok, root, ast = Error.try "running '#{@file}'", loadfile, @file
if not ok
L\print root
@registry\rollback_eval!