mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-11 16:09:31 +03:00
b8a01b5a7e
(cherry picked from commit 663e0e8284c080e9d38821b53950bf9325a1e209)
62 lines
1.9 KiB
Plaintext
62 lines
1.9 KiB
Plaintext
|%
|
|
++ static :: freeze .mdh hoon subset
|
|
|= gen/hoon ^- {inf/(map term dime) elm/manx}
|
|
?+ -.gen
|
|
=/ gen ~(open ap gen)
|
|
?: =(gen ^gen) ~|([%cram-dynamic -.gen] !!)
|
|
$(gen gen)
|
|
::
|
|
$xray [~ (single (shut gen))]
|
|
^ [(malt (frontmatter p.gen)) (single (shut q.gen))]
|
|
==
|
|
::
|
|
++ single :: unwrap one-elem marl
|
|
|= xml/marl ^- manx
|
|
?: ?=({* $~} xml) i.xml
|
|
~|(%many-elems !!)
|
|
::
|
|
++ shut-mart :: xml attrs
|
|
|=({n/mane v/(list beer:hoon)} [n (turn v |=(a/beer:hoon ?^(a !! a)))])
|
|
::
|
|
++ shut :: as xml constant
|
|
|= gen/hoon ^- marl
|
|
?+ -.gen ~|([%bad-xml -.gen] !!)
|
|
$dbug $(gen q.gen)
|
|
::
|
|
$xray
|
|
[[n.g.p.gen (turn a.g.p.gen shut-mart)] $(gen [%smts c.p.gen])]~
|
|
::
|
|
$smts
|
|
?~ p.gen ~
|
|
=- (weld - $(p.gen t.p.gen))
|
|
?^ -.i.p.gen $(gen [%xray i.p.gen])
|
|
~| [%shut-tuna -.i.p.gen]
|
|
?+ -.i.p.gen !!
|
|
$manx ?>(?=($xray -.p.i.p.gen) $(gen p.i.p.gen))
|
|
$marl ?>(?=($smts -.p.i.p.gen) $(gen p.i.p.gen))
|
|
==
|
|
==
|
|
::
|
|
::
|
|
++ frontmatter :: parse ~[[%foo 1] [%bar ~s2]]
|
|
|= gen/hoon ^- (list {term dime})
|
|
?: ?=({$bust $null} gen) ~
|
|
?: ?=($dbug -.gen) $(gen q.gen)
|
|
?. ?=($clsg -.gen) ~|([%bad-frontmatter -.gen] !!)
|
|
%+ turn p.gen
|
|
|= gen/hoon
|
|
?. ?=(^ -.gen)
|
|
=/ gen ~(open ap gen)
|
|
?: =(gen ^gen) ~|([%bad-frontmatter-elem -.gen] !!)
|
|
$(gen gen)
|
|
=/ hed (as-dime p.gen)
|
|
?. =(%tas p.hed) ~|([%bad-frontmatter-key-type p.hed] !!)
|
|
[q.hed (as-dime q.gen)]
|
|
::
|
|
++ as-dime :: %foo ~.foo 0vbar etc
|
|
|= gen/hoon ^- dime
|
|
?: ?=($dbug -.gen) $(gen q.gen)
|
|
?. ?=({?($rock $sand) @ @} gen) ~|([%bad-literal gen] !!)
|
|
+.gen
|
|
--
|