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

Fixes #478. #485

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Released: TBD

### Bug fixes

- [#479](https://github.com/peggyjs/peggy/issues/379)
- [#478](https://github.com/peggyjs/peggy/issues/478) Add "npx" to some doc
examples.
- [#479](https://github.com/peggyjs/peggy/issues/479)
Refactor `cli/fromMem.js` into separate project
[from-mem](https://github.com/peggyjs/from-mem/).
- [#481](https://github.com/peggyjs/peggy/issues/481) Add CLI test for
Expand Down
18 changes: 9 additions & 9 deletions docs/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ <h3 id="generating-a-parser-command-line">Command Line</h3>
<p>To generate a parser from your grammar, use the <code>peggy</code>
command:</p>

<pre><code class="language-console">$ peggy arithmetics.pegjs</code></pre>
<pre><code class="language-console">$ npx peggy arithmetics.pegjs</code></pre>

<p>This writes parser source code into a file with the same name as the grammar
file but with “.js” extension. You can also specify the output file
explicitly:</p>

<pre><code class="language-console">$ peggy -o arithmetics-parser.js arithmetics.pegjs</code></pre>
<pre><code class="language-console">$ npx peggy -o arithmetics-parser.js arithmetics.pegjs</code></pre>

<p>If you omit both input and output file, standard input and standard output
are used.</p>
Expand Down Expand Up @@ -295,33 +295,33 @@ <h3 id="generating-a-parser-command-line">Command Line</h3>

<pre><code class="language-console"># - write test results to stdout (42)
# - exit with the code 0
echo "foo = '1' { return 42 }" | peggy --test 1
echo "foo = '1' { return 42 }" | npx peggy --test 1

# - write a parser error to stdout (Expected "1" but "2" found)
# - exit with the code 2
echo "foo = '1' { return 42 }" | peggy --test 2
echo "foo = '1' { return 42 }" | npx peggy --test 2

# - write an error to stdout (Generation of the source map is useless if you don't
# store a generated parser code, perhaps you forgot to add an `-o/--output` option?)
# - exit with the code 1
echo "foo = '1' { return 42 }" | peggy --source-map --test 1
echo "foo = '1' { return 42 }" | npx peggy --source-map --test 1

# - write an error to stdout (Generation of the source map is useless if you don't
# store a generated parser code, perhaps you forgot to add an `-o/--output` option?)
# - exit with the code 1
echo "foo = '1' { return 42 }" | peggy --source-map --test 2
echo "foo = '1' { return 42 }" | npx peggy --source-map --test 2

# - write an output to `parser.js`,
# - write a source map to `parser.js.map`
# - write test results to stdout (42)
# - exit with the code 0
echo "foo = '1' { return 42 }" | peggy --output parser.js --source-map --test 1
echo "foo = '1' { return 42 }" | npx peggy --output parser.js --source-map --test 1

# - write an output to `parser.js`,
# - write a source map to `parser.js.map`
# - write a parser error to stdout (Expected "1" but "2" found)
# - exit with the code 2
echo "foo = '1' { return 42 }" | peggy --output parser.js --source-map --test 2
echo "foo = '1' { return 42 }" | npx peggy --output parser.js --source-map --test 2
</code></pre>

<h3 id="generating-a-parser-javascript-api">JavaScript API</h3>
Expand Down Expand Up @@ -726,7 +726,7 @@ <h3 id="importing-external-rules">Importing External Rules</h3>
<p><code>number.peggy</code>:</p>
<pre><code class="language-peggy">number = n:$[0-9]+ { return parseInt(n, 10); }</code></pre>
<p>Generate:</p>
<pre><code class="language-console">$ peggy csv.peggy number.peggy</code></pre>
<pre><code class="language-console">$ npx peggy csv.peggy number.peggy</code></pre>
</li>

<li>
Expand Down