on master help sign in
Fixed some parser bugs
1cd661eiko
zod/luau/lib/lua/parser.hoon+50−28
@@ -5,8 +5,15 @@ apex
5|%
5|%
6++ apex
6++ apex
7 %^ tnee %apex ast
7 %^ tnee %apex ast
8+ ;~ pfix
9+ %- punt
10+ ;~ plug
11+ hax
12+ zap
13+ (star ;~(less (just '\0a') next))
14+ ==
15+ ::
8− %+ ifix [ws ws]
16+ %+ ifix [ws ws]
9− ;~ pose
10 (cook |=(=blok [%blok blok]) parse-blok)
17 (cook |=(=blok [%blok blok]) parse-blok)
11 ==
18 ==
12:: The expressions that are separated by binary operators
19:: The expressions that are separated by binary operators
@@ -169,17 +176,17 @@ apex
169 (cold %mod (jest '%'))
176 (cold %mod (jest '%'))
170 (cold %band (jest '&'))
177 (cold %band (jest '&'))
171 (cold %bor (jest '|'))
178 (cold %bor (jest '|'))
172− (cold %bxor (jest '~'))
179+ (cold %eq (jest '=='))
173 (cold %rshft (jest '>>'))
180 (cold %rshft (jest '>>'))
174 (cold %lshft (jest '<<'))
181 (cold %lshft (jest '<<'))
182+ (cold %lteq (jest '<='))
183+ (cold %gteq (jest '>='))
184+ (cold %neq (jest '~='))
185+ (cold %bxor (jest '~'))
175 (cold %and (jest 'and'))
186 (cold %and (jest 'and'))
176 (cold %or (jest 'or'))
187 (cold %or (jest 'or'))
177 (cold %lt (jest '<'))
188 (cold %lt (jest '<'))
178− (cold %lteq (jest '<='))
179− (cold %eq (jest '=='))
180 (cold %gt (jest '>'))
189 (cold %gt (jest '>'))
181− (cold %gteq (jest '>='))
182− (cold %neq (jest '~='))
183 (cold %concat (jest '..'))
190 (cold %concat (jest '..'))
184 ==
191 ==
185++ parse-numeral
192++ parse-numeral
@@ -511,31 +518,41 @@ apex
511++ parse-if
518++ parse-if
512 %^ tnee %parse-if if
519 %^ tnee %parse-if if
513 %+ cook
520 %+ cook
514− |= [* cond=expr * body=blok elsa=(list [cond=expr body=blok]) else=(unit blok) *]
521+ |= [[* cond=expr * body=blok] elsa=(list [cond=expr body=blok]) else=(unit blok) *]
515 [cond body elsa else]
522 [cond body elsa else]
516− ;~ (glue wss)
523+ ;~ plug
517− (jest 'if')
518− parse-expr
519− (jest 'then')
520− parse-blok
521− ::
522− %- star
523− %+ cook
524− |= [* cond=expr * body=blok] [cond body]
525 ;~ (glue wss)
524 ;~ (glue wss)
526− (jest 'elseif')
525+ (jest 'if')
527 parse-expr
526 parse-expr
528 (jest 'then')
527 (jest 'then')
529 parse-blok
528 parse-blok
530 ==
529 ==
531 ::
530 ::
531+ %- star
532+ %+ cook
533+ |= [* cond=expr * body=blok] [cond body]
534+ ;~ pfix
535+ wss
536+ ;~ (glue wss)
537+ (jest 'elseif')
538+ parse-expr
539+ (jest 'then')
540+ parse-blok
541+ ==
542+ ==
543+ ::
532 %- punt
544 %- punt
533 %+ cook
545 %+ cook
534 |= [* =blok] blok
546 |= [* =blok] blok
547+ ;~ pfix
548+ wss
535− ;~ (glue wss)
549+ ;~ (glue wss)
536− (jest 'else')
550+ (jest 'else')
537− parse-blok
551+ parse-blok
552+ ==
538 ==
553 ==
554+ ::
555+ wss
539 (jest 'end')
556 (jest 'end')
540 ==
557 ==
541++ parse-functioncall
558++ parse-functioncall
@@ -601,19 +618,17 @@ apex
601 |= ret=(unit ret) [stats ret]
618 |= ret=(unit ret) [stats ret]
602 %- punt
619 %- punt
603 ;~ pfix
620 ;~ pfix
604− ?~ stats (easy ~) wss
621+ ?~ stats ws wss
605 parse-ret
622 parse-ret
606 ==
623 ==
607++ parse-ret
624++ parse-ret
608 %^ tnee %parse-ret ret
625 %^ tnee %parse-ret ret
609 %+ cook
626 %+ cook
610− |= [[* =exprlist] *] exprlist
627+ |= [* ret=(unit exprlist) *] ret
611 ;~ plug
628 ;~ plug
612− ;~ (glue wss)
613− (jest 'return')
629+ (jest 'return')
614− parse-exprlist
630+ (punt ;~(pfix wss parse-exprlist))
615− ==
616− (punt (just ';'))
631+ (punt ;~(plug ws (just ';')))
617 ==
632 ==
618++ parse-name
633++ parse-name
619 =>
634 =>
@@ -630,8 +645,15 @@ apex
630 =/ prev-edge (prev nail)
645 =/ prev-edge (prev nail)
631 ?~ q.prev-edge prev-edge
646 ?~ q.prev-edge prev-edge
632 ((cont p.u.q.prev-edge) q.u.q.prev-edge)
647 ((cont p.u.q.prev-edge) q.u.q.prev-edge)
648+++ comment
649+ ;~ pfix
650+ (jest '--')
651+ (star ;~(less nl next))
652+ ==
653+++ nl (just '\0a')
633++ w
654++ w
634 ;~ pose
655 ;~ pose
656+ comment
635 gah
657 gah
636 (just '\09')
658 (just '\09')
637 ==
659 ==
zod/luau/lib/lua/printer.hoon+1−1
@@ -464,7 +464,7 @@ print
464 %- zing
464 %- zing
465 :~
465 :~
466 "return "
466 "return "
467− (print-exprlist ret)
467+ ?~ ret "" (print-exprlist u.ret)
468 ==
468 ==
469:: Helpers
469:: Helpers
470::
470::
zod/luau/sur/lua.hoon+1−1
@@ -119,5 +119,5 @@
119+$ args exprlist
119+$ args exprlist
120+$ label name
120+$ label name
121+$ blok [body=(list stat) ret=(unit ret)]
121+$ blok [body=(list stat) ret=(unit ret)]
122−+$ ret exprlist
122++$ ret (unit exprlist)
123--
123--
zod/luau/tests/foo.lua+5
@@ -110,3 +110,8 @@ end
110
110
111
111
112x = -1 + 8
112x = -1 + 8
113+if _VERSION ~= version then
114+ io.stderr:write("This test suite is for ", version,
115+ ", not for ", _VERSION, "\nExiting tests")
116+ return
117+end