PEG.js grammar: Extract the |AnyMatcher| rule

This makes the |Primary| rule a bit more tidy. Also, matching the |.|
character really belongs to the lexical part of the grammar, next to
literals and character classes.
redux
David Majda 10 years ago
parent c0df01b092
commit 4ce7593f5f

File diff suppressed because it is too large Load Diff

@ -561,6 +561,11 @@ describe("PEG.js grammar parser", function() {
/* Digit rules are not tested. */
/* Canonical AnyMatcher is ".". */
it("parses CodeAnymatcher", function() {
expect('start = .').toParseAs(oneRuleGrammar({ type: "any" }));
});
/* Canonical CodeBlock is "{ code }". */
it("parses CodeBlock", function() {
expect('start = "abcd" { code }').toParseAs(actionGrammar(" code "));

@ -166,7 +166,7 @@ Primary
}
/ LiteralMatcher
/ CharacterClassMatcher
/ "." { return { type: "any" }; }
/ AnyMatcher
/ "(" __ expression:Expression __ ")" { return expression; }
/* "Lexical" elements */
@ -394,6 +394,9 @@ DecimalDigit
HexDigit
= [0-9a-f]i
AnyMatcher
= "." { return { type: "any" }; }
CodeBlock "code block"
= "{" code:Code "}" { return code; }

Loading…
Cancel
Save