mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
lexer: fixed broken logics (due to f051d088) and a snakecased variable
This commit is contained in:
18
lib/lexer.js
18
lib/lexer.js
@@ -35,29 +35,31 @@
|
||||
return this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
|
||||
};
|
||||
Lexer.prototype.identifierToken = function() {
|
||||
var close_index, forcedIdentifier, id, tag;
|
||||
var closeIndex, forcedIdentifier, id, tag;
|
||||
if (!(id = this.match(IDENTIFIER))) {
|
||||
return false;
|
||||
}
|
||||
this.i += id.length;
|
||||
if (id === 'all' && this.tag() === 'FOR') {
|
||||
this.token('ALL', id);
|
||||
return true;
|
||||
}
|
||||
forcedIdentifier = this.tagAccessor() || this.match(ASSIGNED, 1);
|
||||
tag = 'IDENTIFIER';
|
||||
if (include(JS_KEYWORDS, id) || !forcedIdentifier && include(COFFEE_KEYWORDS, id)) {
|
||||
tag = id.toUpperCase();
|
||||
if (tag === 'WHEN' && include(LINE_BREAK, this.tag())) {
|
||||
tag = 'LEADING_WHEN';
|
||||
} else if (include(UNARY, tag)) {
|
||||
tag = 'UNARY';
|
||||
}
|
||||
} else if (id === 'all' && this.tag() === 'FOR') {
|
||||
tag = 'ALL';
|
||||
}
|
||||
if (include(UNARY, tag)) {
|
||||
tag = 'UNARY';
|
||||
} else if (include(JS_FORBIDDEN, id)) {
|
||||
if (include(JS_FORBIDDEN, id)) {
|
||||
if (forcedIdentifier) {
|
||||
tag = 'STRING';
|
||||
id = ("\"" + (id) + "\"");
|
||||
if (forcedIdentifier === 'accessor') {
|
||||
close_index = true;
|
||||
closeIndex = true;
|
||||
if (this.tag() !== '@') {
|
||||
this.tokens.pop();
|
||||
}
|
||||
@@ -78,7 +80,7 @@
|
||||
}
|
||||
}
|
||||
this.token(tag, id);
|
||||
if (close_index) {
|
||||
if (closeIndex) {
|
||||
this.token(']', ']');
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user