Skip to content

Commit 0cb9991

Browse files
authored
Merge pull request #351 from peggyjs/docs-feature
Merge doc changes top main
2 parents ffd0c74 + 1681d98 commit 0cb9991

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

docs/documentation.html

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ <h3 id="generating-a-parser-command-line">Command Line</h3>
213213

214214
<pre><code class="language-javascript">// config.js or config.cjs
215215
module.exports = {
216-
allowedStartRules = ["foo", "bar"],
217-
format: "umd",
218-
exportVar: "foo",
219-
input: "fooGrammar.peggy",
220-
plugins: [require("./plugin.js")],
221-
testFile: "myTestInput.foo",
222-
trace: true
216+
allowedStartRules = ["foo", "bar"],
217+
format: "umd",
218+
exportVar: "foo",
219+
input: "fooGrammar.peggy",
220+
plugins: [require("./plugin.js")],
221+
testFile: "myTestInput.foo",
222+
trace: true,
223223
};
224224
</code></pre>
225225

@@ -439,7 +439,7 @@ <h2 id="using-the-parser">Using the Parser</h2>
439439

440440
<pre><code class="language-javascript">parser.parse("abba"); // returns ["a", "b", "b", "a"]
441441

442-
parser.parse("abcd"); // throws an exception </code></pre>
442+
parser.parse("abcd"); // throws an exception</code></pre>
443443

444444
<p>You can tweak parser behavior by passing a second parameter with an options
445445
object to the <code>parse</code> method. The following options are
@@ -465,12 +465,12 @@ <h2 id="using-the-parser">Using the Parser</h2>
465465
<p>As you can see above, parsers can also support their own custom options. For example:</p>
466466

467467
<pre><code class="language-javascript">const parser = peggy.generate(`
468-
{
468+
{
469469
// options are available in the per-parse initializer
470470
console.log(options.validWords); // outputs "[ 'boo', 'baz', 'boop' ]"
471-
}
471+
}
472472

473-
validWord = @word:$[a-z]+ &{ return options.validWords.includes(word) }
473+
validWord = @word:$[a-z]+ &{ return options.validWords.includes(word) }
474474
`);
475475

476476
const result = parser.parse("boo", {
@@ -1216,7 +1216,7 @@ <h3 id="parsing-lists">Parsing Lists</h3>
12161216
= [ \t]*</code></pre>
12171217

12181218
<p>In the grammars created before the repetition operator was added to the peggy
1219-
(in 2.1.0) you could see that approach, which is equivalent of the new approach
1219+
(in 3.0.0) you could see that approach, which is equivalent of the new approach
12201220
with the repetition operator, but less efficient on long lists:</p>
12211221

12221222
<pre><code class="language-peggy">list
@@ -1250,15 +1250,15 @@ <h2 id="error-messages">Error Messages</h2>
12501250
<p>For example, for this rule matching a comma-separated list of integers:</p>
12511251

12521252
<pre><code class="language-peggy">seq
1253-
= integer ("," integer)*</code></pre>
1253+
= integer ("," integer)*</code></pre>
12541254
<p>an input like 1,2,a produces this error message:</p>
12551255

12561256
<blockquote>Expected integer but "a" found.</blockquote>
12571257

12581258
<p>But if we add a human-readable name to the seq production:</p>
12591259

12601260
<pre><code class="language-peggy">seq "list of numbers"
1261-
= integer ("," integer)*</code></pre>
1261+
= integer ("," integer)*</code></pre>
12621262
<p>then Peggy prefers an error message that implies a smaller attempted parse tree:</p>
12631263

12641264
<blockquote>Expected end of input but "," found.</blockquote>
@@ -1291,22 +1291,22 @@ <h2 id="error-messages">Error Messages</h2>
12911291
<p>Messages generated by <code>format()</code> look like this</p>
12921292

12931293
<pre><code class="language-console">Error: Possible infinite loop when parsing (left recursion: start -> proxy -> end -> start)
1294-
--> .\recursion.pegjs:1:1
1294+
--> .\recursion.pegjs:1:1
12951295
|
12961296
1 | start = proxy;
12971297
| ^^^^^
12981298
note: Step 1: call of the rule "proxy" without input consumption
1299-
--> .\recursion.pegjs:1:9
1299+
--> .\recursion.pegjs:1:9
13001300
|
13011301
1 | start = proxy;
13021302
| ^^^^^
13031303
note: Step 2: call of the rule "end" without input consumption
1304-
--> .\recursion.pegjs:2:11
1304+
--> .\recursion.pegjs:2:11
13051305
|
13061306
2 | proxy = a:end { return a; };
13071307
| ^^^
13081308
note: Step 3: call itself without input consumption - left recursion
1309-
--> .\recursion.pegjs:3:8
1309+
--> .\recursion.pegjs:3:8
13101310
|
13111311
3 | end = !start
13121312
| ^^^^^</code></pre>
@@ -1467,8 +1467,7 @@ <h3 id="session-api">Session API</h3>
14671467

14681468
<p>All reporting methods have an identical signature:</p>
14691469

1470-
<pre><code class="language-typescript">(message: string, location?: LocationRange, notes?: DiagnosticNote[]) =&gt; void;
1471-
</code></pre>
1470+
<pre><code class="language-typescript">(message: string, location?: LocationRange, notes?: DiagnosticNote[]) =&gt; void;</code></pre>
14721471

14731472
<ul>
14741473
<li><code>message</code>: a main diagnostic message</li>

0 commit comments

Comments
 (0)