Text nodes: Disallow the "$" character in identifiers

The "$" character will mark text nodes in the future.
redux
David Majda 12 years ago
parent 4e46a6e46e
commit af20f024c7

@ -1383,17 +1383,6 @@ module.exports = (function(){
matchFailed("\"_\"");
}
}
if (r3 === null) {
if (input.charCodeAt(pos) === 36) {
r3 = "$";
pos++;
} else {
r3 = null;
if (reportFailures === 0) {
matchFailed("\"$\"");
}
}
}
}
if (r3 !== null) {
r4 = [];
@ -1410,17 +1399,6 @@ module.exports = (function(){
matchFailed("\"_\"");
}
}
if (r5 === null) {
if (input.charCodeAt(pos) === 36) {
r5 = "$";
pos++;
} else {
r5 = null;
if (reportFailures === 0) {
matchFailed("\"$\"");
}
}
}
}
}
while (r5 !== null) {
@ -1438,17 +1416,6 @@ module.exports = (function(){
matchFailed("\"_\"");
}
}
if (r5 === null) {
if (input.charCodeAt(pos) === 36) {
r5 = "$";
pos++;
} else {
r5 = null;
if (reportFailures === 0) {
matchFailed("\"$\"");
}
}
}
}
}
}

@ -349,11 +349,9 @@ describe("PEG.js grammar parser", function() {
it("parses identifier", function() {
expect('start = a' ).toParseAs(ruleRefGrammar("a"));
expect('start = _' ).toParseAs(ruleRefGrammar("_"));
expect('start = $' ).toParseAs(ruleRefGrammar("$"));
expect('start = aa' ).toParseAs(ruleRefGrammar("aa"));
expect('start = a0' ).toParseAs(ruleRefGrammar("a0"));
expect('start = a_' ).toParseAs(ruleRefGrammar("a_"));
expect('start = a$' ).toParseAs(ruleRefGrammar("a$"));
expect('start = abcd').toParseAs(ruleRefGrammar("abcd"));
expect('start = a\n').toParseAs(ruleRefGrammar("a"));

@ -190,9 +190,12 @@ dot = "." __ { return "."; }
*
* The simplifications were made just to make the implementation little bit
* easier, there is no "philosophical" reason behind them.
*
* Contrary to ECMA 262, the "$" character is not valid because it serves other
* purpose in the grammar.
*/
identifier "identifier"
= head:(letter / "_" / "$") tail:(letter / digit / "_" / "$")* __ {
= head:(letter / "_") tail:(letter / digit / "_")* __ {
return head + tail.join("");
}

Loading…
Cancel
Save