From 99d8b58868bc62cd3cbd4c9759732021d2995ad6 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 28 Aug 2025 00:49:34 -0400 Subject: [PATCH] docs: clarify that a reserved rule must exist in the grammar --- docs/src/creating-parsers/2-the-grammar-dsl.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/src/creating-parsers/2-the-grammar-dsl.md b/docs/src/creating-parsers/2-the-grammar-dsl.md index 5b3eb940..55c59f68 100644 --- a/docs/src/creating-parsers/2-the-grammar-dsl.md +++ b/docs/src/creating-parsers/2-the-grammar-dsl.md @@ -133,12 +133,13 @@ than globally. Can only be used with parse precedence, not lexical precedence. [*node types* file][static-node-types]. - **`reserved`** — similar in structure to the main `rules` property, an object of reserved word sets associated with an -array of reserved rules. The reserved rule in the array must be a terminal token meaning it must be a string, regex, or token, -or a terminal rule. The *first* reserved word set in the object is the global word set, meaning it applies to every rule -in every parse state. However, certain keywords are contextual, depending on the rule. For example, in JavaScript, keywords -are typically not allowed as ordinary variables, however, they *can* be used as a property name. In this situation, the `reserved` -function would be used, and the word set to pass in would be the name of the word set that is declared in the `reserved` -object that corresponds to an empty array, signifying *no* keywords are reserved. +array of reserved rules. The reserved rule in the array must be a terminal token meaning it must be a string, regex, token, +or terminal rule. The reserved rule must also exist and be used in the grammar, specifying arbitrary tokens will not work. +The *first* reserved word set in the object is the global word set, meaning it applies to every rule in every parse state. +However, certain keywords are contextual, depending on the rule. For example, in JavaScript, keywords are typically not allowed +as ordinary variables, however, they *can* be used as a property name. In this situation, the `reserved` function would be used, +and the word set to pass in would be the name of the word set that is declared in the `reserved` object that corresponds to an +empty array, signifying *no* keywords are reserved. [bison-dprec]: https://www.gnu.org/software/bison/manual/html_node/Generalized-LR-Parsing.html [ebnf]: https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form