on master help sign in
Apply suggestions from code review

Co-authored-by: Fang <git@fang.io>

commit7f673c44e008e7b94f60290662e670793de7b45e authorpoprox <51337059+syzygyzer@users.noreply.github.com> dateTue 25 Aug 2020, 15:03 (6 years ago) parent1c85b60
1 file changed+13−9
tutorials/arvo/parsing.md+13−9
tutorials/arvo/parsing.md+13−9
@@ -236,7 +236,7 @@ and returns a `rule`.
236236### `+cold`
237237
238238`+cold` is a `rule` builder that takes in a constant noun we'll call `cus` and a
239−`rule` we'll call `sef` and returns a `rule` identical to the `sef` except it
239+`rule` we'll call `sef`. It returns a `rule` identical to the `sef` except it
240240replaces the parsing result with `cus`.
241241
242242Here we see that `p.q` of the `edge` returned by the `rule` created with `+cold`
@@ -267,8 +267,8 @@ utilizes parsers. That is to say, you'd like the programmer to only worry about
267267passing `tape`s to the parser, and not have to dress up the `tape` as a `nail`
268268themselves. Thus we have several functions for exactly this purpose.
269269
270−These functions take in either a `tape` or an `@` (typically representing a
271−`cord`) with a `rule` and attempts to parse the input with the `rule`. If the
270+These functions take in either a `tape` or a `cord`,
271+alongside a `rule`, and attempt to parse the input with the `rule`. If the
272272parse succeeds, it returns the result. There are crashing and unitized versions
273273of each caller, corresponding to what happens when a parse fails.
274274
@@ -486,8 +486,11 @@ to write the above `rule` is as follows:
486486++ pars
487487 |-
488488 ;~ plug prn
489− ;~ pose knee *tape
490− |. ^$ (easy ~)
489+ ;~ pose
490+ (knee *tape |.(^$))
491+ (easy ~)
492+ ==
493+ ==
491494```
492495
493496You may want to utilize the `~+` rune when writing recursive parsers to cache
@@ -516,12 +519,12 @@ First lets look at the code we're going to use, and then dive into explaining
516519it. If you'd like to follow along, save the following as `expr-parse.hoon` in
517520your `gen/` folder.
518521```hoon
519−:: expr-parse: parse arithmetic expressions
522+:: expr-parse: parse arithmetic expressions
520523::
521524|= xprs=tape
522525|^ (scan xprs tape)
523526++ factor
524− %+ knee @ud
527+ %+ knee *@ud
525528 |. ~+
526529 ;~ pose
527530 dem
@@ -554,7 +557,8 @@ for expressions.
554557```hoon
555558++ factor
556559 %+ knee @ud
557− |. ~+ ;~ pose
560+ |. ~+
561+ ;~ pose
558562 dem
559563 (ifix [lit rit] expr)
560564 ==
@@ -570,7 +574,7 @@ with `+pose`, which says to try each rule in succession until one of them works.
570574
571575Since expressions ultimately reduce to factors, we are actually building a
572576recursive rule. Thus we need to make use of `+knee`. The first argument for
573−`+knee` is `@ud`, since our final answer should be a `@ud`.
577+`+knee` is `*@ud`, since our final answer should be a `@ud`.
574578
575579Then follows the definition of the gate utilized by `+knee`:
576580```hoon