From 9cc7d6af27a206c8d6a393985c7965fb718bc53a Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Mon, 11 Jan 2010 08:46:50 -0500 Subject: [PATCH] little lexer tweak --- documentation/index.html.erb | 2 +- lib/coffee_script/lexer.rb | 2 +- test/fixtures/execution/test_array_comprehension.coffee | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/index.html.erb b/documentation/index.html.erb index f79ff39f..47622c92 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -592,7 +592,7 @@ coffee --print app/scripts/*.coffee > concatenation.js

0.2.3 Axed the unsatisfactory ino keyword, replacing it with of for - object comprehensions. They now look like: for key, value of object. + object comprehensions. They now look like: for prop, value of object.

diff --git a/lib/coffee_script/lexer.rb b/lib/coffee_script/lexer.rb index 575d7108..2abe4b8a 100644 --- a/lib/coffee_script/lexer.rb +++ b/lib/coffee_script/lexer.rb @@ -87,7 +87,7 @@ module CoffeeScript # 'if' will result in an [:IF, "if"] token. tag = KEYWORDS.include?(identifier) ? identifier.upcase.to_sym : :IDENTIFIER tag = :LEADING_WHEN if tag == :WHEN && [:OUTDENT, :INDENT, "\n"].include?(last_tag) - @tokens[-1][0] = :PROPERTY_ACCESS if tag == :IDENTIFIER && last_value == '.' && !(@tokens[-2][1] == '.') + @tokens[-1][0] = :PROPERTY_ACCESS if tag == :IDENTIFIER && last_value == '.' && !(@tokens[-2] && @tokens[-2][1] == '.') @tokens[-1][0] = :PROTOTYPE_ACCESS if tag == :IDENTIFIER && last_value == '::' token(tag, identifier) @i += identifier.length diff --git a/test/fixtures/execution/test_array_comprehension.coffee b/test/fixtures/execution/test_array_comprehension.coffee index 5599ba2f..d39ce6d4 100644 --- a/test/fixtures/execution/test_array_comprehension.coffee +++ b/test/fixtures/execution/test_array_comprehension.coffee @@ -5,8 +5,8 @@ print(results.join(',') is '2,18') obj: {one: 1, two: 2, three: 3} -names: key + '!' for key of obj -odds: key + '!' for key, value of obj when value % 2 isnt 0 +names: prop + '!' for prop of obj +odds: prop + '!' for prop, value of obj when value % 2 isnt 0 print(names.join(' ') is "one! two! three!") print(odds.join(' ') is "one! three!")