[Pkg-javascript-commits] [node-acorn-jsx] 202/484: ES6 Unicode Code Point Escape Sequence support.
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:28 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit a31bad6773e8605e30d40ab504098f6fc087e483
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Wed Jul 23 19:47:13 2014 +0300
ES6 Unicode Code Point Escape Sequence support.
---
acorn.js | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/acorn.js b/acorn.js
index 889b21e..c4fe618 100644
--- a/acorn.js
+++ b/acorn.js
@@ -858,6 +858,27 @@
// Read a string value, interpreting backslash-escapes.
+ function readCodePoint() {
+ var ch = input.charCodeAt(tokPos), code;
+
+ if (ch === 123) {
+ ++tokPos;
+ code = readHexChar();
+ ch = input.charCodeAt(tokPos++);
+ if (code > 0x10FFFF || ch !== 125 /* '}' */) unexpected();
+ } else {
+ code = readHexChar(4);
+ }
+
+ // UTF-16 Encoding
+ if (code <= 0xFFFF) {
+ return String.fromCharCode(code);
+ }
+ var cu1 = ((code - 0x10000) >> 10) + 0xD800;
+ var cu2 = ((code - 0x10000) & 1023) + 0xDC00;
+ return String.fromCharCode(cu1, cu2);
+ }
+
function readString(quote) {
tokPos++;
var out = "";
@@ -884,7 +905,7 @@
case 110: out += "\n"; break; // 'n' -> '\n'
case 114: out += "\r"; break; // 'r' -> '\r'
case 120: out += String.fromCharCode(readHexChar(2)); break; // 'x'
- case 117: out += String.fromCharCode(readHexChar(4)); break; // 'u'
+ case 117: out += readCodePoint(); break; // 'u'
case 85: out += String.fromCharCode(readHexChar(8)); break; // 'U'
case 116: out += "\t"; break; // 't' -> '\t'
case 98: out += "\b"; break; // 'b' -> '\b'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list