8000 Merge pull request #1381 from nchammas/patch-1 · lark-parser/lark@7646fb3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7646fb3

Browse files
authored
Merge pull request #1381 from nchammas/patch-1
Give "Shaping the tree" clear sub-headings
2 parents 262ab71 + 1968b90 commit 7646fb3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

docs/tree_construction.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ The brackets do not appear in the tree by design. The words appear because they
7878

7979
Users can alter the automatic construction of the tree using a collection of grammar features.
8080

81+
### Inlining rules with `_`
8182

82-
* Rules whose name begins with an underscore will be inlined into their containing rule.
83+
Rules whose name begins with an underscore will be inlined into their containing rule.
8384

8485
**Example:**
8586

@@ -94,8 +95,9 @@ Lark will parse "(hello world)" as:
9495
"hello"
9596
"world"
9697

98+
### Conditionally inlining rules with `?`
9799

98-
* Rules that receive a question mark (?) at the beginning of their definition, will be inlined if they have a single child, after filtering.
100+
Rules that receive a question mark (?) at the beginning of their definition, will be inlined if they have a single child, after filtering.
99101

100102
**Example:**
101103

@@ -113,7 +115,9 @@ Lark will parse "hello world (planet)" as:
113115
"world"
114116
"planet"
115117

116-
* Rules that begin with an exclamation mark will keep all their terminals (they won't get filtered).
118+
### Pinning rule terminals with `!`
119+
120+
Rules that begin with an exclamation mark will keep all their terminals (they won't get filtered).
117121

118122
```perl
119123
!expr: "(" expr ")"
@@ -136,7 +140,9 @@ Will parse "((hello world))" as:
136140

137141
Using the `!` prefix is usually a "code smell", and may point to a flaw in your grammar design.
138142

139-
* Aliases - options in a rule can receive an alias. It will be then used as the branch name for the option, instead of the rule name.
143+
### Aliasing rules
144+
145+
Aliases - options in a rule can receive an alias. It will be then used as the branch name for the option, instead of the rule name.
140146

141147
**Example:**
142148

0 commit comments

Comments
 (0)
0