lexer: fixed ASSIGNED

This commit is contained in:
satyr 2010-09-25 23:37:33 +09:00
parent 9a3b736174
commit c515aaac5a
2 changed files with 4 additions and 4 deletions

View File

@ -44,7 +44,7 @@
this.token('ALL', id);
return true;
}
forcedIdentifier = this.tagAccessor() || this.match(ASSIGNED, 1);
forcedIdentifier = this.tagAccessor() || ASSIGNED.test(this.chunk);
tag = 'IDENTIFIER';
if (include(JS_KEYWORDS, id) || !forcedIdentifier && include(COFFEE_KEYWORDS, id)) {
tag = id.toUpperCase();
@ -607,7 +607,7 @@
MULTILINER = /\n/g;
NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|not|delete|typeof|instanceof)$/;
HEREDOC_INDENT = /\n+([ \t]*)|^([ \t]+)/g;
ASSIGNED = /^\s*((?:[a-zA-Z$_@]\w*|["'][^\n]+?["']|\d+)[ \t]*?[:=][^:=])/;
ASSIGNED = /^\s*@?[$A-Za-z_][$\w]*[ \t]*?[:=][^:=>]/;
NEXT_CHARACTER = /^\s*(\S)/;
COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|='];
UNARY = ['UMINUS', 'UPLUS', '!', '!!', '~', 'TYPEOF', 'DELETE'];

View File

@ -79,7 +79,7 @@ exports.Lexer = class Lexer
if id is 'all' and @tag() is 'FOR'
@token 'ALL', id
return true
forcedIdentifier = @tagAccessor() or @match ASSIGNED, 1
forcedIdentifier = @tagAccessor() or ASSIGNED.test @chunk
tag = 'IDENTIFIER'
if include(JS_KEYWORDS, id) or
not forcedIdentifier and include(COFFEE_KEYWORDS, id)
@ -555,7 +555,7 @@ REGEX_ESCAPE = /\\[^#]/g
MULTILINER = /\n/g
NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|not|delete|typeof|instanceof)$/
HEREDOC_INDENT = /\n+([ \t]*)|^([ \t]+)/g
ASSIGNED = /^\s*((?:[a-zA-Z$_@]\w*|["'][^\n]+?["']|\d+)[ \t]*?[:=][^:=])/
ASSIGNED = /^\s*@?[$A-Za-z_][$\w]*[ \t]*?[:=][^:=>]/
NEXT_CHARACTER = /^\s*(\S)/
# Compound assignment tokens.