on 6d45ede help sign in
879 lines 12 kB history raw
1---
2navhome: /docs
3---
6# 4h: parsing (ascii glyphs)
7### `++ace`
9Parse space
11Parses ASCII character 32, space.
13Source
14------
16 ++ ace (just ' ')
18Examples
19--------
21 > (scan " " ace)
22 ~~.
23 > `cord`(scan " " ace)
24 ' '
25 > (ace [[1 1] " "])
26 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q=""]]]]
27 > (ace [[1 1] " abc "])
28 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="abc "]]]]
32***
33### `++bar`
35Parse vertical bar
37Parses ASCII character 124, the vertical bar.
39Source
40------
42 ++ bar (just '|')
44Examples
45--------
47 > (scan "|" bar)
48 ~~~7c.
49 > `cord`(scan "|" bar)
50 '|'
51 > (bar [[1 1] "|"])
52 [p=[p=1 q=2] q=[~ [p=~~~7c. q=[p=[p=1 q=2] q=""]]]]
53 > (bar [[1 1] "|="])
54 [p=[p=1 q=2] q=[~ [p=~~~7c. q=[p=[p=1 q=2] q="="]]]]
58***
59### `++bas`
61Parse backslash
63Parses ASCII character 92, the backslash. Note the extra `\` in the calling of
64`bas` with [`++just`](/docs/hoon/library/2ec#++just) is to escape the escape
65character, `\`.
67Source
68------
70 ++ bas (just '\\')
72Examples
73--------
75 > (scan "\\" bas)
76 ~~~5c.
77 > `cord`(scan "\\" bas)
78 '\'
79 > (bas [[1 1] "\"])
80 ~ <syntax error at [1 18]>
81 > (bas [[1 1] "\\"])
82 [p=[p=1 q=2] q=[~ [p=~~~5c. q=[p=[p=1 q=2] q=""]]]]
83 > (bas [[1 1] "\""])
84 [p=[p=1 q=1] q=~]
88***
89### `++buc`
91Parse dollar sign
93Parses ASCII character 36, the dollar sign.
95Source
96------
98 ++ buc (just '$')
100Examples
101--------
103 > (scan "$" buc)
104 ~~~24.
105 > `cord`(scan "$" buc)
106 '$'
107 > (buc [[1 1] "$"])
108 [p=[p=1 q=2] q=[~ [p=~~~24. q=[p=[p=1 q=2] q=""]]]]
109 > (buc [[1 1] "$%"])
110 [p=[p=1 q=2] q=[~ [p=~~~24. q=[p=[p=1 q=2] q="%"]]]]
114***
115### `++cab`
117Parse underscore
119Parses ASCII character 95, the underscore.
121Source
122------
124 ++ cab (just '_')
126Examples
127--------
129 > (scan "_" cab)
130 ~~~5f.
131 > `cord`(scan "_" cab)
132 '_'
133 > (cab [[1 1] "_"])
134 [p=[p=1 q=2] q=[~ [p=~~~5f. q=[p=[p=1 q=2] q=""]]]]
135 > (cab [[1 1] "|_"])
136 [p=[p=1 q=1] q=~]
140***
141### `++cen`
143Parses percent sign
145Parses ASCII character 37, the percent sign.
147Source
148------
150 ++ cen (just '%')
152Examples
153--------
155 > (scan "%" cen)
156 ~~~25.
157 > `cord`(scan "%" cen)
158 '%'
159 > (cen [[1 1] "%"])
160 [p=[p=1 q=2] q=[~ [p=~~~25. q=[p=[p=1 q=2] q=""]]]]
161 > (cen [[1 1] "%^"])
162 [p=[p=1 q=2] q=[~ [p=~~~25. q=[p=[p=1 q=2] q="^"]]]]
166***
167### `++col`
169Parse colon
171Parses ASCII character 58, the colon
173Source
174------
176 ++ col (just ':')
178Examples
179--------
181 > (scan ":" col)
182 ~~~3a.
183 > `cord`(scan ":" col)
184 ':'
185 > (col [[1 1] ":"])
186 [p=[p=1 q=2] q=[~ [p=~~~3a. q=[p=[p=1 q=2] q=""]]]]
187 > (col [[1 1] ":-"])
188 [p=[p=1 q=2] q=[~ [p=~~~3a. q=[p=[p=1 q=2] q="-"]]]]
192***
193### `++com`
195Parse comma
197Parses ASCII character 44, the comma.
199Source
200------
202 ++ com (just ',')
204Examples
205--------
207 > (scan "," com)
208 ~~~2c.
209 > `cord`(scan "," com)
210 ','
211 > (com [[1 1] ","])
212 [p=[p=1 q=2] q=[~ [p=~~~2c. q=[p=[p=1 q=2] q=""]]]]
213 > (com [[1 1] "not com"])
214 [p=[p=1 q=1] q=~]
218***
219### `++doq`
221Parse double quote
223Parses ASCII character 34, the double quote.
225Source
226------
228 ++ doq (just '"')
230Examples
231--------
233 > (scan "\"" doq)
234 ~~~22.
235 > `cord`(scan "\"" doq)
236 '"'
237 > (doq [[1 1] "\""])
238 [p=[p=1 q=2] q=[~ [p=~~~22. q=[p=[p=1 q=2] q=""]]]]
239 > (doq [[1 1] "not successfully parsed"])
240 [p=[p=1 q=1] q=~]
241 > (scan "see?" doq)
242 ! {1 1}
243 ! 'syntax-error'
244 ! exit
248***
249### `++dot`
251Parse period
253Parses ASCII character 46, the period.
255Source
256------
258 ++ dot (just '.')
260Examples
261--------
263 > (scan "." dot)
264 ~~~.
265 > `cord`(scan "." dot)
266 '.'
267 > (dot [[1 1] "."])
268 [p=[p=1 q=2] q=[~ [p=~~~. q=[p=[p=1 q=2] q=""]]]]
269 > (dot [[1 1] ".^"])
270 [p=[p=1 q=2] q=[~ [p=~~~. q=[p=[p=1 q=2] q="^"]]]]
274***
275### `++fas`
277Parse forward slash
279Parses ASCII character 47, the forward slash.
281Source
282------
284 ++ fas (just '/')
286Examples
287--------
289 > (scan "/" fas)
290 ~~~2f.
291 > `cord`(scan "/" fas)
292 '/'
293 > (fas [[1 1] "/"])
294 [p=[p=1 q=2] q=[~ [p=~~~2f. q=[p=[p=1 q=2] q=""]]]]
295 > (fas [[1 1] "|/"])
296 [p=[p=1 q=1] q=~]
300***
301### `++gal`
303Parse less-than sign
305Parses ASCII character 60, the less-than sign.
307Source
308------
310 ++ gal (just '<')
312Examples
313--------
315 > (scan "<" gal)
316 ~~~3c.
317 > `cord`(scan "<" gal)
318 '<'
319 > (gal [[1 1] "<"])
320 [p=[p=1 q=2] q=[~ [p=~~~3c. q=[p=[p=1 q=2] q=""]]]]
321 > (gal [[1 1] "<+"])
322 [p=[p=1 q=2] q=[~ [p=~~~3c. q=[p=[p=1 q=2] q="+"]]]]
323 > (gal [[1 1] "+<"])
324 [p=[p=1 q=1] q=~]
328***
329### `++gar`
331Parse greater-than sign
333Parses ASCII character 62, the greater-than sign.
335Source
336------
338 ++ gar (just '>')
340Examples
341--------
343 > (scan ">" gar)
344 ~~~3e.
345 > `cord`(scan ">" gar)
346 '>'
347 > (gar [[1 1] ">"])
348 [p=[p=1 q=2] q=[~ [p=~~~3e. q=[p=[p=1 q=2] q=""]]]]
349 > (gar [[1 1] "=>"])
350 [p=[p=1 q=1] q=~]
354***
355### `++hax`
357Parse number sign
359Parses ASCII character 35, the number sign.
361Source
362------
364 ++ hax (just '#')
366Examples
367--------
369 > (scan "#" hax)
370 ~~~23.
371 > `cord`(scan "#" hax)
372 '#'
373 > (hax [[1 1] "#"])
374 [p=[p=1 q=2] q=[~ [p=~~~23. q=[p=[p=1 q=2] q=""]]]]
375 > (hax [[1 1] "#!"])
376 [p=[p=1 q=2] q=[~ [p=~~~23. q=[p=[p=1 q=2] q="!"]]]]
380***
381### `++hep`
383Parse hyphen
385Parses ASCII character 45, the hyphen.
387Source
388------
390 ++ hep (just '-')
392Examples
393--------
395 > (scan "-" hep)
396 ~~-
397 > `cord`(scan "-" hep)
398 '-'
399 > (hep [[1 1] "-"])
400 [p=[p=1 q=2] q=[~ [p=~~- q=[p=[p=1 q=2] q=""]]]]
401 > (hep [[1 1] ":-"])
402 [p=[p=1 q=1] q=~]
406***
407### `++kel`
409Parse left curley bracket
411Parses ASCII character 123, the left curly bracket. Note that `{`
412(`kel`) and `}` (`ker`) open and close a Hoon expression for Hoon string
413interpolation. To parse either of them, they must be escaped.
415Source
416------
418 ++ kel (just '{')
420Examples
421--------
423 > (scan "\{" kel)
424 ~~~7b.
425 > `cord`(scan "\{" kel)
426 '{'
427 > (kel [[1 1] "\{"])
428 [p=[p=1 q=2] q=[~ [p=~~~7b. q=[p=[p=1 q=2] q=""]]]]
429 > (kel [[1 1] " \{"])
430 [p=[p=1 q=1] q=~]
434***
435### `++ker`
437Parse right curley bracket
439Parses ASCII character 125, the right curly bracket. Note that `{`
440(`kel`) and `}` (`ker`) open and close a Hoon expression for Hoon string
441interpolation. To parse either of them, they must be escaped.
443Source
444------
446 ++ ker (just '}')
448Examples
449--------
451 > (scan "}" ker)
452 ~~~7d.
453 > `cord`(scan "}" ker)
454 '}'
455 > (ker [[1 1] "}"])
456 [p=[p=1 q=2] q=[~ [p=~~~7d. q=[p=[p=1 q=2] q=""]]]]
457 > (ker [[1 1] "\{}"])
458 [p=[p=1 q=1] q=~]
462***
463### `++ket`
465Parse caret
467Parses ASCII character 94, the caret.
469Source
470------
472 ++ ket (just '^')
474Examples
475--------
477 > (scan "^" ket)
478 ~~~5e.
479 > `cord`(scan "^" ket)
480 '^'
481 > (ket [[1 1] "^"])
482 [p=[p=1 q=2] q=[~ [p=~~~5e. q=[p=[p=1 q=2] q=""]]]]
483 > (ket [[1 1] ".^"])
484 [p=[p=1 q=1] q=~]
487***
488### `++lus`
490Parse plus sign
492Parses ASCII character 43, the plus sign.
494Source
495------
497 ++ lus (just '+')
499Examples
500--------
502 > (scan "+" lus)
503 ~~~2b.
504 > `cord`(scan "+" lus)
505 '+'
506 > (lus [[1 1] "+"])
507 [p=[p=1 q=2] q=[~ [p=~~~2b. q=[p=[p=1 q=2] q=""]]]]
508 > (lus [[1 1] ".+"])
509 [p=[p=1 q=1] q=~]
513***
514### `++pam`
516Parse ampersand
518Parses ASCII character 38, the ampersand.
520Source
521------
523 ++ pam (just '&')
525Examples
526--------
528 > (scan "&" pam)
529 ~~~26.
530 > `cord`(scan "&" pam)
531 '&'
532 > (pam [[1 1] "&"])
533 [p=[p=1 q=2] q=[~ [p=~~~26. q=[p=[p=1 q=2] q=""]]]]
534 > (pam [[1 1] "?&"])
535 [p=[p=1 q=1] q=~]
539***
540### `++pat`
542Parse "at" sign
544Parses ASCII character 64, the "at" sign.
546Source
547------
549 ++ pat (just '@')
551Examples
552--------
554 > (scan "@" pat)
555 ~~~4.
556 > `cord`(scan "@" pat)
557 '@'
558 > (pat [[1 1] "@"])
559 [p=[p=1 q=2] q=[~ [p=~~~4. q=[p=[p=1 q=2] q=""]]]]
560 > (pat [[1 1] "?@"])
561 [p=[p=1 q=1] q=~]
565***
566### `++pel`
568Parse left parenthesis
570Parses ASCII character 40, the left parenthesis.
572Source
573------
575 ++ pel (just '(')
577Examples
578--------
580 > (scan "(" pel)
581 ~~~28.
582 > `cord`(scan "(" pel)
583 '('
584 > (pel [[1 1] "("])
585 [p=[p=1 q=2] q=[~ [p=~~~28. q=[p=[p=1 q=2] q=""]]]]
586 > (pel [[1 1] ";("])
587 [p=[p=1 q=1] q=~]
591***
592### `++per`
594Parse right parenthesis
596Parses ASCII character 41, the right parenthesis.
598Source
599------
601 ++ per (just ')')
603Examples
604--------
606 > (scan ")" per)
607 ~~~29.
608 > `cord`(scan ")" per)
609 ')'
610 > (per [[1 1] ")"])
611 [p=[p=1 q=2] q=[~ [p=~~~29. q=[p=[p=1 q=2] q=""]]]]
612 > (per [[1 1] " )"])
613 [p=[p=1 q=1] q=~]
617***
618### `++sel`
620Parse left square bracket
622Parses ASCII character 91, the left square bracket.
624Source
625------
627 ++ sel (just '[')
629Examples
630--------
632 > (scan "[" sel)
633 ~~~5b.
634 > `cord`(scan "[" sel)
635 '['
636 > (sel [[1 1] "["])
637 [p=[p=1 q=2] q=[~ [p=~~~5b. q=[p=[p=1 q=2] q=""]]]]
638 > (sel [[1 1] "-["])
639 [p=[p=1 q=1] q=~]
643***
644### `++sem`
646Parse semicolon
648Parses ASCII character 59, the semicolon.
650Source
651------
653 ++ sem (just ';')
655Examples
656--------
658 > (scan ";" sem)
659 ~~~3b.
660 > `cord`(scan ";" sem)
661 ';'
662 > (sem [[1 1] ";"])
663 [p=[p=1 q=2] q=[~ [p=~~~3b. q=[p=[p=1 q=2] q=""]]]]
664 > (sem [[1 1] " ;"])
665 [p=[p=1 q=1] q=~]
669***
670### `++ser`
672Parse right square bracket
674Parses ASCII character 93, the right square bracket.
676Source
677------
679 ++ ser (just ']')
681Examples
682--------
684 > (scan "]" ser)
685 ~~~5d.
686 > `cord`(scan "]" ser)
687 ']'
688 > (ser [[1 1] "]"])
689 [p=[p=1 q=2] q=[~ [p=~~~5d. q=[p=[p=1 q=2] q=""]]]]
690 > (ser [[1 1] "[ ]"])
691 [p=[p=1 q=1] q=~]
695***
696### `++sig`
698Parse tilde
700Parses ASCII character 126, the tilde.
702Source
703------
705 ++ sig (just '~')
707Examples
708--------
710 > (scan "~" sig)
711 ~~~~
712 > `cord`(scan "~" sig)
713 '~'
714 > (sig [[1 1] "~"])
715 [p=[p=1 q=2] q=[~ [p=~~~~ q=[p=[p=1 q=2] q=""]]]]
716 > (sig [[1 1] "?~"])
717 [p=[p=1 q=1] q=~]
721***
722### `++soq`
724Parse single quote
726Parses ASCII character 39, soq. Note the extra '' is to escape the first
727`soq` because soq delimits a [`++cord`]().
729Source
730------
732 ++ soq (just '\'')
734Examples
735--------
737 > (scan "'" soq)
738 ~~~27.
739 > `cord`(scan "'" soq)
740 '''
741 > (soq [[1 1] "'"])
742 [p=[p=1 q=2] q=[~ [p=~~~27. q=[p=[p=1 q=2] q=""]]]]
743 > (soq [[1 1] ">'"])
744 [p=[p=1 q=1] q=~]
748***
749### `++tar`
751Parse asterisk
753Parses ASCII character 42, the asterisk.
755Source
756------
758 ++ tar (just '*')
760Examples
761--------
763 > (scan "*" tar)
764 ~~~2a.
765 > `cord`(scan "*" tar)
766 '*'
767 > (tar [[1 1] "*"])
768 [p=[p=1 q=2] q=[~ [p=~~~2a. q=[p=[p=1 q=2] q=""]]]]
769 > (tar [[1 1] ".*"])
770 [p=[p=1 q=1] q=~]
774***
775### `++tec`
777Parse backtick
779Parses ASCII character 96, the backtick (also known as the "grave
780accent").
782Source
783------
785 ++ tec (just '`') :: backTiCk
787Examples
788--------
790 > (scan "`" tec)
791 ~~~6.
792 > `cord`(scan "`" tec)
793 '`'
794 > (tec [[1 1] "`"])
795 [p=[p=1 q=2] q=[~ [p=~~~6. q=[p=[p=1 q=2] q=""]]]]
796 > (tec [[1 1] " `"])
797 [p=[p=1 q=1] q=~]
801***
802### `++tis`
804Parse equals sign
806Parses ASCII character 61, the equals sign.
808Source
809------
811 ++ tis (just '=')
813Examples
814--------
816 > (scan "=" tis)
817 ~~~3d.
818 > `cord`(scan "=" tis)
819 '='
820 > (tis [[1 1] "="])
821 [p=[p=1 q=2] q=[~ [p=~~~3d. q=[p=[p=1 q=2] q=""]]]]
822 > (tis [[1 1] "|="])
823 [p=[p=1 q=1] q=~]
827***
828### `++wut`
830Parses question mark
832Parses ASCII character 63, the question mark.
834Source
835------
837 ++ wut (just '?')
839Examples
840--------
842 > (scan "?" wut)
843 ~~~3f.
844 > `cord`(scan "?" wut)
845 '?'
846 > (wut [[1 1] "?"])
847 [p=[p=1 q=2] q=[~ [p=~~~3f. q=[p=[p=1 q=2] q=""]]]]
848 > (wut [[1 1] ".?"])
849 [p=[p=1 q=1] q=~]
853***
854### `++zap`
856Exclamation point
858Parses ASCII character 33, the exclamation point zap.
860Source
861------
863 ++ zap (just '!')
865Examples
866--------
868 > (scan "!" zap)
869 ~~~21.
870 > `cord`(scan "!" zap)
871 '!'
872 > (zap [[1 1] "!"])
873 [p=[p=1 q=2] q=[~ [p=~~~21. q=[p=[p=1 q=2] q=""]]]]
874 > (zap [[1 1] "?!"])
875 [p=[p=1 q=1] q=~]
879***