on 5cbb435 help sign in
7 files changed+20−49
since splitsnapshots
unifiedsplit
TODO.md−1 desk/lib/lua/interpreter.hoon+7−34 desk/lib/lua/parser.hoon+2−2 desk/lib/lua/printer.hoon+5−5 desk/res/lua/baz.lua+2−3 desk/res/lua/foo.lua+2−2 desk/sur/lua.hoon+2−2
TODO.md−1
@@ -8,4 +8,3 @@
88- [x] ^ should be higher priority than unary ops
99- [x] Unifiy parened exprs
1010- [ ] pow
11−- [ ] attributes
desk/lib/lua/interpreter.hoon+7−34
@@ -33,7 +33,7 @@
3333 $:
3434 tables=$~([(malt ~[[0 *table]]) 1] (objects table))
3535 global-env=table
36− local-envs=$~(~[(malt ~[['_ENV' table+[0 ~]]])] (lest (map name value)))
36+ local-envs=$~(~[(malt ~[['_ENV' table+[0 ~]]])] (list (map name value)))
3737 ==
3838++ eval-m
3939 |$ [val]
@@ -62,26 +62,20 @@
6262 =<
6363 |= =blok
6464 ^- (eval-m value)
65− %- with-local
6665 =/ body body.blok
66+ ;< ~ bind push-local
6767 |-
6868 ^- (eval-m value)
6969 ?~ body
7070 ?~ ret.blok (pure nil+~)
7171 ?~ u.ret.blok (pure nil+~)
7272 ;< rets=(lest value) bind (eval-exprlist u.u.ret.blok)
73− (pure (multires rets))
73+ (pure multires+rets)
7474 ;< ~ bind (eval-stat i.body)
7575 ;< ret=value bind $(body t.body)
76+ ;< ~ bind pop-local
7677 (pure ret)
7778 |%
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)
8579 ++ push-local
8680 ^- (eval-m ~)
8781 |= st=state
@@ -91,15 +85,10 @@
9185 ^- (eval-m ~)
9286 |= st=state
9387 =. local-envs.st
94− ?~ t.local-envs.st !!
88+ ?~ local-envs.st !!
9589 t.local-envs.st
9690 [st ~]
9791 --
98−++ multires
99− |= vals=(lest value)
100− ^- value
101− ?~ t.vals i.vals
102− multires+vals
10392++ eval-exprlist
10493 |= vals=exprlist
10594 ^- (eval-m (lest value))
@@ -125,31 +114,15 @@
125114 (set-table ->-.i.asmnts (~(put by tabl) ->+.i.asmnts +.i.asmnts))
126115 ==
127116 $(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)
144117 ==
145118++ set-var
146119 |= var=name
147120 |= val=value
148121 ^- (eval-m ~)
149122 ;< envs=(list (map name value)) bind get-local-envs
150− =/ new-envs=(unit (lest (map name value)))
123+ =/ new-envs=(unit (list (map name value)))
151124 |-
152− ^- (unit (lest (map name value)))
125+ ^- (unit (list (map name value)))
153126 ?~ envs ~
154127 ?. (~(has by i.envs) var)
155128 =/ rest $(envs t.envs)
desk/lib/lua/parser.hoon+2−2
@@ -568,7 +568,7 @@ apex
568568++ parse-local-asmnt
569569 %^ tnee %parse-local-asmnt local-asmnt
570570 %+ cook
571− |= [* * =attrnamelist rhs=(unit explist)] [attrnamelist rhs]
571+ |= [* * =attnamelist rhs=(unit explist)] [attnamelist rhs]
572572 ;~ plug
573573 (jest 'local')
574574 wss
@@ -582,7 +582,7 @@ apex
582582 ==
583583 ==
584584++ parse-attnamelist
585− %^ tnee %parse-attnamelist attrnamelist
585+ %^ tnee %parse-attnamelist attnamelist
586586 %+ most (ifix [ws ws] com)
587587 ;~ plug
588588 parse-name
desk/lib/lua/printer.hoon+5−5
@@ -264,7 +264,7 @@ print
264264 %- zing
265265 :~
266266 "local "
267− (print-attrnamelist attrnamelist.local-asmnt)
267+ (print-attnamelist attnamelist.local-asmnt)
268268 ?~ rhs.local-asmnt ""
269269 %- zing
270270 :~
@@ -272,13 +272,13 @@ print
272272 (print-explist u.rhs.local-asmnt)
273273 ==
274274 ==
275−:: attrnamelist
275+:: attnamelist
276276::
277−++ print-attrnamelist
278− |= =attrnamelist
277+++ print-attnamelist
278+ |= =attnamelist
279279 ^- tape
280280 %- commaed
281− %+ turn attrnamelist
281+ %+ turn attnamelist
282282 |= [=name attr=(unit attrib)]
283283 %- zing
284284 :~
desk/res/lua/baz.lua+2−3
@@ -1,6 +1,5 @@
11x = 8
22
3−local y = x + 3
3+y = x
44
5−
6−return y / 2
5+return y
desk/res/lua/foo.lua+2−2
@@ -47,9 +47,9 @@ do
4747 return 8, foo;
4848end
4949
50−-- print('the way of the future')
50+print('the way of the future')
5151
52−-- print 'hello'
52+print 'hello'
5353
5454h{key1 = 'Sonmi~451'}
5555
desk/sur/lua.hoon+2−2
@@ -104,8 +104,8 @@
104104+$ funcbody [pars=parlist body=blok]
105105+$ parlist [pars=(list name) wildcard=?]
106106+$ local-function [=name body=funcbody]
107−+$ local-asmnt [=attrnamelist rhs=(unit exprlist)]
108−+$ attrnamelist (lest [=name attr=(unit attrib)])
107++$ local-asmnt [=attnamelist rhs=(unit exprlist)]
108++$ attnamelist (lest [=name attr=(unit attrib)])
109109+$ attrib
110110 $?
111111 %const