1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

one step at a time

This commit is contained in:
Jeremy Ashkenas 2010-03-21 22:05:49 -04:00
parent 4f8ae3ccbe
commit 162f6b9d5c
2 changed files with 7 additions and 7 deletions

View file

@ -122,14 +122,14 @@
// referenced as property names here, so you can still do `jQuery.is()` even // referenced as property names here, so you can still do `jQuery.is()` even
// though `is` means `===` otherwise. // though `is` means `===` otherwise.
Lexer.prototype.identifier_token = function identifier_token() { Lexer.prototype.identifier_token = function identifier_token() {
var id, space, tag; var accessed, id, tag;
if (!((id = this.match(IDENTIFIER, 1)))) { if (!((id = this.match(IDENTIFIER, 1)))) {
return false; return false;
} }
this.name_access_type(); this.name_access_type();
space = this.prev() && this.prev().spaced; accessed = include(ACCESSORS, this.tag(0));
tag = 'IDENTIFIER'; tag = 'IDENTIFIER';
if (include(KEYWORDS, id) && !(include(ACCESSORS, this.tag(0)) && !space)) { if (!accessed && include(KEYWORDS, id)) {
tag = id.toUpperCase(); tag = id.toUpperCase();
} }
if (include(RESERVED, id)) { if (include(RESERVED, id)) {
@ -139,7 +139,7 @@
tag = 'LEADING_WHEN'; tag = 'LEADING_WHEN';
} }
this.i += id.length; this.i += id.length;
if (space && include(COFFEE_ALIASES, id)) { if (!accessed && include(COFFEE_ALIASES, id)) {
tag = (id = CONVERSIONS[id]); tag = (id = CONVERSIONS[id]);
} }
this.token(tag, id); this.token(tag, id);

View file

@ -94,13 +94,13 @@ exports.Lexer: class Lexer
identifier_token: -> identifier_token: ->
return false unless id: @match IDENTIFIER, 1 return false unless id: @match IDENTIFIER, 1
@name_access_type() @name_access_type()
space: @prev() and @prev().spaced accessed: include ACCESSORS, @tag(0)
tag: 'IDENTIFIER' tag: 'IDENTIFIER'
tag: id.toUpperCase() if include(KEYWORDS, id) and not (include(ACCESSORS, @tag(0)) and not space) tag: id.toUpperCase() if not accessed and include(KEYWORDS, id)
@identifier_error id if include RESERVED, id @identifier_error id if include RESERVED, id
tag: 'LEADING_WHEN' if tag is 'WHEN' and include LINE_BREAK, @tag() tag: 'LEADING_WHEN' if tag is 'WHEN' and include LINE_BREAK, @tag()
@i += id.length @i += id.length
tag: id: CONVERSIONS[id] if space and include(COFFEE_ALIASES, id) tag: id: CONVERSIONS[id] if not accessed and include(COFFEE_ALIASES, id)
@token(tag, id) @token(tag, id)
true true