Mention rule order as the fallback criteria in docs

Fixes #702
This commit is contained in:
Max Brunsfeld 2020-07-29 10:04:05 -07:00
parent 6941217c46
commit 4ec7d80968

View file

@ -505,6 +505,8 @@ Grammars often contain multiple tokens that can match the same characters. For e
4. **Match Specificity** - If there are two valid tokens with the same precedence and which both match the same number of characters, Tree-sitter will prefer a token that is specified in the grammar as a `String` over a token specified as a `RegExp`.
5. **Rule Order** - If none of the above criteria can be used to select one token over another, Tree-sitter will prefer the token that appears earlier in the grammar.
### Keywords
Many languages have a set of *keyword* tokens (e.g. `if`, `for`, `return`), as well as a more general token (e.g. `identifier`) that matches any word, including many of the keyword strings. For example, JavaScript has a keyword `instanceof`, which is used as a binary operator, like this: