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

Update documentation.html #506

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ markw65 <mark@replayroutes.com> (https://github.com/markw65/)
Andy (https://github.com/AndrewRayCode)
Kristian Dupont <kristian@kristiandupont.com> (https://github.com/kristiandupont/)
Lumi Pakkanen <lumi.pakkanen@gmail.com> (https://github.com/frostburn/)
Steven Spungin <steven@spungin.tv> (https://github.com/flamenco/)
XenoS (https://github.com/XenoS-ITA)
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Unreleased

### Bug fixes

### Documentation
- Added END OF INPUT (`!.`).

4.0.2
-----

Expand Down
35 changes: 35 additions & 0 deletions docs/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,41 @@ <h3 id="grammar-syntax-and-semantics-parsing-expression-types">Parsing Expressio
</div>
</dd>

<dt><code>!.</code> (END OF INPUT)</dt>

<dd>
<p>Match END OF INPUT. This <em>Bang Dot</em> sequence will match a completely empty input,
or patterns up to the end of input. This is a composite rule;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"patterns up to the end of the rule" isn't clear. I think you mean that it's useful when used as a predicate, but we probably need some more words.

It should NOT be placed inside a character set or quote.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line seems obvious to me (we don't say this about any of the other primitives), and as such, it was confusing. Maybe remove?

For example <code>"f" !.</code>
will test for end of input after the character "f".</p>
<div class="example">
<div>
<div><em>Example:</em> <code>no_input = !.</code></div>
<div><em>Matches:</em> <code>""</code></div>
<div><em>Does not match:</em> <code>"f"</code></div>
</div>
<div class="try">
<em>Try it:</em>
<input type="text" value="" class="exampleInput" name="no_input">
<div class="result"></div>
</div>
</div>

<div class="example">
<div>
<div><em>Example:</em> <code>end_of_input = "f" !.</code></div>
<div><em>Matches:</em> <code>"f[EOI]"</code></div>
<div><em>Does not match:</em> <code>"f [EOI]"</code>, <code>""</code></div>
</div>
<div class="try">
<em>Try it:</em>
<input type="text" value="f" class="exampleInput" name="end_of_input">
<div class="result"></div>
</div>
</div>
</dd>

<dt><code>[<em>characters</em>]</code></dt>

<dd>
Expand Down
92 changes: 90 additions & 2 deletions docs/js/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function peg$parse(input, options) {
var peg$FAILED = {};
var peg$source = options.grammarSource;

var peg$startRuleFunctions = { literal: peg$parseliteral, literal_i: peg$parseliteral_i, any: peg$parseany, class: peg$parseclass, not_class_i: peg$parsenot_class_i, rule: peg$parserule, child: peg$parsechild, paren: peg$parseparen, paren_pluck: peg$parseparen_pluck, star: peg$parsestar, plus: peg$parseplus, repetition: peg$parserepetition, maybe: peg$parsemaybe, posAssertion: peg$parseposAssertion, negAssertion: peg$parsenegAssertion, posPredicate: peg$parseposPredicate, negPredicate: peg$parsenegPredicate, dollar: peg$parsedollar, label: peg$parselabel, pluck_1: peg$parsepluck_1, pluck_2: peg$parsepluck_2, sequence: peg$parsesequence, action: peg$parseaction, alt: peg$parsealt, rest: peg$parserest };
var peg$startRuleFunctions = { literal: peg$parseliteral, literal_i: peg$parseliteral_i, any: peg$parseany, class: peg$parseclass, not_class_i: peg$parsenot_class_i, rule: peg$parserule, child: peg$parsechild, paren: peg$parseparen, paren_pluck: peg$parseparen_pluck, star: peg$parsestar, plus: peg$parseplus, repetition: peg$parserepetition, maybe: peg$parsemaybe, posAssertion: peg$parseposAssertion, negAssertion: peg$parsenegAssertion, posPredicate: peg$parseposPredicate, negPredicate: peg$parsenegPredicate, dollar: peg$parsedollar, label: peg$parselabel, pluck_1: peg$parsepluck_1, pluck_2: peg$parsepluck_2, sequence: peg$parsesequence, action: peg$parseaction, alt: peg$parsealt, rest: peg$parserest, no_input: peg$parseno_input, end_of_input: peg$parseend_of_input };
var peg$startRuleFunction = peg$parseliteral;

var peg$c0 = "foo";
Expand All @@ -184,6 +184,7 @@ function peg$parse(input, options) {
var peg$c5 = "bar";
var peg$c6 = " ";
var peg$c7 = "c";
var peg$c8 = "f";

var peg$r0 = /^[a-z]/;
var peg$r1 = /^[^a-z]/i;
Expand All @@ -205,6 +206,7 @@ function peg$parse(input, options) {
var peg$e12 = peg$literalExpectation("c", false);
var peg$e13 = peg$classExpectation([["a", "c"]], false, false);
var peg$e14 = peg$otherExpectation("The rest of the input");
var peg$e15 = peg$literalExpectation("f", false);

var peg$f0 = function(match, rest) { return {match, rest}; };
var peg$f1 = function(match, rest) { return {match, rest}; };
Expand Down Expand Up @@ -235,6 +237,8 @@ function peg$parse(input, options) {
var peg$f26 = function() { return location(); };
var peg$f27 = function(match, rest) { return {match, rest}; };
var peg$f28 = function(match, rest) { return {match, rest}; };
var peg$f29 = function(match, rest) { return {match, rest}; };
var peg$f30 = function(match, rest) { return {match, rest}; };
var peg$currPos = options.peg$currPos | 0;
var peg$savedPos = peg$currPos;
var peg$posDetailsCache = [{ line: 1, column: 1 }];
Expand Down Expand Up @@ -1508,6 +1512,90 @@ function peg$parse(input, options) {
return s0;
}

function peg$parseno_input() {
var s0, s1, s2;

s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
if (input.length > peg$currPos) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e2); }
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = undefined;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
s2 = peg$parserest();
peg$savedPos = s0;
s0 = peg$f29(s1, s2);
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}

return s0;
}

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

s0 = peg$currPos;
s1 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 102) {
s2 = peg$c8;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e15); }
}
if (s2 !== peg$FAILED) {
s3 = peg$currPos;
peg$silentFails++;
if (input.length > peg$currPos) {
s4 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e2); }
}
peg$silentFails--;
if (s4 === peg$FAILED) {
s3 = undefined;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s2 = [s2, s3];
s1 = s2;
} else {
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$f30(s1, s2);
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}

return s0;
}

peg$result = peg$startRuleFunction();

if (options.peg$library) {
Expand Down Expand Up @@ -1537,7 +1625,7 @@ function peg$parse(input, options) {
}

root.peggyExamples = {
StartRules: ["literal", "literal_i", "any", "class", "not_class_i", "rule", "child", "paren", "paren_pluck", "star", "plus", "repetition", "maybe", "posAssertion", "negAssertion", "posPredicate", "negPredicate", "dollar", "label", "pluck_1", "pluck_2", "sequence", "action", "alt", "rest"],
StartRules: ["literal", "literal_i", "any", "class", "not_class_i", "rule", "child", "paren", "paren_pluck", "star", "plus", "repetition", "maybe", "posAssertion", "negAssertion", "posPredicate", "negPredicate", "dollar", "label", "pluck_1", "pluck_2", "sequence", "action", "alt", "rest", "no_input", "end_of_input"],
SyntaxError: peg$SyntaxError,
parse: peg$parse
};
Expand Down
4 changes: 4 additions & 0 deletions docs/js/examples.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ action = match:(" "+ "a" { return location(); }) rest:rest { return {match, rest
alt = match:("a" / "b" / "c") rest:rest { return {match, rest}; }

rest "The rest of the input" = $.*

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is a nitpick, but can you move your new rule above rest please?

no_input = match:!. rest:rest { return {match, rest}; }

end_of_input = match:("f" !.) rest:rest { return {match, rest}; }
2 changes: 1 addition & 1 deletion docs/js/test-bundle.min.js

Large diffs are not rendered by default.