introduce escape sequence '\\' for '\' in AQL
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches06/matches06.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches06/matches06.3.query.aql
index 98f547b..c773633 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/matches06/matches06.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches06/matches06.3.query.aql
@@ -7,18 +7,18 @@
 
 for $a in [matches("mnop","."),
 matches("abcdefABCDEF","/d"),
-matches("12345","\d"),
-matches("abcdefGHIJK","\D"),
-matches("       ","\s"),
-matches("       ","\S"),
+matches("12345","\\d"),
+matches("abcdefGHIJK","\\D"),
+matches("       ","\\s"),
+matches("       ","\\S"),
 matches("Welcome to pattern matching!","[a-zA-Z_0-9]"),
 matches("!@#$%^&*()","[a-zA-Z_0-9]"),
-matches("!@#$%^&*()","[^\W]"),
-matches("!@#$%^&*","[^\w]"),
-matches("0xffff","[\p{XDigit}]"),
-matches("FFFFFFFF","[\p{XDigit}]"),
-matches("abcdefgh","[\p{javaLowerCase}]"),
-matches("ABCDEF","[\p{javaLowerCase}]"),
-matches(codepoint-to-string([0163]),"[\p{Sc}]")]
+matches("!@#$%^&*()","[^\\W]"),
+matches("!@#$%^&*","[^\\w]"),
+matches("0xffff","[\\p{XDigit}]"),
+matches("FFFFFFFF","[\\p{XDigit}]"),
+matches("abcdefgh","[\\p{javaLowerCase}]"),
+matches("ABCDEF","[\\p{javaLowerCase}]"),
+matches(codepoint-to-string([0163]),"[\\p{Sc}]")]
 return $a
 
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/startwith02/startwith02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/startwith02/startwith02.3.query.aql
index 7d6c8c1..4622e7d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/startwith02/startwith02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/startwith02/startwith02.3.query.aql
@@ -13,7 +13,7 @@
 start-with("abcdef",lowercase("ABCDEf")),
 start-with("abcdef","abcdef"),
 start-with("abcdef","abc "),
-start-with("abc\tdef","abc\t"),
+start-with("abc\\tdef","abc\\t"),
 start-with(" abcdef","abc"),
 start-with("0x1FF","0"),
 start-with("<ID>","<"),
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strlen02/strlen02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/strlen02/strlen02.3.query.aql
index 564ca83..3915cdf 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/strlen02/strlen02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strlen02/strlen02.3.query.aql
@@ -12,7 +12,7 @@
 string-length("abcd EFGH ijkl MNOP qrstu"),
 string-length("   Hello World    !!!!....:-)"),
 string-length(string-concat(["test string to","concatenate"])),
-string-length("~!@#$%^&*()_+{}:?<>/.,';`][\")]
+string-length("~!@#$%^&*()_+{}:?<>/.,';`][\\")]
 return $a
 */
 
@@ -22,5 +22,5 @@
 string-length("abcdEFGHijklMNOPqrstu"),
 string-length("abcd EFGH ijkl MNOP qrstu"),
 string-length("   Hello World    !!!!....:-)"),
-string-length("~!@#$%^&*()_+{}:?<>/.,';`][\")]
+string-length("~!@#$%^&*()_+{}:?<>/.,';`][\\")]
 return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02/strtocpt02.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02/strtocpt02.3.query.aql
index 8ce8ac8..246a333 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02/strtocpt02.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02/strtocpt02.3.query.aql
@@ -4,5 +4,5 @@
  * Date         : 7th Aug 2012
  */
 
-let $x := "\"'-=_+|\,./<>?:;~`"
+let $x := "\"'-=_+|\\,./<>?:;~`"
 return string-to-codepoint($x)
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/parser/ScopeChecker.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/parser/ScopeChecker.java
index b1c4c5d..d95596b 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/parser/ScopeChecker.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/parser/ScopeChecker.java
@@ -157,7 +157,8 @@
     public static final String removeQuotesAndEscapes(String s) {
         char q = s.charAt(0); // simple or double quote
         String stripped = s.substring(1, s.length() - 1);
-        return stripped.replaceAll("\\\\" + q, "\\" + q);
+        stripped = stripped.replace("\\" + q, "" + q);
+        return stripped.replace("\\\\", "\\");
     }
 
     public String extractFragment(int beginLine, int beginColumn, int endLine, int endColumn) {
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index 1044d2e..ba843f0 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -2297,9 +2297,11 @@
 <DEFAULT,IN_DBL_BRACE>
 TOKEN :
 {
-    <STRING_LITERAL : ("\"" (<EscapeQuot> | ~["\""])* "\"") | ("\'"(<EscapeApos> | ~["\'"])* "\'")>
+    <STRING_LITERAL : ("\"" (<EscapeQuot> | <EscapeBslash> | ~["\"","\\"])* "\"") 
+        | ("\'"(<EscapeApos> | <EscapeBslash> | ~["\'","\\"])* "\'")>
   | < #EscapeQuot: "\\\"" >
   | < #EscapeApos: "\\\'" >
+  | < #EscapeBslash: "\\\\" >
 }
 
 <DEFAULT,IN_DBL_BRACE>