Ox.tokenize: handle '.1'

This commit is contained in:
rolux 2012-06-21 08:08:45 +02:00
parent 625325a6e6
commit 71218cd61f

View file

@ -903,8 +903,8 @@ Ox.tokenize <f> Tokenizes JavaScript
14
> Ox.tokenize('return /foo/gi;')[2].value.length
7
> Ox.tokenize('[0xFF, 1e1, 1e+1, 1e-1, 1e+1+1]').length
17
> Ox.tokenize('[.1, 0xFF, 1e1, 1e+1, 1e-1, 1e+1+1]').length
20
@*/
Ox.tokenize = (function() {
@ -999,7 +999,10 @@ Ox.tokenize = (function() {
} else if (linebreak.indexOf(char) > -1) {
type = 'linebreak';
while (linebreak.indexOf(source[++cursor]) > -1) {}
} else if (number.indexOf(char) > -1) {
} else if (
number.indexOf(char) > -1
|| char == '.' && number.indexOf(source[cursor + 1]) > -1
) {
type = 'number';
while ((number + '.abcdefxABCDEFX+-').indexOf(source[++cursor]) > -1) {
if (
@ -1016,6 +1019,7 @@ Ox.tokenize = (function() {
}
while (regexp.indexOf(source[++cursor]) > -1) {}
} else if (operator.indexOf(char) > -1) {
// has to be tested after number and regexp
type = 'operator';
while (operator.indexOf(char += source[++cursor]) > -1 && cursor < length) {}
} else if (string.indexOf(delimiter = char) > -1) {