aboutsummaryrefslogtreecommitdiffstats
path: root/core/init.moon
diff options
context:
space:
mode:
Diffstat (limited to 'core/init.moon')
-rw-r--r--core/init.moon20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/init.moon b/core/init.moon
index f0456c2..c91f0e4 100644
--- a/core/init.moon
+++ b/core/init.moon
@@ -7,9 +7,29 @@ import Scope from require 'core.scope'
load_!
import Cell, RootCell from require 'core.cell'
+import cell, program from require 'core.parsing'
{
:Const, :Cell, :RootCell
:Op, :Action, :FnDef
:Scope
+
+ parse: program\match
+ eval: do
+ class BuiltinRegistry
+ new: =>
+ @last = 1
+
+ register: (thing, tag) =>
+ with tag or Const.sym "builtin.#{@last}"
+ @last += 1
+
+ registry = BuiltinRegistry!
+
+ (str, inject) ->
+ scope = Scope.from_table require 'lib.builtin'
+ scope\use inject if inject
+
+ ast = assert (cell\match str), "failed to parse: #{str}"
+ Const.wrap ast\eval scope, registry
}