From daf2c01d8bf88feeb191573d99eb9bb0ecde6d67 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 5 Mar 2018 09:35:52 -0800 Subject: [PATCH] Add docs section about hidden rules --- docs/creating-parsers.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/creating-parsers.md b/docs/creating-parsers.md index efd9f239..69e35b3c 100644 --- a/docs/creating-parsers.md +++ b/docs/creating-parsers.md @@ -327,6 +327,10 @@ binary_expression: $ => choice( ), ``` +### Hiding rules + +You may have noticed in the above examples that some of the grammar rule name like `_expression` and `_type` began with an underscore. Starting a rule's name with an underscore causes the rule to be *hidden* in the syntax tree. This is useful for rules like `_expression` in the grammars above, which always just wrap a single child node. If these nodes were not hidden, they would add substantial depth and noise to the syntax tree without making it any easier to understand. + ## Dealing with LR conflicts [cst]: https://en.wikipedia.org/wiki/Parse_tree