mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
FIXES #383: Numbers that start with . not recognized
This commit is contained in:
12
lib/lexer.js
12
lib/lexer.js
@@ -157,12 +157,18 @@
|
||||
};
|
||||
// Matches numbers, including decimals, hex, and exponential notation.
|
||||
Lexer.prototype.number_token = function() {
|
||||
var number;
|
||||
var leading, number;
|
||||
if (!(number = this.match(NUMBER, 1))) {
|
||||
return false;
|
||||
}
|
||||
this.token('NUMBER', number);
|
||||
this.i += number.length;
|
||||
if (starts(number, (leading = '.') + leading)) {
|
||||
while (starts(number, leading)) {
|
||||
this.token(leading, leading);
|
||||
number = number.substring(leading.length);
|
||||
}
|
||||
}
|
||||
this.token('NUMBER', number);
|
||||
return true;
|
||||
};
|
||||
// Matches strings, including multi-line strings. Ensures that quotation marks
|
||||
@@ -655,7 +661,7 @@
|
||||
JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED);
|
||||
// Token matching regexes.
|
||||
IDENTIFIER = /^([a-zA-Z\$_](\w|\$)*)/;
|
||||
NUMBER = /^(\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\.[0-9]+)?(e[+\-]?[0-9]+)?)))\b/i;
|
||||
NUMBER = /^(((\b0(x|X)[0-9a-fA-F]+)|(((\b[0-9]+(\.[0-9]+)?)|([\.]+[0-9]+))(e[+\-]?[0-9]+)?)))\b/i;
|
||||
HEREDOC = /^("{6}|'{6}|"{3}\n?([\s\S]*?)\n?([ \t]*)"{3}|'{3}\n?([\s\S]*?)\n?([ \t]*)'{3})/;
|
||||
INTERPOLATION = /^\$([a-zA-Z_@]\w*(\.\w+)*)/;
|
||||
OPERATOR = /^([+\*&|\/\-%=<>:!?]+)([ \t]*)/;
|
||||
|
||||
Reference in New Issue
Block a user