From 2231d67cef5ab10d91a3ec6c0cf7f860c8782ad5 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Thu, 31 Dec 2009 13:26:38 -0500 Subject: [PATCH] making assignment token detection a regex like all the others --- lib/coffee_script/lexer.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/coffee_script/lexer.rb b/lib/coffee_script/lexer.rb index 56f45c8c..3fb03c7b 100644 --- a/lib/coffee_script/lexer.rb +++ b/lib/coffee_script/lexer.rb @@ -29,6 +29,7 @@ module CoffeeScript REGEX = /\A(\/(.*?)[^\\]\/[imgy]{0,4})/ MULTI_DENT = /\A((\n([ \t]*)?)+)/ LAST_DENT = /\n([ \t]*)/ + ASSIGNMENT = /\A(:|=)\Z/ # Token cleaning regexes. JS_CLEANER = /(\A`|`\Z)/ @@ -36,9 +37,6 @@ module CoffeeScript COMMENT_CLEANER = /(^\s*#|\n\s*$)/ NO_NEWLINE = /\A([+\*&|\/\-%=<>:!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)\Z/ - # Assignment tokens. - ASSIGN = [':', '='] - # Scan by attempting to match tokens one character at a time. Slow and steady. def tokenize(code) @code = code.chomp # Cleanup code by remove extra line breaks @@ -174,7 +172,7 @@ module CoffeeScript value = @chunk[OPERATOR, 1] tag_parameters if value && value.match(CODE) value ||= @chunk[0,1] - tag = ASSIGN.include?(value) ? :ASSIGN : value + tag = value.match(ASSIGNMENT) ? :ASSIGN : value token(tag, value) @i += value.length end