added some comments

This commit is contained in:
johncburnham 2014-05-31 18:41:27 -07:00
parent 130f653433
commit e080ee108d

View File

@ -1772,19 +1772,19 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eB, parsing (tracing) :: :: section 2eB, parsing (tracing) ::
:: ::
++ last |= [zyc=hair naz=hair] ++ last |= [zyc=hair naz=hair] :: farther trace
^- hair ^- hair
?: =(p.zyc p.naz) ?: =(p.zyc p.naz)
?:((gth q.zyc q.naz) zyc naz) ?:((gth q.zyc q.naz) zyc naz)
?:((gth p.zyc p.naz) zyc naz) ?:((gth p.zyc p.naz) zyc naz)
:: ::
++ lust |= [weq=char naz=hair] ++ lust |= [weq=char naz=hair] :: detect newline
^- hair ^- hair
?:(=(10 weq) [+(p.naz) 1] [p.naz +(q.naz)]) ?:(=(10 weq) [+(p.naz) 1] [p.naz +(q.naz)])
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eC, parsing (custom rules) :: :: section 2eC, parsing (custom rules) ::
:: ::
++ cold ++ cold :: replace w/ constant
~/ %cold ~/ %cold
|* [cus=* sef=_rule] |* [cus=* sef=_rule]
~/ %fun ~/ %fun
@ -1794,7 +1794,7 @@
vex vex
[p=p.vex q=[~ u=[p=cus q=q.u.q.vex]]] [p=p.vex q=[~ u=[p=cus q=q.u.q.vex]]]
:: ::
++ cook ++ cook :: apply gate
~/ %cook ~/ %cook
|* [poq=_,* sef=_rule] |* [poq=_,* sef=_rule]
~/ %fun ~/ %fun
@ -1804,7 +1804,7 @@
vex vex
[p=p.vex q=[~ u=[p=(poq p.u.q.vex) q=q.u.q.vex]]] [p=p.vex q=[~ u=[p=(poq p.u.q.vex) q=q.u.q.vex]]]
:: ::
++ easy ++ easy :: always parse
~/ %easy ~/ %easy
|* huf=* |* huf=*
~/ %fun ~/ %fun
@ -1812,19 +1812,19 @@
^- (like ,_huf) ^- (like ,_huf)
[p=p.tub q=[~ u=[p=huf q=tub]]] [p=p.tub q=[~ u=[p=huf q=tub]]]
:: ::
++ fail |=(tub=nail [p=p.tub q=~]) ++ fail |=(tub=nail [p=p.tub q=~]) :: never parse
++ full ++ full :: has to fully parse
|* sef=_rule |* sef=_rule
|= tub=nail |= tub=nail
=+ vex=(sef tub) =+ vex=(sef tub)
?@(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~])) ?@(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~]))
:: ::
++ funk ++ funk :: add to tape first
|* [pre=tape sef=_rule] |* [pre=tape sef=_rule]
|= tub=nail |= tub=nail
(sef p.tub (weld pre q.tub)) (sef p.tub (weld pre q.tub))
:: ::
++ here ++ here :: place-based apply
~/ %here ~/ %here
|* [hez=_|=([a=pint b=*] [a b]) sef=_rule] |* [hez=_|=([a=pint b=*] [a b]) sef=_rule]
~/ %fun ~/ %fun
@ -1834,7 +1834,7 @@
vex vex
[p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]] [p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]]
:: ::
++ jest ++ jest :: match a cord
|= daf=@t |= daf=@t
|= tub=nail |= tub=nail
=+ fad=daf =+ fad=daf
@ -1846,7 +1846,7 @@
$(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 1 daf)) $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 1 daf))
:: ::
++ just :: XX redundant, jest ++ just :: XX redundant, jest
~/ %just ~/ %just :: match a char
|= daf=char |= daf=char
~/ %fun ~/ %fun
|= tub=nail |= tub=nail
@ -1857,13 +1857,13 @@
(fail tub) (fail tub)
(next tub) (next tub)
:: ::
++ knee ++ knee :: callbacks
|* [gar=* sef=_|.(rule)] |* [gar=* sef=_|.(rule)]
|= tub=nail |= tub=nail
^- (like ,_gar) ^- (like ,_gar)
((sef) tub) ((sef) tub)
:: ::
++ mask ++ mask :: match char in set
~/ %mask ~/ %mask
|= bud=(list char) |= bud=(list char)
~/ %fun ~/ %fun
@ -1875,7 +1875,7 @@
(fail tub) (fail tub)
(next tub) (next tub)
:: ::
++ next ++ next :: consume a char
|= tub=nail |= tub=nail
^- (like char) ^- (like char)
?@ q.tub ?@ q.tub
@ -1883,7 +1883,7 @@
=+ zac=(lust i.q.tub p.tub) =+ zac=(lust i.q.tub p.tub)
[zac [~ i.q.tub [zac t.q.tub]]] [zac [~ i.q.tub [zac t.q.tub]]]
:: ::
++ sear ++ sear :: conditional cook
~/ %sear ~/ %sear
|* [pyq=_|=(* *(unit)) sef=_rule] |* [pyq=_|=(* *(unit)) sef=_rule]
~/ %fun ~/ %fun
@ -1896,7 +1896,7 @@
[p=p.vex q=~] [p=p.vex q=~]
[p=p.vex q=[~ u=[p=u.gey q=q.u.q.vex]]] [p=p.vex q=[~ u=[p=u.gey q=q.u.q.vex]]]
:: ::
++ shim ++ shim :: match char in range
~/ %shim ~/ %shim
|= [les=@ mos=@] |= [les=@ mos=@]
~/ %fun ~/ %fun
@ -1908,7 +1908,7 @@
(fail tub) (fail tub)
(next tub) (next tub)
:: ::
++ stag ++ stag :: add a label
~/ %stag ~/ %stag
|* [gob=* sef=_rule] |* [gob=* sef=_rule]
~/ %fun ~/ %fun
@ -1982,7 +1982,7 @@
?> ?=(^ q.wag) ?> ?=(^ q.wag)
[(last p.vex p.wag) [~ (raq p.u.q.vex p.u.q.wag) q.u.q.wag]] [(last p.vex p.wag) [~ (raq p.u.q.vex p.u.q.wag) q.u.q.wag]]
:: ::
++ stun ++ stun :: parse several times
~/ %stun ~/ %stun
|* [[les=@ mos=@] fel=_rule] |* [[les=@ mos=@] fel=_rule]
~/ %fun ~/ %fun
@ -2006,7 +2006,7 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eD, parsing (combinators) :: :: section 2eD, parsing (combinators) ::
:: ::
++ bend ++ bend :: conditional comp
~/ %bend ~/ %bend
|* raq=_|*([a=* b=*] [~ u=[a b]]) |* raq=_|*([a=* b=*] [~ u=[a b]])
~/ %fun ~/ %fun
@ -2024,7 +2024,7 @@
:: ::
++ comp ++ comp
~/ %comp ~/ %comp
|* raq=_|*([a=* b=*] [a b]) |* raq=_|*([a=* b=*] [a b]) :: arbitrary compose
~/ %fun ~/ %fun
|* [vex=edge sab=_rule] |* [vex=edge sab=_rule]
?@ q.vex ?@ q.vex
@ -2035,18 +2035,18 @@
[p=yur q=q.yit] [p=yur q=q.yit]
[p=yur q=[~ u=[p=(raq p.u.q.vex p.u.q.yit) q=q.u.q.yit]]] [p=yur q=[~ u=[p=(raq p.u.q.vex p.u.q.yit) q=q.u.q.yit]]]
:: ::
++ glue ++ glue :: add rule
~/ %glue ~/ %glue
|* bus=_rule |* bus=_rule
~/ %fun ~/ %fun
|* [vex=edge sab=_rule] |* [vex=edge sab=_rule]
(plug vex ;~(pfix bus sab)) (plug vex ;~(pfix bus sab))
:: ::
++ pfix ++ pfix :: discard first rule
~/ %pfix ~/ %pfix
(comp |*([a=* b=*] b)) (comp |*([a=* b=*] b))
:: ::
++ plug ++ plug :: first then second
~/ %plug ~/ %plug
|* [vex=edge sab=_rule] |* [vex=edge sab=_rule]
?@ q.vex ?@ q.vex
@ -2057,7 +2057,7 @@
[p=yur q=q.yit] [p=yur q=q.yit]
[p=yur q=[~ u=[p=[p.u.q.vex p.u.q.yit] q=q.u.q.yit]]] [p=yur q=[~ u=[p=[p.u.q.vex p.u.q.yit] q=q.u.q.yit]]]
:: ::
++ pose ++ pose :: first or second
~/ %pose ~/ %pose
|* [vex=edge sab=_rule] |* [vex=edge sab=_rule]
?@ q.vex ?@ q.vex
@ -2065,7 +2065,7 @@
[p=(last p.vex p.roq) q=q.roq] [p=(last p.vex p.roq) q=q.roq]
vex vex
:: ::
++ sfix ++ sfix :: discard second rule
~/ %sfix ~/ %sfix
(comp |*([a=* b=*] a)) (comp |*([a=* b=*] a))
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ -2107,7 +2107,7 @@
|* [bus=_rule fel=_rule] |* [bus=_rule fel=_rule]
;~((comp raq) fel (stir rud raq ;~(pfix bus fel))) ;~((comp raq) fel (stir rud raq ;~(pfix bus fel)))
:: ::
++ star ++ star :: 0 or more times
|* fel=_rule |* fel=_rule
(stir `(list ,_(wonk *fel))`~ |*([a=* b=*] [a b]) fel) (stir `(list ,_(wonk *fel))`~ |*([a=* b=*] [a b]) fel)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ -2149,16 +2149,19 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eG, parsing (whitespace) :: :: section 2eG, parsing (whitespace) ::
:: ::
++ dog ;~(plug dot gay) ++ dog ;~(plug dot gay) ::
++ doh ;~(plug ;~(plug hep hep) gay) ++ doh ;~(plug ;~(plug hep hep) gay) ::
++ dun (cold ~ ;~(plug hep hep)) ++ dun (cold ~ ;~(plug hep hep)) :: -- (phep) to ~
++ duq (cold ~ ;~(plug tis hep)) ++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~
++ duz (cold ~ ;~(plug tis tis)) ++ gah (mask [`@`10 ' ' ~]) :: newline or ace
++ gah (mask [`@`10 ' ' ~]) ++ gap (cold ~ ;~(plug gaq (star ;~(pose vul gah)))) ::
++ gap (cold ~ ;~(plug gaq (star ;~(pose vul gah)))) ++ gaq ;~ pose :: end of line
++ gaq ;~(pose (just `@`10) ;~(plug gah ;~(pose gah vul)) vul) (just `@`10)
++ gay ;~(pose gap (easy ~)) ;~(plug gah ;~(pose gah vul))
++ vul %- cold :- ~ vul
==
++ gay ;~(pose gap (easy ~)) ::
++ vul %- cold :- ~ :: comments
;~ plug col col ;~ plug col col
(star ;~(pose (shim 32 126) (shim 128 255))) (star ;~(pose (shim 32 126) (shim 128 255)))
(just `@`10) (just `@`10)
@ -2166,31 +2169,39 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eH, parsing (idioms) :: :: section 2eH, parsing (idioms) ::
:: ::
++ alf ;~(pose low hig) ++ alf ;~(pose low hig) :: alphabetic
++ aln ;~(pose low hig nud) ++ aln ;~(pose low hig nud) :: alphanumeric
++ alp ;~(pose low hig nud hep) ++ alp ;~(pose low hig nud hep) :: alphanumeric and -
++ bet ;~(pose (cold 2 hep) (cold 3 lus)) ++ bet ;~(pose (cold 2 hep) (cold 3 lus)) :: axis syntax - +
++ bin (bass 2 (most gon but)) ++ bin (bass 2 (most gon but)) :: binary to atom
++ but (cook |=(a=@ (sub a '0')) (shim '0' '1')) ++ but (cook |=(a=@ (sub a '0')) (shim '0' '1')) :: binary digit
++ cit (cook |=(a=@ (sub a '0')) (shim '0' '7')) ++ cit (cook |=(a=@ (sub a '0')) (shim '0' '7')) :: octal digit
++ dem (bass 10 (most gon dit)) ++ dem (bass 10 (most gon dit)) :: decimal to atom
++ dit (cook |=(a=@ (sub a '0')) (shim '0' '9')) ++ dit (cook |=(a=@ (sub a '0')) (shim '0' '9')) :: decimal digit
++ gul ;~(pose (cold 2 gal) (cold 3 gar)) ++ gul ;~(pose (cold 2 gal) (cold 3 gar)) :: axis syntax < >
++ gon ;~(pose ;~(plug bas gay fas) (easy ~)) ++ gon ;~(pose ;~(plug bas gay fas) (easy ~)) :: long numbers \ /
++ hex (bass 16 (most gon hit)) ++ hex (bass 16 (most gon hit)) :: hex to atom
++ hig (shim 'A' 'Z') ++ hig (shim 'A' 'Z') :: uppercase
++ hit ;~ pose ++ hit ;~ pose :: hex digits
dit dit
(cook |=(a=char (sub a 87)) (shim 'a' 'f')) (cook |=(a=char (sub a 87)) (shim 'a' 'f'))
(cook |=(a=char (sub a 55)) (shim 'A' 'F')) (cook |=(a=char (sub a 55)) (shim 'A' 'F'))
== ==
++ low (shim 'a' 'z') ++ low (shim 'a' 'z') :: lowercase
++ mes (cook |=([a=@ b=@] (add (mul 16 a) b)) ;~(plug hit hit)) ++ mes %+ cook :: hexbyte
++ nix (boss 256 (star ;~(pose aln cab))) |=([a=@ b=@] (add (mul 16 a) b))
++ nud (shim '0' '9') ;~(plug hit hit)
++ poy ;~(pfix bas ;~(pose bas soq mes)) ++ nix (boss 256 (star ;~(pose aln cab))) ::
++ qit ;~(pose (shim 32 38) (shim 40 91) (shim 93 126) (shim 128 255) poy) ++ nud (shim '0' '9') :: numeric
++ qut (ifix [soq soq] (boss 256 (more gon qit))) ++ poy ;~(pfix bas ;~(pose bas soq mes)) :: escape chars
++ qit ;~ pose :: chars in a cord
(shim 32 38)
(shim 40 91)
(shim 93 126)
(shim 128 255)
poy
==
++ qut (ifix [soq soq] (boss 256 (more gon qit))) :: cord
++ sym ++ sym
%+ cook %+ cook
|=(a=tape (rap 3 ^-((list ,@) a))) |=(a=tape (rap 3 ^-((list ,@) a)))
@ -2208,7 +2219,7 @@
?> ?=(^ q.wag) ?> ?=(^ q.wag)
[p.wag [~ (peg p.u.q.vex p.u.q.wag) q.u.q.wag]] [p.wag [~ (peg p.u.q.vex p.u.q.wag) q.u.q.wag]]
== ==
++ vit ++ vit :: base64 digit
;~ pose ;~ pose
(cook |=(a=@ (sub a 65)) (shim 'A' 'Z')) (cook |=(a=@ (sub a 65)) (shim 'A' 'Z'))
(cook |=(a=@ (sub a 71)) (shim 'a' 'z')) (cook |=(a=@ (sub a 71)) (shim 'a' 'z'))
@ -2219,7 +2230,7 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2eI, parsing (external) :: :: section 2eI, parsing (external) ::
:: ::
++ rash |*([naf=@ sab=_rule] (scan (trip naf) sab)) ++ rash |*([naf=@ sab=_rule] (scan (trip naf) sab)) ::
++ rush |*([naf=@ sab=_rule] (rust (trip naf) sab)) ++ rush |*([naf=@ sab=_rule] (rust (trip naf) sab))
++ rust |* [los=tape sab=_rule] ++ rust |* [los=tape sab=_rule]
=+ vex=((full sab) [[1 1] los]) =+ vex=((full sab) [[1 1] los])
@ -8523,7 +8534,6 @@
++ gunk ~+((glue muck)) ++ gunk ~+((glue muck))
++ butt |*(zor=_rule ?:(tol ;~(sfix zor ;~(plug gap duz)) zor)) ++ butt |*(zor=_rule ?:(tol ;~(sfix zor ;~(plug gap duz)) zor))
++ ulva |*(zor=_rule ?.(tol fail ;~(sfix zor ;~(plug gap dun)))) ++ ulva |*(zor=_rule ?.(tol fail ;~(sfix zor ;~(plug gap dun))))
++ neck ;~(pose duz ;~(pfix ;~(plug duq gap) wisp))
++ hank (most muck loaf) ++ hank (most muck loaf)
++ loaf ?:(tol tall wide) ++ loaf ?:(tol tall wide)
++ lobe ?:(tol howl toil) ++ lobe ?:(tol howl toil)