Ox.tokenize: handle hex numbers and numbers with exponent
This commit is contained in:
parent
c4ad59bdb6
commit
56c6ef98c7
1 changed files with 10 additions and 2 deletions
|
@ -892,8 +892,9 @@ Ox.tokenize <f> Tokenizes JavaScript
|
|||
14
|
||||
> Ox.tokenize('return /foo/g;')[2].value.length
|
||||
6
|
||||
> Ox.tokenize('[0xFF, 1e1, 1e+1, 1e-1, 1e+1+1]').length
|
||||
17
|
||||
@*/
|
||||
// FIXME: numbers (hex, exp, etc.)
|
||||
Ox.tokenize = (function() {
|
||||
|
||||
// see https://github.com/mozilla/narcissus/blob/master/lib/lexer.js
|
||||
|
@ -989,7 +990,14 @@ Ox.tokenize = (function() {
|
|||
while (linebreak.indexOf(source[++cursor]) > -1) {}
|
||||
} else if (number.indexOf(char) > -1) {
|
||||
type = 'number';
|
||||
while ((number + '.').indexOf(source[++cursor]) > -1) {}
|
||||
while ((number + '.abcdefxABCDEFX+-').indexOf(source[++cursor]) > -1) {
|
||||
if (
|
||||
source[cursor - 1] != 'e' && source[cursor - 1] != 'E'
|
||||
&& (source[cursor] == '+' || source[cursor] == '-')
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (char == '/' && isRegExp(tokens)) {
|
||||
type = 'regexp';
|
||||
while ((char = source[++cursor]) != '/' && cursor < length) {
|
||||
|
|
Loading…
Reference in a new issue