This repository has been archived by the owner on Oct 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
startup.hl
139 lines (109 loc) · 3.28 KB
/
startup.hl
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* File responsible for initializing Micro.
*
* Creates three Active Events __[p5.io.unroll-path.@MICRO]__ - Which evaluates
* to the _"/micro/"_ folder, and is used as a _"path variable"_.
* In addition, it creates both of our __[micro.evaluate.xxx]__ events, one
* called _"file"_ and another caller _"folder"_, which allows you to evaluate
* a single Hyperlambda file, or evaluate all Hyperlambda files recursively
* inside a specified folder.
*/
/*
* Creates the _"path"_ Active Event that points to our _"/micro/"_ folder.
*/
split:x:/..?name
=:/
set:x:/@split/0/-
join:x:/@split/*?name
sep:/
eval-x:x:/+/*
create-event:p5.io.unroll-path.@MICRO
return:/{0}
:x:/@join?value
/*
* This Active Event allows you to execute one or more Hyperlambda files.
*
* The Hyperlambda file(s) you wish to execute is given as __[\_arg]__.
* All other arguments will be passed into your file(s) as arguments.
*/
create-event:micro.evaluate.file
/*
* Used as "signal object" to separate arguments from the rest of the lambda.
*/
.signal
/*
* Sanity checking arguments.
*/
micro.lambda.contract.min:x:/..
_arg:string
/*
* Loading up all files given as [_arg] arguments.
*/
load-file:x:/@.signal/--/<-/_arg?value
/*
* Adding all arguments given to evaluation of file into [eval].
*/
add:x:/../*/eval
src:x:/@.signal/--(!/_arg)/<-
/*
* Evaluating [load-file]'s children, with the arguments applied in the above [add] invocation.
*/
eval:x:/@load-file/*
/*
* Returning the results of the above evaluation to caller.
*/
insert-after:x:/@.signal
src:x:/@eval/*
set:x:/..?value
src:x:/@eval?value
/*
* Evaluates all Hyperlambda files within the specified folder(s) recursively.
*
* The Hyperlambda folder(s) you wish to execute is given as __[\_arg]__.
* All other arguments will be passed into your folders' files as they are being evaluated.
*/
create-event:micro.evaluate.folder
/*
* Used as "signal object" to separate arguments from the rest of the lambda.
*/
.signal
/*
* Sanity checking arguments.
*/
micro.lambda.contract.min:x:/..
_arg:string
/*
* Listing all Hyperlambda files in directories we're given.
*/
list-files:x:/../*/_arg?value
filter:.hl
/*
* Evaluating all Hyperlambda files from that folder, making sure we
* pass in arguments given.
*/
add:x:/+
src:x:/@.signal/--(!/_arg)/<-
micro.evaluate.file:x:/@list-files/*?name
/*
* Returning the results of the above evaluation to caller.
*/
insert-after:x:/@.signal
src:x:/@micro.evaluate.file/*
set:x:/..?value
src:x:/@eval?value
/*
* Listing all folders recursively, within the folder(s) we've just evaluated.
*/
list-folders:x:/../*/_arg?value
/*
* If the above [list-folder] gave us any result(s), we recursively invoke self,
* making sure we pass in the same arguments we were given.
*/
if:x:/-/*
add:x:/+
src:x:/@.signal/--(!/_arg)/<-
micro.evaluate.folder:x:/@list-folders/*?name
/*
* Evaluates all Hyperlambda files recursively within the "@MICRO/startup/" folder.
*/
micro.evaluate.folder:@MICRO/startup/