[Pkg-javascript-commits] [node-acorn-jsx] 203/484: Added octal and binary number support; added ES6 version checks.
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 839338b2704962098f7f0da786198219e0457734
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Wed Jul 23 21:07:57 2014 +0300
Added octal and binary number support; added ES6 version checks.
---
acorn.js | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/acorn.js b/acorn.js
index c4fe618..b866d70 100644
--- a/acorn.js
+++ b/acorn.js
@@ -692,10 +692,13 @@
case 58: ++tokPos; return finishToken(_colon);
case 63: ++tokPos; return finishToken(_question);
- // '0x' is a hexadecimal number.
case 48: // '0'
var next = input.charCodeAt(tokPos + 1);
- if (next === 120 || next === 88) return readHexNumber();
+ if (next === 120 || next === 88) return readRadixNumber(16); // '0x', '0X' - hex number
+ if (options.ecmaVersion >= 6) {
+ if (next === 111 || next === 79) return readRadixNumber(8); // '0o', '0O' - octal number
+ if (next === 98 || next === 66) return readRadixNumber(2); // '0b', '0B' - binary number
+ }
// Anything else beginning with a digit is an integer, octal
// number, or float.
case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
@@ -821,10 +824,10 @@
return total;
}
- function readHexNumber() {
+ function readRadixNumber(radix) {
tokPos += 2; // 0x
- var val = readInt(16);
- if (val == null) raise(tokStart + 2, "Expected hexadecimal number");
+ var val = readInt(radix);
+ if (val == null) raise(tokStart + 2, "Expected number in radix " + radix);
if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number");
return finishToken(_num, val);
}
@@ -862,6 +865,7 @@
var ch = input.charCodeAt(tokPos), code;
if (ch === 123) {
+ if (options.ecmaVersion < 6) unexpected();
++tokPos;
code = readHexChar();
ch = input.charCodeAt(tokPos++);
@@ -1776,6 +1780,9 @@
else if (isStatement) unexpected();
else node.id = null;
node.params = [];
+ if (options.ecmaVersion >= 6) {
+ node.defaults = [];
+ }
node.rest = null;
expect(_parenL);
for (;;) {
--
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