diff --git a/docs/documentation.html b/docs/documentation.html index 48856b59..d29f6f54 100644 --- a/docs/documentation.html +++ b/docs/documentation.html @@ -270,9 +270,28 @@

Using the Parser

tracer
Tracer to use.
+ +
... (any others)
+
Made available in the "options" variable
-

Parsers can also support their own custom options.

+

Parsers can also support their own custom options. For example:

+ +
const parser = peggy.generate(`
+{
+  // options are available in the per-parse initializer
+  console.log(options.validWords);  // outputs "[ 'boo', 'baz', 'boop' ]"
+}
+
+validWord = word:$[a-z]+ &{ return options.validWords.includes(word) } { return word }
+`);
+
+const result = parser.parse("boo", {
+  validWords: [ "boo", "baz", "boop"]
+});
+
+console.log(result);  // outputs "boo"
+

Grammar Syntax and Semantics