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

@ -596,8 +596,9 @@ describe("PEG.js grammar parser", function() {
/* Canonical Code is " code ". */
it("parses Code", function() {
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();

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

Loading…
Cancel
Save