2title = "4j: Parsing (Bases and Base Digits)"
10A core containing numeric parser primitives.
23 <36.ecc 414.gly 100.xkc 1.ypj %164>
26------------------------------------------------------------------------
32Parsing `++rule`. Parses a pair of base-16 digits. Used in escapes.
45 ++ bix (bass 16 (stun [2 2] six))
59------------------------------------------------------------------------
65Parsing `++rule`. Parses an atom of odor `@pE`, a phrase of two bytes
79 ++ hif (boss 256 ;~(plug tip tiq (easy ~)))
85 > (scan "doznec" hif:ab)
87 > (scan "pittyp" hif:ab)
91------------------------------------------------------------------------
95Parse two phonetic pairs
97Parsing `++rule`. Parses and unscrambles an atom of odor @pF, a phrase
98of two two-byte pairs that are encoded (and scrambled) phonetically.
112 |=([a/@ b/@] (wred:un ~(zug mu ~(zag mu [a b]))))
113 ;~(plug hif ;~(pfix hep hif))
119 > (scan "pittyp-pittyp" huf:ab)
121 > (scan "tasfyn-partyv" huf:ab)
123 > `@ux`(scan "tasfyn-partyv" huf:ab)
127------------------------------------------------------------------------
131Parse 8 phonetic bytes
133Parsing `++rule`. Parses an atom of odor @pG, a phrase of eight of
147 ++ hyf (bass 0x1.0000.0000 ;~(plug huf ;~(pfix hep huf) (easy ~)))
153 > (scan "sondel-forsut-tillyn-nillyt" hyf:ab)
154 q=365.637.097.828.335.095
155 > `@u`~sondel-forsut-tillyn-nillyt
156 365.637.097.828.335.095
159------------------------------------------------------------------------
165Parsing `++rule`. Parses up to five base-32 digits without a leading zero.
169Up to five @uv (base 64) digits.
178 ++ pev (bass 32 ;~(plug sev (stun [0 4] siv)))
186 > (scan "290j" pev:ab)
188 > (scan "123456" pev:ab)
191 > (scan "090j" pev:ab)
192 ~ <syntax error at [1 11]>
195------------------------------------------------------------------------
201Parsing `++rule`. Parses up to five base-64 digits without a leading zero.
205Up to five @uw (base 64) digits.
214 ++ pew (bass 64 ;~(plug sew (stun [0 4] siw)))
222 > (scan "aQ~9" pew:ab)
226 > (scan "123456" pew:ab)
229 > (scan "012345" pew:ab)
234------------------------------------------------------------------------
240Parsing `++rule`. Parses exactly five base-32 digits.
249 ++ piv (bass 32 (stun [5 5] siv))
255 > (scan "10b3l" piv:ab)
262------------------------------------------------------------------------
268Parsing `++rule`. Parses exactly five base-64 digits.
277 ++ piw (bass 64 (stun [5 5] siw))
283 > (scan "2C-pZ" piw:ab)
291------------------------------------------------------------------------
297Parsing `++rule`. Parses a binary number of up to 4 digits in length without
307 ++ qeb (bass 2 ;~(plug seb (stun [0 3] sib)))
315 > (scan "101" qeb:ab)
317 > (scan "1111" qeb:ab)
319 > (scan "11111" qeb:ab)
327------------------------------------------------------------------------
333Parsing `++rule`. Parses a hexadecimal number of up to 4 digits in length
334without a leading zero.
343 ++ qex (bass 16 ;~(plug sex (stun [0 3] hit)))
351 > (scan "18ac" qex:ab)
353 > (scan "18acc" qex:ab)
356 > (scan "08ac" qex:ab)
361------------------------------------------------------------------------
367Parsing `++rule`. Parses exactly four binary digits.
376 ++ qib (bass 2 (stun [4 4] sib))
382 > (scan "0001" qib:ab)
384 > (scan "0100" qib:ab)
386 > (scan "110" qib:ab)
391------------------------------------------------------------------------
397Parsing `++rule`. Parses exactly four hexadecimal digits.
406 ++ qix (bass 16 (stun [4 4] six))
412 > (scan "0100" qix:ab)
414 > (scan "10ff" qix:ab)
421------------------------------------------------------------------------
427Parsing `++rule`. Parses the number 1.
436 ++ seb (cold 1 (just '1'))
445 ! ~zod/try/~2014.10.23..22.34.21..bfdd/:<[1 1].[1 18]>
448 ! ~zod/try/~2014.10.23..22.34.29..d399/:<[1 1].[1 18]>
452------------------------------------------------------------------------
458Parsing `++rule`. Parses a nonzero decimal digit.
467 ++ sed (cook |=(a/@ (sub a '0')) (shim '1' '9'))
480------------------------------------------------------------------------
486Parsing `++rule`. Parses a nonzero base-32 digit
495 ++ sev ;~(pose sed sov)
503 ~zod/socialnet=> (scan "0" sev:ab)
508------------------------------------------------------------------------
514Parsing `++rule`. Parses a nonzero base-64 digit
523 ++ sew ;~(pose sed sow)
536------------------------------------------------------------------------
542Parsing `++rule`. Parses a nonzero hexadecimal digit.
551 ++ sex ;~(pose sed sox)
564------------------------------------------------------------------------
570Parsing `++rule`. Parses a binary digit.
579 ++ sib (cook |=(a/@ (sub a '0')) (shim '0' '1'))
587 ~zod/socialnet=> (scan "0" sib:ab)
591------------------------------------------------------------------------
597Parsing `++rule`. Parses a decimal digit.
606 ++ sid (cook |=(a/@ (sub a '0')) (shim '0' '9'))
616------------------------------------------------------------------------
622Parsing `++rule`. Parses a base-32 digit.
631 ++ siv ;~(pose sid sov)
641------------------------------------------------------------------------
647Parsing `++rule`. Parses a base-64 digit.
656 ++ siw ;~(pose sid sow)
666------------------------------------------------------------------------
672Parsing `++rule`. Parses a hexadecimal digit.
681 ++ six ;~(pose sid sox)
691------------------------------------------------------------------------
697Parsing `++rule`. Parses a base-32 letter.
706 ++ sov (cook |=(a/@ (sub a 87)) (shim 'a' 'v'))
715------------------------------------------------------------------------
721Parsing `++rule`. Parses a base-64 letter/symbol.
731 (cook |=(a/@ (sub a 87)) (shim 'a' 'z'))
732 (cook |=(a/@ (sub a 29)) (shim 'A' 'Z'))
745------------------------------------------------------------------------
751Parsing `++rule`. Parses a hexadecimal letter.
760 ++ sox (cook |=(a/@ (sub a 87)) (shim 'a' 'f'))
770------------------------------------------------------------------------
776Parsing `++rule`. Parses a decimal number of up to 3 digits without a
786 ++ ted (bass 10 ;~(plug sed (stun [0 2] sid)))
794 > (scan "214" ted:ab)
796 > (scan "2140" ted:ab)
803------------------------------------------------------------------------
809Parsing `++rule`. Parses the leading phonetic byte, which represents a
819 ++ tip (sear |=(a/@ (ins:po a)) til)
825 > (scan "doz" tip:ab)
828 > (scan "pit" tip:ab)
832------------------------------------------------------------------------
836Trailing phonetic syllable
838Parsing `++rule`. Parses the trailing phonetic byte, which represents a
848 ++ tiq (sear |=(a/@ (ind:po a)) til)
854 > (scan "zod" tiq:ab)
856 > (scan "nec" tiq:ab)
860------------------------------------------------------------------------
864Parse 3 decimal digits
866Parsing `++rule`. Parses exactly three decimal digits.
875 ++ tid (bass 10 (stun [3 3] sid))
881 > (scan "013" tid:ab)
888------------------------------------------------------------------------
894Parsing `++rule`. Parses exactly three lowercase letters.
903 ++ til (boss 256 (stun [3 3] low))
909 > (scan "mer" til:ab)
911 > `@t`(scan "mer" til:ab)
918------------------------------------------------------------------------
924Parsing rule. Parses characters from an atom of the span odor `@ta`.
934 |=(a/tape (rap 3 ^-((list @) a)))
935 (star ;~(pose nud low hep dot sig cab))
941 > `@ta`(scan "asa-lom_tak" urs:ab)
943 > `@t`(scan "asa-lom_tak" urs:ab)
947------------------------------------------------------------------------
953Parsing rule. Parses all characters of the span odor `@ta` except
964 |=(a/tape (rap 3 ^-((list @) a)))
965 (star ;~(pose nud low hep dot sig))
971 > `@t`(scan "asa-lom.t0k" urt:ab)
975------------------------------------------------------------------------
979Parse bas, soq, or bix
981Parsing rule. Parses an escaped backslash, single quote, or hex pair
991 ++ voy ;~(pfix bas ;~(pose bas soq bix))
997 > (scan "\\0a" voy:ab)
999 > (scan "\\'" voy:ab)
1003------------------------------------------------------------------------
1007Top-level atom parser engine
1009A core containing top-level atom parsers.
1026 <14.vpu 414.mof 100.xkc 1.ypj %164>
1029------------------------------------------------------------------------
1035Parser modifier. Parses 0 or the sample rule `fel`.
1046 ++ ape |*(fel/rule ;~(pose (cold 0 (just '0')) fel))
1052 > (scan "202" (star (ape:ag (cold 2 (just '2')))))
1056------------------------------------------------------------------------
1062Parsing rule. Parses a binary number without a leading zero.
1071 ++ bay (ape (bass 16 ;~(plug qeb:ab (star ;~(pfix dog qib:ab)))))
1077 > (scan "10.0110" bay:ag)
1081------------------------------------------------------------------------
1087Parsing rule. Parses a `@is`, an IPv6 address.
1096 ++ bip =+ tod=(ape qex:ab)
1097 (bass 0x1.0000 ;~(plug tod (stun [7 7] ;~(pfix dog tod))))
1103 > (scan "0.0.ea.3e6c.0.0.0.0" bip:ag)
1104 q=283.183.420.760.121.105.516.068.864
1105 > `@is`(scan "0.0.ea.3e6c.0.0.0.0" bip:ag)
1106 .0.0.ea.3e6c.0.0.0.0
1109------------------------------------------------------------------------
1113Parse decimal with dots
1115Parsing rule. Parses a decimal number that includes dot separators.
1124 ++ dem (ape (bass 1.000 ;~(plug ted:ab (star ;~(pfix dog tid:ab)))))
1130 > (scan "52" dem:ag)
1132 > (scan "13.507" dem:ag)
1136------------------------------------------------------------------------
1142Parsing rule. Parses a decimal number without a leading zero.
1151 ++ dim (ape (bass 10 ;~(plug sed:ab (star sid:ab))))
1157 > (scan "52" dim:ag)
1159 > (scan "013507" dim:ag)
1164------------------------------------------------------------------------
1168Parse decimal with leading `0`
1170Parsing rule. Parses a decmial number with leading zeroes.
1179 ++ dum (bass 10 (plus sid:ab))
1185 > (scan "52" dum:ag)
1187 > (scan "0000052" dum:ag)
1189 > (scan "13507" dim:ag)
1193------------------------------------------------------------------------
1199Parsing rule. Parses an atom of odor `@p`, the phonetic base.
1209 (bass 0x1.0000.0000.0000.0000 (most doh hyf:ab))
1219 > (scan "zod" fed:ag)
1221 > (scan "nec" fed:ag)
1223 > (scan "sondel" fed:ag)
1227 > (scan "tillyn-nillyt" fed:ag)
1229 > (scan "tillyn-nillyt-tasfyn-partyv" fed:ag)
1230 15.331.165.687.565.582.592
1231 > (scan "tillyn-nillyt-tasfyn-partyv--novweb-talrud-talmud-sonfyr" fed:ag)
1232 282.810.089.790.159.633.869.501.053.313.363.681.181
1235------------------------------------------------------------------------
1241Parsing rule. Parses a hexadecimal number
1250 ++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab)))))
1258 > (scan "1a" hex:ag)
1260 > (scan "3.ac8d" hex:ag)
1262 > `@ux`(scan "3.ac8d" hex:ag)
1266------------------------------------------------------------------------
1272Parsing rule. Parses an IPv4 address.
1281 ++ lip =+ tod=(ape ted:ab)
1282 (bass 256 ;~(plug tod (stun [3 3] ;~(pfix dog tod))))
1288 > (scan "127.0.0.1" lip:ag)
1290 > `@if`(scan "127.0.0.1" lip:ag)
1292 > `@if`(scan "8.8.8.8" lip:ag)
1296------------------------------------------------------------------------
1300Parse Base-32 with dots
1302Parsing rule. Parses a Base-32 number with dot separators.
1311 ++ viz (ape (bass 0x200.0000 ;~(plug pev:ab (star ;~(pfix dog piv:ab)))))
1317 > (scan "e2.ol4pm" viz:ag)
1321------------------------------------------------------------------------
1327Parsing rule. Parses a raw base-32 string.
1336 ++ vum (bass 32 (plus siv:ab))
1342 > (scan "e2ol4pm" vum:ag)
1346------------------------------------------------------------------------
1352Parsing rule. Parses a base-64 number.
1361 ++ wiz (ape (bass 0x4000.0000 ;~(plug pew:ab (star ;~(pfix dog piw:ab)))))
1369 > (scan "e2O.l4Xpm" wiz:ag)
1370 q=61.764.130.813.526
1376Core used to scramble 16-bit atoms
1378A door that contains arms that are used to scramble two atoms, `top`
1379and `bot`. Used especially in the phonetic base to disguise the
1380relationship between a destroyer and its cruiser.
1400 > ~(. mu 0x20e5 0x5901)
1401 <3.sjm [[@ux @ux] <414.hhh 100.xkc 1.ypj %164>]>
1404------------------------------------------------------------------------
1410Produces the cell of `top` and `bot` with `top` scrambled to the result
1411of adding `bot` to `top` modulo 16. Used to scramble the name of a
1425 ++ zag [p=(end 4 1 (add top bot)) q=bot]
1431 > `[@ux @ux]`~(zag mu 0x20e0 0x201)
1435------------------------------------------------------------------------
1439Subtract bottom from top
1441The inverse of `++zag`. Produces the cell of `top` and `bot` with
1442`top` unscrambled. The unscrambled `top` is the sum of the sample `top`
1443and the 16-bit complement of `bot`. Used to unscramble the name of the
1457 ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot]
1463 > `[@ux @ux]`~(zig mu 0x2f46 0x1042)
1467------------------------------------------------------------------------
1471Concatenate into atom
1473Produces the concatenation of `top` and `bot`. Used to assemble a
1487 ++ zug (mix (lsh 4 1 top) bot)
1493 > `@ux`~(zug mu 0x10e1 0xfa)
1501Digit rendering engine
1503A door containing arms that render digits at bases 10, 16, 32, and
1523 <4.gut [@ud <414.hhh 100.xkc 1.ypj %164>]>
1526------------------------------------------------------------------------
1532Renders a decimal digit as an atom of an ACII byte value.
1554------------------------------------------------------------------------
1560Renders a hexadecimal digit as an atom of an ASCII byte value.
1571 ++ x ?:((gte tig 10) (add tig 87) d)
1584------------------------------------------------------------------------
1590Renders a base-32 digit as an atom of an ASCII byte value.
1599 ++ v ?:((gte tig 10) (add tig 87) d)
1613------------------------------------------------------------------------
1619Renders a base-64 digit as an atom of an ASCII byte value.
1630 ++ w ?:(=(tig 63) '~' ?:(=(tig 62) '-' ?:((gte tig 36) (add tig 29) x)))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list