merging in master

This commit is contained in:
Jeremy Ashkenas
2010-02-02 20:38:44 -05:00
5 changed files with 1310 additions and 1181 deletions

View File

@@ -234,6 +234,7 @@ rule
| Object { result = ValueNode.new(val[0]) }
| Parenthetical { result = ValueNode.new(val[0]) }
| Range { result = ValueNode.new(val[0]) }
| This { result = ValueNode.new(val[0]) }
| Value Accessor { result = val[0] << val[1] }
| Invocation Accessor { result = ValueNode.new(val[0], [val[1]]) }
;
@@ -296,6 +297,12 @@ rule
SUPER CALL_START ArgList CALL_END { result = CallNode.new(Value.new('super'), val[2]) }
;
# This references, either naked or to a property.
This:
'@' { result = ThisNode.new }
| '@' IDENTIFIER { result = ThisNode.new(val[1]) }
;
# The range literal.
Range:
"[" Expression

View File

@@ -429,6 +429,18 @@ module CoffeeScript
end
end
# A this-reference, using '@'.
class ThisNode < Node
def initialize(property=nil)
@property = property
end
def compile_node(o)
prop = @property ? ".#{@property}" : ''
write("this#{prop}")
end
end
# A range literal. Ranges can be used to extract portions (slices) of arrays,
# or to specify a range for array comprehensions.
class RangeNode < Node

File diff suppressed because it is too large Load Diff