on master help sign in
Merge pull request #1008 from risruc-habteb/patch-2
4166e68poprox
tutorials/hoon/parsing.md+8−8
@@ -321,10 +321,10 @@ documented among the [parser builders](@/docs/reference/library/4f.md).
321surrounded on both sides by text that matches a pair of `rule`s, which is discarded.
321surrounded on both sides by text that matches a pair of `rule`s, which is discarded.
322
322
323```
323```
324−> (scan "(42)" (ifix [lit rit] (jest '42')))
324+> (scan "(42)" (ifix [pal par] (jest '42')))
325'42'
325'42'
326```
326```
327−`+lit` and `+rit` are shorthand for `(just '(')` and `(just ')')`, respectively. All
327+`+pal` and `+par` are shorthand for `(just '(')` and `(just ')')`, respectively. All
328ASCII glyphs have counterparts of this sort, documented
328ASCII glyphs have counterparts of this sort, documented
329[here](@/docs/reference/library/4h.md).
329[here](@/docs/reference/library/4h.md).
330
330
@@ -520,13 +520,13 @@ your `gen/` folder.
520:: expr-parse: parse arithmetic expressions
520:: expr-parse: parse arithmetic expressions
521::
521::
522|= xprs=tape
522|= xprs=tape
523−|^ (scan xprs tape)
523+|^ (scan xprs expr)
524++ factor
524++ factor
525 %+ knee *@ud
525 %+ knee *@ud
526 |. ~+
526 |. ~+
527 ;~ pose
527 ;~ pose
528 dem
528 dem
529− (ifix [lit rit] expr)
529+ (ifix [pal par] expr)
530 ==
530 ==
531++ turm
531++ turm
532 %+ knee *@ud
532 %+ knee *@ud
@@ -563,15 +563,15 @@ for expressions.
563 |. ~+
563 |. ~+
564 ;~ pose
564 ;~ pose
565 dem
565 dem
566− (ifix [lit rit] expr)
566+ (ifix [pal par] expr)
567 ==
567 ==
568```
568```
569
569
570A _factor_ is either a decimal number or an expression surrounded by parentheses. Put
570A _factor_ is either a decimal number or an expression surrounded by parentheses. Put
571into Hoon terms, a decimal number is parsed by the `rule` `+dem` and an
571into Hoon terms, a decimal number is parsed by the `rule` `+dem` and an
572expression is parsed by removing the surrounding parentheses and then passing
572expression is parsed by removing the surrounding parentheses and then passing
573−the result to the expression parser arm `+expr`, given by the `rule` `(ifix [lit
573+the result to the expression parser arm `+expr`, given by the `rule` `(ifix [pal
574−rit] expr)`. Since we want to parse our expression with one or the other, we
574+par] expr)`. Since we want to parse our expression with one or the other, we
575chain these two `rule`s together using the monadic applicator rune `;~` along
575chain these two `rule`s together using the monadic applicator rune `;~` along
576with `+pose`, which says to try each rule in succession until one of them works.
576with `+pose`, which says to try each rule in succession until one of them works.
577
577
@@ -584,7 +584,7 @@ Then follows the definition of the gate utilized by `+knee`:
584 |. ~+
584 |. ~+
585 ;~ pose
585 ;~ pose
586 dem
586 dem
587− (ifix [lit rit] expr)
587+ (ifix [pal par] expr)
588 ==
588 ==
589```
589```
590`~+` is used to cache the parser, so that it does not need to be computed over
590`~+` is used to cache the parser, so that it does not need to be computed over