mirror of
https://github.com/urbit/shrub.git
synced 2025-01-08 22:18:12 +03:00
refactors +parse:der
This commit is contained in:
parent
fffff33dfc
commit
e194b15b78
@ -290,19 +290,17 @@
|
|||||||
:: +de:der: decode atom to +spec:asn1
|
:: +de:der: decode atom to +spec:asn1
|
||||||
::
|
::
|
||||||
++ de
|
++ de
|
||||||
=< |= [len=@ud dat=@ux]
|
|= [len=@ud dat=@ux]
|
||||||
^- (unit spec:asn1)
|
^- (unit spec:asn1)
|
||||||
:: XX refactor into +parse
|
:: XX refactor into +parse
|
||||||
=/ a (rip 3 dat)
|
=/ a (rip 3 dat)
|
||||||
=/ b ~| %der-invalid-len
|
=/ b ~| %der-invalid-len
|
||||||
(sub len (lent a))
|
(sub len (lent a))
|
||||||
(rust `(list @D)`(weld a (reap b 0)) parse)
|
(rust `(list @D)`(weld a (reap b 0)) parse)
|
||||||
|%
|
:: +parse:der: DER parser combinator
|
||||||
:: +parse:de:der: DER parser combinator
|
|
||||||
::
|
::
|
||||||
++ parse
|
++ parse
|
||||||
%+ cook |*(a=* `spec:asn1`a) :: XX fix
|
=< ^- $-(nail (like spec:asn1))
|
||||||
:: ^- $-(nail (like spec:asn1))
|
|
||||||
;~ pose
|
;~ pose
|
||||||
(stag %int (bass 256 (sear int ;~(pfix (tag 2) till))))
|
(stag %int (bass 256 (sear int ;~(pfix (tag 2) till))))
|
||||||
(stag %bit (^boss 256 (cook tail ;~(pfix (tag 3) till)))) :: XX test
|
(stag %bit (^boss 256 (cook tail ;~(pfix (tag 3) till)))) :: XX test
|
||||||
@ -313,11 +311,12 @@
|
|||||||
(stag %set (sear recur ;~(pfix (tag 49) till)))
|
(stag %set (sear recur ;~(pfix (tag 49) till)))
|
||||||
(stag %con ;~(plug (sear context next) till))
|
(stag %con ;~(plug (sear context next) till))
|
||||||
==
|
==
|
||||||
:: +tag:de:der: parse tag byte
|
|%
|
||||||
|
:: +tag:parse:der: parse tag byte
|
||||||
::
|
::
|
||||||
++ tag
|
++ tag
|
||||||
|=(a=@D (just a))
|
|=(a=@D (just a))
|
||||||
:: +int:de:der: sear unsigned big-endian bytes
|
:: +int:parse:der: sear unsigned big-endian bytes
|
||||||
::
|
::
|
||||||
++ int
|
++ int
|
||||||
|= a=(list @D)
|
|= a=(list @D)
|
||||||
@ -326,11 +325,11 @@
|
|||||||
?: ?=([@ ~] a) `a
|
?: ?=([@ ~] a) `a
|
||||||
?. =(0 i.a) `a
|
?. =(0 i.a) `a
|
||||||
?.((gth i.t.a 127) ~ `t.a)
|
?.((gth i.t.a 127) ~ `t.a)
|
||||||
:: +recur:de:der: parse bytes for a list of +spec:asn1
|
:: +recur:parse:der: parse bytes for a list of +spec:asn1
|
||||||
::
|
::
|
||||||
++ recur
|
++ recur
|
||||||
|=(a=(list @) (rust a (star parse)))
|
|=(a=(list @) (rust a (star parse)))
|
||||||
:: +context:de:der: decode context-specific tag byte
|
:: +context:parse:der: decode context-specific tag byte
|
||||||
::
|
::
|
||||||
++ context
|
++ context
|
||||||
|= a=@D
|
|= a=@D
|
||||||
@ -339,7 +338,7 @@
|
|||||||
:+ ~
|
:+ ~
|
||||||
=(1 (cut 0 [5 1] a))
|
=(1 (cut 0 [5 1] a))
|
||||||
(dis 0x1f a)
|
(dis 0x1f a)
|
||||||
:: +boss:de:der: shadowed to count as well
|
:: +boss:parse:der: shadowed to count as well
|
||||||
::
|
::
|
||||||
:: Use for parsing +octs more broadly?
|
:: Use for parsing +octs more broadly?
|
||||||
::
|
::
|
||||||
@ -350,7 +349,7 @@
|
|||||||
:- (lent waq)
|
:- (lent waq)
|
||||||
(reel waq |=([p=@ q=@] (add p (mul wuc q))))
|
(reel waq |=([p=@ q=@] (add p (mul wuc q))))
|
||||||
tyd
|
tyd
|
||||||
:: +till:de:der: parser combinator for len-prefixed bytes
|
:: +till:parse:der: parser combinator for len-prefixed bytes
|
||||||
::
|
::
|
||||||
:: advance until
|
:: advance until
|
||||||
::
|
::
|
||||||
|
Loading…
Reference in New Issue
Block a user