Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 10 commits
  • 60 files changed
  • 2 commit comments
  • 1 contributor
Showing with 962 additions and 893 deletions.
  1. +1 −1 README
  2. +4 −4 Rakefile
  3. +1 −1 coffee-script.gemspec
  4. 0 documentation/{cs/aliases.cs → coffee/aliases.coffee}
  5. 0 documentation/{cs/array_comprehensions.cs → coffee/array_comprehensions.coffee}
  6. 0 documentation/{cs/assignment.cs → coffee/assignment.coffee}
  7. +1 −1 documentation/{cs/conditionals.cs → coffee/conditionals.coffee}
  8. 0 documentation/{cs/embedded.cs → coffee/embedded.coffee}
  9. 0 documentation/{cs/expressions.cs → coffee/expressions.coffee}
  10. 0 documentation/{cs/functions.cs → coffee/functions.coffee}
  11. 0 documentation/{cs/objects_and_arrays.cs → coffee/objects_and_arrays.coffee}
  12. 0 documentation/{cs/overview.cs → coffee/overview.coffee}
  13. 0 documentation/{cs/scope.cs → coffee/scope.coffee}
  14. 0 documentation/{cs/slices.cs → coffee/slices.coffee}
  15. 0 documentation/{cs/strings.cs → coffee/strings.coffee}
  16. +2 −2 documentation/{cs/super.cs → coffee/super.coffee}
  17. 0 documentation/{cs/switch.cs → coffee/switch.coffee}
  18. 0 documentation/{cs/try.cs → coffee/try.coffee}
  19. 0 documentation/{cs/while.cs → coffee/while.coffee}
  20. +0 −3 documentation/cs/intro.cs
  21. +0 −11 documentation/cs/punctuation.cs
  22. +27 −14 documentation/index.html.erb
  23. +3 −1 documentation/js/array_comprehensions.js
  24. +8 −4 documentation/js/super.js
  25. +4 −4 examples/{code.cs → code.coffee}
  26. 0 examples/{documents.cs → documents.coffee}
  27. +2 −2 examples/{poignant.cs → poignant.coffee}
  28. 0 examples/{syntax_errors.cs → syntax_errors.coffee}
  29. 0 examples/{underscore.cs → underscore.coffee}
  30. +48 −25 index.html
  31. +1 −1 lib/coffee-script.rb
  32. +1 −1 lib/coffee_script/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences
  33. +46 −47 lib/coffee_script/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage
  34. +1 −1 lib/coffee_script/command_line.rb
  35. +33 −28 lib/coffee_script/grammar.y
  36. +5 −1 lib/coffee_script/lexer.rb
  37. +1 −1 lib/coffee_script/narwhal/{coffee-script.cs → coffee-script.coffee}
  38. +1 −1 lib/coffee_script/narwhal/js/coffee-script.js
  39. +2 −2 lib/coffee_script/narwhal/js/loader.js
  40. 0 lib/coffee_script/narwhal/{launcher.cs → launcher.coffee}
  41. +4 −4 lib/coffee_script/narwhal/{loader.cs → loader.coffee}
  42. +30 −34 lib/coffee_script/nodes.rb
  43. +691 −661 lib/coffee_script/parser.rb
  44. +1 −1 package.json
  45. 0 test/fixtures/{each.cs → each.coffee}
  46. +9 −5 test/fixtures/each.js
  47. +1 −1 test/fixtures/each.tokens
  48. +9 −5 test/fixtures/each_no_wrap.js
  49. 0 test/fixtures/execution/{array_comprehension.cs → array_comprehension.coffee}
  50. 0 test/fixtures/execution/{assign_to_try_catch.cs → assign_to_try_catch.coffee}
  51. +3 −3 test/fixtures/execution/{calling_super.cs → calling_super.coffee}
  52. +5 −0 test/fixtures/execution/chained_calls.coffee
  53. 0 test/fixtures/execution/{fancy_if_statement.cs → fancy_if_statement.coffee}
  54. +0 −10 test/fixtures/execution/keyword_operators.cs
  55. +5 −1 test/fixtures/execution/{test_everything.cs → test_everything.coffee}
  56. 0 test/fixtures/execution/{test_switch.cs → test_switch.coffee}
  57. 0 test/fixtures/{inner_comments.cs → inner_comments.coffee}
  58. +3 −3 test/unit/test_execution.rb
  59. +6 −6 test/unit/test_lexer.rb
  60. +3 −3 test/unit/test_parser.rb
View
@@ -26,7 +26,7 @@
gem install coffee-script
Compile a script:
- coffee-script /path/to/script.cs
+ coffee-script /path/to/script.coffee
For documentation, usage, and examples, see:
http://jashkenas.github.com/coffee-script/
View
@@ -13,21 +13,21 @@ end
namespace :build do
desc "Recompile the Racc parser (pass -v and -g for verbose debugging)"
- task :parser, :extra_args do |t, args|
- sh "racc #{args[:extra_args]} -o lib/coffee_script/parser.rb lib/coffee_script/grammar.y"
+ task :parser, :racc_args do |t, args|
+ sh "racc #{args[:racc_args]} -o lib/coffee_script/parser.rb lib/coffee_script/grammar.y"
end
desc "Compile the Narwhal interface for --interactive and --run"
task :narwhal do
- sh "bin/coffee-script lib/coffee_script/narwhal/*.cs -o lib/coffee_script/narwhal/js"
+ sh "bin/coffee-script lib/coffee_script/narwhal/*.coffee -o lib/coffee_script/narwhal/js"
end
end
desc "Build the documentation page"
task :doc do
source = 'documentation/index.html.erb'
- child = fork { exec "bin/coffee-script documentation/cs/*.cs -o documentation/js -w" }
+ child = fork { exec "bin/coffee-script documentation/coffee/*.coffee -o documentation/js -w" }
at_exit { Process.kill("INT", child) }
Signal.trap("INT") { exit }
loop do
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'coffee-script'
- s.version = '0.1.3' # Keep version in sync with coffee-script.rb
+ s.version = '0.1.4' # Keep version in sync with coffee-script.rb
s.date = '2009-12-25'
s.homepage = "http://jashkenas.github.com/coffee-script/"
@@ -6,4 +6,4 @@
date: if friday then sue else jill.
-expensive ||: do_the_math()
+expensive ||= do_the_math()
File renamed without changes.
@@ -3,13 +3,13 @@
alert(this.name + " moved " + meters + "m.").
Snake: name => this.name: name.
-Snake extends new Animal()
+Snake extends Animal
Snake.prototype.move: =>
alert("Slithering...")
super(5).
Horse: name => this.name: name.
-Horse extends new Animal()
+Horse extends Animal
Horse.prototype.move: =>
alert("Galloping...")
super(45).
File renamed without changes.
File renamed without changes.
@@ -1,3 +0,0 @@
-# CoffeeScript on the left, JS on the right.
-
-square: x => x * x.
@@ -1,11 +0,0 @@
-# Comments start with hash marks.
-
-# Periods mark the end of a block.
-left_hand: if raining then umbrella else parasol.
-
-# To signal the beginning of the next expression,
-# use "then", or a newline.
-left_hand: if raining
- umbrella
-else
- parasol.
@@ -3,7 +3,7 @@
def code_for(file, executable=false)
@stripper ||= /(\A\(function\(\)\{\n|\}\)\(\);\Z|^ )/
return '' unless File.exists?("documentation/js/#{file}.js")
- cs = File.read("documentation/cs/#{file}.cs")
+ cs = File.read("documentation/coffee/#{file}.coffee")
js = File.read("documentation/js/#{file}.js").gsub(@stripper, '')
cshtml = Uv.parse(cs, 'xhtml', 'coffeescript', false, 'idle', false)
jshtml = Uv.parse(js, 'xhtml', 'javascript', false, 'idle', false)
@@ -92,11 +92,11 @@ gem install coffee-script</pre>
<p>
Installing the gem provides the <tt>coffee-script</tt> command, which can
- be used to compile CoffeeScript <tt>.cs</tt> files into JavaScript, as
- well as debug them. In conjunction with
+ be used to compile CoffeeScript <tt>.coffee</tt> files into JavaScript, as
+ well as debug them. In conjunction with
<a href="http://narwhaljs.org/">Narwhal</a>, the <tt>coffee-script</tt>
- command also provides direct evaluation and an interactive REPL.
- When compiling to JavaScript, <tt>coffee-script</tt> writes the output
+ command also provides direct evaluation and an interactive REPL.
+ When compiling to JavaScript, <tt>coffee-script</tt> writes the output
as <tt>.js</tt> files in the same directory by default, but output
can be customized with the following options:
</p>
@@ -105,7 +105,7 @@ gem install coffee-script</pre>
<tr>
<td width="25%"><code>-i, --interactive</code></td>
<td>
- Launch an interactive CoffeeScript session.
+ Launch an interactive CoffeeScript session.
Requires <a href="http://narwhaljs.org/">Narwhal</a>.
</td>
</tr>
@@ -187,9 +187,10 @@ gem install coffee-script</pre>
</p>
<pre>
-coffee-script path/to/script.cs
-coffee-script --watch --lint experimental.cs
-coffee-script --print app/scripts/*.cs > concatenation.js</pre>
+coffee-script path/to/script.coffee
+coffee-script --interactive
+coffee-script --watch --lint experimental.coffee
+coffee-script --print app/scripts/*.coffee > concatenation.js</pre>
<h2>Language Reference</h2>
@@ -273,9 +274,9 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
</p>
<%= code_for('conditionals') %>
<p>
- The conditional assignment operators are available: <tt>||:</tt>,
+ The conditional assignment operators are available: <tt>||=</tt>,
which only assigns a value to a variable if the variable's current value
- is falsy, and <tt>&amp;&amp;:</tt>, which only replaces the value of
+ is falsy, and <tt>&amp;&amp;=</tt>, which only replaces the value of
truthy variables.
</p>
@@ -444,16 +445,28 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
<h2 id="change_log">Change Log</h2>
<p>
+ <b class="header" style="margin-top: 20px;">0.1.4</b>
+ The official CoffeeScript extension is now <tt>.coffee</tt> instead of
+ <tt>.cs</tt>, which properly belongs to
+ <a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a>.
+ Due to popular demand, you can now also use <tt>=</tt> to assign. Unlike
+ JavaScript, <tt>=</tt> can also be used within object literals, interchangeably
+ with <tt>:</tt>. Made a grammatical fix for chained function calls
+ like <tt>func(1)(2)(3)(4)</tt>. Inheritance and super no longer use
+ <tt>__proto__</tt>, so they should be IE-compatible now.
+ </p>
+
+ <p>
<b class="header" style="margin-top: 20px;">0.1.3</b>
- The <tt>coffee-script</tt> command now includes <tt>--interactive</tt>,
+ The <tt>coffee-script</tt> command now includes <tt>--interactive</tt>,
which launches an interactive CoffeeScript session, and <tt>--run</tt>,
which directly compiles and executes a script. Both options depend on a
working installation of Narwhal.
- The <tt>aint</tt> keyword has been replaced by <tt>isnt</tt>, which goes
+ The <tt>aint</tt> keyword has been replaced by <tt>isnt</tt>, which goes
together a little smoother with <tt>is</tt>.
Quoted strings are now allowed as identifiers within object literals: eg.
<tt>{"5+5": 10}</tt>.
- All assignment operators now use a colon: <tt>+:</tt>, <tt>-:</tt>,
+ All assignment operators now use a colon: <tt>+:</tt>, <tt>-:</tt>,
<tt>*:</tt>, etc.
</p>
@@ -11,9 +11,11 @@
lunch = __d;
// Zebra-stripe a table.
var __e = table;
+ var __h = [];
for (var __f=0, __g=__e.length; __f<__g; __f++) {
var row = __e[__f];
var i = __f;
- i % 2 === 0 ? highlight(row) : null;
+ __h[__f] = i % 2 === 0 ? highlight(row) : null;
}
+ __h;
})();
@@ -8,19 +8,23 @@
this.name = name;
return this.name;
};
- Snake.prototype.__proto__ = new Animal();
+ Snake.__superClass__ = Animal.prototype;
+ Snake.prototype = new Animal();
+ Snake.prototype.constructor = Snake;
Snake.prototype.move = function() {
alert("Slithering...");
- return Snake.prototype.__proto__.move.call(this, 5);
+ return Snake.__superClass__.move.call(this, 5);
};
var Horse = function(name) {
this.name = name;
return this.name;
};
- Horse.prototype.__proto__ = new Animal();
+ Horse.__superClass__ = Animal.prototype;
+ Horse.prototype = new Animal();
+ Horse.prototype.constructor = Horse;
Horse.prototype.move = function() {
alert("Galloping...");
- return Horse.prototype.__proto__.move.call(this, 45);
+ return Horse.__superClass__.move.call(this, 45);
};
var sam = new Snake("Sammy the Python");
var tom = new Horse("Tommy the Palomino");
@@ -62,8 +62,8 @@
race().
# Conditional assignment:
-good ||: evil
-wine &&: cheese
+good ||= evil
+wine &&= cheese
# Nested property access and calls.
((moon.turn(360))).shapes[3].move({x: 45, y: 30}).position['top'].offset('x')
@@ -145,13 +145,13 @@
alert(this.name + " moved " + meters + "m.").
Snake: name => this.name: name.
-Snake extends new Animal()
+Snake extends Animal
Snake.prototype.move: =>
alert('Slithering...')
super(5).
Horse: name => this.name: name.
-Horse extends new Animal()
+Horse extends Animal
Horse.prototype.move: =>
alert('Galloping...')
super(45).
File renamed without changes.
@@ -81,9 +81,9 @@
hit: damage =>
p_up: Math.rand( this.charisma )
if p_up % 9 is 7
- this.life +: p_up / 4
+ this.life += p_up / 4
puts( "[" + this.name + " magick powers up " + p_up + "!]" ).
- this.life -: damage
+ this.life -= damage
if this.life <= 0 then puts( "[" + this.name + " has died.]" )..
# This method takes one turn in a fight.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.

Showing you all comments on commits in this comparison.

@noonat
Contributor
noonat commented on 11c394f Dec 25, 2009

Woo! I'm glad. Allowing : is cool but it just didn't feel natural to me...

@liamoc
liamoc commented on 4b7c965 Dec 26, 2009

Yay!