Browse Source

Work around the fact that IE does not recognize "\v" in strings.

redux
David Majda 12 years ago
parent
commit
7fc491412d
  1. 2
      examples/javascript.pegjs
  2. 2
      lib/metagrammar.js
  3. 2
      lib/metagrammar.pegjs
  4. 6
      test/metagrammar-test.js

2
examples/javascript.pegjs

@ -230,7 +230,7 @@ SingleEscapeCharacter: ['"\\bfnrtv] {
.replace("n", "\n")
.replace("r", "\r")
.replace("t", "\t")
.replace("v", "\v")
.replace("v", "\x0B") // IE does not recognize "\v".
}
NonEscapeCharacter: (!EscapeCharacter / LineTerminator) SourceCharacter {

2
lib/metagrammar.js

@ -2394,7 +2394,7 @@ PEG.grammarParser = (function(){
.replace("n", "\n")
.replace("r", "\r")
.replace("t", "\t")
.replace("v", "\v")
.replace("v", "\x0B") // IE does not recognize "\v".
}).apply(this, result234)
: null;

2
lib/metagrammar.pegjs

@ -166,7 +166,7 @@ simpleEscapeSequence: "\\" !(digit / "x" / "u" / eolChar) . {
.replace("n", "\n")
.replace("r", "\r")
.replace("t", "\t")
.replace("v", "\v")
.replace("v", "\x0B") // IE does not recognize "\v".
}
zeroEscapeSequence: "\\0" !digit { return "\0"; }

6
test/metagrammar-test.js

@ -327,7 +327,8 @@ with (PEG.Grammar) {
grammarParserParses('start: "\\n"', literalGrammar("\n"));
grammarParserParses('start: "\\r"', literalGrammar("\r"));
grammarParserParses('start: "\\t"', literalGrammar("\t"));
grammarParserParses('start: "\\v"', literalGrammar("\v"));
/* IE does not recognize "\v". */
grammarParserParses('start: "\\v"', literalGrammar("\x0B"));
grammarParserParses('start: "\\a"', literalGrammar("a"));
});
@ -430,7 +431,8 @@ with (PEG.Grammar) {
/* Canonical whitespace is " ". */
test("parses whitespace", function() {
grammarParserParses('start:\t"abcd"', simpleGrammar);
grammarParserParses('start:\v"abcd"', simpleGrammar);
/* IE does not recognize "\v". */
grammarParserParses('start:\x0B"abcd"', simpleGrammar);
grammarParserParses('start:\f"abcd"', simpleGrammar);
grammarParserParses('start: "abcd"', simpleGrammar);
grammarParserParses('start:\u00A0"abcd"', simpleGrammar);

Loading…
Cancel
Save