mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 18:12:47 +03:00
Moved spat/spud/stab, refactored json
This commit is contained in:
parent
b26deda123
commit
5798c490b1
@ -3672,6 +3672,12 @@
|
|||||||
:+ %rose [['/' ~] ['/' ~] ['/' ~]]
|
:+ %rose [['/' ~] ['/' ~] ['/' ~]]
|
||||||
|- ^- (list tank)
|
|- ^- (list tank)
|
||||||
(turn bon |=(a=@ [%leaf (rip 3 a)]))
|
(turn bon |=(a=@ [%leaf (rip 3 a)]))
|
||||||
|
::
|
||||||
|
++ spat |=(pax=path (crip (spud pax))) :: path to cord
|
||||||
|
++ spud |=(pax=path ~(ram re (smyt pax))) :: path to tape
|
||||||
|
++ stab :: parse span to path
|
||||||
|
|= zep=@ta ^- path
|
||||||
|
(rash zep ;~(pfix fas (more fas urs:ab)))
|
||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
:: section 2eM, regular-expressions ::
|
:: section 2eM, regular-expressions ::
|
||||||
::
|
::
|
||||||
@ -6096,7 +6102,6 @@
|
|||||||
|= typ=type ^- tank
|
|= typ=type ^- tank
|
||||||
~(duck ut typ)
|
~(duck ut typ)
|
||||||
::
|
::
|
||||||
++ spat |=(pax=path (rap 3 (spud pax))) :: path to cord
|
|
||||||
++ spec :: reconstruct type
|
++ spec :: reconstruct type
|
||||||
|= vax=vase
|
|= vax=vase
|
||||||
^- vase
|
^- vase
|
||||||
@ -6108,7 +6113,6 @@
|
|||||||
[%wtgr [%wtts [%leaf %tas -.q.vax] [%$ 2]~] [%$ 1]]
|
[%wtgr [%wtts [%leaf %tas -.q.vax] [%$ 2]~] [%$ 1]]
|
||||||
(~(fuse ut p.vax) [%cell %noun %noun])
|
(~(fuse ut p.vax) [%cell %noun %noun])
|
||||||
::
|
::
|
||||||
++ spud |=(pax=path ~(ram re (dish:ut [~ %path] pax))) :: path to tape
|
|
||||||
++ slew :: get axis in vase
|
++ slew :: get axis in vase
|
||||||
|= [axe=@ vax=vase] ^- (unit vase)
|
|= [axe=@ vax=vase] ^- (unit vase)
|
||||||
?. |- ^- ?
|
?. |- ^- ?
|
||||||
@ -6144,10 +6148,6 @@
|
|||||||
[* * *] $(wad [n.wad ~ r.wad], vax $(wad l.wad))
|
[* * *] $(wad [n.wad ~ r.wad], vax $(wad l.wad))
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ stab :: parse cord to path
|
|
||||||
|= zep=@ta ^- path
|
|
||||||
(need (rush zep ;~(pfix fas ;~(sfix (more fas urs:ab) fas))))
|
|
||||||
::
|
|
||||||
++ wash :: render tank at width
|
++ wash :: render tank at width
|
||||||
|= [[tab=@ edg=@] tac=tank] ^- wall
|
|= [[tab=@ edg=@] tac=tank] ^- wall
|
||||||
(~(win re tac) tab edg)
|
(~(win re tac) tab edg)
|
||||||
|
@ -501,58 +501,38 @@
|
|||||||
$(a +.a)
|
$(a +.a)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ poja :: parse JSON
|
++ poja !: :: parse JSON
|
||||||
|%
|
|%
|
||||||
++ apex :: JSON object
|
++ apex ;~(pose abox obox) :: JSON object
|
||||||
;~(pose abox obox)
|
|
||||||
++ valu :: JSON value
|
++ valu :: JSON value
|
||||||
%+ knee *json |. ~+
|
%+ knee *json |. ~+
|
||||||
;~ pfix spac
|
;~ pfix spac
|
||||||
;~ pose
|
;~ pose
|
||||||
(cold ~ (jest 'null'))
|
(cold ~ (jest 'null'))
|
||||||
(jify %b bool)
|
(stag %b bool)
|
||||||
(jify %s stri)
|
(stag %s stri)
|
||||||
(cook |=(s=tape [%n p=(rap 3 s)]) numb)
|
(cook |=(s=tape [%n p=(rap 3 s)]) numb)
|
||||||
abox
|
abox
|
||||||
obox
|
obox
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
:: JSON arrays
|
:: JSON arrays
|
||||||
++ arra (ifix [sel (ws ser)] (more (ws com) valu))
|
++ abox (stag %a (ifix [sel (ws ser)] (more (ws com) valu)))
|
||||||
++ abox (cook |=(elts=(list json) [%a p=elts]) arra)
|
|
||||||
:: JSON objects
|
:: JSON objects
|
||||||
++ pair ;~((comp |=([k=@ta v=json] [k v])) ;~(sfix (ws stri) (ws col)) valu)
|
++ pair ;~(plug ;~(sfix (ws stri) (ws col)) valu)
|
||||||
++ obje (ifix [(ws kel) (ws ker)] (more (ws com) pair))
|
++ obje (ifix [(ws kel) (ws ker)] (more (ws com) pair))
|
||||||
++ obox (cook |=(s=(list ,[@ta json]) [%o p=(mo s)]) obje)
|
++ obox (stag %o (cook mo obje))
|
||||||
:: JSON booleans
|
:: JSON booleans
|
||||||
++ bool ;~(pose (cold & (jest 'true')) (cold | (jest 'false')))
|
++ bool ;~(pose (cold & (jest 'true')) (cold | (jest 'false')))
|
||||||
:: JSON strings
|
:: JSON strings
|
||||||
++ stri
|
++ stri (cook crip (ifix [doq doq] (star jcha)))
|
||||||
(cook |=(s=(list ,@) (rap 3 s)) (ifix [doq doq] (star jcha)))
|
++ jcha ;~(pose ;~(less doq bas prn) esca) :: character in string
|
||||||
++ jcha :: character in string
|
|
||||||
;~ pose
|
|
||||||
esca
|
|
||||||
;~ pose
|
|
||||||
:: Non-escape string characters
|
|
||||||
(shim 32 33)
|
|
||||||
(shim 35 91)
|
|
||||||
(shim 93 126)
|
|
||||||
(shim 128 255)
|
|
||||||
==
|
|
||||||
==
|
|
||||||
++ esca :: Escaped character
|
++ esca :: Escaped character
|
||||||
;~ pfix bas
|
;~ pfix bas
|
||||||
;~ pose
|
;~ pose
|
||||||
doq
|
doq fas soq bas
|
||||||
fas
|
(sear ~(get by `(map ,@t ,@)`(mo b/8 t/9 n/10 f/12 r/13 ~)) low)
|
||||||
soq
|
;~(pfix (just 'u') (cook tuft qix:ab)) :: 4-digit hex to UTF-8
|
||||||
bas
|
|
||||||
(cold 8 (just 'b'))
|
|
||||||
(cold 9 (just 't'))
|
|
||||||
(cold 10 (just 'n'))
|
|
||||||
(cold 12 (just 'f'))
|
|
||||||
(cold 13 (just 'r'))
|
|
||||||
;~(pfix (just 'u') (cook tuft qix:ab)) :: Convert 4-digit hex to UTF-8
|
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
:: JSON numbers
|
:: JSON numbers
|
||||||
@ -561,28 +541,23 @@
|
|||||||
(mayb (piec hep))
|
(mayb (piec hep))
|
||||||
;~ pose
|
;~ pose
|
||||||
(piec (just '0'))
|
(piec (just '0'))
|
||||||
;~((comp twel) (piec (shim '1' '9')) digs)
|
;~(plug (shim '1' '9') digs)
|
||||||
==
|
==
|
||||||
(mayb frac)
|
(mayb frac)
|
||||||
(mayb expo)
|
(mayb expo)
|
||||||
==
|
==
|
||||||
++ digs (star (shim '0' '9'))
|
++ digs (star (shim '0' '9'))
|
||||||
++ expo :: Exponent part
|
++ expo :: Exponent part
|
||||||
;~ (comp twel)
|
;~ (comp twel)
|
||||||
(piec (mask "eE"))
|
(piec (mask "eE"))
|
||||||
(mayb (piec (mask "+-")))
|
(mayb (piec (mask "+-")))
|
||||||
digs
|
digs
|
||||||
==
|
==
|
||||||
++ frac :: Fractional part
|
++ frac ;~(plug dot digs) :: Fractional part
|
||||||
;~ (comp twel)
|
|
||||||
(piec dot)
|
|
||||||
digs
|
|
||||||
==
|
|
||||||
:: whitespace
|
:: whitespace
|
||||||
++ spac (star (mask [`@`9 `@`10 `@`13 ' ' ~]))
|
++ spac (star (mask [`@`9 `@`10 `@`13 ' ' ~]))
|
||||||
++ ws |*(sef=_rule ;~(pfix spac sef))
|
++ ws |*(sef=_rule ;~(pfix spac sef))
|
||||||
:: plumbing
|
:: plumbing
|
||||||
++ jify |*([t=@ta r=_rule] (cook |*([v=*] [t p=v]) r))
|
|
||||||
++ mayb |*(bus=_rule ;~(pose bus (easy "")))
|
++ mayb |*(bus=_rule ;~(pose bus (easy "")))
|
||||||
++ twel |=([a=tape b=tape] (weld a b))
|
++ twel |=([a=tape b=tape] (weld a b))
|
||||||
++ piec
|
++ piec
|
||||||
@ -2311,7 +2286,7 @@
|
|||||||
[p.one [%& [*cart (weld q.q.q.one q.q.q.two)]]]
|
[p.one [%& [*cart (weld q.q.q.one q.q.q.two)]]]
|
||||||
::
|
::
|
||||||
++ glam
|
++ glam
|
||||||
|= zar=@p ^- tape
|
|= zar=@pD ^- tape
|
||||||
%+ snag zar
|
%+ snag zar
|
||||||
^- (list tape)
|
^- (list tape)
|
||||||
:~ "Tianming" "Pepin the Short" "Haile Selassie" "Alfred the Great"
|
:~ "Tianming" "Pepin the Short" "Haile Selassie" "Alfred the Great"
|
||||||
|
Loading…
Reference in New Issue
Block a user