shrub/tree/json.hook

72 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-08-04 02:49:34 +03:00
::
2015-08-04 06:54:39 +03:00
:::: /hook/json/tree
::
2015-08-04 02:49:34 +03:00
/? 314
2015-08-04 04:37:19 +03:00
/+ tree
2015-08-04 02:49:34 +03:00
/= gas /$ fuel
2015-08-04 04:37:19 +03:00
/= dat /^ tree-include
/: /===/tree-gen /%
/tree-include/
2015-08-04 02:49:34 +03:00
::
2015-08-04 04:37:19 +03:00
/= kid /^ (map span tree-include)
/: /===/tree-gen /% 2 /_
/tree-include/
!:
2015-08-04 02:49:34 +03:00
::::
::
2015-08-04 04:37:19 +03:00
|%
++ schema (dict ,[term $|(mark schema)])
++ dict |*(a=_,* $&([a (dict a)] a))
++ query
$% [%kids p=(list query)]
[%name %t]
2015-08-06 02:48:34 +03:00
[%path %t]
2015-08-04 04:37:19 +03:00
[%snip %r]
[%head %r]
[%body %r]
[%meta %j]
==
++ to-queries
|= a=schema ^- (list query)
?@(-.a [(to-query a) ~] [(to-query -.a) $(a +.a)])
2015-08-04 02:49:34 +03:00
::
2015-08-04 04:37:19 +03:00
++ to-query
|= a=[term $|(mark schema)]
~| invalid-query/a
?+ -.a ;;(query a)
%kids [%kids (to-queries ?@(+.a !! +.a))]
==
++ from-type :: XX holding out for noun odors
|= a=$%([%t p=cord] [%r p=json] [%j p=json])
?- -.a
%t [%s p.a]
%r p.a
%j p.a
==
++ from-queries
|= [bem=beam quy=(list query)]
=< (jobe (turn quy .))
|= a=query
:- -.a
?- -.a
%name (from-type +.a ?^(s.bem i.s.bem q.bem))
2015-08-06 02:48:34 +03:00
%path (from-type +.a (crip (spud (flop s.bem))))
2015-08-04 04:37:19 +03:00
%head (from-type +.a head.dat)
%snip (from-type +.a snip.dat)
%meta (from-type +.a meta.dat)
%body (from-type +.a body.dat)
%kids ?< (~(has by (mo p.a)) %kids) :: XX recursion?
2015-08-06 05:13:41 +03:00
=< o/(~(urn by kid) .)
2015-08-04 04:37:19 +03:00
|= [dir=span dak=tree-include]
2015-08-06 05:13:41 +03:00
^^$(quy p.a, s.bem [dir s.bem], dat dak, kid ~)
==
2015-08-04 04:37:19 +03:00
--
2015-08-04 02:49:34 +03:00
!:
::::
::
^- json
2015-08-04 04:37:19 +03:00
=+ ^= schem
=+ seh=(fall (~(get by qix.gas) 'q') 'body.r')
~|(bad-noun/seh ;;(schema (rash seh read-schem)))
(from-queries bem.gas(s but.gas) (to-queries schem))