Skip to content

Commit

Permalink
Merge pull request peggyjs#485 from hildjj/npx-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hildjj authored Feb 23, 2024
2 parents eb90c17 + 1aa1b52 commit 01de4b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
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

0 comments on commit 01de4b6

Please sign in to comment.