aboutsummaryrefslogtreecommitdiff
path: root/cordova/node_modules/pegjs/lib/compiler/js.js
diff options
context:
space:
mode:
authorKumar Priyansh <[email protected]>2019-01-19 12:37:14 +0530
committerKumar Priyansh <[email protected]>2019-01-19 12:37:14 +0530
commitdcdfc94cb39dfe2c39925a0145ffa45e2d061c30 (patch)
tree4f6379d955555b298c0e7b83a67e264240ee5614 /cordova/node_modules/pegjs/lib/compiler/js.js
parent76f7b3678d3f1ff99c3935a774d420453b0c3cb9 (diff)
downloadWeatherApp-dcdfc94cb39dfe2c39925a0145ffa45e2d061c30.tar.xz
WeatherApp-dcdfc94cb39dfe2c39925a0145ffa45e2d061c30.zip
Initial Upload via GIT
Diffstat (limited to 'cordova/node_modules/pegjs/lib/compiler/js.js')
-rw-r--r--cordova/node_modules/pegjs/lib/compiler/js.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/cordova/node_modules/pegjs/lib/compiler/js.js b/cordova/node_modules/pegjs/lib/compiler/js.js
new file mode 100644
index 0000000..3da25a4
--- /dev/null
+++ b/cordova/node_modules/pegjs/lib/compiler/js.js
@@ -0,0 +1,58 @@
+"use strict";
+
+function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
+
+/* JavaScript code generation helpers. */
+var js = {
+ stringEscape: function(s) {
+ /*
+ * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string
+ * literal except for the closing quote character, backslash, carriage
+ * return, line separator, paragraph separator, and line feed. Any character
+ * may appear in the form of an escape sequence.
+ *
+ * For portability, we also escape all control and non-ASCII characters.
+ * Note that the "\v" escape sequence is not used because IE does not like
+ * it.
+ */
+ return s
+ .replace(/\\/g, '\\\\') // backslash
+ .replace(/"/g, '\\"') // closing double quote
+ .replace(/\0/g, '\\0') // null
+ .replace(/\x08/g, '\\b') // backspace
+ .replace(/\t/g, '\\t') // horizontal tab
+ .replace(/\n/g, '\\n') // line feed
+ .replace(/\f/g, '\\f') // form feed
+ .replace(/\r/g, '\\r') // carriage return
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
+ .replace(/[\x10-\x1F\x7F-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
+ .replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
+ .replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
+ },
+
+ regexpClassEscape: function(s) {
+ /*
+ * Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1.
+ *
+ * For portability, we also escape all control and non-ASCII characters.
+ */
+ return s
+ .replace(/\\/g, '\\\\') // backslash
+ .replace(/\//g, '\\/') // closing slash
+ .replace(/\]/g, '\\]') // closing bracket
+ .replace(/\^/g, '\\^') // caret
+ .replace(/-/g, '\\-') // dash
+ .replace(/\0/g, '\\0') // null
+ .replace(/\t/g, '\\t') // horizontal tab
+ .replace(/\n/g, '\\n') // line feed
+ .replace(/\v/g, '\\x0B') // vertical tab
+ .replace(/\f/g, '\\f') // form feed
+ .replace(/\r/g, '\\r') // carriage return
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
+ .replace(/[\x10-\x1F\x7F-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
+ .replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
+ .replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
+ }
+};
+
+module.exports = js;