on master help sign in
TODO.md+1
since splitsnapshots
unifiedsplit
@@ -8,3 +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+- [ ] attributes
desk/lib/lua/interpreter.hoon+35−7
@@ -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]
@@ -62,20 +62,26 @@
62 =<
62 =<
63 |= =blok
63 |= =blok
64 ^- (eval-m value)
64 ^- (eval-m value)
65+ %- with-local
65 =/ body body.blok
66 =/ body body.blok
66− ;< ~ bind push-local
67 |-
67 |-
68 ^- (eval-m value)
68 ^- (eval-m value)
69 ?~ body
69 ?~ body
70 ?~ ret.blok (pure nil+~)
70 ?~ ret.blok (pure nil+~)
71 ?~ u.ret.blok (pure nil+~)
71 ?~ u.ret.blok (pure nil+~)
72 ;< rets=(lest value) bind (eval-exprlist u.u.ret.blok)
72 ;< rets=(lest value) bind (eval-exprlist u.u.ret.blok)
73− (pure multires+rets)
73+ (pure (multires rets))
74 ;< ~ bind (eval-stat i.body)
74 ;< ~ bind (eval-stat i.body)
75 ;< ret=value bind $(body t.body)
75 ;< ret=value bind $(body t.body)
76− ;< ~ bind pop-local
77 (pure ret)
76 (pure ret)
78 |%
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)
79 ++ push-local
85 ++ push-local
80 ^- (eval-m ~)
86 ^- (eval-m ~)
81 |= st=state
87 |= st=state
@@ -85,10 +91,15 @@
85 ^- (eval-m ~)
91 ^- (eval-m ~)
86 |= st=state
92 |= st=state
87 =. local-envs.st
93 =. local-envs.st
88− ?~ local-envs.st !!
94+ ?~ t.local-envs.st !!
89 t.local-envs.st
95 t.local-envs.st
90 [st ~]
96 [st ~]
91 --
97 --
98+++ multires
99+ |= vals=(lest value)
100+ ^- value
101+ ?~ t.vals i.vals
102+ multires+vals
92++ eval-exprlist
103++ eval-exprlist
93 |= vals=exprlist
104 |= vals=exprlist
94 ^- (eval-m (lest value))
105 ^- (eval-m (lest value))
@@ -114,15 +125,31 @@
114 (set-table ->-.i.asmnts (~(put by tabl) ->+.i.asmnts +.i.asmnts))
125 (set-table ->-.i.asmnts (~(put by tabl) ->+.i.asmnts +.i.asmnts))
115 ==
126 ==
116 $(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)
117 ==
144 ==
118++ set-var
145++ set-var
119 |= var=name
146 |= var=name
120 |= val=value
147 |= val=value
121 ^- (eval-m ~)
148 ^- (eval-m ~)
122 ;< envs=(list (map name value)) bind get-local-envs
149 ;< envs=(list (map name value)) bind get-local-envs
123− =/ new-envs=(unit (list (map name value)))
150+ =/ new-envs=(unit (lest (map name value)))
124 |-
151 |-
125− ^- (unit (list (map name value)))
152+ ^- (unit (lest (map name value)))
126 ?~ envs ~
153 ?~ envs ~
127 ?. (~(has by i.envs) var)
154 ?. (~(has by i.envs) var)
128 =/ rest $(envs t.envs)
155 =/ rest $(envs t.envs)
@@ -159,6 +186,7 @@
159 =/ tail=value (normalize-multires i.vals)
186 =/ tail=value (normalize-multires i.vals)
160 ?: ?=(%multires -.tail) +.tail [tail ~]
187 ?: ?=(%multires -.tail) +.tail [tail ~]
161 [i.vals $(vals t.vals)]
188 [i.vals $(vals t.vals)]
189+ ?~ t.res i.res
162 multires+res
190 multires+res
163 ==
191 ==
164++ 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