allowing @properties to be referenced in naked interpolations

This commit is contained in:
Jeremy Ashkenas
2010-03-05 21:05:31 -05:00
parent d250e9e9cc
commit 4c3b0b9a74
3 changed files with 19 additions and 7 deletions

View File

@@ -73,7 +73,7 @@ ASSIGNMENT : /^(:|=)$/
# Interpolation matching regexes.
INTERPOLATED_EXPRESSION: /(^|[\s\S]*?(?:[\\]|\\\\)?)(\${[\s\S]*?(?:[^\\]|\\\\)})/
INTERPOLATED_IDENTIFIER: /(^|[\s\S]*?(?:[\\]|\\\\)?)(\$([a-zA-Z_]\w*))/
INTERPOLATED_IDENTIFIER: /(^|[\s\S]*?(?:[\\]|\\\\)?)(\$([a-zA-Z_@]\w*))/
# Token cleaning regexes.
JS_CLEANER : /(^`|`$)/g
@@ -367,7 +367,7 @@ exports.Lexer: class Lexer
tokens.push ['STRING', quote + before.substring(0, before.length - 1) + expression + quote] if before.length
else
tokens.push ['STRING', quote + before + quote] if before.length
nested: lexer.tokenize '(' + expression.substring(2, expression.length - 1) + ')', {rewrite: no}
nested: lexer.tokenize expression.substring(2, expression.length - 1), {rewrite: no}
nested.pop()
tokens.push ['TOKENS', nested]
str: str.substring(group.length)
@@ -379,7 +379,9 @@ exports.Lexer: class Lexer
tokens.push ['STRING', quote + before.substring(0, before.length - 1) + identifier + quote] if before.length
else
tokens.push ['STRING', quote + before + quote] if before.length
tokens.push ['IDENTIFIER', identifier.substring(1)]
id: identifier.substring(1)
id: 'this.' + id.substring(1) if id.substring(0, 1) is '@'
tokens.push ['IDENTIFIER', id]
str: str.substring(group.length)
else
tokens.push ['STRING', quote + str + quote]