on d452c09 help sign in
874 lines 12 kB history raw
1# 4h: parsing (ascii glyphs)
2### `++ace`
4Parse space
6Parses ASCII character 32, space.
8Source
9------
11 ++ ace (just ' ')
13Examples
14--------
16 > (scan " " ace)
17 ~~.
18 > `cord`(scan " " ace)
19 ' '
20 > (ace [[1 1] " "])
21 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q=""]]]]
22 > (ace [[1 1] " abc "])
23 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="abc "]]]]
27***
28### `++bar`
30Parse vertical bar
32Parses ASCII character 124, the vertical bar.
34Source
35------
37 ++ bar (just '|')
39Examples
40--------
42 > (scan "|" bar)
43 ~~~7c.
44 > `cord`(scan "|" bar)
45 '|'
46 > (bar [[1 1] "|"])
47 [p=[p=1 q=2] q=[~ [p=~~~7c. q=[p=[p=1 q=2] q=""]]]]
48 > (bar [[1 1] "|="])
49 [p=[p=1 q=2] q=[~ [p=~~~7c. q=[p=[p=1 q=2] q="="]]]]
53***
54### `++bas`
56Parse backslash
58Parses ASCII character 92, the backslash. Note the extra `\` in the calling of
59`bas` with [`++just`](/doc/hoon/library/2ec#++just) is to escape the escape
60character, `\`.
62Source
63------
65 ++ bas (just '\\')
67Examples
68--------
70 > (scan "\\" bas)
71 ~~~5c.
72 > `cord`(scan "\\" bas)
73 '\'
74 > (bas [[1 1] "\"])
75 ~ <syntax error at [1 18]>
76 > (bas [[1 1] "\\"])
77 [p=[p=1 q=2] q=[~ [p=~~~5c. q=[p=[p=1 q=2] q=""]]]]
78 > (bas [[1 1] "\""])
79 [p=[p=1 q=1] q=~]
83***
84### `++buc`
86Parse dollar sign
88Parses ASCII character 36, the dollar sign.
90Source
91------
93 ++ buc (just '$')
95Examples
96--------
98 > (scan "$" buc)
99 ~~~24.
100 > `cord`(scan "$" buc)
101 '$'
102 > (buc [[1 1] "$"])
103 [p=[p=1 q=2] q=[~ [p=~~~24. q=[p=[p=1 q=2] q=""]]]]
104 > (buc [[1 1] "$%"])
105 [p=[p=1 q=2] q=[~ [p=~~~24. q=[p=[p=1 q=2] q="%"]]]]
109***
110### `++cab`
112Parse underscore
114Parses ASCII character 95, the underscore.
116Source
117------
119 ++ cab (just '_')
121Examples
122--------
124 > (scan "_" cab)
125 ~~~5f.
126 > `cord`(scan "_" cab)
127 '_'
128 > (cab [[1 1] "_"])
129 [p=[p=1 q=2] q=[~ [p=~~~5f. q=[p=[p=1 q=2] q=""]]]]
130 > (cab [[1 1] "|_"])
131 [p=[p=1 q=1] q=~]
135***
136### `++cen`
138Parses percent sign
140Parses ASCII character 37, the percent sign.
142Source
143------
145 ++ cen (just '%')
147Examples
148--------
150 > (scan "%" cen)
151 ~~~25.
152 > `cord`(scan "%" cen)
153 '%'
154 > (cen [[1 1] "%"])
155 [p=[p=1 q=2] q=[~ [p=~~~25. q=[p=[p=1 q=2] q=""]]]]
156 > (cen [[1 1] "%^"])
157 [p=[p=1 q=2] q=[~ [p=~~~25. q=[p=[p=1 q=2] q="^"]]]]
161***
162### `++col`
164Parse colon
166Parses ASCII character 58, the colon
168Source
169------
171 ++ col (just ':')
173Examples
174--------
176 > (scan ":" col)
177 ~~~3a.
178 > `cord`(scan ":" col)
179 ':'
180 > (col [[1 1] ":"])
181 [p=[p=1 q=2] q=[~ [p=~~~3a. q=[p=[p=1 q=2] q=""]]]]
182 > (col [[1 1] ":-"])
183 [p=[p=1 q=2] q=[~ [p=~~~3a. q=[p=[p=1 q=2] q="-"]]]]
187***
188### `++com`
190Parse comma
192Parses ASCII character 44, the comma.
194Source
195------
197 ++ com (just ',')
199Examples
200--------
202 > (scan "," com)
203 ~~~2c.
204 > `cord`(scan "," com)
205 ','
206 > (com [[1 1] ","])
207 [p=[p=1 q=2] q=[~ [p=~~~2c. q=[p=[p=1 q=2] q=""]]]]
208 > (com [[1 1] "not com"])
209 [p=[p=1 q=1] q=~]
213***
214### `++doq`
216Parse double quote
218Parses ASCII character 34, the double quote.
220Source
221------
223 ++ doq (just '"')
225Examples
226--------
228 > (scan "\"" doq)
229 ~~~22.
230 > `cord`(scan "\"" doq)
231 '"'
232 > (doq [[1 1] "\""])
233 [p=[p=1 q=2] q=[~ [p=~~~22. q=[p=[p=1 q=2] q=""]]]]
234 > (doq [[1 1] "not successfully parsed"])
235 [p=[p=1 q=1] q=~]
236 > (scan "see?" doq)
237 ! {1 1}
238 ! 'syntax-error'
239 ! exit
243***
244### `++dot`
246Parse period
248Parses ASCII character 46, the period.
250Source
251------
253 ++ dot (just '.')
255Examples
256--------
258 > (scan "." dot)
259 ~~~.
260 > `cord`(scan "." dot)
261 '.'
262 > (dot [[1 1] "."])
263 [p=[p=1 q=2] q=[~ [p=~~~. q=[p=[p=1 q=2] q=""]]]]
264 > (dot [[1 1] ".^"])
265 [p=[p=1 q=2] q=[~ [p=~~~. q=[p=[p=1 q=2] q="^"]]]]
269***
270### `++fas`
272Parse forward slash
274Parses ASCII character 47, the forward slash.
276Source
277------
279 ++ fas (just '/')
281Examples
282--------
284 > (scan "/" fas)
285 ~~~2f.
286 > `cord`(scan "/" fas)
287 '/'
288 > (fas [[1 1] "/"])
289 [p=[p=1 q=2] q=[~ [p=~~~2f. q=[p=[p=1 q=2] q=""]]]]
290 > (fas [[1 1] "|/"])
291 [p=[p=1 q=1] q=~]
295***
296### `++gal`
298Parse less-than sign
300Parses ASCII character 60, the less-than sign.
302Source
303------
305 ++ gal (just '<')
307Examples
308--------
310 > (scan "<" gal)
311 ~~~3c.
312 > `cord`(scan "<" gal)
313 '<'
314 > (gal [[1 1] "<"])
315 [p=[p=1 q=2] q=[~ [p=~~~3c. q=[p=[p=1 q=2] q=""]]]]
316 > (gal [[1 1] "<+"])
317 [p=[p=1 q=2] q=[~ [p=~~~3c. q=[p=[p=1 q=2] q="+"]]]]
318 > (gal [[1 1] "+<"])
319 [p=[p=1 q=1] q=~]
323***
324### `++gar`
326Parse greater-than sign
328Parses ASCII character 62, the greater-than sign.
330Source
331------
333 ++ gar (just '>')
335Examples
336--------
338 > (scan ">" gar)
339 ~~~3e.
340 > `cord`(scan ">" gar)
341 '>'
342 > (gar [[1 1] ">"])
343 [p=[p=1 q=2] q=[~ [p=~~~3e. q=[p=[p=1 q=2] q=""]]]]
344 > (gar [[1 1] "=>"])
345 [p=[p=1 q=1] q=~]
349***
350### `++hax`
352Parse number sign
354Parses ASCII character 35, the number sign.
356Source
357------
359 ++ hax (just '#')
361Examples
362--------
364 > (scan "#" hax)
365 ~~~23.
366 > `cord`(scan "#" hax)
367 '#'
368 > (hax [[1 1] "#"])
369 [p=[p=1 q=2] q=[~ [p=~~~23. q=[p=[p=1 q=2] q=""]]]]
370 > (hax [[1 1] "#!"])
371 [p=[p=1 q=2] q=[~ [p=~~~23. q=[p=[p=1 q=2] q="!"]]]]
375***
376### `++hep`
378Parse hyphen
380Parses ASCII character 45, the hyphen.
382Source
383------
385 ++ hep (just '-')
387Examples
388--------
390 > (scan "-" hep)
391 ~~-
392 > `cord`(scan "-" hep)
393 '-'
394 > (hep [[1 1] "-"])
395 [p=[p=1 q=2] q=[~ [p=~~- q=[p=[p=1 q=2] q=""]]]]
396 > (hep [[1 1] ":-"])
397 [p=[p=1 q=1] q=~]
401***
402### `++kel`
404Parse left curley bracket
406Parses ASCII character 123, the left curly bracket. Note that `{`
407(`kel`) and `}` (`ker`) open and close a Hoon expression for Hoon string
408interpolation. To parse either of them, they must be escaped.
410Source
411------
413 ++ kel (just '{')
415Examples
416--------
418 > (scan "\{" kel)
419 ~~~7b.
420 > `cord`(scan "\{" kel)
421 '{'
422 > (kel [[1 1] "\{"])
423 [p=[p=1 q=2] q=[~ [p=~~~7b. q=[p=[p=1 q=2] q=""]]]]
424 > (kel [[1 1] " \{"])
425 [p=[p=1 q=1] q=~]
429***
430### `++ker`
432Parse right curley bracket
434Parses ASCII character 125, the right curly bracket. Note that `{`
435(`kel`) and `}` (`ker`) open and close a Hoon expression for Hoon string
436interpolation. To parse either of them, they must be escaped.
438Source
439------
441 ++ ker (just '}')
443Examples
444--------
446 > (scan "}" ker)
447 ~~~7d.
448 > `cord`(scan "}" ker)
449 '}'
450 > (ker [[1 1] "}"])
451 [p=[p=1 q=2] q=[~ [p=~~~7d. q=[p=[p=1 q=2] q=""]]]]
452 > (ker [[1 1] "\{}"])
453 [p=[p=1 q=1] q=~]
457***
458### `++ket`
460Parse caret
462Parses ASCII character 94, the caret.
464Source
465------
467 ++ ket (just '^')
469Examples
470--------
472 > (scan "^" ket)
473 ~~~5e.
474 > `cord`(scan "^" ket)
475 '^'
476 > (ket [[1 1] "^"])
477 [p=[p=1 q=2] q=[~ [p=~~~5e. q=[p=[p=1 q=2] q=""]]]]
478 > (ket [[1 1] ".^"])
479 [p=[p=1 q=1] q=~]
482***
483### `++lus`
485Parse plus sign
487Parses ASCII character 43, the plus sign.
489Source
490------
492 ++ lus (just '+')
494Examples
495--------
497 > (scan "+" lus)
498 ~~~2b.
499 > `cord`(scan "+" lus)
500 '+'
501 > (lus [[1 1] "+"])
502 [p=[p=1 q=2] q=[~ [p=~~~2b. q=[p=[p=1 q=2] q=""]]]]
503 > (lus [[1 1] ".+"])
504 [p=[p=1 q=1] q=~]
508***
509### `++pam`
511Parse ampersand
513Parses ASCII character 38, the ampersand.
515Source
516------
518 ++ pam (just '&')
520Examples
521--------
523 > (scan "&" pam)
524 ~~~26.
525 > `cord`(scan "&" pam)
526 '&'
527 > (pam [[1 1] "&"])
528 [p=[p=1 q=2] q=[~ [p=~~~26. q=[p=[p=1 q=2] q=""]]]]
529 > (pam [[1 1] "?&"])
530 [p=[p=1 q=1] q=~]
534***
535### `++pat`
537Parse "at" sign
539Parses ASCII character 64, the "at" sign.
541Source
542------
544 ++ pat (just '@')
546Examples
547--------
549 > (scan "@" pat)
550 ~~~4.
551 > `cord`(scan "@" pat)
552 '@'
553 > (pat [[1 1] "@"])
554 [p=[p=1 q=2] q=[~ [p=~~~4. q=[p=[p=1 q=2] q=""]]]]
555 > (pat [[1 1] "?@"])
556 [p=[p=1 q=1] q=~]
560***
561### `++pel`
563Parse left parenthesis
565Parses ASCII character 40, the left parenthesis.
567Source
568------
570 ++ pel (just '(')
572Examples
573--------
575 > (scan "(" pel)
576 ~~~28.
577 > `cord`(scan "(" pel)
578 '('
579 > (pel [[1 1] "("])
580 [p=[p=1 q=2] q=[~ [p=~~~28. q=[p=[p=1 q=2] q=""]]]]
581 > (pel [[1 1] ";("])
582 [p=[p=1 q=1] q=~]
586***
587### `++per`
589Parse right parenthesis
591Parses ASCII character 41, the right parenthesis.
593Source
594------
596 ++ per (just ')')
598Examples
599--------
601 > (scan ")" per)
602 ~~~29.
603 > `cord`(scan ")" per)
604 ')'
605 > (per [[1 1] ")"])
606 [p=[p=1 q=2] q=[~ [p=~~~29. q=[p=[p=1 q=2] q=""]]]]
607 > (per [[1 1] " )"])
608 [p=[p=1 q=1] q=~]
612***
613### `++sel`
615Parse left square bracket
617Parses ASCII character 91, the left square bracket.
619Source
620------
622 ++ sel (just '[')
624Examples
625--------
627 > (scan "[" sel)
628 ~~~5b.
629 > `cord`(scan "[" sel)
630 '['
631 > (sel [[1 1] "["])
632 [p=[p=1 q=2] q=[~ [p=~~~5b. q=[p=[p=1 q=2] q=""]]]]
633 > (sel [[1 1] "-["])
634 [p=[p=1 q=1] q=~]
638***
639### `++sem`
641Parse semicolon
643Parses ASCII character 59, the semicolon.
645Source
646------
648 ++ sem (just ';')
650Examples
651--------
653 > (scan ";" sem)
654 ~~~3b.
655 > `cord`(scan ";" sem)
656 ';'
657 > (sem [[1 1] ";"])
658 [p=[p=1 q=2] q=[~ [p=~~~3b. q=[p=[p=1 q=2] q=""]]]]
659 > (sem [[1 1] " ;"])
660 [p=[p=1 q=1] q=~]
664***
665### `++ser`
667Parse right square bracket
669Parses ASCII character 93, the right square bracket.
671Source
672------
674 ++ ser (just ']')
676Examples
677--------
679 > (scan "]" ser)
680 ~~~5d.
681 > `cord`(scan "]" ser)
682 ']'
683 > (ser [[1 1] "]"])
684 [p=[p=1 q=2] q=[~ [p=~~~5d. q=[p=[p=1 q=2] q=""]]]]
685 > (ser [[1 1] "[ ]"])
686 [p=[p=1 q=1] q=~]
690***
691### `++sig`
693Parse tilde
695Parses ASCII character 126, the tilde.
697Source
698------
700 ++ sig (just '~')
702Examples
703--------
705 > (scan "~" sig)
706 ~~~~
707 > `cord`(scan "~" sig)
708 '~'
709 > (sig [[1 1] "~"])
710 [p=[p=1 q=2] q=[~ [p=~~~~ q=[p=[p=1 q=2] q=""]]]]
711 > (sig [[1 1] "?~"])
712 [p=[p=1 q=1] q=~]
716***
717### `++soq`
719Parse single quote
721Parses ASCII character 39, soq. Note the extra '' is to escape the first
722`soq` because soq delimits a [`++cord`]().
724Source
725------
727 ++ soq (just '\'')
729Examples
730--------
732 > (scan "'" soq)
733 ~~~27.
734 > `cord`(scan "'" soq)
735 '''
736 > (soq [[1 1] "'"])
737 [p=[p=1 q=2] q=[~ [p=~~~27. q=[p=[p=1 q=2] q=""]]]]
738 > (soq [[1 1] ">'"])
739 [p=[p=1 q=1] q=~]
743***
744### `++tar`
746Parse asterisk
748Parses ASCII character 42, the asterisk.
750Source
751------
753 ++ tar (just '*')
755Examples
756--------
758 > (scan "*" tar)
759 ~~~2a.
760 > `cord`(scan "*" tar)
761 '*'
762 > (tar [[1 1] "*"])
763 [p=[p=1 q=2] q=[~ [p=~~~2a. q=[p=[p=1 q=2] q=""]]]]
764 > (tar [[1 1] ".*"])
765 [p=[p=1 q=1] q=~]
769***
770### `++tec`
772Parse backtick
774Parses ASCII character 96, the backtick (also known as the "grave
775accent").
777Source
778------
780 ++ tec (just '`') :: backTiCk
782Examples
783--------
785 > (scan "`" tec)
786 ~~~6.
787 > `cord`(scan "`" tec)
788 '`'
789 > (tec [[1 1] "`"])
790 [p=[p=1 q=2] q=[~ [p=~~~6. q=[p=[p=1 q=2] q=""]]]]
791 > (tec [[1 1] " `"])
792 [p=[p=1 q=1] q=~]
796***
797### `++tis`
799Parse equals sign
801Parses ASCII character 61, the equals sign.
803Source
804------
806 ++ tis (just '=')
808Examples
809--------
811 > (scan "=" tis)
812 ~~~3d.
813 > `cord`(scan "=" tis)
814 '='
815 > (tis [[1 1] "="])
816 [p=[p=1 q=2] q=[~ [p=~~~3d. q=[p=[p=1 q=2] q=""]]]]
817 > (tis [[1 1] "|="])
818 [p=[p=1 q=1] q=~]
822***
823### `++wut`
825Parses question mark
827Parses ASCII character 63, the question mark.
829Source
830------
832 ++ wut (just '?')
834Examples
835--------
837 > (scan "?" wut)
838 ~~~3f.
839 > `cord`(scan "?" wut)
840 '?'
841 > (wut [[1 1] "?"])
842 [p=[p=1 q=2] q=[~ [p=~~~3f. q=[p=[p=1 q=2] q=""]]]]
843 > (wut [[1 1] ".?"])
844 [p=[p=1 q=1] q=~]
848***
849### `++zap`
851Exclamation point
853Parses ASCII character 33, the exclamation point zap.
855Source
856------
858 ++ zap (just '!')
860Examples
861--------
863 > (scan "!" zap)
864 ~~~21.
865 > `cord`(scan "!" zap)
866 '!'
867 > (zap [[1 1] "!"])
868 [p=[p=1 q=2] q=[~ [p=~~~21. q=[p=[p=1 q=2] q=""]]]]
869 > (zap [[1 1] "?!"])
870 [p=[p=1 q=1] q=~]
874***