You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/grammar.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,11 +99,13 @@ num_list: "[" _separated{NUMBER, ","} "]" // Will match "[1, 2, 3]" etc.
99
99
100
100
### Priority
101
101
102
-
Terminals can be assigned priority only when using a lexer (future versions may support Earley's dynamic lexing).
102
+
Terminals can be assigned a priority to influence lexing. Terminal priorities
103
+
are signed integers with a default value of 0.
103
104
104
-
Priority can be either positive or negative. If not specified for a terminal, it defaults to 1.
105
+
When using a lexer, the highest priority terminals are always matched first.
105
106
106
-
Highest priority terminals are always matched first.
107
+
When using Earley's dynamic lexing, terminal priorities are used to prefer
108
+
certain lexings and resolve ambiguity.
107
109
108
110
### Regexp Flags
109
111
@@ -228,9 +230,12 @@ four_words: word ~ 4
228
230
229
231
### Priority
230
232
231
-
Rules can be assigned priority only when using Earley (future versions may support LALR as well).
233
+
Like terminals, rules can be assigned a priority. Rule priorities are signed
234
+
integers with a default value of 0.
232
235
233
-
Priority can be either positive or negative. In not specified for a terminal, it's assumed to be 1 (i.e. the default).
236
+
When using LALR, the highest priority rules are used to resolve collision errors.
237
+
238
+
When using Earley, rule priorities are used to resolve ambiguity.
234
239
235
240
<a name="dirs"></a>
236
241
## Directives
@@ -321,4 +326,4 @@ Can also be used to implement a plugin system where a core grammar is extended b
321
326
%extend NUMBER: /0x\w+/
322
327
```
323
328
324
-
For both `%extend` and `%override`, there is not requirement for a rule/terminal to come from another file, but that is probably the most common usecase
329
+
For both `%extend`and`%override`, there is not requirement for a rule/terminal to come from another file, but that is probably the most common usecase
0 commit comments