Don't use the "i" suffix for case-insensitive class descriptions

If the described class is case-sensitive, nothing changes.

If the described class is case-insensitive, its description doesn't
indicate that anymore. The indication was awkward and it was meaningful
only for parser users familiar with PEG.js grammar syntax (typically a
minority). For cases where case insensitivity indication is vital, named
rules can be used to customize the reporting.

Note that literal descriptions already ignore the case-sensitivity flag;
this commit only makes things consistent.
redux
David Majda 9 years ago
parent b2d7f9e02f
commit d48983dd6a

@ -632,7 +632,7 @@ function generateBytecode(ast) {
+ classDescriptionEscape(part[1])
: classDescriptionEscape(part);
}).join("")
+ "]" + (node.ignoreCase ? "i" : "");
+ "]";
regexpIndex = addConst(regexp);
expectedIndex = addConst([

@ -288,7 +288,7 @@
peg$c129 = /^[0-9]/,
peg$c130 = { type: "class", value: "[0-9]", description: "[0-9]" },
peg$c131 = /^[0-9a-f]/i,
peg$c132 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
peg$c132 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]" },
peg$c133 = ".",
peg$c134 = { type: "literal", value: ".", description: "\".\"" },
peg$c135 = function() { return { type: "any", location: location() }; },

@ -616,7 +616,7 @@ describe("compiler pass |generateBytecode|", function() {
it("defines correct constants", function() {
expect(pass).toChangeAST('start = [a]i', constsDetails([
'/^[a]/i',
'{ type: "class", value: "[a]i", description: "[a]i" }'
'{ type: "class", value: "[a]i", description: "[a]" }'
]));
});
});

Loading…
Cancel
Save