mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-11 04:48:00 +03:00
rege refactoring
This commit is contained in:
parent
afaf131c72
commit
b27098ab6c
815
arvo/hoon.hoon
815
arvo/hoon.hoon
@ -132,7 +132,7 @@
|
|||||||
$% [%lite p=char] :: literal
|
$% [%lite p=char] :: literal
|
||||||
[%pair p=rege q=rege] :: ordering
|
[%pair p=rege q=rege] :: ordering
|
||||||
[%capt p=rege q=@u] :: capture group
|
[%capt p=rege q=@u] :: capture group
|
||||||
[%brac p=@] :: p is 256 bitmask
|
[%brac p=@I] :: p is 256 bitmask
|
||||||
[%eith p=rege q=rege] :: either
|
[%eith p=rege q=rege] :: either
|
||||||
[%mant p=rege] :: greedy 0 or more
|
[%mant p=rege] :: greedy 0 or more
|
||||||
[%plls p=rege] :: greedy 1 or more
|
[%plls p=rege] :: greedy 1 or more
|
||||||
@ -3677,430 +3677,413 @@
|
|||||||
++ pars
|
++ pars
|
||||||
|= [a=tape] :: parse tape to rege
|
|= [a=tape] :: parse tape to rege
|
||||||
^- (unit rege)
|
^- (unit rege)
|
||||||
=+ foo=((full anns) [[1 1] a])
|
=+ foo=((full apex:rags) [[1 1] a])
|
||||||
?~ q.foo
|
?~ q.foo
|
||||||
~
|
~
|
||||||
[~ p.u.q.foo]
|
[~ p.u.q.foo]
|
||||||
::
|
::
|
||||||
++ nor
|
++ rags :: rege parsers
|
||||||
;~ pose
|
=> |%
|
||||||
(shim 1 35)
|
++ nor ;~(less (mask "^$()|*?+.[\\") (shim 1 127)) :: non-control char
|
||||||
(shim 37 39)
|
++ les ;~(less bas asp) :: not backslash
|
||||||
(shim 44 45)
|
++ lep ;~(less (mask "^[]\\") asp) :: charset non-control
|
||||||
(shim 47 62)
|
++ asp (shim 32 126) :: printable ascii
|
||||||
(shim 64 90)
|
++ alb ;~(less ser asp) :: charset literal char
|
||||||
(shim 93 93)
|
++ mis ;~(less aln asp) :: non alphanumeric
|
||||||
(shim 95 122)
|
--
|
||||||
(shim 123 123)
|
|%
|
||||||
(shim 125 127)
|
++ apex :: top level
|
||||||
==
|
%+ knee *rege |. ~+
|
||||||
++ les ;~(pose (shim 32 91) (shim 93 126))
|
;~ pose
|
||||||
++ lep ;~(pose (shim 32 45) (shim 46 90) (shim 95 126))
|
;~((bend |=(a=[rege rege] (some [%eith a]))) mall ;~(pfix bar apex))
|
||||||
++ alm (shim 32 126)
|
(stag %eith ;~(plug (easy %empt) ;~(pfix bar apex)))
|
||||||
++ alb ;~(pose (shim 32 92) (shim 94 126))
|
(easy %empt)
|
||||||
++ mis ;~(pose (shim 32 47) (shim 58 64) (shim 91 96) (shim 123 126))
|
==
|
||||||
::
|
::
|
||||||
++ anns :: top level rege parse
|
++ mall
|
||||||
%+ knee *rege |. ~+
|
%+ knee *rege |. ~+
|
||||||
;~ pose
|
;~((bend |=(a=[rege rege] (some [%pair a]))) bets mall)
|
||||||
;~((bend |=(a=[rege rege] (some [%eith a]))) mall ;~(pfix bar anns))
|
::
|
||||||
(stag %eith ;~(plug (easy %empt) ;~(pfix bar anns)))
|
++ bets
|
||||||
(easy %empt)
|
%+ knee *rege |. ~+
|
||||||
==
|
|
||||||
::
|
|
||||||
++ mall
|
|
||||||
%+ knee *rege |. ~+
|
|
||||||
;~((bend |=(a=[rege rege] (some [%pair a]))) bets mall)
|
|
||||||
::
|
|
||||||
++ bets
|
|
||||||
%+ knee *rege |. ~+
|
|
||||||
|= tub=nail
|
|
||||||
=+ vex=(chun tub)
|
|
||||||
?~ q.vex
|
|
||||||
vex
|
|
||||||
=+ a=p.u.q.vex
|
|
||||||
%- ;~ pose
|
|
||||||
(cold [%eith %empt a] (jest '??'))
|
|
||||||
(cold [%manl a] (jest '*?'))
|
|
||||||
(cold [%plll a] (jest '+?'))
|
|
||||||
(cold [%eith a %empt] wut)
|
|
||||||
(cold [%mant a] tar)
|
|
||||||
(cold [%plls a] lus)
|
|
||||||
(stag %betl ;~(plug (easy a) ;~(sfix rang wut)))
|
|
||||||
(stag %betw ;~(plug (easy a) rang))
|
|
||||||
(stag %binl ;~(plug (easy a) (ifix [kel (jest ',}?')] dim:ag)))
|
|
||||||
(stag %bant ;~(plug (easy a) (ifix [kel (jest '}?')] dim:ag)))
|
|
||||||
(stag %bant ;~(plug (easy a) (ifix [kel ker] dim:ag)))
|
|
||||||
(stag %bint ;~(plug (easy a) (ifix [kel (jest ',}')] dim:ag)))
|
|
||||||
(easy a)
|
|
||||||
==
|
|
||||||
q.u.q.vex
|
|
||||||
::
|
|
||||||
++ ranc
|
|
||||||
|= [a=@ b=@]
|
|
||||||
^- @
|
|
||||||
?:((gth a b) 0 (con (bex a) $(a +(a))))
|
|
||||||
::
|
|
||||||
++ flap |=(a=@ (mix a (dec (bex 256))))
|
|
||||||
::
|
|
||||||
++ rang
|
|
||||||
%+ sear |=([a=@ b=@] ?:((lte a b) (some [a b]) ~))
|
|
||||||
(ifix [kel ker] ;~(plug dim:ag ;~(pfix com dim:ag)))
|
|
||||||
::
|
|
||||||
++ chun
|
|
||||||
%+ knee *rege |. ~+
|
|
||||||
;~ pose
|
|
||||||
(cold %ende buc)
|
|
||||||
(cold %sart ket)
|
|
||||||
(cold %dote dot)
|
|
||||||
%+ cook |=(a=(list char) (reel a |=([p=char q=rege] [%pair [%lite p] q])))
|
|
||||||
;~(pfix (jest '\\Q') cape)
|
|
||||||
|= tub=nail
|
|= tub=nail
|
||||||
=+ foo=;~(plug kel dim:ag ;~(pose ker (jest ',}') ;~(plug com dim:ag ker)))
|
=+ vex=(chun tub)
|
||||||
=+ bar=(foo tub)
|
?~ q.vex
|
||||||
?~(q.bar (chad tub) (fail tub))
|
vex
|
||||||
(cook |=([a=rege] [%capt a 0]) (ifix [pel per] anns))
|
=+ a=p.u.q.vex
|
||||||
%+ cook |=([a=rege] [%capt a 0])
|
%- ;~ pose
|
||||||
(ifix [;~(plug (jest '(?P<') (plus aln) gar) per] anns)
|
(cold [%eith %empt a] (jest '??'))
|
||||||
(ifix [(jest '(?:') per] anns)
|
(cold [%manl a] (jest '*?'))
|
||||||
(stag %brac ;~(pfix sel seac))
|
(cold [%plll a] (jest '+?'))
|
||||||
==
|
(cold [%eith a %empt] wut)
|
||||||
::
|
(cold [%mant a] tar)
|
||||||
++ seac
|
(cold [%plls a] lus)
|
||||||
|= tub=nail
|
(stag %betl ;~(plug (easy a) ;~(sfix rang wut)))
|
||||||
?~ q.tub
|
(stag %betw ;~(plug (easy a) rang))
|
||||||
(fail tub)
|
(stag %binl ;~(plug (easy a) (ifix [kel (jest ',}?')] dim:ag)))
|
||||||
?: =(i.q.tub '^')
|
(stag %bant ;~(plug (easy a) (ifix [kel (jest '}?')] dim:ag)))
|
||||||
(;~(pfix ket (cook flap sead)) tub)
|
(stag %bant ;~(plug (easy a) (ifix [kel ker] dim:ag)))
|
||||||
(sead tub)
|
(stag %bint ;~(plug (easy a) (ifix [kel (jest ',}')] dim:ag)))
|
||||||
::
|
(easy a)
|
||||||
++ sead
|
==
|
||||||
%+ knee *@ |. ~+
|
q.u.q.vex
|
||||||
;~ pose
|
::
|
||||||
|
++ ranc
|
||||||
|
|= [a=@ b=@]
|
||||||
|
^- @
|
||||||
|
?:((gth a b) 0 (con (bex a) $(a +(a))))
|
||||||
|
::
|
||||||
|
++ flap |=(a=@ (mix a (dec (bex 256))))
|
||||||
|
::
|
||||||
|
++ rang
|
||||||
|
%+ sear |=([a=@ b=@] ?:((lte a b) (some [a b]) ~))
|
||||||
|
(ifix [kel ker] ;~(plug dim:ag ;~(pfix com dim:ag)))
|
||||||
|
::
|
||||||
|
++ chun
|
||||||
|
%+ knee *rege |. ~+
|
||||||
|
;~ pose
|
||||||
|
(cold %ende buc)
|
||||||
|
(cold %sart ket)
|
||||||
|
(cold %dote dot)
|
||||||
|
%+ cook |=(a=(list char) (reel a |=([p=char q=rege] [%pair [%lite p] q])))
|
||||||
|
;~(pfix (jest '\\Q') cape)
|
||||||
|
|= tub=nail
|
||||||
|
=+ foo=;~(plug kel dim:ag ;~(pose ker (jest ',}') ;~(plug com dim:ag ker)))
|
||||||
|
=+ bar=(foo tub)
|
||||||
|
?~(q.bar (chad tub) (fail tub))
|
||||||
|
(cook |=([a=rege] [%capt a 0]) (ifix [pel per] apex))
|
||||||
|
%+ cook |=([a=rege] [%capt a 0])
|
||||||
|
(ifix [;~(plug (jest '(?P<') (plus aln) gar) per] apex)
|
||||||
|
(ifix [(jest '(?:') per] apex)
|
||||||
|
(stag %brac ;~(pfix sel seac))
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ seac
|
||||||
|= tub=nail
|
|= tub=nail
|
||||||
?~ q.tub
|
?~ q.tub
|
||||||
(fail tub)
|
(fail tub)
|
||||||
?. =(i.q.tub ']')
|
?: =(i.q.tub '^')
|
||||||
(fail tub)
|
(;~(pfix ket (cook flap sead)) tub)
|
||||||
?~ t.q.tub
|
(sead tub)
|
||||||
(fail tub)
|
::
|
||||||
?: =(i.t.q.tub '-')
|
++ sead
|
||||||
?~ t.t.q.tub
|
%+ knee *@ |. ~+
|
||||||
|
;~ pose
|
||||||
|
|= tub=nail
|
||||||
|
?~ q.tub
|
||||||
(fail tub)
|
(fail tub)
|
||||||
?: =(i.t.t.q.tub ']')
|
?. =(i.q.tub ']')
|
||||||
(;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub)
|
(fail tub)
|
||||||
(fail tub)
|
?~ t.q.tub
|
||||||
(;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub)
|
(fail tub)
|
||||||
|= tub=nail
|
?: =(i.t.q.tub '-')
|
||||||
?~ q.tub
|
?~ t.t.q.tub
|
||||||
(fail tub)
|
(fail tub)
|
||||||
?. =(i.q.tub '-')
|
?: =(i.t.t.q.tub ']')
|
||||||
(fail tub)
|
(;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub)
|
||||||
?~ t.q.tub
|
(fail tub)
|
||||||
(fail tub)
|
(;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub)
|
||||||
?: =(i.t.q.tub '-')
|
|= tub=nail
|
||||||
?~ t.t.q.tub
|
?~ q.tub
|
||||||
|
(fail tub)
|
||||||
|
?. =(i.q.tub '-')
|
||||||
|
(fail tub)
|
||||||
|
?~ t.q.tub
|
||||||
|
(fail tub)
|
||||||
|
?: =(i.t.q.tub '-')
|
||||||
|
?~ t.t.q.tub
|
||||||
|
(fail tub)
|
||||||
|
?: =(i.t.t.q.tub ']')
|
||||||
|
(;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub)
|
||||||
|
(fail tub)
|
||||||
|
(;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub)
|
||||||
|
(cook |=(a=[@ @] (con a)) ;~(plug seap sade))
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ sade
|
||||||
|
%+ knee *@ |. ~+
|
||||||
|
;~ pose
|
||||||
|
(cold (bex '-') (jest '-]'))
|
||||||
|
(cold 0 ser)
|
||||||
|
(cook |=([p=@ q=@] `@`(con p q)) ;~(plug seap sade))
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ seap
|
||||||
|
%+ knee *@ |. ~+
|
||||||
|
;~ pose
|
||||||
|
unid
|
||||||
|
%+ ifix (jest '[:')^(jest ':]')
|
||||||
|
;~(pose ;~(pfix ket (cook flap chas)) chas)
|
||||||
|
%+ sear |=([a=@ b=@] ?:((gth a b) ~ (some (ranc a b))))
|
||||||
|
;~(plug asp ;~(pfix hep alb))
|
||||||
|
|= tub=nail
|
||||||
|
?~ q.tub
|
||||||
|
(fail tub)
|
||||||
|
?~ t.q.tub
|
||||||
|
((cook bex les) tub)
|
||||||
|
?: =(i.t.q.tub '-')
|
||||||
|
?~ t.t.q.tub
|
||||||
|
((cook bex les) tub)
|
||||||
|
?: =(i.t.t.q.tub ']')
|
||||||
|
((cook bex les) tub)
|
||||||
(fail tub)
|
(fail tub)
|
||||||
?: =(i.t.t.q.tub ']')
|
|
||||||
(;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub)
|
|
||||||
(fail tub)
|
|
||||||
(;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub)
|
|
||||||
(cook |=(a=[@ @] (con a)) ;~(plug seap sade))
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ sade
|
|
||||||
%+ knee *@ |. ~+
|
|
||||||
;~ pose
|
|
||||||
(cold (bex '-') (jest '-]'))
|
|
||||||
(cold 0 ser)
|
|
||||||
(cook |=([p=@ q=@] `@`(con p q)) ;~(plug seap sade))
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ seap
|
|
||||||
%+ knee *@ |. ~+
|
|
||||||
;~ pose
|
|
||||||
unid
|
|
||||||
(cold lower (jest '[:lower:]'))
|
|
||||||
(cold upper (jest '[:upper:]'))
|
|
||||||
(cold digit (jest '[:digit:]'))
|
|
||||||
(cold print (jest '[:print:]'))
|
|
||||||
(cold graph (jest '[:graph:]'))
|
|
||||||
(cold blank (jest '[:blank:]'))
|
|
||||||
(cold space (jest '[:space:]'))
|
|
||||||
(cold cntrl (jest '[:cntrl:]'))
|
|
||||||
(cold alpha (jest '[:alpha:]'))
|
|
||||||
(cold xdigit (jest '[:xdigit:]'))
|
|
||||||
(cold alnum (jest '[:alnum:]'))
|
|
||||||
(cold punct (jest '[:punct:]'))
|
|
||||||
(cold (flap lower) (jest '[:^lower:]'))
|
|
||||||
(cold (flap upper) (jest '[:^upper:]'))
|
|
||||||
(cold (flap digit) (jest '[:^digit:]'))
|
|
||||||
(cold (flap print) (jest '[:^print:]'))
|
|
||||||
(cold (flap graph) (jest '[:^graph:]'))
|
|
||||||
(cold (flap blank) (jest '[:^blank:]'))
|
|
||||||
(cold (flap space) (jest '[:^space:]'))
|
|
||||||
(cold (flap cntrl) (jest '[:^cntrl:]'))
|
|
||||||
(cold (flap alpha) (jest '[:^alpha:]'))
|
|
||||||
(cold (flap xdigit) (jest '[:^xdigit:]'))
|
|
||||||
(cold (flap alnum) (jest '[:^alnum:]'))
|
|
||||||
(cold (flap punct) (jest '[:^punct:]'))
|
|
||||||
%+ sear |=([a=@ b=@] ?:((gth a b) ~ (some (ranc a b))))
|
|
||||||
;~(plug alm ;~(pfix hep alb))
|
|
||||||
|= tub=nail
|
|
||||||
?~ q.tub
|
|
||||||
(fail tub)
|
|
||||||
?~ t.q.tub
|
|
||||||
((cook bex les) tub)
|
((cook bex les) tub)
|
||||||
?: =(i.t.q.tub '-')
|
;~(pfix bas escd)
|
||||||
?~ t.t.q.tub
|
==
|
||||||
((cook bex les) tub)
|
::
|
||||||
?: =(i.t.t.q.tub ']')
|
++ cape
|
||||||
((cook bex les) tub)
|
%+ knee *tape |. ~+
|
||||||
(fail tub)
|
;~ pose
|
||||||
((cook bex les) tub)
|
(cold ~ (jest '\\E'))
|
||||||
;~(pfix bas escd)
|
;~(plug next cape)
|
||||||
==
|
(cook |=(a=char (tape [a ~])) next)
|
||||||
|
(full (easy ~))
|
||||||
|
==
|
||||||
|
++ chas :: ascii character set
|
||||||
|
=- (sear ~(get by -) sym)
|
||||||
|
%- mo ^- (list ,[@tas @I])
|
||||||
|
:~ alnum/alnum alpha/alpha ascii/ascii blank/blank cntrl/cntrl
|
||||||
|
digit/digit graph/graph lower/lower print/print punct/punct
|
||||||
|
space/space upper/upper word/wordc xdigit/xdigit
|
||||||
|
==
|
||||||
|
:: Character sets
|
||||||
|
++ alnum :(con lower upper digit)
|
||||||
|
++ alpha :(con lower upper)
|
||||||
|
++ ascii (ranc 0 127)
|
||||||
|
++ blank (con (bex 32) (bex 9))
|
||||||
|
++ cntrl :(con (ranc 0 31) (bex 127))
|
||||||
|
++ digit (ranc '0' '9')
|
||||||
|
++ graph (ranc 33 126)
|
||||||
|
++ lower (ranc 'a' 'z')
|
||||||
|
++ print (ranc 32 126)
|
||||||
|
++ punct ;: con
|
||||||
|
(ranc '!' '/')
|
||||||
|
(ranc ':' '@')
|
||||||
|
(ranc '[' '`')
|
||||||
|
(ranc '{' '~')
|
||||||
|
==
|
||||||
|
++ space :(con (ranc 9 13) (bex ' '))
|
||||||
|
++ upper (ranc 'A' 'Z')
|
||||||
|
++ white :(con (bex ' ') (ranc 9 10) (ranc 12 13))
|
||||||
|
++ wordc :(con digit lower upper (bex '_'))
|
||||||
|
++ xdigit :(con (ranc 'a' 'f') (ranc 'A' 'F') digit)
|
||||||
|
::
|
||||||
|
++ chad
|
||||||
|
%+ knee *rege |. ~+
|
||||||
|
;~(pose (stag %lite nor) (stag %brac unid) ;~(pfix bas escp))
|
||||||
|
::
|
||||||
|
++ escd
|
||||||
|
%+ knee *@ |. ~+
|
||||||
|
;~ pose
|
||||||
|
(cold (bex 7) (just 'a'))
|
||||||
|
(cold (bex 9) (just 't'))
|
||||||
|
(cold (bex 10) (just 'n'))
|
||||||
|
(cold (bex 11) (just 'v'))
|
||||||
|
(cold (bex 12) (just 'f'))
|
||||||
|
(cold (bex 13) (just 'r'))
|
||||||
|
(cold (bex 0) (just '0'))
|
||||||
|
(sear |=(a=@ ?:((lth a 256) (some (bex a)) ~)) (bass 8 (stun [2 3] cit)))
|
||||||
|
(cook bex ;~(pfix (just 'x') (bass 16 (stun [2 2] hit))))
|
||||||
|
(cook bex (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit))))
|
||||||
|
(cook bex mis)
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ escp
|
||||||
|
%+ knee *rege |. ~+
|
||||||
|
;~ pose
|
||||||
|
(cold %empt (just 'Q'))
|
||||||
|
(cold [%lite `@tD`0] (just '0'))
|
||||||
|
(cold [%lite `@tD`7] (just 'a'))
|
||||||
|
(cold [%lite `@tD`9] (just 't'))
|
||||||
|
(cold [%lite `@tD`10] (just 'n'))
|
||||||
|
(cold [%lite `@tD`11] (just 'v'))
|
||||||
|
(cold [%lite `@tD`12] (just 'f'))
|
||||||
|
(cold [%lite `@tD`13] (just 'r'))
|
||||||
|
(sear |=(a=@ ?:((lth a 256) (some [%lite a]) ~)) (bass 8 (stun [2 3] cit)))
|
||||||
|
(stag %lite ;~(pfix (just 'x') (bass 16 (stun [2 2] hit))))
|
||||||
|
(stag %lite (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit))))
|
||||||
|
(cold %dote (just 'C'))
|
||||||
|
(cold %sart (just 'A'))
|
||||||
|
(cold %ende (just 'z'))
|
||||||
|
(cold %boun (just 'b'))
|
||||||
|
(cold %bout (just 'B'))
|
||||||
|
(stag %brac (cold wordc (just 'w')))
|
||||||
|
(stag %brac (cold (flap wordc) (just 'W')))
|
||||||
|
(stag %lite mis)
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ unid
|
||||||
|
%+ knee *@ |. ~+
|
||||||
|
;~ pose
|
||||||
|
(cold digit (jest '\\d'))
|
||||||
|
(cold (flap digit) (jest '\\D'))
|
||||||
|
(cold white (jest '\\s'))
|
||||||
|
(cold (flap white) (jest '\\S'))
|
||||||
|
(cold wordc (jest '\\w'))
|
||||||
|
(cold (flap wordc) (jest '\\W'))
|
||||||
|
==
|
||||||
|
--
|
||||||
::
|
::
|
||||||
++ cape
|
++ ra :: regex engine
|
||||||
%+ knee *tape |. ~+
|
|_ a=rege
|
||||||
;~ pose
|
++ proc :: capture numbering
|
||||||
(cold ~ (jest '\\E'))
|
|= b=@
|
||||||
;~(plug next cape)
|
=- -(+ +>.$(a a))
|
||||||
(cook |=(a=char (tape [a ~])) next)
|
^- [p=@ a=rege]
|
||||||
(full (easy ~))
|
?- a
|
||||||
==
|
[%capt *] =+ foo=$(a p.a, b +(b))
|
||||||
::
|
[p.foo [%capt a.foo b]]
|
||||||
++ lower (ranc 'a' 'z')
|
[%eith *] =+ foo=$(a p.a)
|
||||||
++ upper (ranc 'A' 'Z')
|
=+ bar=$(a q.a, b p.foo)
|
||||||
++ digit (ranc '0' '9')
|
[p.bar [%eith a.foo a.bar]]
|
||||||
++ print (ranc 32 126)
|
[%pair *] =+ foo=$(a p.a)
|
||||||
++ graph (ranc 33 126)
|
=+ bar=$(a q.a, b p.foo)
|
||||||
++ blank (con (bex 32) (bex 9))
|
[p.bar [%pair a.foo a.bar]]
|
||||||
++ space :(con (ranc 9 13) (bex ' '))
|
[%manl *] =+ foo=$(a p.a)
|
||||||
++ cntrl :(con (ranc 0 31) (bex 127))
|
[p.foo [%manl a.foo]]
|
||||||
++ alpha :(con lower upper)
|
[%plll *] =+ foo=$(a p.a)
|
||||||
++ alnum :(con lower upper digit)
|
[p.foo [%plll a.foo]]
|
||||||
++ punct ;: con
|
[%binl *] =+ foo=$(a p.a)
|
||||||
(ranc '!' '/')
|
[p.foo [%binl a.foo q.a]]
|
||||||
(ranc ':' '@')
|
[%betl *] =+ foo=$(a p.a)
|
||||||
(ranc '[' '`')
|
[p.foo [%betl a.foo q.a r.a]]
|
||||||
(ranc '{' '~')
|
[%mant *] =+ foo=$(a p.a)
|
||||||
==
|
[p.foo [%mant a.foo]]
|
||||||
++ wordc :(con digit lower upper (bex 95))
|
[%plls *] =+ foo=$(a p.a)
|
||||||
++ white :(con (bex ' ') (ranc 9 10) (ranc 12 13))
|
[p.foo [%plls a.foo]]
|
||||||
++ xdigit :(con (ranc 'a' 'f') (ranc 'A' 'F') digit)
|
[%bant *] =+ foo=$(a p.a)
|
||||||
::
|
[p.foo [%bant a.foo q.a]]
|
||||||
++ chad
|
[%bint *] =+ foo=$(a p.a)
|
||||||
%+ knee *rege |. ~+
|
[p.foo [%bint a.foo q.a]]
|
||||||
;~(pose (stag %lite nor) (stag %brac unid) ;~(pfix bas escp))
|
[%betw *] =+ foo=$(a p.a)
|
||||||
::
|
[p.foo [%betw a.foo q.a r.a]]
|
||||||
++ escd
|
* [b a]
|
||||||
%+ knee *@ |. ~+
|
==
|
||||||
;~ pose
|
::
|
||||||
(cold (bex 7) (just 'a'))
|
++ cont
|
||||||
(cold (bex 9) (just 't'))
|
|= [a=(map ,@u tape) b=(map ,@u tape)]
|
||||||
(cold (bex 10) (just 'n'))
|
(~(gas by _(map ,@u tape)) (weld (~(tap by a)) (~(tap by b))))
|
||||||
(cold (bex 11) (just 'v'))
|
::
|
||||||
(cold (bex 12) (just 'f'))
|
++ abor
|
||||||
(cold (bex 13) (just 'r'))
|
|= [a=char b=(unit ,[tape (map ,@u tape)])]
|
||||||
(cold (bex 0) (just '0'))
|
^- (unit ,[tape (map ,@u tape)])
|
||||||
(sear |=(a=@ ?:((lth a 256) (some (bex a)) ~)) (bass 8 (stun [2 3] cit)))
|
?~ b
|
||||||
(cook bex ;~(pfix (just 'x') (bass 16 (stun [2 2] hit))))
|
b
|
||||||
(cook bex (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit))))
|
[~ [[a -.u.b] +.u.b]]
|
||||||
(cook bex mis)
|
::
|
||||||
==
|
++ matc
|
||||||
::
|
|= [b=tape c=tape]
|
||||||
++ escp
|
^- (unit (map ,@u tape))
|
||||||
%+ knee *rege |. ~+
|
=+ foo=`(unit ,[tape (map ,@u tape)])`(deep b %empt c)
|
||||||
;~ pose
|
(bind foo |*(a=^ (~(put by +.a) 0 -.a)))
|
||||||
(cold %empt (just 'Q'))
|
::
|
||||||
(cold [%lite `@tD`0] (just '0'))
|
++ chet
|
||||||
(cold [%lite `@tD`7] (just 'a'))
|
|= [b=(unit ,[tape (map ,@u tape)]) c=tape d=tape]
|
||||||
(cold [%lite `@tD`9] (just 't'))
|
^- (unit ,[tape (map ,@u tape)])
|
||||||
(cold [%lite `@tD`10] (just 'n'))
|
?~ b
|
||||||
(cold [%lite `@tD`11] (just 'v'))
|
b
|
||||||
(cold [%lite `@tD`12] (just 'f'))
|
?~ -.u.b
|
||||||
(cold [%lite `@tD`13] (just 'r'))
|
b
|
||||||
(sear |=(a=@ ?:((lth a 256) (some [%lite a]) ~)) (bass 8 (stun [2 3] cit)))
|
=+ bar=(deep (slag (lent -.u.b) c) %empt d)
|
||||||
(stag %lite ;~(pfix (just 'x') (bass 16 (stun [2 2] hit))))
|
?~ bar
|
||||||
(stag %lite (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit))))
|
bar
|
||||||
(cold %dote (just 'C'))
|
|
||||||
(cold %sart (just 'A'))
|
|
||||||
(cold %ende (just 'z'))
|
|
||||||
(cold %boun (just 'b'))
|
|
||||||
(cold %bout (just 'B'))
|
|
||||||
(stag %brac (cold wordc (just 'w')))
|
|
||||||
(stag %brac (cold (flap wordc) (just 'W')))
|
|
||||||
(stag %lite mis)
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ unid
|
|
||||||
%+ knee *@ |. ~+
|
|
||||||
;~ pose
|
|
||||||
(cold digit (jest '\\d'))
|
|
||||||
(cold (flap digit) (jest '\\D'))
|
|
||||||
(cold white (jest '\\s'))
|
|
||||||
(cold (flap white) (jest '\\S'))
|
|
||||||
(cold wordc (jest '\\w'))
|
|
||||||
(cold (flap wordc) (jest '\\W'))
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ proc :: capture numbering
|
|
||||||
|= [a=rege b=@]
|
|
||||||
^- [@ rege]
|
|
||||||
?- a
|
|
||||||
[%capt *] =+ foo=$(a p.a, b +(b))
|
|
||||||
[-.foo [%capt +.foo b]]
|
|
||||||
[%eith *] =+ foo=$(a p.a)
|
|
||||||
=+ bar=$(a q.a, b -.foo)
|
|
||||||
[-.bar [%eith +.foo +.bar]]
|
|
||||||
[%pair *] =+ foo=$(a p.a)
|
|
||||||
=+ bar=$(a q.a, b -.foo)
|
|
||||||
[-.bar [%pair +.foo +.bar]]
|
|
||||||
[%manl *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%manl +.foo]]
|
|
||||||
[%plll *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%plll +.foo]]
|
|
||||||
[%binl *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%binl +.foo q.a]]
|
|
||||||
[%betl *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%betl +.foo q.a r.a]]
|
|
||||||
[%mant *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%mant +.foo]]
|
|
||||||
[%plls *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%plls +.foo]]
|
|
||||||
[%bant *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%bant +.foo q.a]]
|
|
||||||
[%bint *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%bint +.foo q.a]]
|
|
||||||
[%betw *] =+ foo=$(a p.a)
|
|
||||||
[-.foo [%betw +.foo q.a r.a]]
|
|
||||||
* [b a]
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ cont
|
|
||||||
|= [a=(map ,@u tape) b=(map ,@u tape)]
|
|
||||||
(~(gas by _(map ,@u tape)) (weld (~(tap by a)) (~(tap by b))))
|
|
||||||
::
|
|
||||||
++ abor
|
|
||||||
|= [a=char b=(unit ,[tape (map ,@u tape)])]
|
|
||||||
^- (unit ,[tape (map ,@u tape)])
|
|
||||||
?~ b
|
|
||||||
b
|
b
|
||||||
[~ [[a -.u.b] +.u.b]]
|
++ blak (some ["" _(map ,@u tape)])
|
||||||
::
|
++ word |=(a=char =((dis wordc:rags (bex a)) 0))
|
||||||
++ matc
|
++ deep
|
||||||
|= [a=rege b=tape c=tape]
|
|= [b=tape c=rege d=tape]
|
||||||
^- (unit (map ,@u tape))
|
^- (unit ,[tape (map ,@u tape)])
|
||||||
=+ foo=`(unit ,[tape (map ,@u tape)])`(deep a b %empt c)
|
?- a
|
||||||
(bind foo |*(a=^ (~(put by +.a) 0 -.a)))
|
%dote ?~(b ~ (some [[i.b ~] _(map ,@u tape)]))
|
||||||
::
|
%ende ?~(b blak ~)
|
||||||
++ chet
|
%sart ?:(=(b d) blak ~)
|
||||||
|= [a=(unit ,[tape (map ,@u tape)]) b=rege c=tape d=tape]
|
%empt blak
|
||||||
^- (unit ,[tape (map ,@u tape)])
|
%boun =+ ^= luc
|
||||||
?~ a
|
?: =(b d)
|
||||||
a
|
&
|
||||||
=+ ft=u.a
|
=+ foo=(slag (dec (sub (lent d) (lent b))) d)
|
||||||
?~ -.ft
|
(word -.foo)
|
||||||
a
|
=+ cuc=?~(b & (word -.b))
|
||||||
=+ bar=(deep b (slag (lent -.ft) c) %empt d)
|
?:(!=(luc cuc) blak ~)
|
||||||
?~ bar
|
%bout =+ ^= luc
|
||||||
bar
|
?: =(b d)
|
||||||
a
|
&
|
||||||
++ blak (some ["" _(map ,@u tape)])
|
=+ foo=(slag (dec (sub (lent d) (lent b))) d)
|
||||||
++ deep
|
(word -.foo)
|
||||||
|= [a=rege b=tape c=rege d=tape]
|
=+ cuc=?~(b & (word -.b))
|
||||||
^- (unit ,[tape (map ,@u tape)])
|
?:(=(luc cuc) blak ~)
|
||||||
?- a
|
[%capt *] =+ foo=$(a p.a)
|
||||||
%dote ?~(b ~ (some [[i.b ~] _(map ,@u tape)]))
|
?~ foo
|
||||||
%ende ?~(b blak ~)
|
foo
|
||||||
%sart ?:(=(b d) blak ~)
|
=+ ft=u.foo
|
||||||
%empt blak
|
=+ bar=$(a c, b (slag (lent -.ft) b), c %empt)
|
||||||
%boun =+ ^= luc
|
?~ bar
|
||||||
?: =(b d)
|
bar
|
||||||
&
|
[~ [-.ft (~(put by +.ft) q.a -.ft)]]
|
||||||
=+ foo=(slag (dec (sub (lent d) (lent b))) d)
|
[%lite *] ?~(b ~ ?:(=(i.b p.a) (some [[i.b ~] _(map ,@u tape)]) ~))
|
||||||
=((dis wordc (bex -.foo)) 0)
|
[%brac *] ?~ b
|
||||||
=+ cuc=?~(b & =((dis wordc (bex -.b)) 0))
|
~
|
||||||
?:(!=(luc cuc) blak ~)
|
?. =((dis (bex `@`i.b) p.a) 0)
|
||||||
%bout =+ ^= luc
|
(some [[i.b ~] _(map ,@u tape)])
|
||||||
?: =(b d)
|
|
||||||
&
|
|
||||||
=+ foo=(slag (dec (sub (lent d) (lent b))) d)
|
|
||||||
=((dis wordc (bex -.foo)) 0)
|
|
||||||
=+ cuc=?~(b & =((dis wordc (bex -.b)) 0))
|
|
||||||
?:(=(luc cuc) blak ~)
|
|
||||||
[%capt *] =+ foo=$(a p.a)
|
|
||||||
?~ foo
|
|
||||||
foo
|
|
||||||
=+ ft=u.foo
|
|
||||||
=+ bar=$(a c, b (slag (lent -.ft) b), c %empt)
|
|
||||||
?~ bar
|
|
||||||
bar
|
|
||||||
[~ [-.ft (~(put by +.ft) q.a -.ft)]]
|
|
||||||
[%lite *] ?~(b ~ ?:(=(i.b p.a) (some [[i.b ~] _(map ,@u tape)]) ~))
|
|
||||||
[%brac *] ?~ b
|
|
||||||
~
|
~
|
||||||
?. =((dis (bex `@`i.b) p.a) 0)
|
[%eith *] =+ foo=(chet(a c) $(a p.a) b d)
|
||||||
(some [[i.b ~] _(map ,@u tape)])
|
=+ bar=(chet(a c) $(a q.a) b d)
|
||||||
~
|
?~ foo
|
||||||
[%eith *] =+ foo=(chet $(a p.a) c b d)
|
bar
|
||||||
=+ bar=(chet $(a q.a) c b d)
|
?~ bar
|
||||||
?~ foo
|
foo
|
||||||
|
=+ ft=u.foo
|
||||||
|
=+ bt=u.bar
|
||||||
|
?: (gte (lent -.ft) (lent -.bt))
|
||||||
|
foo
|
||||||
bar
|
bar
|
||||||
?~ bar
|
[%pair *] =+ foo=$(a p.a, c [%pair q.a c])
|
||||||
foo
|
?~ foo
|
||||||
=+ ft=u.foo
|
foo
|
||||||
=+ bt=u.bar
|
=+ ft=u.foo
|
||||||
?: (gte (lent -.ft) (lent -.bt))
|
=+ bar=$(a q.a, b (slag (lent -.ft) b))
|
||||||
foo
|
?~ bar
|
||||||
bar
|
bar
|
||||||
[%pair *] =+ foo=$(a p.a, c [%pair q.a c])
|
=+ bt=u.bar
|
||||||
?~ foo
|
[~ [(weld -.ft -.bt) (cont +.ft +.bt)]]
|
||||||
foo
|
[%manl *] =+ foo=$(a p.a)
|
||||||
=+ ft=u.foo
|
?~ foo
|
||||||
=+ bar=$(a q.a, b (slag (lent -.ft) b))
|
blak
|
||||||
?~ bar
|
?~ -.u.foo
|
||||||
bar
|
blak
|
||||||
=+ bt=u.bar
|
$(a [%eith %empt [%pair p.a [%eith %empt a]]])
|
||||||
[~ [(weld -.ft -.bt) (cont +.ft +.bt)]]
|
[%mant *] =+ foo=$(a p.a)
|
||||||
[%manl *] =+ foo=$(a p.a)
|
?~ foo
|
||||||
?~ foo
|
blak
|
||||||
blak
|
=+ ft=u.foo
|
||||||
?~ -.u.foo
|
?~ -.ft
|
||||||
blak
|
blak
|
||||||
$(a [%eith %empt [%pair p.a [%eith %empt a]]])
|
$(a [%eith [%pair p.a [%eith a %empt]] %empt])
|
||||||
[%mant *] =+ foo=$(a p.a)
|
[%plls *] $(a [%pair p.a [%mant p.a]])
|
||||||
?~ foo
|
[%plll *] $(a [%pair p.a [%manl p.a]])
|
||||||
blak
|
[%binl *] =+ min=?:(=(q.a 0) 0 (dec q.a))
|
||||||
=+ ft=u.foo
|
?: =(q.a 0)
|
||||||
?~ -.ft
|
$(a [%manl p.a])
|
||||||
blak
|
$(a [%pair p.a [%binl p.a min]])
|
||||||
$(a [%eith [%pair p.a [%eith a %empt]] %empt])
|
[%bant *] ?: =(0 q.a)
|
||||||
[%plls *] $(a [%pair p.a [%mant p.a]])
|
blak
|
||||||
[%plll *] $(a [%pair p.a [%manl p.a]])
|
$(a [%pair p.a [%bant p.a (dec q.a)]])
|
||||||
[%binl *] =+ min=?:(=(q.a 0) 0 (dec q.a))
|
[%bint *] =+ min=?:(=(q.a 0) 0 (dec q.a))
|
||||||
?: =(q.a 0)
|
?: =(q.a 0)
|
||||||
$(a [%manl p.a])
|
$(a [%mant p.a])
|
||||||
$(a [%pair p.a [%binl p.a min]])
|
$(a [%pair p.a [%bint p.a min]])
|
||||||
[%bant *] ?: =(0 q.a)
|
[%betw *] ?: =(0 r.a)
|
||||||
blak
|
blak
|
||||||
$(a [%pair p.a [%bant p.a (dec q.a)]])
|
?: =(q.a 0)
|
||||||
[%bint *] =+ min=?:(=(q.a 0) 0 (dec q.a))
|
$(a [%eith [%pair p.a [%betw p.a 0 (dec r.a)]] %empt])
|
||||||
?: =(q.a 0)
|
$(a [%pair p.a [%betw p.a (dec q.a) (dec r.a)]])
|
||||||
$(a [%mant p.a])
|
[%betl *] ?: =(0 r.a)
|
||||||
$(a [%pair p.a [%bint p.a min]])
|
blak
|
||||||
[%betw *] ?: =(0 r.a)
|
?: =(q.a 0)
|
||||||
blak
|
$(a [%eith %empt [%pair p.a [%betl p.a 0 (dec r.a)]]])
|
||||||
?: =(q.a 0)
|
$(a [%pair p.a [%betl p.a (dec q.a) (dec r.a)]])
|
||||||
$(a [%eith [%pair p.a [%betw p.a 0 (dec r.a)]] %empt])
|
==
|
||||||
$(a [%pair p.a [%betw p.a (dec q.a) (dec r.a)]])
|
--
|
||||||
[%betl *] ?: =(0 r.a)
|
|
||||||
blak
|
|
||||||
?: =(q.a 0)
|
|
||||||
$(a [%eith %empt [%pair p.a [%betl p.a 0 (dec r.a)]]])
|
|
||||||
$(a [%pair p.a [%betl p.a (dec q.a) (dec r.a)]])
|
|
||||||
==
|
|
||||||
::
|
::
|
||||||
++ rexp :: Regex match
|
++ rexp :: Regex match
|
||||||
~/ %rexp
|
~/ %rexp
|
||||||
@ -4116,15 +4099,15 @@
|
|||||||
$(a (dec a))
|
$(a (dec a))
|
||||||
=+ par=(pars a)
|
=+ par=(pars a)
|
||||||
?~ par ~
|
?~ par ~
|
||||||
=+ poc=(proc u.par 1)
|
=+ poc=(~(proc ra u.par) 1)
|
||||||
=+ c=b
|
=+ c=b
|
||||||
|-
|
|-
|
||||||
=+ foo=(matc +.poc c b)
|
=+ foo=(matc:poc c b)
|
||||||
?~ foo
|
?~ foo
|
||||||
?~ c
|
?~ c
|
||||||
[~ ~]
|
[~ ~]
|
||||||
$(c t.c)
|
$(c t.c)
|
||||||
[~ [~ (bar (dec -.poc) u.foo)]]
|
[~ [~ (bar (dec p.poc) u.foo)]]
|
||||||
::
|
::
|
||||||
++ repg :: Global regex replace
|
++ repg :: Global regex replace
|
||||||
~/ %repg
|
~/ %repg
|
||||||
@ -4132,12 +4115,12 @@
|
|||||||
^- (unit tape)
|
^- (unit tape)
|
||||||
=+ par=(pars a)
|
=+ par=(pars a)
|
||||||
?~ par ~
|
?~ par ~
|
||||||
=+ poc=(proc u.par 1)
|
=+ poc=(~(proc ra u.par) 1)
|
||||||
=+ d=b
|
=+ d=b
|
||||||
:- ~
|
:- ~
|
||||||
|-
|
|-
|
||||||
^- tape
|
^- tape
|
||||||
=+ foo=(matc +.poc d b)
|
=+ foo=(matc:poc d b)
|
||||||
?~ foo
|
?~ foo
|
||||||
?~ d
|
?~ d
|
||||||
~
|
~
|
||||||
@ -9603,7 +9586,7 @@
|
|||||||
++ sled $+ [(unit (set monk)) term beam] :: namespace function
|
++ sled $+ [(unit (set monk)) term beam] :: namespace function
|
||||||
(unit (unit cage)) ::
|
(unit (unit cage)) ::
|
||||||
++ slut $+(* (unit (unit))) :: old namespace
|
++ slut $+(* (unit (unit))) :: old namespace
|
||||||
++ vile :: reflexive constants
|
++ vile :: reflexive constants
|
||||||
$: typ=type :: -:!>(*type)
|
$: typ=type :: -:!>(*type)
|
||||||
duc=type :: -:!>(*duct)
|
duc=type :: -:!>(*duct)
|
||||||
pah=type :: -:!>(*path)
|
pah=type :: -:!>(*path)
|
||||||
|
Loading…
Reference in New Issue
Block a user