on master help sign in
TODO.md+1−3
since splitsnapshots
unifiedsplit
@@ -8,6 +8,4 @@
8- [x] ^ should be higher priority than unary ops
8- [x] ^ should be higher priority than unary ops
9- [x] Unifiy parened exprs
9- [x] Unifiy parened exprs
10- [ ] pow
10- [ ] pow
11−
11+- [ ] attributes
12−
13− {f()} -- creates a list with all results from f().
desk/lib/lua/interpreter.hoon+51−5
@@ -33,7 +33,7 @@
33 $:
33 $:
34 tables=$~([(malt ~[[0 *table]]) 1] (objects table))
34 tables=$~([(malt ~[[0 *table]]) 1] (objects table))
35 global-env=table
35 global-env=table
36− local-envs=$~(~[(malt ~[['_ENV' table+[0 ~]]])] (list (map name value)))
36+ local-envs=$~(~[(malt ~[['_ENV' table+[0 ~]]])] (lest (map name value)))
37 ==
37 ==
38++ eval-m
38++ eval-m
39 |$ [val]
39 |$ [val]
@@ -59,8 +59,10 @@
59 |= state
59 |= state
60 [st ~]
60 [st ~]
61++ eval-blok
61++ eval-blok
62+ =<
62 |= =blok
63 |= =blok
63 ^- (eval-m value)
64 ^- (eval-m value)
65+ %- with-local
64 =/ body body.blok
66 =/ body body.blok
65 |-
67 |-
66 ^- (eval-m value)
68 ^- (eval-m value)
@@ -68,9 +70,36 @@
68 ?~ ret.blok (pure nil+~)
70 ?~ ret.blok (pure nil+~)
69 ?~ u.ret.blok (pure nil+~)
71 ?~ u.ret.blok (pure nil+~)
70 ;< rets=(lest value) bind (eval-exprlist u.u.ret.blok)
72 ;< rets=(lest value) bind (eval-exprlist u.u.ret.blok)
71− (pure multires+rets)
73+ (pure (multires rets))
72 ;< ~ bind (eval-stat i.body)
74 ;< ~ bind (eval-stat i.body)
73− $(body t.body)
75+ ;< ret=value bind $(body t.body)
76+ (pure ret)
77+ |%
78+ ++ with-local
79+ |* act=(eval-m)
80+ ^- _act
81+ ;< ~ bind push-local
82+ ;< res=_val:$:act bind act
83+ ;< ~ bind pop-local
84+ (pure res)
85+ ++ push-local
86+ ^- (eval-m ~)
87+ |= st=state
88+ =. local-envs.st [*(map name value) local-envs.st]
89+ [st ~]
90+ ++ pop-local
91+ ^- (eval-m ~)
92+ |= st=state
93+ =. local-envs.st
94+ ?~ t.local-envs.st !!
95+ t.local-envs.st
96+ [st ~]
97+ --
98+++ multires
99+ |= vals=(lest value)
100+ ^- value
101+ ?~ t.vals i.vals
102+ multires+vals
74++ eval-exprlist
103++ eval-exprlist
75 |= vals=exprlist
104 |= vals=exprlist
76 ^- (eval-m (lest value))
105 ^- (eval-m (lest value))
@@ -96,15 +125,31 @@
96 (set-table ->-.i.asmnts (~(put by tabl) ->+.i.asmnts +.i.asmnts))
125 (set-table ->-.i.asmnts (~(put by tabl) ->+.i.asmnts +.i.asmnts))
97 ==
126 ==
98 $(asmnts t.asmnts)
127 $(asmnts t.asmnts)
128+ %local-asmnt
129+ =/ lhs=(list name)
130+ %+ turn attrnamelist.stat
131+ |= [=name attr=(unit attrib)]
132+ ?> ?=(~ attr)
133+ name
134+ ;< actual-values=(list [name value]) bind
135+ ?~ rhs.stat (pure ~)
136+ ;< rhs=(list value) bind (eval-exprlist u.rhs.stat)
137+ (pure (zip lhs rhs))
138+ ;< st=state bind get-state
139+ =. i.local-envs.st
140+ %- ~(uni by i.local-envs.st)
141+ %- malt
142+ (weld (turn lhs |=(=name [name `value`nil+~])) actual-values)
143+ (set-state st)
99 ==
144 ==
100++ set-var
145++ set-var
101 |= var=name
146 |= var=name
102 |= val=value
147 |= val=value
103 ^- (eval-m ~)
148 ^- (eval-m ~)
104 ;< envs=(list (map name value)) bind get-local-envs
149 ;< envs=(list (map name value)) bind get-local-envs
105− =/ new-envs=(unit (list (map name value)))
150+ =/ new-envs=(unit (lest (map name value)))
106 |-
151 |-
107− ^- (unit (list (map name value)))
152+ ^- (unit (lest (map name value)))
108 ?~ envs ~
153 ?~ envs ~
109 ?. (~(has by i.envs) var)
154 ?. (~(has by i.envs) var)
110 =/ rest $(envs t.envs)
155 =/ rest $(envs t.envs)
@@ -141,6 +186,7 @@
141 =/ tail=value (normalize-multires i.vals)
186 =/ tail=value (normalize-multires i.vals)
142 ?: ?=(%multires -.tail) +.tail [tail ~]
187 ?: ?=(%multires -.tail) +.tail [tail ~]
143 [i.vals $(vals t.vals)]
188 [i.vals $(vals t.vals)]
189+ ?~ t.res i.res
144 multires+res
190 multires+res
145 ==
191 ==
146++ process-varlist
192++ process-varlist
desk/lib/lua/parser.hoon+2−2
@@ -568,7 +568,7 @@ apex
568++ parse-local-asmnt
568++ parse-local-asmnt
569 %^ tnee %parse-local-asmnt local-asmnt
569 %^ tnee %parse-local-asmnt local-asmnt
570 %+ cook
570 %+ cook
571− |= [* * =attnamelist rhs=(unit explist)] [attnamelist rhs]
571+ |= [* * =attrnamelist rhs=(unit explist)] [attrnamelist rhs]
572 ;~ plug
572 ;~ plug
573 (jest 'local')
573 (jest 'local')
574 wss
574 wss
@@ -582,7 +582,7 @@ apex
582 ==
582 ==
583 ==
583 ==
584++ parse-attnamelist
584++ parse-attnamelist
585− %^ tnee %parse-attnamelist attnamelist
585+ %^ tnee %parse-attnamelist attrnamelist
586 %+ most (ifix [ws ws] com)
586 %+ most (ifix [ws ws] com)
587 ;~ plug
587 ;~ plug
588 parse-name
588 parse-name
desk/lib/lua/printer.hoon+5−5
@@ -264,7 +264,7 @@ print
264 %- zing
264 %- zing
265 :~
265 :~
266 "local "
266 "local "
267− (print-attnamelist attnamelist.local-asmnt)
267+ (print-attrnamelist attrnamelist.local-asmnt)
268 ?~ rhs.local-asmnt ""
268 ?~ rhs.local-asmnt ""
269 %- zing
269 %- zing
270 :~
270 :~
@@ -272,13 +272,13 @@ print
272 (print-explist u.rhs.local-asmnt)
272 (print-explist u.rhs.local-asmnt)
273 ==
273 ==
274 ==
274 ==
275−:: attnamelist
275+:: attrnamelist
276::
276::
277−++ print-attnamelist
277+++ print-attrnamelist
278− |= =attnamelist
278+ |= =attrnamelist
279 ^- tape
279 ^- tape
280 %- commaed
280 %- commaed
281− %+ turn attnamelist
281+ %+ turn attrnamelist
282 |= [=name attr=(unit attrib)]
282 |= [=name attr=(unit attrib)]
283 %- zing
283 %- zing
284 :~
284 :~
desk/res/lua/baz.lua+3−2
@@ -1,5 +1,6 @@
1x = 8
1x = 8
2
2
3−y = x
3+local y = x + 3
4
4
5+
5−return y
6+return y / 2
desk/res/lua/foo.lua+2−2
@@ -47,9 +47,9 @@ do
47 return 8, foo;
47 return 8, foo;
48end
48end
49
49
50−print('the way of the future')
50+-- print('the way of the future')
51
51
52−print 'hello'
52+-- print 'hello'
53
53
54h{key1 = 'Sonmi~451'}
54h{key1 = 'Sonmi~451'}
55
55
desk/sur/lua.hoon+2−2
@@ -104,8 +104,8 @@
104+$ funcbody [pars=parlist body=blok]
104+$ funcbody [pars=parlist body=blok]
105+$ parlist [pars=(list name) wildcard=?]
105+$ parlist [pars=(list name) wildcard=?]
106+$ local-function [=name body=funcbody]
106+$ local-function [=name body=funcbody]
107−+$ local-asmnt [=attnamelist rhs=(unit exprlist)]
107++$ local-asmnt [=attrnamelist rhs=(unit exprlist)]
108−+$ attnamelist (lest [=name attr=(unit attrib)])
108++$ attrnamelist (lest [=name attr=(unit attrib)])
109+$ attrib
109+$ attrib
110 $?
110 $?
111 %const
111 %const