coffee-script 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/coffee-script.gemspec +2 -2
- data/lib/coffee-script.rb +1 -1
- data/lib/coffee_script/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage +34 -39
- data/lib/coffee_script/grammar.y +12 -8
- data/lib/coffee_script/lexer.rb +3 -2
- data/lib/coffee_script/narwhal/lib/coffee-script.js +14 -11
- data/lib/coffee_script/nodes.rb +191 -119
- data/lib/coffee_script/parser.rb +1289 -1222
- data/lib/coffee_script/scope.rb +6 -5
- data/lib/coffee_script/value.rb +14 -0
- data/package.json +1 -1
- metadata +2 -2
data/lib/coffee_script/scope.rb
CHANGED
@@ -5,12 +5,13 @@ module CoffeeScript
|
|
5
5
|
# whether a variable has been seen before or if it needs to be declared.
|
6
6
|
class Scope
|
7
7
|
|
8
|
-
attr_reader :parent, :expressions, :variables, :temp_variable
|
8
|
+
attr_reader :parent, :expressions, :function, :variables, :temp_variable
|
9
9
|
|
10
10
|
# Initialize a scope with its parent, for lookups up the chain,
|
11
|
-
# as well as the Expressions body where it should declare its variables
|
12
|
-
|
13
|
-
|
11
|
+
# as well as the Expressions body where it should declare its variables,
|
12
|
+
# and the function that it wraps.
|
13
|
+
def initialize(parent, expressions, function)
|
14
|
+
@parent, @expressions, @function = parent, expressions, function
|
14
15
|
@variables = {}
|
15
16
|
@temp_variable = @parent ? @parent.temp_variable.dup : '__a'
|
16
17
|
end
|
@@ -44,7 +45,7 @@ module CoffeeScript
|
|
44
45
|
def free_variable
|
45
46
|
@temp_variable.succ! while check(@temp_variable)
|
46
47
|
@variables[@temp_variable.to_sym] = :var
|
47
|
-
@temp_variable.dup
|
48
|
+
Value.new(@temp_variable.dup)
|
48
49
|
end
|
49
50
|
|
50
51
|
# Ensure that an assignment is made at the top of scope (or top-level
|
data/lib/coffee_script/value.rb
CHANGED
@@ -2,6 +2,8 @@ module CoffeeScript
|
|
2
2
|
|
3
3
|
# Instead of producing raw Ruby objects, the Lexer produces values of this
|
4
4
|
# class, wrapping native objects tagged with line number information.
|
5
|
+
# Values masquerade as both strings and nodes -- being used both as nodes in
|
6
|
+
# the AST, and as literally-interpolated values in the generated code.
|
5
7
|
class Value
|
6
8
|
attr_reader :value, :line
|
7
9
|
|
@@ -45,6 +47,18 @@ module CoffeeScript
|
|
45
47
|
def match(regex)
|
46
48
|
@value.match(regex)
|
47
49
|
end
|
50
|
+
|
51
|
+
def children
|
52
|
+
[]
|
53
|
+
end
|
54
|
+
|
55
|
+
def statement_only?
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
59
|
+
def contains?
|
60
|
+
false
|
61
|
+
end
|
48
62
|
end
|
49
63
|
|
50
64
|
end
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffee-script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Ashkenas
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-17 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|