PEG.js grammar: Improve the |Code| rule a bit

Instead of matching segments between blocks character by character,
match them as a whole. Also align the style with other similar rules
(e.g. the comment ones).
redux
David Majda 10 years ago
parent 64eb5faf54
commit e78ffbba9c

File diff suppressed because one or more lines are too long

@ -595,9 +595,10 @@ describe("PEG.js grammar parser", function() {
/* Canonical Code is " code ". */ /* Canonical Code is " code ". */
it("parses Code", function() { it("parses Code", function() {
expect('start = "abcd" {a}' ).toParseAs(actionGrammar("a")); expect('start = "abcd" {a}' ).toParseAs(actionGrammar("a"));
expect('start = "abcd" {{a}}').toParseAs(actionGrammar("{a}")); expect('start = "abcd" {abc}' ).toParseAs(actionGrammar("abc"));
expect('start = "abcd" {abc}').toParseAs(actionGrammar("abc")); expect('start = "abcd" {{a}}' ).toParseAs(actionGrammar("{a}"));
expect('start = "abcd" {{a}{b}{c}}').toParseAs(actionGrammar("{a}{b}{c}"));
expect('start = "abcd" {{}').toFailToParse(); expect('start = "abcd" {{}').toFailToParse();
expect('start = "abcd" {}}').toFailToParse(); expect('start = "abcd" {}}').toFailToParse();

@ -414,7 +414,7 @@ CodeBlock "code block"
= "{" code:Code "}" { return code; } = "{" code:Code "}" { return code; }
Code Code
= $([^{}] / "{" Code "}")* = $((![{}] SourceCharacter)+ / "{" Code "}")*
/* /*
* Unicode Character Categories * Unicode Character Categories

Loading…
Cancel
Save