on master help sign in
finish combinators
commitf9765c36d2c1032fec02f69f91452e04db6eaadd authorJONATHAN PAPROCKI <jon@tlon.io> dateTue 4 Aug 2020, 12:09 (6 years ago) parentfffb204
1 file changed+37−1
tutorials/arvo/parsing.md+37−1
tutorials/arvo/parsing.md+37−1
@@ -339,9 +339,45 @@ The syntax to combine parsers (chain them together) is
339339```
340340The `rule`s are composed together using the combinator as an
341341intermediate function, which takes product of a `rule` (an `edge`) and a `rule` and turns
342−it into a sample (a `nail`) for the next `rule`.
342+it into a sample (a `nail`) for the next `rule` to handle.
343343
344+### `+plug`
344345
346+`+plug` simply takes the `nail` in the `edge` produced by one rule and passes it
347+to the next `rule`, forming a cell of the results as it proceeds.
348+
349+```
350+> (scan "starship" ;~(plug (jest 'star') (jest 'ship')))
351+['star' 'ship']
352+```
353+
354+### `+pose`
355+
356+`+pose` tries each `rule` you hand it successively until it finds one that
357+works.
358+
359+```
360+> (scan "a" ;~(pose (just 'a') (just 'b')))
361+'a'
362+> (scan "b" ;~(pose (just 'a') (just 'b')))
363+'b'
364+```
365+
366+### `+glue`
367+
368+`+glue` parses a delimiter in between each `rule` and forms a cell of the
369+results of each `rule`.
370+
371+```
372+> (scan "a,b" ;~((glue com) (just 'a') (just 'b')))
373+['a' 'b']
374+> (scan "a,b,a" ;~((glue com) (just 'a') (just 'b')))
375+{1 4}
376+syntax error
377+```
378+
379+
380+
345381### Parsing atoms
346382
347383[Recall](@/docs/tutorials/hoon/lists.md) that `cord`s are atoms with the aura