Permalink
...
Comparing changes
Open a pull request
- 10 commits
- 60 files changed
- 2 commit comments
- 1 contributor
Unified
Split
Showing
with
962 additions
and 893 deletions.
- +1 −1 README
- +4 −4 Rakefile
- +1 −1 coffee-script.gemspec
- 0 documentation/{cs/aliases.cs → coffee/aliases.coffee}
- 0 documentation/{cs/array_comprehensions.cs → coffee/array_comprehensions.coffee}
- 0 documentation/{cs/assignment.cs → coffee/assignment.coffee}
- +1 −1 documentation/{cs/conditionals.cs → coffee/conditionals.coffee}
- 0 documentation/{cs/embedded.cs → coffee/embedded.coffee}
- 0 documentation/{cs/expressions.cs → coffee/expressions.coffee}
- 0 documentation/{cs/functions.cs → coffee/functions.coffee}
- 0 documentation/{cs/objects_and_arrays.cs → coffee/objects_and_arrays.coffee}
- 0 documentation/{cs/overview.cs → coffee/overview.coffee}
- 0 documentation/{cs/scope.cs → coffee/scope.coffee}
- 0 documentation/{cs/slices.cs → coffee/slices.coffee}
- 0 documentation/{cs/strings.cs → coffee/strings.coffee}
- +2 −2 documentation/{cs/super.cs → coffee/super.coffee}
- 0 documentation/{cs/switch.cs → coffee/switch.coffee}
- 0 documentation/{cs/try.cs → coffee/try.coffee}
- 0 documentation/{cs/while.cs → coffee/while.coffee}
- +0 −3 documentation/cs/intro.cs
- +0 −11 documentation/cs/punctuation.cs
- +27 −14 documentation/index.html.erb
- +3 −1 documentation/js/array_comprehensions.js
- +8 −4 documentation/js/super.js
- +4 −4 examples/{code.cs → code.coffee}
- 0 examples/{documents.cs → documents.coffee}
- +2 −2 examples/{poignant.cs → poignant.coffee}
- 0 examples/{syntax_errors.cs → syntax_errors.coffee}
- 0 examples/{underscore.cs → underscore.coffee}
- +48 −25 index.html
- +1 −1 lib/coffee-script.rb
- +1 −1 lib/coffee_script/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences
- +46 −47 lib/coffee_script/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage
- +1 −1 lib/coffee_script/command_line.rb
- +33 −28 lib/coffee_script/grammar.y
- +5 −1 lib/coffee_script/lexer.rb
- +1 −1 lib/coffee_script/narwhal/{coffee-script.cs → coffee-script.coffee}
- +1 −1 lib/coffee_script/narwhal/js/coffee-script.js
- +2 −2 lib/coffee_script/narwhal/js/loader.js
- 0 lib/coffee_script/narwhal/{launcher.cs → launcher.coffee}
- +4 −4 lib/coffee_script/narwhal/{loader.cs → loader.coffee}
- +30 −34 lib/coffee_script/nodes.rb
- +691 −661 lib/coffee_script/parser.rb
- +1 −1 package.json
- 0 test/fixtures/{each.cs → each.coffee}
- +9 −5 test/fixtures/each.js
- +1 −1 test/fixtures/each.tokens
- +9 −5 test/fixtures/each_no_wrap.js
- 0 test/fixtures/execution/{array_comprehension.cs → array_comprehension.coffee}
- 0 test/fixtures/execution/{assign_to_try_catch.cs → assign_to_try_catch.coffee}
- +3 −3 test/fixtures/execution/{calling_super.cs → calling_super.coffee}
- +5 −0 test/fixtures/execution/chained_calls.coffee
- 0 test/fixtures/execution/{fancy_if_statement.cs → fancy_if_statement.coffee}
- +0 −10 test/fixtures/execution/keyword_operators.cs
- +5 −1 test/fixtures/execution/{test_everything.cs → test_everything.coffee}
- 0 test/fixtures/execution/{test_switch.cs → test_switch.coffee}
- 0 test/fixtures/{inner_comments.cs → inner_comments.coffee}
- +3 −3 test/unit/test_execution.rb
- +6 −6 test/unit/test_lexer.rb
- +3 −3 test/unit/test_parser.rb
View
2
README
| @@ -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
8
Rakefile
| @@ -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 | ||
View
2
coffee-script.gemspec
| @@ -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/" | ||
View
0
documentation/cs/aliases.cs → documentation/coffee/aliases.coffee
File renamed without changes.
View
0
documentation/cs/array_comprehensions.cs → ...tation/coffee/array_comprehensions.coffee
File renamed without changes.
View
0
documentation/cs/assignment.cs → documentation/coffee/assignment.coffee
File renamed without changes.
View
2
documentation/cs/conditionals.cs → documentation/coffee/conditionals.coffee
| @@ -6,4 +6,4 @@ | ||
| date: if friday then sue else jill. | ||
| -expensive ||: do_the_math() | ||
| +expensive ||= do_the_math() | ||
View
0
documentation/cs/embedded.cs → documentation/coffee/embedded.coffee
File renamed without changes.
View
0
documentation/cs/expressions.cs → documentation/coffee/expressions.coffee
File renamed without changes.
View
0
documentation/cs/functions.cs → documentation/coffee/functions.coffee
File renamed without changes.
View
0
documentation/cs/objects_and_arrays.cs → ...entation/coffee/objects_and_arrays.coffee
File renamed without changes.
View
0
documentation/cs/overview.cs → documentation/coffee/overview.coffee
File renamed without changes.
View
0
documentation/cs/scope.cs → documentation/coffee/scope.coffee
File renamed without changes.
View
0
documentation/cs/slices.cs → documentation/coffee/slices.coffee
File renamed without changes.
View
0
documentation/cs/strings.cs → documentation/coffee/strings.coffee
File renamed without changes.
View
4
documentation/cs/super.cs → documentation/coffee/super.coffee
| @@ -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). | ||
View
0
documentation/cs/switch.cs → documentation/coffee/switch.coffee
File renamed without changes.
View
0
documentation/cs/try.cs → documentation/coffee/try.coffee
File renamed without changes.
View
0
documentation/cs/while.cs → documentation/coffee/while.coffee
File renamed without changes.
View
3
documentation/cs/intro.cs
| @@ -1,3 +0,0 @@ | ||
| -# CoffeeScript on the left, JS on the right. | ||
| - | ||
| -square: x => x * x. |
View
11
documentation/cs/punctuation.cs
| @@ -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. |
View
41
documentation/index.html.erb
| @@ -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>&&:</tt>, which only replaces the value of | ||
| + is falsy, and <tt>&&=</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> | ||
View
4
documentation/js/array_comprehensions.js
| @@ -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; | ||
| })(); | ||
View
12
documentation/js/super.js
| @@ -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"); | ||
View
8
examples/code.cs → examples/code.coffee
| @@ -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). | ||
View
0
examples/documents.cs → examples/documents.coffee
File renamed without changes.
View
4
examples/poignant.cs → examples/poignant.coffee
| @@ -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. | ||
View
0
examples/syntax_errors.cs → examples/syntax_errors.coffee
File renamed without changes.
View
0
examples/underscore.cs → examples/underscore.coffee
File renamed without changes.
Oops, something went wrong.