mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
CoffeeScript-in-CoffeeScript can compile @property references.
This commit is contained in:
@@ -473,6 +473,18 @@ IndexNode: exports.IndexNode: inherit Node, {
|
||||
}
|
||||
|
||||
|
||||
# A this-reference, using '@'.
|
||||
ThisNode: exports.ThisNode: inherit Node, {
|
||||
|
||||
constructor: (property) ->
|
||||
@property: property or null
|
||||
|
||||
compile_node: (o) ->
|
||||
'this' + (if @property then '.' + @property else '')
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -230,6 +230,7 @@ grammar: {
|
||||
o "Object", -> new ValueNode($1)
|
||||
o "Parenthetical", -> new ValueNode($1)
|
||||
o "Range", -> new ValueNode($1)
|
||||
o "This", -> new ValueNode($1)
|
||||
o "Value Accessor", -> $1.push($2)
|
||||
o "Invocation Accessor", -> new ValueNode($1, [$2])
|
||||
]
|
||||
@@ -291,6 +292,12 @@ grammar: {
|
||||
o "SUPER CALL_START ArgList CALL_END", -> new CallNode('super', $3)
|
||||
]
|
||||
|
||||
# This references, either naked or to a property.
|
||||
This: [
|
||||
o "@", -> new ThisNode()
|
||||
o "@ IDENTIFIER", -> new ThisNode(yytext)
|
||||
]
|
||||
|
||||
# The range literal.
|
||||
Range: [
|
||||
o "[ Expression . . Expression ]", -> new RangeNode($2, $5)
|
||||
|
||||
Reference in New Issue
Block a user