shrub/try/bin/pars.hoon
2014-08-11 20:12:58 -07:00

46 lines
1.3 KiB
Plaintext

!:
=> |%
++ norm
|* (pole ,_:/(*$&(_rule tape)))
?~ +< ~
=> .(+< [i=+<- t=+<+])
:_ t=$(+< t)
=+ rul=->->.i
^= i
?~ rul [%| p=rul]
?~ +.rul [%| p=rul]
?@ &2.rul [%| p=;;(tape rul)]
[%& p=rul]
++ parz
|* (list (each ,_rule tape))
?~ +< (easy ~)
?: ?=(| -.i) ;~(pfix (jest (crip p.i)) $(+< t))
%+ cook |*([* *] [i t]=+<)
;~(plug p.i $(+< t))
++ scanf
|* [tape (pole ,_:/(*$&(_rule tape)))]
=> .(+< [a b]=+<)
~! (scan "" (parz (norm ;"number {dim:ag}\-{dim:ag}")))
~! (norm ;"qwert{y/o/p/~}as{rule}d")
::=+ aaaa
%. (scan a (parz (norm b)))
|* (list)
?~ +< ~
?~ t i
[i $(+< t)]
--
|= ^
|= ~ :: [tape (pole ,_:/(*$&($+(nail edge) tape))) ~] ::$|(~ [p=gate ~])]
::=> .(+< [a=&1.+< b=&2.+<]) :: c=|2.+<])
=- ~[$/!>(res)]~
^= res
:::- (scanf a b)
:: (p.c ^+(+<.p.c (scanf a b)))
=+ n=;~(pfix (star (just '0')) (cook |=(@ud +<) dim:ag))
:- ^- @da %- year
=- `date`dat(- [%& -.dat], |6 ~[(div (mul |6.dat (bex 16)) 1.000)])
dat=(scanf "2014-08-12T02:11:57.030Z" ;"{n}\-{n}\-{n}T{n}:{n}:{n}.{n}Z")
=+ (scanf "It is 12:54, offset 2" ;"It is {n}:{n}, offset {n}")
~! -
`[p=@ q=@ r=@]`-