Added \uFEFF (BOM) to the definition of whitespace in the metagrammar.

The Rhino bug that prevented inclusion of \uFEFF among the whitespace characters
is no longer relevant here because we compile character classes into regexps
now, which avoids the infinite recursion.
This commit is contained in:
David Majda 2010-04-11 11:24:36 +02:00
parent 383c5acaa6
commit 3291c70d97
3 changed files with 5 additions and 7 deletions

View file

@ -3212,13 +3212,13 @@ PEG.grammarParser = (function(){
var savedReportMatchFailures = context.reportMatchFailures; var savedReportMatchFailures = context.reportMatchFailures;
context.reportMatchFailures = false; context.reportMatchFailures = false;
if (this._input.substr(this._pos).match(/^[   - ]/) !== null) { if (this._input.substr(this._pos).match(/^[   - ]/) !== null) {
var result301 = this._input[this._pos]; var result301 = this._input[this._pos];
this._pos++; this._pos++;
} else { } else {
var result301 = null; var result301 = null;
if (context.reportMatchFailures) { if (context.reportMatchFailures) {
this._matchFailed('[' + "   - " + ']'); this._matchFailed('[' + "   - " + ']');
} }
} }
context.reportMatchFailures = savedReportMatchFailures; context.reportMatchFailures = savedReportMatchFailures;

View file

@ -205,8 +205,5 @@ eol "end of line": "\n" / "\r\n" / "\r" / "\u2028" / "\u2029"
eolChar: [\n\r\u2028\u2029] eolChar: [\n\r\u2028\u2029]
/* /* Modelled after ECMA-262, 5th ed., 7.2. */
* Modelled after ECMA-262, 5th ed., 7.2. \uFEFF should be between the whitespace "whitespace": [ \t\v\f\u00A0\uFEFF\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]
* characters too, but it causes infinite loop in Rhino.
*/
whitespace "whitespace": [ \t\v\f\u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]

View file

@ -434,6 +434,7 @@ with (PEG.Grammar) {
grammarParserParses('start:\f"abcd"', simpleGrammar); grammarParserParses('start:\f"abcd"', simpleGrammar);
grammarParserParses('start: "abcd"', simpleGrammar); grammarParserParses('start: "abcd"', simpleGrammar);
grammarParserParses('start:\u00A0"abcd"', simpleGrammar); grammarParserParses('start:\u00A0"abcd"', simpleGrammar);
grammarParserParses('start:\uFEFF"abcd"', simpleGrammar);
grammarParserParses('start:\u1680"abcd"', simpleGrammar); grammarParserParses('start:\u1680"abcd"', simpleGrammar);
grammarParserParses('start:\u180E"abcd"', simpleGrammar); grammarParserParses('start:\u180E"abcd"', simpleGrammar);
grammarParserParses('start:\u2000"abcd"', simpleGrammar); grammarParserParses('start:\u2000"abcd"', simpleGrammar);