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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
----
-- `alive` public API.
--
-- @module init
L or= setmetatable {}, __index: => ->
import ValueStream, EventStream, IOStream from require 'core.stream'
import Result from require 'core.result'
import Scope from require 'core.scope'
import Error from require 'core.error'
import Registry, SimpleRegistry from require 'core.registry'
import Tag from require 'core.tag'
import Cell from require 'core.cell'
import cell, program from require 'core.parsing'
with require 'core.cycle'
\load!
globals = Scope.from_table require 'core.builtin'
--- exports
-- @table exports
-- @tfield ValueStream ValueStream
-- @tfield EventStream EventStream
-- @tfield IOStream IOStream
-- @tfield Result Result
-- @tfield Cell Cell
-- @tfield RootCell RootCell
-- @tfield Scope Scope
-- @tfield Error Error
-- @tfield Registry Registry
-- @tfield Tag Tag
-- @tfield Scope globals global definitons
-- @tfield parse function to turn a `string` into a root `Cell`
{
:ValueStream, :EventStream, :IOStream
:Cell, :RootCell
:Result, :Scope, :Error
:Registry, :SimpleRegistry, :Tag
:globals
parse: (str) ->
assert (program\match str), Error 'syntax', "failed to parse"
eval: (str, inject) ->
scope = Scope nil, globals
scope\use inject if inject
ast = assert (program\match str), "failed to parse"
result = ast\eval scope
result\const!
}
|