Skip to content

Commit

Permalink
Merge pull request peggyjs#459 from hildjj/fix-examples
Browse files Browse the repository at this point in the history
Fix examples
  • Loading branch information
hildjj authored Jan 27, 2024
2 parents e7e0c86 + 5318e7f commit 750c558
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 62 deletions.
6 changes: 3 additions & 3 deletions docs/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ <h4 id="importing">Importing</h4>

<pre><code class="language-javascript">import peggy from "peggy";</code></pre>

<p>With some configurations of Typescript, you might need:</p>
<p>With some configurations of Typescript or other tools, you might need:</p>

<pre><code class="language-javascript">import * as peggy from "peggy";</code></pre>

Expand Down Expand Up @@ -1098,7 +1098,7 @@ <h3 id="grammar-syntax-and-semantics-parsing-expression-types">Parsing Expressio

<div class="example">
<div>
<div><em>Example:</em> <br><code>posPredicate = [0-9]+ &amp;{return parseInt(match, 10) &lt; 100}</code></div>
<div><em>Example:</em> <br><code>posPredicate = @num:$[0-9]+ &amp;{return parseInt(num, 10) &lt; 100}</code></div>
<div><em>Matches:</em> <code>"0"</code>, <code>"99"</code></div>
<div><em>Does not match:</em> <code>"100"</code>, <code>"-1"</code>, <code>""</code></div>
</div>
Expand Down Expand Up @@ -1128,7 +1128,7 @@ <h3 id="grammar-syntax-and-semantics-parsing-expression-types">Parsing Expressio

<div class="example">
<div>
<div><em>Example:</em> <br><code>negPredicate = $[0-9]+ !{ return parseInt(match, 10) &lt; 100 }</code></div>
<div><em>Example:</em> <br><code>negPredicate = @num:$[0-9]+ !{ return parseInt(num, 10) &lt; 100 }</code></div>
<div><em>Matches:</em> <code>"100"</code>, <code>"156"</code></div>
<div><em>Does not match:</em> <code>"56"</code>, <code>"-1"</code>, <code>""</code></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/js/benchmark-bundle.min.js

Large diffs are not rendered by default.

122 changes: 68 additions & 54 deletions docs/js/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ function peg$parse(input, options) {
var peg$f12 = function(match, rest) { return {match, rest}; };
var peg$f13 = function(match, rest) { return {match, rest}; };
var peg$f14 = function(match, rest) { return {match, rest}; };
var peg$f15 = function(match) { return parseInt(match, 10) < 100 };
var peg$f15 = function(num) { return parseInt(num, 10) < 100 };
var peg$f16 = function(match, rest) { return {match, rest}; };
var peg$f17 = function(match) { return parseInt(match, 10) < 100 };
var peg$f17 = function(num) { return parseInt(num, 10) < 100 };
var peg$f18 = function(match, rest) { return {match, rest}; };
var peg$f19 = function(match, rest) { return {match, rest}; };
var peg$f20 = function(foo) { return {foo}; };
Expand Down Expand Up @@ -909,53 +909,60 @@ function peg$parse(input, options) {
}

function peg$parseposPredicate() {
var s0, s1, s2, s3;
var s0, s1, s2, s3, s4;

s0 = peg$currPos;
s1 = peg$currPos;
s2 = [];
s3 = input.charAt(peg$currPos);
if (peg$r2.test(s3)) {
s2 = peg$currPos;
s3 = [];
s4 = input.charAt(peg$currPos);
if (peg$r2.test(s4)) {
peg$currPos++;
} else {
s3 = peg$FAILED;
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e6); }
}
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = input.charAt(peg$currPos);
if (peg$r2.test(s3)) {
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = input.charAt(peg$currPos);
if (peg$r2.test(s4)) {
peg$currPos++;
} else {
s3 = peg$FAILED;
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e6); }
}
}
} else {
s2 = peg$FAILED;
s3 = peg$FAILED;
}
if (s2 !== peg$FAILED) {
s1 = input.substring(s1, peg$currPos);
if (s3 !== peg$FAILED) {
s2 = input.substring(s2, peg$currPos);
} else {
s1 = s2;
s2 = s3;
}
if (s1 !== peg$FAILED) {
if (s2 !== peg$FAILED) {
peg$savedPos = peg$currPos;
s2 = peg$f15(s1);
if (s2) {
s2 = undefined;
s3 = peg$f15(s2);
if (s3) {
s3 = undefined;
} else {
s2 = peg$FAILED;
s3 = peg$FAILED;
}
if (s2 !== peg$FAILED) {
s3 = peg$parserest();
peg$savedPos = s0;
s0 = peg$f16(s1, s3);
if (s3 !== peg$FAILED) {
s1 = s2;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
peg$currPos = s1;
s1 = peg$FAILED;
}
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
s2 = peg$parserest();
peg$savedPos = s0;
s0 = peg$f16(s1, s2);
} else {
peg$currPos = s0;
s0 = peg$FAILED;
Expand All @@ -965,53 +972,60 @@ function peg$parse(input, options) {
}

function peg$parsenegPredicate() {
var s0, s1, s2, s3;
var s0, s1, s2, s3, s4;

s0 = peg$currPos;
s1 = peg$currPos;
s2 = [];
s3 = input.charAt(peg$currPos);
if (peg$r2.test(s3)) {
s2 = peg$currPos;
s3 = [];
s4 = input.charAt(peg$currPos);
if (peg$r2.test(s4)) {
peg$currPos++;
} else {
s3 = peg$FAILED;
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e6); }
}
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = input.charAt(peg$currPos);
if (peg$r2.test(s3)) {
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = input.charAt(peg$currPos);
if (peg$r2.test(s4)) {
peg$currPos++;
} else {
s3 = peg$FAILED;
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e6); }
}
}
} else {
s2 = peg$FAILED;
s3 = peg$FAILED;
}
if (s2 !== peg$FAILED) {
s1 = input.substring(s1, peg$currPos);
if (s3 !== peg$FAILED) {
s2 = input.substring(s2, peg$currPos);
} else {
s1 = s2;
s2 = s3;
}
if (s1 !== peg$FAILED) {
if (s2 !== peg$FAILED) {
peg$savedPos = peg$currPos;
s2 = peg$f17(s1);
if (s2) {
s2 = peg$FAILED;
s3 = peg$f17(s2);
if (s3) {
s3 = peg$FAILED;
} else {
s2 = undefined;
s3 = undefined;
}
if (s2 !== peg$FAILED) {
s3 = peg$parserest();
peg$savedPos = s0;
s0 = peg$f18(s1, s3);
if (s3 !== peg$FAILED) {
s1 = s2;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
peg$currPos = s1;
s1 = peg$FAILED;
}
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
s2 = peg$parserest();
peg$savedPos = s0;
s0 = peg$f18(s1, s2);
} else {
peg$currPos = s0;
s0 = peg$FAILED;
Expand Down
4 changes: 2 additions & 2 deletions docs/js/examples.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ posAssertion = match:"a" &"b" rest:rest { return {match, rest}; }

negAssertion = match:"a" !"b" rest:rest { return {match, rest}; }

posPredicate = match:$[0-9]+ &{ return parseInt(match, 10) < 100 } rest:rest { return {match, rest}; }
posPredicate = match:(@num:$[0-9]+ &{ return parseInt(num, 10) < 100 }) rest:rest { return {match, rest}; }

negPredicate = match:$[0-9]+ !{ return parseInt(match, 10) < 100 } rest:rest { return {match, rest}; }
negPredicate = match:(@num:$[0-9]+ !{ return parseInt(num, 10) < 100 }) rest:rest { return {match, rest}; }

dollar = match:$"a"+ rest:rest { return {match, rest}; }

Expand Down
2 changes: 1 addition & 1 deletion docs/js/test-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/vendor/peggy/peggy.min.js

Large diffs are not rendered by default.

0 comments on commit 750c558

Please sign in to comment.