Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken indentation of some codeblocks #348

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions docs/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ <h3 id="generating-a-parser-command-line">Command Line</h3>

<pre><code class="language-javascript">// config.js or config.cjs
module.exports = {
allowedStartRules = ["foo", "bar"],
format: "umd",
exportVar: "foo",
input: "fooGrammar.peggy",
plugins: [require("./plugin.js")],
testFile: "myTestInput.foo",
trace: true
allowedStartRules = ["foo", "bar"],
format: "umd",
exportVar: "foo",
input: "fooGrammar.peggy",
plugins: [require("./plugin.js")],
testFile: "myTestInput.foo",
trace: true,
};
</code></pre>

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

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

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

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

<pre><code class="language-javascript">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) }
validWord = @word:$[a-z]+ &{ return options.validWords.includes(word) }
`);

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

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

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

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

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

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

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

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

<pre><code class="language-console">Error: Possible infinite loop when parsing (left recursion: start -> proxy -> end -> start)
--> .\recursion.pegjs:1:1
--> .\recursion.pegjs:1:1
|
1 | start = proxy;
| ^^^^^
note: Step 1: call of the rule "proxy" without input consumption
--> .\recursion.pegjs:1:9
--> .\recursion.pegjs:1:9
|
1 | start = proxy;
| ^^^^^
note: Step 2: call of the rule "end" without input consumption
--> .\recursion.pegjs:2:11
--> .\recursion.pegjs:2:11
|
2 | proxy = a:end { return a; };
| ^^^
note: Step 3: call itself without input consumption - left recursion
--> .\recursion.pegjs:3:8
--> .\recursion.pegjs:3:8
|
3 | end = !start
| ^^^^^</code></pre>
Expand Down Expand Up @@ -1467,8 +1467,7 @@ <h3 id="session-api">Session API</h3>

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

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

<ul>
<li><code>message</code>: a main diagnostic message</li>
Expand Down