on master help sign in
unwrap prefix exprs
d9e37e7iko
desk/lib/lua/parser.hoon+11−2
@@ -33,7 +33,7 @@ apex
33 parse-numeral
33 parse-numeral
34 ::
34 ::
35 %+ cook
35 %+ cook
36− |=(=prefix-expr [%prefix-expr prefix-expr])
36+ |=(=prefix-expr (unwrap-prefix [%prefix-expr prefix-expr]))
37 (knee *prefix-expr |.(parse-prefix-expr))
37 (knee *prefix-expr |.(parse-prefix-expr))
38 ::
38 ::
39 %+ cook
39 %+ cook
@@ -136,7 +136,11 @@ apex
136 --
136 --
137++ parse-expr
137++ parse-expr
138 %^ tnee %parse-expr expr
138 %^ tnee %parse-expr expr
139+ %+ cook unwrap-prefix
140+ ;~ pose
139− %+ cook process-expr-list parse-expr-list
141+ %+ cook process-expr-list parse-expr-list
142+ (ifix [;~(plug (just '(') ws) ;~(plug ws (just ')'))] (knee *expr |.(parse-expr)))
143+ ==
140++ parse-parened-expr
144++ parse-parened-expr
141 %^ tnee %parse-parened-expr prefix-expr
145 %^ tnee %parse-parened-expr prefix-expr
142 %+ cook
146 %+ cook
@@ -960,4 +964,9 @@ apex
960 |= [nedl=* stak=(list *)]
964 |= [nedl=* stak=(list *)]
961 ^- ?
965 ^- ?
962 ?=(^ (find ~[nedl] stak))
966 ?=(^ (find ~[nedl] stak))
967+++ unwrap-prefix
968+ |= x=expr
969+ ^- expr
970+ ?: ?=([%prefix-expr %expr *] x) $(x +>.x)
971+ x
963--
972--
desk/ted/test-lua.hoon−8
@@ -74,14 +74,6 @@
74 ?~ cycled-ast-unit (pure:m %err)
74 ?~ cycled-ast-unit (pure:m %err)
75 =/ ast u.cycled-ast-unit
75 =/ ast u.cycled-ast-unit
76 ~? (has-flag %print-asts) ast
76 ~? (has-flag %print-asts) ast
77− ~& %printing-parsed
78− =/ printed (lua-printer ast)
79− ~& %comparing-printed
80− ?. =(printed ^printed) (pure:m %err)
81− ~& %parsing-reprinted
82− =/ cycled-ast-unit (parse printed)
83− ?~ cycled-ast-unit (pure:m %err)
84− =/ ast u.cycled-ast-unit
85 ~& %comparing-asts
77 ~& %comparing-asts
86 ?. =(^ast ast) (pure:m %err)
78 ?. =(^ast ast) (pure:m %err)
87 (pure:m %ok)
79 (pure:m %ok)