From 61a39e04fcfcd50b1654d1fa2cbb732b7884f2a0 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sun, 12 Sep 2010 15:48:31 -0400 Subject: [PATCH] Issue #680. @::prop versus this::prop, fixed lexing regex. --- lib/lexer.js | 2 +- src/lexer.coffee | 2 +- test/test_expressions.coffee | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 7095ed3d..78dc4a79 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -629,7 +629,7 @@ MULTILINER = /\n/g; NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/; HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g; - ASSIGNED = /^\s*(([a-zA-Z\$_@]\w*|["'][^\r\n]+?["']|\d+)[ \t]*?[:=][^=])/; + ASSIGNED = /^\s*(([a-zA-Z\$_@]\w*|["'][^\r\n]+?["']|\d+)[ \t]*?[:=][^:=])/; NEXT_CHARACTER = /^\s*(\S)/; COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|=']; UNARY = ['UMINUS', 'UPLUS', '!', '!!', '~', 'TYPEOF', 'DELETE']; diff --git a/src/lexer.coffee b/src/lexer.coffee index 9344bffa..f21444d1 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -545,7 +545,7 @@ JS_CLEANER = /(^`|`$)/g MULTILINER = /\n/g NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/ HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g -ASSIGNED = /^\s*(([a-zA-Z\$_@]\w*|["'][^\r\n]+?["']|\d+)[ \t]*?[:=][^=])/ +ASSIGNED = /^\s*(([a-zA-Z\$_@]\w*|["'][^\r\n]+?["']|\d+)[ \t]*?[:=][^:=])/ NEXT_CHARACTER = /^\s*(\S)/ # Compound assignment tokens. diff --git a/test/test_expressions.coffee b/test/test_expressions.coffee index 9c9500fc..9572a6c7 100644 --- a/test/test_expressions.coffee +++ b/test/test_expressions.coffee @@ -25,4 +25,16 @@ obj = { } ok obj.num is obj.func() -ok obj.num is obj.result \ No newline at end of file +ok obj.num is obj.result + + +# Should be able to look at prototypes on keywords. +obj = + withAt: -> @::prop + withThis: -> this::prop + proto: + prop: 100 + +obj.prototype = obj.proto +ok obj.withAt() is 100 +ok obj.withThis() is 100 \ No newline at end of file