From 7fc491412db5a817fe3aa7bd70cfbbbb98242404 Mon Sep 17 00:00:00 2001 From: David Majda Date: Wed, 14 Apr 2010 21:29:05 +0200 Subject: [PATCH] Work around the fact that IE does not recognize "\v" in strings. --- examples/javascript.pegjs | 2 +- lib/metagrammar.js | 2 +- lib/metagrammar.pegjs | 2 +- test/metagrammar-test.js | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/javascript.pegjs b/examples/javascript.pegjs index 2fd06f2..9ee3fd9 100644 --- a/examples/javascript.pegjs +++ b/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 { diff --git a/lib/metagrammar.js b/lib/metagrammar.js index 53f9095..daab3e0 100644 --- a/lib/metagrammar.js +++ b/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; diff --git a/lib/metagrammar.pegjs b/lib/metagrammar.pegjs index 76d4f39..147d86c 100644 --- a/lib/metagrammar.pegjs +++ b/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"; } diff --git a/test/metagrammar-test.js b/test/metagrammar-test.js index 1664eec..31f7b40 100644 --- a/test/metagrammar-test.js +++ b/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);