@@ -7,41 +7,40 @@ template = "doc.html"
77## `++bass`
88
99Parser modifier: LSB
10−ordered `++list` as atom of a `++base`.
10+ordered `list` as atom of a `base`.
1111
1212#### Accepts
1313
1414`wuc` is an atom.
1515
16−`tyd` is a `++rule`.
16+`tyd` is a `rule`.
1717
1818#### Produces
1919
20−A `++rule`.
20+A `rule`.
2121
2222#### Source
2323
2424```hoon
25− ++ bass
26− |* {wuc/@ tyd/rule}
27− %+ cook
28− |= waq/(list @)
29− %+ roll
30− waq
31− =|({p/@ q/@} |.((add p (mul wuc q))))
32− tyd
33− ::
25+++ bass
26+ |* [wuc=@ tyd=rule]
27+ %+ cook
28+ |= waq=(list @)
29+ %+ roll
30+ waq
31+ =|([p=@ q=@] |.((add p (mul wuc q))))
32+ tyd
3433```
3534
3635#### Examples
3736
3837```
39− > (scan "123" (bass 10 (star dit)))
40− q=123
41− > (scan "123" (bass 8 (star dit)))
42− q=83
43− > `@ub`(scan "123" (bass 8 (star dit)))
44− 0b101.0011
38+> (scan "123" (bass 10 (star dit)))
39+q=123
40+> (scan "123" (bass 8 (star dit)))
41+q=83
42+> `@ub`(scan "123" (bass 8 (star dit)))
43+0b101.0011
4544```
4645
4746---
@@ -50,43 +49,42 @@ A `++rule`.
5049
5150Parser modifier: LSB
5251
53−Ordered `++list` as atom of a `++base`.
52+Ordered `list` as atom of a `base`.
5453
5554#### Accepts
5655
5756`wuc` is an atom.
5857
59−`tyd` is a `++rule`.
58+`tyd` is a `rule`.
6059
6160#### Produces
6261
63−A `++rule`.
62+A `rule`.
6463
6564#### Source
6665
6766```hoon
68− ++ boss
69− |* {wuc/@ tyd/rule}
70− %+ cook
71− |= waq/(list @)
72− %+ reel
73− waq
74− =|({p/@ q/@} |.((add p (mul wuc q))))
75− tyd
76− ::
67+++ boss
68+ |* [wuc=@ tyd=rule]
69+ %+ cook
70+ |= waq=(list @)
71+ %+ reel
72+ waq
73+ =|([p=@ q=@] |.((add p (mul wuc q))))
74+ tyd
7775```
7876
7977#### Examples
8078
8179```
82− > (scan "123" (boss 10 (star dit)))
83− q=321
80+> (scan "123" (boss 10 (star dit)))
81+321
8482
85− > `@t`(scan "bam" (boss 256 (star alp)))
86− 'bam'
83+> `@t`(scan "bam" (boss 256 (star alp)))
84+'bam'
8785
88− > `@ux`(scan "bam" (boss 256 (star alp)))
89− 0x6d.6162
86+> `@ux`(scan "bam" (boss 256 (star alp)))
87+0x6d.6162
9088```
9189
9290---
@@ -95,41 +93,41 @@ A `++rule`.
9593
9694Replace with constant
9795
98−Parser modifier. Accepts a `++rule` `sef` and produces a parser that
99−produces a constant `cus`, assuming `sef` is successful.
96+Parser modifier. Accepts a `rule` `sef` and produces a parser that produces a
97+constant `cus`, assuming `sef` is successful.
10098
10199#### Accepts
102100
103101`cus` is a constant noun.
104102
105−`sef` is a `++rule`.
103+`sef` is a `rule`.
106104
107105#### Produces
108106
109−An `++edge`.
107+An `edge`.
110108
111109#### Source
112110
113111```hoon
114− ++ cold :: replace w+ constant
115− ~/ %cold
116− |* {cus/* sef/rule}
117− ~/ %fun
118− |= tub/nail
119− =+ vex=(sef tub)
120− ?~ q.vex
121− vex
122− [p=p.vex q=[~ u=[p=cus q=q.u.q.vex]]]
112+++ cold
113+ ~/ %cold
114+ |* [cus=* sef=rule]
115+ ~/ %fun
116+ |= tub=nail
117+ =+ vex=(sef tub)
118+ ?~ q.vex
119+ vex
120+ [p=p.vex q=[~ u=[p=cus q=q.u.q.vex]]]
123121```
124122
125123#### Examples
126124
127125```
128− > ((cold %foo (just 'a')) [[1 1] "abc"])
129− [p=[p=1 q=2] q=[~ u=[p=%foo q=[p=[p=1 q=2] q="bc"]]]]
126+> ((cold %foo (just 'a')) [[1 1] "abc"])
127+[p=[p=1 q=2] q=[~ u=[p=%foo q=[p=[p=1 q=2] q="bc"]]]]
130128
131− > ((cold %foo (just 'a')) [[1 1] "bc"])
132− [p=[p=1 q=1] q=~]
129+> ((cold %foo (just 'a')) [[1 1] "bc"])
130+[p=[p=1 q=1] q=~]
133131```
134132
135133---
@@ -139,47 +137,46 @@ An `++edge`.
139137Apply gate
140138
141139Parser modifier. Produces a parser that takes a (successful) result of a
142−`++rule` `sef` and slams it through `poq`.
140+`rule` `sef` and slams it through `poq`.
143141
144142#### Accepts
145143
146144`poq` is a gate.
147145
148−`sef` is a `++rule`.
146+`sef` is a `rule`.
149147
150148#### Produces
151149
152−An `++rule`.
150+An `rule`.
153151
154152#### Source
155153
156154```hoon
157− ++ cook :: apply gate
158− ~/ %cook
159− |* {poq/gate sef/rule}
160− ~/ %fun
161− |= tub/nail
162− =+ vex=(sef tub)
163− ?~ q.vex
164− vex
165− [p=p.vex q=[~ u=[p=(poq p.u.q.vex) q=q.u.q.vex]]]
166− ::
155+++ cook
156+ ~/ %cook
157+ |* [poq=gate sef=rule]
158+ ~/ %fun
159+ |= tub=nail
160+ =+ vex=(sef tub)
161+ ?~ q.vex
162+ vex
163+ [p=p.vex q=[~ u=[p=(poq p.u.q.vex) q=q.u.q.vex]]]
167164```
168165
169166#### Examples
170167
171168```
172− > ((cook ,@ud (just 'a')) [[1 1] "abc"])
173− [p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]]
169+> ((cook ,@ud (just 'a')) [[1 1] "abc"])
170+[p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]]
174171
175− > ((cook ,@tas (just 'a')) [[1 1] "abc"])
176− [p=[p=1 q=2] q=[~ u=[p=%a q=[p=[p=1 q=2] q="bc"]]]]
172+> ((cook ,@tas (just 'a')) [[1 1] "abc"])
173+[p=[p=1 q=2] q=[~ u=[p=%a q=[p=[p=1 q=2] q="bc"]]]]
177174
178− > ((cook |=(a=@ +(a)) (just 'a')) [[1 1] "abc"])
179− [p=[p=1 q=2] q=[~ u=[p=98 q=[p=[p=1 q=2] q="bc"]]]]
175+> ((cook |=(a=@ +(a)) (just 'a')) [[1 1] "abc"])
176+[p=[p=1 q=2] q=[~ u=[p=98 q=[p=[p=1 q=2] q="bc"]]]]
180177
181− > ((cook |=(a=@ `@t`+(a)) (just 'a')) [[1 1] "abc"])
182− [p=[p=1 q=2] q=[~ u=[p='b' q=[p=[p=1 q=2] q="bc"]]]]
178+> ((cook |=(a=@ `@t`+(a)) (just 'a')) [[1 1] "abc"])
179+[p=[p=1 q=2] q=[~ u=[p='b' q=[p=[p=1 q=2] q="bc"]]]]
183180```
184181
185182---
@@ -197,32 +194,71 @@ without consuming any text.
197194
198195#### Produces
199196
200−A `++rule`.
197+A `rule`.
201198
202199#### Source
203200
204201```hoon
205− ++ easy :: always parse
206− ~/ %easy
207− |* huf=*
208− ~/ %fun
209− |= tub=nail
210− ^- (like ,_huf)
211− [p=p.tub q=[~ u=[p=huf q=tub]]]
212− ::
202+++ easy
203+ ~/ %easy
204+ |* huf=*
205+ ~/ %fun
206+ |= tub=nail
207+ ^- (like _huf)
208+ [p=p.tub q=[~ u=[p=huf q=tub]]]
213209```
214210
215211#### Examples
216212
217213```
218− > ((easy %foo) [[1 1] "abc"])
219− [p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="abc"]]]]
214+> ((easy %foo) [[1 1] "abc"])
215+[p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="abc"]]]]
220216
221− > ((easy %foo) [[1 1] "bc"])
222− [p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="bc"]]]]
217+> ((easy %foo) [[1 1] "bc"])
218+[p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="bc"]]]]
223219
224− > ((easy 'a') [[1 1] "bc"])
225− [p=[p=1 q=1] q=[~ [p='a' q=[p=[p=1 q=1] q="bc"]]]]
220+> ((easy 'a') [[1 1] "bc"])
221+[p=[p=1 q=1] q=[~ [p='a' q=[p=[p=1 q=1] q="bc"]]]]
222+```
223+
224+---
225+
226+## `++fuss`
227+
228+Has A or B?
229+
230+If string `sic` is parsed: `%.y`. If string `non` is parsed: `%.n`. Otherwise, fail.
231+
232+#### Accepts
233+
234+`sic` is a `@t`.
235+
236+`non` is a `@t`.
237+
238+#### Produces
239+
240+A `rule`.
241+
242+#### Source
243+
244+```hoon
245+++ fuss
246+ |= [sic=@t non=@t]
247+ ;~(pose (cold %& (jest sic)) (cold %| (jest non)))
248+```
249+
250+#### Examples
251+
252+```
253+> (rash 'foo' (fuss 'foo' 'bar'))
254+%.y
255+
256+> (rash 'bar' (fuss 'foo' 'bar'))
257+%.n
258+
259+> (rash 'baz' (fuss 'foo' 'bar'))
260+{1 3}
261+syntax error
226262```
227263
228264---
@@ -231,39 +267,38 @@ A `++rule`.
231267
232268Parse to end
233269
234−Parser modifier. Accepts a `++rule` `sef`, and produces a parser that succeeds only
235−when the of `tub` is fully consumed using `sef`.
270+Parser modifier. Accepts a `rule` `sef`, and produces a parser that succeeds
271+only when the `tape` of `tub` is fully consumed using `sef`.
236272
237273#### Accepts
238274
239−`sef` is a `++rule`.
275+`sef` is a `rule`.
240276
241277#### Produces
242278
243−A `++rule`.
279+A `rule`.
244280
245281#### Source
246282
247283```hoon
248− ++ full :: parse to end
249− |* sef=_rule
250− |= tub=nail
251− =+ vex=(sef tub)
252− ?~(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~]))
253− ::
284+++ full
285+ |* sef=rule
286+ |= tub=nail
287+ =+ vex=(sef tub)
288+ ?~(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~]))
254289```
255290
256291#### Examples
257292
258293```
259− > ((full (just 'a')) [[1 1] "ab"])
260− [p=[p=1 q=2] q=~]
294+> ((full (just 'a')) [[1 1] "ab"])
295+[p=[p=1 q=2] q=~]
261296
262− > ((full (jest 'ab')) [[1 1] "ab"])
263− [p=[p=1 q=3] q=[~ u=[p='ab' q=[p=[p=1 q=3] q=""]]]]
297+> ((full (jest 'ab')) [[1 1] "ab"])
298+[p=[p=1 q=3] q=[~ u=[p='ab' q=[p=[p=1 q=3] q=""]]]]
264299
265− > ((full ;~(plug (just 'a') (just 'b'))) [[1 1] "ab"])
266− [p=[p=1 q=3] q=[~ u=[p=[~~a ~~b] q=[p=[p=1 q=3] q=""]]]]
300+> ((full ;~(plug (just 'a') (just 'b'))) [[1 1] "ab"])
301+[p=[p=1 q=3] q=[~ u=[p=['a' 'b'] q=[p=[p=1 q=3] q=""]]]]
267302```
268303
269304---
@@ -272,35 +307,35 @@ A `++rule`.
272307
273308Add to tape
274309
275−Parser modifier: prepend text to `++tape` before applying parser.
310+Parser modifier: prepend text to `tape` before applying parser.
276311
277312#### Accepts
278313
279−`pre` is a `++tape`
314+`pre` is a `tape`
280315
281−`sef` is a `++rule`
316+`sef` is a `rule`
282317
283318#### Produces
284319
285−A `++rule`.
320+A `rule`.
286321
287322#### Source
288323
289324```hoon
290− ++ funk :: add to tape first
291− |* {pre/tape sef/rule}
292− |= tub/nail
293− (sef p.tub (weld pre q.tub))
325+++ funk
326+ |* [pre=tape sef=rule]
327+ |= tub=nail
328+ (sef p.tub (weld pre q.tub))
294329```
295330
296331#### Examples
297332
298333```
299− > ((funk "abc prefix-" (jest 'abc')) [[1 1] "to be parsed"])
300− [p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=" prefix-to be parsed"]]]]
334+> ((funk "abc prefix-" (jest 'abc')) [[1 1] "to be parsed"])
335+[p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=" prefix-to be parsed"]]]]
301336
302− > ((funk "parse" (just 'a')) [[1 4] " me"])
303− [p=[p=1 q=4] q=~]
337+> ((funk "parse" (just 'a')) [[1 4] " me"])
338+[p=[p=1 q=4] q=~]
304339```
305340
306341---
@@ -311,85 +346,139 @@ Place-based apply
311346
312347Parser modifier. Similar to `++cook` in that it produces a parser that takes a
313348(successful) result of `sef` and slams it through `hez`. `hez` accepts a
314−`++pint` `a` and a noun `b`, which is what the parser parsed.
349+`pint` `a` and a noun `b`, which is what the parser parsed.
315350
316351#### Accepts
317352
318353`hez` is a gate.
319354
320−`sef` is a `++rule`
355+`sef` is a `rule`
321356
322357#### Produces
323358
324−A `++rule`.
359+A `rule`.
325360
326361#### Source
327362
328363```hoon
329− ++ here :: place-based apply
330− ~/ %here
331− |* {hez/_|=({a/pint b/*} [a b]) sef/rule}
332− ~/ %fun
333− |= tub/nail
334− =+ vex=(sef tub)
335− ?~ q.vex
336− vex
337− [p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]]
338− ::
364+++ here
365+ ~/ %here
366+ =+ [hez=|=([a=pint b=*] [a b]) sef=*rule]
367+ |@
368+ ++ $
369+ ~/ %fun
370+ |= tub=nail
371+ =+ vex=(sef tub)
372+ ?~ q.vex
373+ vex
374+ [p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]]
375+ --
339376```
340377
341378#### Examples
342379
343380```
344− > (scan "abc" (star alf))
345− "abc"
381+> (scan "abc" (star alf))
382+"abc"
383+
384+> (scan "abc" (here |*(^ +<) (star alf)))
385+[[[p=1 q=1] p=1 q=4] "abc"]
386+
387+> (scan "abc" (star (here |*(^ +<) alf)))
388+~[[[[p=1 q=1] p=1 q=2] ~~a] [[[p=1 q=2] p=1 q=3] ~~b] [[[p=1 q=3] p=1 q=4] ~~c]]
389+```
390+
391+## `++inde`
392+
393+Indentation block
394+
395+Apply `rule` to indented block starting at current column number, omitting the
396+leading whitespace.
397+
398+#### Accepts
399+
400+`sef` is a `rule`.
401+
402+#### Produces
403+
404+A `rule`.
405+
406+#### Source
407+
408+```hoon
409+++ inde |* sef=rule
410+ |= nail ^+ (sef)
411+ =+ [har tap]=[p q]:+<
412+ =+ lev=(fil 3 (dec q.har) ' ')
413+ =+ eol=(just `@t`10)
414+ =+ =- roq=((star ;~(pose prn ;~(sfix eol (jest lev)) -)) har tap)
415+ ;~(simu ;~(plug eol eol) eol)
416+ ?~ q.roq roq
417+ =+ vex=(sef har(q 1) p.u.q.roq)
418+ =+ fur=p.vex(q (add (dec q.har) q.p.vex))
419+ ?~ q.vex vex(p fur)
420+ =- vex(p fur, u.q -)
421+ :+ &3.vex
422+ &4.vex(q.p (add (dec q.har) q.p.&4.vex))
423+ =+ res=|4.vex
424+ |- ?~ res |4.roq
425+ ?. =(10 -.res) [-.res $(res +.res)]
426+ (welp [`@t`10 (trip lev)] $(res +.res))
427+```
346428
347− > (scan "abc" (here |*(^ +<) (star alf)))
348− [[[p=1 q=1] p=1 q=4] "abc"]
429+#### Examples
349430
350− > (scan "abc" (star (here |*(^ +<) alf)))
351− ~[[[[p=1 q=1] p=1 q=2] ~~a] [[[p=1 q=2] p=1 q=3] ~~b] [[[p=1 q=3] p=1 q=4] ~~c]]
431+```
432+> `tape`(scan " foo\0a bar" ;~(pfix ace ace ace (inde (star ;~(pose prn (just '\0a'))))))
433+"foo\0abar"
352434```
353435
436+#### Discussion
437+
438+Note the amount of indentation whitespace to be stripped from the beginning of
439+each line is determined by the value of `q` (the column) in the `hair` when
440+`++inde` is first called. This means something like the `pfix` expression in the
441+example above is necessary to set the level of indentation. Additionally, the
442+`rule` given to `++inde` must consume the whole line including the line ending.
443+
354444---
355445
356446## `++ifix`
357447
358448Infix
359449
360−Parser modifier: surround with pair of `++rule`s, the output of which is
450+Parser modifier: surround with pair of `rule`s, the output of which is
361451discarded.
362452
363453#### Accepts
364454
365−`fel` is a pair of `++rule`s.
455+`fel` is a pair of `rule`s.
366456
367−`hof` is a `++rule`.
457+`hof` is a `rule`.
368458
369459#### Produces
370460
371−A `++rule`.
461+A `rule`.
372462
373463#### Source
374464
375465```hoon
376− ++ ifix
377− |* {fel/{rule rule} hof/rule}
378− ~! +<
379− ~! +<:-.fel
380− ~! +<:+.fel
381− ;~(pfix -.fel ;~(sfix hof +.fel))
382− ::
466+++ ifix
467+ |* [fel=[rule rule] hof=rule]
468+ ~! +<
469+ ~! +<:-.fel
470+ ~! +<:+.fel
471+ ;~(pfix -.fel ;~(sfix hof +.fel))
383472```
384473
385474#### Examples
386475
387476```
388− > (scan "-40-" (ifix [hep hep] dem))
389− q=40
477+> (scan "-40-" (ifix [hep hep] dem))
478+40
390479
391− > (scan "4my4" (ifix [dit dit] (star alf)))
392− "my"
480+> (scan "4my4" (ifix [dit dit] (star alf)))
481+"my"
393482```
394483
395484---
@@ -406,43 +495,42 @@ Match and consume a cord.
406495
407496#### Produces
408497
409−An `++edge`.
498+A `rule`.
410499
411500#### Source
412501
413502```hoon
414− ++ jest :: match a cord
415− |= daf/@t
416− |= tub/nail
417− =+ fad=daf
418− |- ^- (like @t)
419− ?: =(`@`0 daf)
420− [p=p.tub q=[~ u=[p=fad q=tub]]]
421− ?: |(?=($~ q.tub) !=((end 3 1 daf) i.q.tub))
422− (fail tub)
423− $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 1 daf))
424− ::
503+++ jest
504+ |= daf=@t
505+ |= tub=nail
506+ =+ fad=daf
507+ |- ^- (like @t)
508+ ?: =(`@`0 daf)
509+ [p=p.tub q=[~ u=[p=fad q=tub]]]
510+ ?: |(?=(~ q.tub) !=((end 3 daf) i.q.tub))
511+ (fail tub)
512+ $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 daf))
425513```
426514
427515#### Examples
428516
429517```
430− > ((jest 'abc') [[1 1] "abc"])
431− [p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=""]]]]
518+> ((jest 'abc') [[1 1] "abc"])
519+[p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=""]]]]
432520
433− > (scan "abc" (jest 'abc'))
434− 'abc'
521+> (scan "abc" (jest 'abc'))
522+'abc'
435523
436− > (scan "abc" (jest 'acb'))
437− ! {1 2}
438− ! 'syntax-error'
439− ! exit
524+> (scan "abc" (jest 'acb'))
525+! {1 2}
526+! 'syntax-error'
527+! exit
440528
441− > ((jest 'john doe') [[1 1] "john smith"])
442− [p=[p=1 q=6] q=~]
529+> ((jest 'john doe') [[1 1] "john smith"])
530+[p=[p=1 q=6] q=~]
443531
444− > ((jest 'john doe') [[1 1] "john doe"])
445− [p=[p=1 q=9] q=[~ [p='john doe' q=[p=[p=1 q=9] q=""]]]]
532+> ((jest 'john doe') [[1 1] "john doe"])
533+[p=[p=1 q=9] q=[~ [p='john doe' q=[p=[p=1 q=9] q=""]]]]
446534```
447535
448536---
@@ -455,45 +543,44 @@ Match and consume a single character.
455543
456544#### Accepts
457545
458−`daf` is a `++char`
546+`daf` is a `char`
459547
460548#### Produces
461549
462−A `++rule`.
550+A `rule`.
463551
464552#### Source
465553
466554```hoon
467− ++ just :: XX redundant, jest
468− ~/ %just :: match a char
469− |= daf/char
470− ~/ %fun
471− |= tub/nail
472− ^- (like char)
473− ?~ q.tub
474− (fail tub)
475− ?. =(daf i.q.tub)
476− (fail tub)
477− (next tub)
478− ::
555+++ just
556+ ~/ %just
557+ |= daf=char
558+ ~/ %fun
559+ |= tub=nail
560+ ^- (like char)
561+ ?~ q.tub
562+ (fail tub)
563+ ?. =(daf i.q.tub)
564+ (fail tub)
565+ (next tub)
479566```
480567
481568#### Examples
482569
483570```
484− > ((just 'a') [[1 1] "abc"])
485− [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]]
571+> ((just 'a') [[1 1] "abc"])
572+[p=[p=1 q=2] q=[~ [p='a' q=[p=[p=1 q=2] q="bc"]]]]
486573
487− > (scan "abc" (just 'a'))
488− ! {1 2}
489− ! 'syntax-error'
490− ! exit
574+> (scan "abc" (just 'a'))
575+! {1 2}
576+! 'syntax-error'
577+! exit
491578
492− > (scan "a" (just 'a'))
579+> (scan "a" (just 'a'))
580+'a'
493581
494− ~~a
495− > (scan "%" (just '%'))
496− ~~~25.
582+> (scan "%" (just '%'))
583+'%'
497584```
498585
499586---
@@ -509,47 +596,49 @@ compiled.
509596
510597`gar` is a noun.
511598
512−`sef` is a gate that accepts a `++rule`
599+`sef` is a gate that accepts a `rule`
513600
514601#### Produces
515602
516−A `++rule`.
603+A `rule`.
517604
518605#### Source
519606
520607```hoon
521− ++ knee :: callbacks
522− |* {gar/* sef/_|.(*rule)}
523− |= tub/nail
524− ^- (like _gar)
525− ((sef) tub)
526− ::
608+++ knee
609+ =| [gar=* sef=_|.(*rule)]
610+ |@ ++ $
611+ |= tub=nail
612+ ^- (like _gar)
613+ ((sef) tub)
614+ --
527615```
528616
529617#### Examples
530618
531619```
532− > |-(;~(plug prn ;~(pose $ (easy ~))))
533− ! rest-loop
534− ! exit
535−
536− > |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~))))
537− < 1.obo
538− [ c=c=tub=[p=[p=@ud q=@ud] q=""]
539− b
540− < 1.bes
541− [ c=tub=[p=[p=@ud q=@ud] q=""]
542− b=<1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]>
543− a=<1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]>
544− v=<414.fvk 101.jzo 1.ypj %164>
545− ]
546− >
547− a
548− ... 450 lines omitted ...
620+> |-(;~(plug prn ;~(pose $ (easy ~))))
621+! rest-loop
622+! exit
623+
624+> |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~))))
625+< 1.obo
626+ [ c=c=tub=[p=[p=@ud q=@ud] q=""]
627+ b
628+ < 1.bes
629+ [ c=tub=[p=[p=@ud q=@ud] q=""]
630+ b=<1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]>
631+ a=<1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]>
632+ v=<414.fvk 101.jzo 1.ypj %164>
549633 ]
550634 >
551− > (scan "abcd" |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~)))))
552− [~~a "bcd"]
635+ a
636+ ... 450 lines omitted ...
637+ ]
638+>
639+
640+> (scan "abcd" |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~)))))
641+['a' "bcd"]
553642```
554643
555644---
@@ -558,48 +647,46 @@ A `++rule`.
558647
559648Match char
560649
561−Parser generator. Matches the next character if it is in a list of
562−characters.
650+Parser generator. Matches the next character if it is in a list of characters.
563651
564652#### Accepts
565653
566−`bud` is a list of `++char`
654+`bud` is a list of `char`
567655
568656#### Produces
569657
570−A `++rule`.
658+A `rule`.
571659
572660#### Source
573661
574662```hoon
575− ++ mask :: match char in set
576− ~/ %mask
577− |= bud/(list char)
578− ~/ %fun
579− |= tub/nail
580− ^- (like char)
581− ?~ q.tub
582− (fail tub)
583− ?. (lien bud |=(a/char =(i.q.tub a)))
584− (fail tub)
585− (next tub)
586− ::
663+++ mask
664+ ~/ %mask
665+ |= bud=(list char)
666+ ~/ %fun
667+ |= tub=nail
668+ ^- (like char)
669+ ?~ q.tub
670+ (fail tub)
671+ ?. (lien bud |=(a=char =(i.q.tub a)))
672+ (fail tub)
673+ (next tub)
587674```
588675
589676#### Examples
590677
591678```
592− > (scan "a" (mask "cba"))
593− ~~a
679+> (scan "a" (mask "cba"))
680+'a'
594681
595− > ((mask "abc") [[1 1] "abc"])
596− [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]]
682+> ((mask "abc") [[1 1] "abc"])
683+[p=[p=1 q=2] q=[~ [p='a' q=[p=[p=1 q=2] q="bc"]]]]
597684
598− > ((mask "abc") [[1 1] "bbc"])
599− [p=[p=1 q=2] q=[~ [p=~~b q=[p=[p=1 q=2] q="bc"]]]]
685+> ((mask "abc") [[1 1] "bbc"])
686+[p=[p=1 q=2] q=[~ [p='b' q=[p=[p=1 q=2] q="bc"]]]]
600687
601− > ((mask "abc") [[1 1] "dbc"])
602− [p=[p=1 q=1] q=~]
688+> ((mask "abc") [[1 1] "dbc"])
689+[p=[p=1 q=1] q=~]
603690```
604691
605692---
@@ -608,38 +695,37 @@ A `++rule`.
608695
609696Parse list with delimiter
610697
611−Parser modifier: Parse a list of matches using a delimiter `++rule`.
698+Parser modifier: Parse a list of matches using a delimiter `rule`.
612699
613700#### Accepts
614701
615−`bus` is a `++rule`.
702+`bus` is a `rule`.
616703
617−`fel` is a `++rule`.
704+`fel` is a `rule`.
618705
619706#### Produces
620707
621−A `++rule`.
708+A `rule`.
622709
623710#### Source
624711
625712```hoon
626− ++ more
627− |* {bus/rule fel/rule}
628− ;~(pose (most bus fel) (easy ~))
629− ::
713+++ more
714+ |* [bus=rule fel=rule]
715+ ;~(pose (most bus fel) (easy ~))
630716```
631717
632718#### Examples
633719
634720```
635− > (scan "" (more ace dem))
636− ~
721+> (scan "" (more ace dem))
722+~
637723
638− > (scan "40 20" (more ace dem))
639− [q=40 ~[q=20]]
724+> (scan "40 20" (more ace dem))
725+[40 [i=20 t=~]]
640726
641− > (scan "40 20 60 1 5" (more ace dem))
642− [q=40 ~[q=20 q=60 q=1 q=5]]
727+> (scan "40 20 60 1 5" (more ace dem))
728+[40 [i=20 t=~[60 1 5]]]
643729```
644730
645731---
@@ -648,39 +734,38 @@ A `++rule`.
648734
649735Parse list of at least one match
650736
651−Parser modifier: parse a `++list` of at least one match using a delimiter `++rule`.
737+Parser modifier: parse a `list` of at least one match using a delimiter `rule`.
652738
653739#### Accepts
654740
655−`bus` is a `++rule`.
741+`bus` is a `rule`.
656742
657−`fel` is a `++rule`.
743+`fel` is a `rule`.
658744
659745#### Produces
660746
661−A `++rule`.
747+A `rule`.
662748
663749#### Source
664750
665751```hoon
666− ++ most
667− |* {bus/rule fel/rule}
668− ;~(plug fel (star ;~(pfix bus fel)))
669− ::
752+++ most
753+ |* [bus=rule fel=rule]
754+ ;~(plug fel (star ;~(pfix bus fel)))
670755```
671756
672757#### Examples
673758
674759```
675− > (scan "40 20" (most ace dem))
676− [q=40 ~[q=20]]
760+> (scan "40 20" (most ace dem))
761+[40 [i=20 t=~]]
677762
678− > (scan "40 20 60 1 5" (most ace dem))
679− [q=40 ~[q=20 q=60 q=1 q=5]]
763+> (scan "40 20 60 1 5" (most ace dem))
764+[40 [i=20 t=~[60 1 5]]]
680765
681− > (scan "" (most ace dem))
682− ! {1 1}
683− ! exit
766+> (scan "" (most ace dem))
767+! {1 1}
768+! exit
684769```
685770
686771---
@@ -693,33 +778,76 @@ Consume any character, producing it as a result.
693778
694779#### Accepts
695780
696−`tub` is a `++nail`
781+`tub` is a `nail`
697782
698783#### Produces
699784
700−An `++edge`.
785+An `edge`.
701786
702787#### Source
703788
704789```hoon
705− ++ next :: consume a char
706− |= tub/nail
707− ^- (like char)
708− ?~ q.tub
709− (fail tub)
710− =+ zac=(lust i.q.tub p.tub)
711− [zac [~ i.q.tub [zac t.q.tub]]]
712− ::
790+++ next
791+ |= tub=nail
792+ ^- (like char)
793+ ?~ q.tub
794+ (fail tub)
795+ =+ zac=(lust i.q.tub p.tub)
796+ [zac [~ i.q.tub [zac t.q.tub]]]
713797```
714798
715799#### Examples
716800
717801```
718− > (next [[1 1] "ebc"])
719− [p=[p=1 q=2] q=[~ [p=~~e q=[p=[p=1 q=2] q="bc"]]]]
802+> (next [[1 1] "ebc"])
803+[p=[p=1 q=2] q=[~ [p='e' q=[p=[p=1 q=2] q="bc"]]]]
720804
721− > (next [[1 1] "john jumps jones"])
722− [p=[p=1 q=2] q=[~ [p=~~j q=[p=[p=1 q=2] q="ohn jumps jones"]]]]
805+> (next [[1 1] "john jumps jones"])
806+[p=[p=1 q=2] q=[~ [p='j' q=[p=[p=1 q=2] q="ohn jumps jones"]]]]
807+```
808+
809+---
810+
811+## `++perk`
812+
813+Parse cube fork
814+
815+Given `a`, a list of `@tas`, match any one in the list and produce it. Note the
816+list should not be a `list` type, but just a null-terminated cell like `~[%foo %bar %baz]`. The type produced will be a union of the items in the given list,
817+so you can use a `?-` expression on the output.
818+
819+#### Accepts
820+
821+`a` is a `(pole @tas)`.
822+
823+#### Produces
824+
825+A `rule`.
826+
827+#### Source
828+
829+```hoon
830+++ perk
831+ |* a=(pole @tas)
832+ ?~ a fail
833+ ;~ pose
834+ (cold -.a (jest -.a))
835+ $(a +.a)
836+ ==
837+```
838+
839+#### Examples
840+
841+```
842+> (scan "foo" (perk ~[%foo %bar]))
843+%foo
844+
845+> (scan "bar" (perk ~[%foo %bar]))
846+%bar
847+
848+> (scan "baz" (perk ~[%foo %bar]))
849+{1 3}
850+syntax error
723851```
724852
725853---
@@ -728,79 +856,112 @@ An `++edge`.
728856
729857List of at least one match.
730858
731−Parser modifier: parse `++list` of at least one match.
859+Parser modifier: parse `list` of at least one match.
732860
733861#### Accepts
734862
735−`fel` is a `++rule`.
863+`fel` is a `rule`.
736864
737865#### Produces
738866
739−A `++rule`.
867+A `rule`.
740868
741869#### Source
742870
743871```hoon
744− ++ plus |*(fel/rule ;~(plug fel (star fel)))
872+++ plus |*(fel=rule ;~(plug fel (star fel))) ::
745873```
746874
747875#### Examples
748876
749877```
750− > (scan ">>>>" (cook lent (plus gar)))
751− 4
878+> (scan ">>>>" (cook lent (plus gar)))
879+4
752880
753− > (scan "- - " (plus ;~(pose ace hep)))
754− [~~- " - "]
881+> (scan "- - " (plus ;~(pose ace hep)))
882+['-' [i=' ' t=~[' ' '-' ' ']]]
755883
756− > `tape`(scan "- - " (plus ;~(pose ace hep)))
757− "- - "
884+> `tape`(scan "- - " (plus ;~(pose ace hep)))
885+"- - "
758886
759− > `(pole ,@t)`(scan "- - " (plus ;~(pose ace hep)))
760− ['-' [' ' [' ' ['-' [' ' ~]]]]]
887+> `(pole ,@t)`(scan "- - " (plus ;~(pose ace hep)))
888+['-' [' ' [' ' ['-' [' ' ~]]]]]
889+```
890+
891+---
892+
893+## `++punt`
894+
895+Unitized parse
896+
897+Either successfully apply `rule` `a` and produce a `unit` of the result, or produce `~`.
898+
899+#### Accepts
900+
901+`a` is a `rule`.
902+
903+#### Produces
904+
905+A `rule`.
906+
907+#### Source
908+
909+```hoon
910+++ punt |*([a=rule] ;~(pose (stag ~ a) (easy ~)))
911+```
912+
913+#### Example
914+
915+```
916+> ((punt (jest 'foo')) 1^1 "foo")
917+[p=[p=1 q=4] q=[~ u=[p=[~ 'foo'] q=[p=[p=1 q=4] q=~]]]]
918+
919+> ((punt (jest 'foo')) 1^1 "bar")
920+[p=[p=1 q=1] q=[~ [p=~ q=[p=[p=1 q=1] q="bar"]]]]
761921```
762922
763923---
764924
765925## `++sear`
766926
767−Conditional `++cook`
927+Conditional `cook`
768928
769−Conditional `++cook`. Slams the result through a gate that produces
929+Conditional `cook`. Slams the result through a gate that produces
770930a unit; if that unit is empty, fail.
771931
772932#### Accepts
773933
774−`tub` is a `++nail`.
934+`pyq` is a gate that produces a `unit`.
935+
936+`sef` is a `rule`.
775937
776938#### Produces
777939
778−A `++rule`.
940+A `rule`.
779941
780942#### Source
781943
782944```hoon
783− ++ sear :: conditional cook
784− |* {pyq/$-(* (unit)) sef/rule}
785− |= tub/nail
786− =+ vex=(sef tub)
787− ?~ q.vex
788− vex
789− =+ gey=(pyq p.u.q.vex)
790− ?~ gey
791− [p=p.vex q=~]
792− [p=p.vex q=[~ u=[p=u.gey q=q.u.q.vex]]]
793− ::
945+++ sear
946+ |* [pyq=$-(* (unit)) sef=rule]
947+ |= tub=nail
948+ =+ vex=(sef tub)
949+ ?~ q.vex
950+ vex
951+ =+ gey=(pyq p.u.q.vex)
952+ ?~ gey
953+ [p=p.vex q=~]
954+ [p=p.vex q=[~ u=[p=u.gey q=q.u.q.vex]]]
794955```
795956
796957#### Examples
797958
798959```
799− > ((sear |=(a/* ?@(a (some a) ~)) (just `a`)) [[1 1] "abc"])
800− [p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]]
960+> ((sear |=(a=* ?@(a (some a) ~)) (just 'a')) [[1 1] "abc"])
961+[p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]]
801962
802− > ((sear |=(* ~) (just 'a')) [[1 1] "abc"])
803− [p=[p=1 q=2] q=~]
963+> ((sear |=(* ~) (just 'a')) [[1 1] "abc"])
964+[p=[p=1 q=2] q=~]
804965```
805966
806967---
@@ -809,7 +970,7 @@ A `++rule`.
809970
810971Char in range
811972
812−Match characters (`++char`) within a range.
973+Match characters (`char`) within a range.
813974
814975#### Accepts
815976
@@ -819,75 +980,73 @@ Match characters (`++char`) within a range.
819980
820981#### Produces
821982
822−A `++rule`.
983+A `rule`.
823984
824985#### Source
825986
826987```hoon
827− ++ shim :: match char in range
828− ~/ %shim
829− |= {les/@ mos/@}
830− ~/ %fun
831− |= tub/nail
832− ^- (like char)
833− ?~ q.tub
834− (fail tub)
835− ?. ?&((gte i.q.tub les) (lte i.q.tub mos))
836− (fail tub)
837− (next tub)
838− ::
988+++ shim
989+ ~/ %shim
990+ |= [les=@ mos=@]
991+ ~/ %fun
992+ |= tub=nail
993+ ^- (like char)
994+ ?~ q.tub
995+ (fail tub)
996+ ?. ?&((gte i.q.tub les) (lte i.q.tub mos))
997+ (fail tub)
998+ (next tub)
839999```
8401000
8411001#### Examples
8421002
8431003```
844− > ((shim 'a' 'z') [[1 1] "abc"])
845− [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]]
1004+> `tape`(rash 'abc' (plus (shim 'a' 'z')))
1005+"abc"
8461006
847− > ((shim 'a' 'Z') [[1 1] "abc"])
848− [p=[p=1 q=1] q=~]
849−
850− > ((shim 'a' 'Z') [[1 1] "Abc"])
851− [p=[p=1 q=2] q=[~ [p=~~~41. q=[p=[p=1 q=2] q="bc"]]]]
1007+> `tape`(rash 'ABC' (plus (shim 'a' 'z')))
1008+{1 1}
1009+syntax error
8521010```
8531011
8541012---
8551013
856−## `++slug` {#slug}
1014+## `++slug`
8571015
8581016Use gate to parse delimited list
8591017
860−Parser modifier: By composing with a gate, parse a delimited `++list` of
1018+Parser modifier: By composing with a gate, parse a delimited `list` of
8611019matches.
8621020
8631021#### Accepts
8641022
865−`bus` is a `++rule`.
1023+`raq` is a binary gate.
1024+
1025+`bus` is a `rule`.
8661026
867−`fel` is a `++rule`.
1027+`fel` is a `rule`.
8681028
8691029#### Produces
8701030
871−A `++rule`.
1031+A `rule`.
8721032
8731033#### Source
8741034
8751035```hoon
876− ++ slug
877− |* raq/_|*({a/* b/*} [a b])
878− |* {bus/rule fel/rule}
879− ;~((comp raq) fel (stir +<+.raq raq ;~(pfix bus fel)))
880− ::
1036+++ slug
1037+ |* raq=_=>(~ |*([a=* b=*] [a b]))
1038+ |* [bus=rule fel=rule]
1039+ ;~((comp raq) fel (stir +<+.raq raq ;~(pfix bus fel)))
8811040```
8821041
8831042#### Examples
8841043
8851044```
886− > (scan "20+5+110" ((slug add) lus dem))
887− 135
1045+> (scan "20+5+110" ((slug add) lus dem))
1046+135
8881047
889− > `@t`(scan "a b c" ((slug |=(a/[@ @t] (cat 3 a))) ace alp))
890− 'abc'
1048+> `@t`(scan "a b c" ((slug |=(a=[@t @t] (cat 3 a))) ace alp))
1049+'abc'
8911050```
8921051
8931052---
@@ -896,7 +1055,7 @@ A `++rule`.
8961055
8971056Add label
8981057
899−Add a label to an edge parsed by a rule.
1058+Add a label to an `edge` parsed by a `rule`.
9001059
9011060#### Accepts
9021061
@@ -906,34 +1065,27 @@ Add a label to an edge parsed by a rule.
9061065
9071066#### Produces
9081067
909−A `++rule`.
1068+A `rule`.
9101069
9111070#### Source
9121071
9131072```hoon
914− ++ stag :: add a label
915− ~/ %stag
916− |* {gob/* sef/rule}
917− ~/ %fun
918− |= tub/nail
919− =+ vex=(sef tub)
920− ?~ q.vex
921− vex
922− [p=p.vex q=[~ u=[p=[gob p.u.q.vex] q=q.u.q.vex]]]
923− ::
1073+++ stag
1074+ ~/ %stag
1075+ |* [gob=* sef=rule]
1076+ ~/ %fun
1077+ |= tub=nail
1078+ =+ vex=(sef tub)
1079+ ?~ q.vex
1080+ vex
1081+ [p=p.vex q=[~ u=[p=[gob p.u.q.vex] q=q.u.q.vex]]]
9241082```
9251083
9261084#### Examples
9271085
9281086```
929− > ((stag %foo (just 'a')) [[1 1] "abc"])
930− [p=[p=1 q=2] q=[~ u=[p=[%foo ~~a] q=[p=[p=1 q=2] q="bc"]]]]
931−
932− > ((stag "xyz" (jest 'abc')) [[1 1] "abc"])
933− [p=[p=1 q=4] q=[~ u=[p=["xyz" 'abc'] q=[p=[p=1 q=4] q=""]]]]
934−
935− > ((stag 10.000 (shim 0 100)) [[1 1] "abc"])
936− [p=[p=1 q=2] q=[~ u=[p=[10.000 ~~a] q=[p=[p=1 q=2] q="bc"]]]]
1087+> (rash 'abc' (stag %foo (jest 'abc')))
1088+[%foo 'abc']
9371089```
9381090
9391091---
@@ -942,41 +1094,45 @@ A `++rule`.
9421094
9431095List of matches
9441096
945−Parser modifier: parse `++list` of matches.
1097+Parser modifier: parse `list` of matches.
9461098
9471099#### Accepts
9481100
949−`fel` is a `++rule`.
1101+`fel` is a `rule`.
9501102
9511103#### Produces
9521104
1105+A `rule`.
1106+
1107+#### Source
1108+
9531109```hoon
954− ++ star :: 0 or more times
955− |* fel/rule
956− (stir `(list _(wonk *fel))`~ |*({a/* b/*} [a b]) fel)
1110+++ star
1111+ |* fel=rule
1112+ (stir `(list _(wonk *fel))`~ |*([a=* b=*] [a b]) fel)
9571113```
9581114
9591115#### Examples
9601116
9611117```
962− > (scan "aaaaa" (just 'a'))
963− ! {1 2}
964− ! 'syntax-error'
965− ! exit
1118+> (scan "aaaaa" (just 'a'))
1119+! {1 2}
1120+! 'syntax-error'
1121+! exit
9661122
967− > (scan "aaaaa" (star (just 'a')))
968− "aaaaa"
1123+> (scan "aaaaa" (star (just 'a')))
1124+"aaaaa"
9691125
970− > (scan "abcdef" (star (just 'a')))
971− ! {1 2}
972− ! 'syntax-error'
973− ! exit
1126+> (scan "abcdef" (star (just 'a')))
1127+! {1 2}
1128+! 'syntax-error'
1129+! exit
9741130
975− > (scan "abcabc" (star (jest 'abc')))
976− <|abc abc|>
1131+> (scan "abcabc" (star (jest 'abc')))
1132+<|abc abc|>
9771133
978− > (scan "john smith" (star (shim 0 200)))
979− "john smith"
1134+> (scan "john smith" (star (shim 0 200)))
1135+"john smith"
9801136```
9811137
9821138---
@@ -985,7 +1141,8 @@ Parser modifier: parse `++list` of matches.
9851141
9861142Add faces
9871143
988−Add faces `[p q]` to range-parser pairs in a list.
1144+Add faces `[p q]` to range-parser pairs in a list. Typically used in combination
1145+with [`++stew`](#stew).
9891146
9901147#### Accepts
9911148
@@ -993,97 +1150,114 @@ Add faces `[p q]` to range-parser pairs in a list.
9931150
9941151#### Produces
9951152
1153+A `(list [p=?(@ [@ @]) q=rule])`.
1154+
9961155#### Source
9971156
9981157```hoon
999− ++ stet
1000− |* leh/(list {?(@ {@ @}) rule})
1001− |-
1002− ?~ leh
1003− ~
1004− [i=[p=-.i.leh q=+.i.leh] t=$(leh t.leh)]
1005− ::
1158+++ stet
1159+ |* leh=(list [?(@ [@ @]) rule])
1160+ |-
1161+ ?~ leh
1162+ ~
1163+ [i=[p=-.i.leh q=+.i.leh] t=$(leh t.leh)]
10061164```
10071165
10081166#### Examples
10091167
10101168```
1011− > (stet (limo [[5 (just 'a')] [1 (jest 'abc')] [[1 1] (shim 0 200)]
1012− [[1 10] (cold %foo (just 'a'))]~]))
1013− ~[
1014− [p=5 q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1015− [p=1 q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1016− [p=[1 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1017− [p=[1 10] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1018− ]
1019− > [[[1 1] (just 'a')] [[2 1] (shim 0 200)] ~]
1020− [ [[1 1] <1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]>]
1021− [[2 1] <1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]>]
1022− ~
1023− ]
1024− > (stet (limo [[[1 1] (just 'a')] [[2 1] (shim 0 200)] ~]))
1025− ~[
1026− [p=[1 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1027− [p=[2 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1028− ]
1169+> =rule %- stew
1170+ %- stet
1171+ %- limo
1172+ :~
1173+ [['a' 'z'] (cook |=(a=@ (sub a 32)) alp)]
1174+ [['A' 'Z'] (cook |=(a=@ (add a 32)) alp)]
1175+ ==
1176+
1177+> `tape`(rash 'fooBARbaz' (star rule))
1178+"FOObarBAZ"
10291179```
10301180
10311181---
10321182
10331183## `++stew`
10341184
1035−Switch by first
1185+Switch by first char
1186+
1187+Parser generator. From an associative `list` of characters or character
1188+ranges to `rule`s, construct a `map`, and parse `tape`s only
1189+with `rule`s associated with a range that the `tape`'s first character falls in.
1190+
1191+#### Accepts
1192+
1193+`leh` is a `(list [p=?(@ [@ @]) q=rule])`, where `p` is a `char` or `char` range.
1194+
1195+#### Produces
1196+
1197+A `rule`.
1198+
1199+#### Source
10361200
10371201```hoon
1038− ++ stew :: switch by first char
1039− ~/ %stew
1040− |* leh/(list {p/?(@ {@ @}) q/rule}) :: char+range keys
1041− =+ ^= wor :: range complete lth
1042− |= {ort/?(@ {@ @}) wan/?(@ {@ @})}
1043− ?@ ort
1044− ?@(wan (lth ort wan) (lth ort -.wan))
1045− ?@(wan (lth +.ort wan) (lth +.ort -.wan))
1046− =+ ^= hel :: build parser map
1047− =+ hel=`(tree _?>(?=(^ leh) i.leh))`~
1048− |- ^+ hel
1049− ?~ leh
1050− ~
1051− =+ yal=$(leh t.leh)
1052− |- ^+ hel
1053− ?~ yal
1054− [i.leh ~ ~]
1055− ?: (wor p.i.leh p.n.yal)
1056− =+ nuc=$(yal l.yal)
1057− ?> ?=(^ nuc)
1058− ?: (vor p.n.yal p.n.nuc)
1059− [n.yal nuc r.yal]
1060− [n.nuc l.nuc [n.yal r.nuc r.yal]]
1061− =+ nuc=$(yal r.yal)
1062− ?> ?=(^ nuc)
1063− ?: (vor p.n.yal p.n.nuc)
1064− [n.yal l.yal nuc]
1065− [n.nuc [n.yal l.yal l.nuc] r.nuc]
1066− ~% %fun ..^$ ~
1067− |= tub/nail
1068− ?~ q.tub
1069− (fail tub)
1070− |-
1071− ?~ hel
1072− (fail tub)
1073− ?: ?@ p.n.hel
1074− =(p.n.hel i.q.tub)
1075− ?&((gte i.q.tub -.p.n.hel) (lte i.q.tub +.p.n.hel))
1076− :: (q.n.hel [(lust i.q.tub p.tub) t.q.tub])
1077− (q.n.hel tub)
1078− ?: (wor i.q.tub p.n.hel)
1079− $(hel l.hel)
1080− $(hel r.hel)
1081− ::
1082−```
1083−
1084−Parser generator. From an associative `++list` of characters or character
1085−ranges to `++rule`s, construct a `++map`, and parse `++tape`s only
1086−with `++rules` associated with a range that the `++tape`'s first character falls in.
1202+++ stew :: switch by first char
1203+ ~/ %stew
1204+ |* leh=(list [p=?(@ [@ @]) q=rule]) :: char+range keys
1205+ =+ ^= wor :: range complete lth
1206+ |= [ort=?(@ [@ @]) wan=?(@ [@ @])]
1207+ ?@ ort
1208+ ?@(wan (lth ort wan) (lth ort -.wan))
1209+ ?@(wan (lth +.ort wan) (lth +.ort -.wan))
1210+ =+ ^= hel :: build parser map
1211+ =+ hel=`(tree _?>(?=(^ leh) i.leh))`~
1212+ |- ^+ hel
1213+ ?~ leh
1214+ ~
1215+ =+ yal=$(leh t.leh)
1216+ |- ^+ hel
1217+ ?~ yal
1218+ [i.leh ~ ~]
1219+ ?: (wor p.i.leh p.n.yal)
1220+ =+ nuc=$(yal l.yal)
1221+ ?> ?=(^ nuc)
1222+ ?: (mor p.n.yal p.n.nuc)
1223+ [n.yal nuc r.yal]
1224+ [n.nuc l.nuc [n.yal r.nuc r.yal]]
1225+ =+ nuc=$(yal r.yal)
1226+ ?> ?=(^ nuc)
1227+ ?: (mor p.n.yal p.n.nuc)
1228+ [n.yal l.yal nuc]
1229+ [n.nuc [n.yal l.yal l.nuc] r.nuc]
1230+ ~% %fun ..^$ ~
1231+ |= tub=nail
1232+ ?~ q.tub
1233+ (fail tub)
1234+ |-
1235+ ?~ hel
1236+ (fail tub)
1237+ ?: ?@ p.n.hel
1238+ =(p.n.hel i.q.tub)
1239+ ?&((gte i.q.tub -.p.n.hel) (lte i.q.tub +.p.n.hel))
1240+ :: (q.n.hel [(lust i.q.tub p.tub) t.q.tub])
1241+ (q.n.hel tub)
1242+ ?: (wor i.q.tub p.n.hel)
1243+ $(hel l.hel)
1244+ $(hel r.hel)
1245+```
1246+
1247+#### Examples
1248+
1249+```
1250+> =rule %- stew
1251+ %- stet
1252+ %- limo
1253+ :~
1254+ [['a' 'z'] (cook |=(a=@ (sub a 32)) alp)]
1255+ [['A' 'Z'] (cook |=(a=@ (add a 32)) alp)]
1256+ ==
1257+
1258+> `tape`(rash 'fooBARbaz' (star rule))
1259+"FOObarBAZ"
1260+```
10871261
10881262---
10891263
@@ -1091,7 +1265,7 @@ with `++rules` associated with a range that the `++tape`'s first character falls
10911265
10921266Parse repeatedly
10931267
1094−Parse with `++rule` as many times as possible, and fold over results with a
1268+Parse with `rule` as many times as possible, and fold over results with a
10951269binary gate.
10961270
10971271#### Accepts
@@ -1100,37 +1274,51 @@ binary gate.
11001274
11011275`raq` is a gate that takes two nouns and produces a cell.
11021276
1103−`fel` is a rule.
1277+`fel` is a `rule`.
11041278
11051279#### Produces
11061280
1107−A rule.
1281+A `rule`.
11081282
11091283#### Source
11101284
11111285```hoon
1112− ++ stir
1113− ~/ %stir
1114− |* {rud/* raq/_=>(~ |*({a/* b/*} [a b])) fel/rule}
1115− ~/ %fun
1116− |= tub/nail
1117− ^- (like _rud)
1118− =+ vex=(fel tub)
1119− ?~ q.vex
1120− [p.vex [~ rud tub]]
1121− =+ wag=$(tub q.u.q.vex)
1122− ?> ?=(^ q.wag)
1123− [(last p.vex p.wag) [~ (raq p.u.q.vex p.u.q.wag) q.u.q.wag]]
1286+++ stir
1287+ ~/ %stir
1288+ |* [rud=* raq=_=>(~ |*([a=* b=*] [a b])) fel=rule]
1289+ ~/ %fun
1290+ |= tub=nail
1291+ ^- (like _rud)
1292+ ::
1293+ :: lef: successful interim parse results (per .fel)
1294+ :: wag: initial accumulator (.rud in .tub at farthest success)
1295+ ::
1296+ =+ ^= [lef wag]
1297+ =| lef=(list _(fel tub))
1298+ |- ^- [_lef (pair hair [~ u=(pair _rud nail)])]
1299+ =+ vex=(fel tub)
1300+ ?~ q.vex
1301+ :- lef
1302+ [p.vex [~ rud tub]]
1303+ $(lef [vex lef], tub q.u.q.vex)
1304+ ::
1305+ :: fold .lef into .wag, combining results with .raq
1306+ ::
1307+ %+ roll lef
1308+ |= _[vex=(fel tub) wag=wag] :: q.vex is always (some)
1309+ ^+ wag
1310+ :- (last p.vex p.wag)
1311+ [~ (raq p.u.+.q.vex p.u.q.wag) q.u.q.wag]
11241312```
11251313
11261314#### Examples
11271315
11281316```
1129− > (scan "abc" (stir *@ add prn))
1130− 294
1317+> (scan "abc" (stir *@ add prn))
1318+294
11311319
1132− > (roll "abc" add)
1133− b=294
1320+> (roll "abc" add)
1321+294
11341322```
11351323
11361324---
@@ -1143,49 +1331,50 @@ Parse bounded number of times.
11431331
11441332#### Accepts
11451333
1146−`[les=@ mos=@]` is a cell of atoms indicating the bounds.
1334+`lig` is a cell of atoms (`[@ @]`) indicating the bounds.
11471335
1148−`fel` is a `++rule`.
1336+`fel` is a `rule`.
11491337
11501338#### Produces
11511339
1152−A `++rule`.
1340+A `rule`.
11531341
11541342#### Source
11551343
11561344```hoon
1157− ++ stun :: parse several times
1158− |* {lig/{@ @} fel/rule}
1159− |= tub/nail
1160− ^- (like (list _(wonk (fel))))
1161− ?: =(0 +.lig)
1162− [p.tub [~ ~ tub]]
1163− =+ vex=(fel tub)
1164− ?~ q.vex
1165− ?: =(0 -.lig)
1166− [p.vex [~ ~ tub]]
1167− vex
1168− =+ ^= wag %= $
1169− -.lig ?:(=(0 -.lig) 0 (dec -.lig))
1170− +.lig ?:(=(0 +.lig) 0 (dec +.lig))
1171− tub q.u.q.vex
1172− ==
1173− ?~ q.wag
1174− wag
1175− [p.wag [~ [p.u.q.vex p.u.q.wag] q.u.q.wag]]
1345+++ stun
1346+ ~/ %stun
1347+ |* [lig=[@ @] fel=rule]
1348+ |= tub=nail
1349+ ^- (like (list _(wonk (fel))))
1350+ ?: =(0 +.lig)
1351+ [p.tub [~ ~ tub]]
1352+ =+ vex=(fel tub)
1353+ ?~ q.vex
1354+ ?: =(0 -.lig)
1355+ [p.vex [~ ~ tub]]
1356+ vex
1357+ =+ ^= wag %= $
1358+ -.lig ?:(=(0 -.lig) 0 (dec -.lig))
1359+ +.lig ?:(=(0 +.lig) 0 (dec +.lig))
1360+ tub q.u.q.vex
1361+ ==
1362+ ?~ q.wag
1363+ wag
1364+ [p.wag [~ [p.u.q.vex p.u.q.wag] q.u.q.wag]]
11761365```
11771366
11781367#### Examples
11791368
11801369```
1181− > ((stun [5 10] prn) [1 1] "aquickbrownfoxran")
1182− [p=[p=1 q=11] q=[~ [p="aquickbrow" q=[p=[p=1 q=11] q="nfoxran"]]]]
1370+> ((stun [5 10] prn) [1 1] "aquickbrownfoxran")
1371+[p=[p=1 q=11] q=[~ [p="aquickbrow" q=[p=[p=1 q=11] q="nfoxran"]]]]
11831372
1184− > ((stun [5 10] prn) [1 1] "aquickbro")
1185− [p=[p=1 q=10] q=[~ [p="aquickbro" q=[p=[p=1 q=10] q=""]]]]
1373+> ((stun [5 10] prn) [1 1] "aquickbro")
1374+[p=[p=1 q=10] q=[~ [p="aquickbro" q=[p=[p=1 q=10] q=""]]]]
11861375
1187− > ((stun [5 10] prn) [1 1] "aqui")
1188− [p=[p=1 q=5] q=~]
1376+> ((stun [5 10] prn) [1 1] "aqui")
1377+[p=[p=1 q=5] q=~]
11891378```
11901379
11911380---