Skip to content

Commit

Permalink
Fixes peggyjs#10. Updates docs with an options example and making it …
Browse files Browse the repository at this point in the history
…clear that you can pass in anything you want to options.
  • Loading branch information
hildjj committed Apr 19, 2021
1 parent a822ffe commit c870361
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,28 @@ <h2 id="using-the-parser">Using the Parser</h2>

<dt><code>tracer</code></dt>
<dd>Tracer to use.</dd>

<dt><code>...</code> (any others)</dt>
<dd>Made available in the "options" variable</dd>
</dl>

<p>Parsers can also support their own custom options.</p>
<p>Parsers can also support their own custom options. For example:</p>

<pre><code>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"
</code></pre>

<h2 id="grammar-syntax-and-semantics">Grammar Syntax and Semantics</h2>

Expand Down

0 comments on commit c870361

Please sign in to comment.