got coffeescript compiling in the browser

This commit is contained in:
Jeremy Ashkenas 2010-02-13 15:25:04 -05:00
parent 79bb0da153
commit a90bf75395
15 changed files with 140 additions and 86 deletions

View File

@ -824,5 +824,13 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
</div> </div>
<script type="text/javascript" src="lib/coffee_script/underscore.js"></script>
<script type="text/javascript" src="lib/coffee_script/rewriter.js"></script>
<script type="text/javascript" src="lib/coffee_script/lexer.js"></script>
<script type="text/javascript" src="lib/coffee_script/parser.js"></script>
<script type="text/javascript" src="lib/coffee_script/scope.js"></script>
<script type="text/javascript" src="lib/coffee_script/nodes.js"></script>
<script type="text/javascript" src="lib/coffee_script/coffee-script.js"></script>
</body> </body>
</html> </html>

View File

@ -1,6 +1,6 @@
(function(){ (function(){
var solipsism, speed; var solipsism, speed;
if ((typeof mind !== "undefined" && mind !== null) && (typeof !world !== "undefined" && !world !== null)) { if ((typeof mind !== "undefined" && mind !== null) && !(typeof world !== "undefined" && world !== null)) {
solipsism = true; solipsism = true;
} }
speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140; speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140;

View File

@ -1,10 +1,9 @@
(function(){ (function(){
var Account; var Account;
Account = function Account(customer, cart) { Account = function Account(customer, cart) {
var __a;
this.customer = customer; this.customer = customer;
this.cart = cart; this.cart = cart;
__a = $('.shopping_cart').bind('click', (function(__this) { return $('.shopping_cart').bind('click', (function(__this) {
var __func = function(event) { var __func = function(event) {
return this.customer.purchase(this.cart); return this.customer.purchase(this.cart);
}; };
@ -12,6 +11,5 @@
return __func.apply(__this, arguments); return __func.apply(__this, arguments);
}); });
})(this)); })(this));
return Account === this.constructor ? this : __a;
}; };
})(); })();

View File

@ -5,33 +5,31 @@
return alert(this.name + " moved " + meters + "m."); return alert(this.name + " moved " + meters + "m.");
}; };
Snake = function Snake(name) { Snake = function Snake(name) {
var __a; this.name = name;
__a = this.name = name; return this;
return Snake === this.constructor ? this : __a; };
Snake.prototype.move = function move() {
alert("Slithering...");
return Snake.__superClass__.move.call(this, 5);
}; };
__a = function(){}; __a = function(){};
__a.prototype = Animal.prototype; __a.prototype = Animal.prototype;
Snake.__superClass__ = Animal.prototype; Snake.__superClass__ = Animal.prototype;
Snake.prototype = new __a(); Snake.prototype = new __a();
Snake.prototype.constructor = Snake; Snake.prototype.constructor = Snake;
Snake.prototype.move = function move() {
alert("Slithering...");
return Snake.__superClass__.move.call(this, 5);
};
Horse = function Horse(name) { Horse = function Horse(name) {
var __b; this.name = name;
__b = this.name = name; return this;
return Horse === this.constructor ? this : __b; };
Horse.prototype.move = function move() {
alert("Galloping...");
return Horse.__superClass__.move.call(this, 45);
}; };
__b = function(){}; __b = function(){};
__b.prototype = Animal.prototype; __b.prototype = Animal.prototype;
Horse.__superClass__ = Animal.prototype; Horse.__superClass__ = Animal.prototype;
Horse.prototype = new __b(); Horse.prototype = new __b();
Horse.prototype.constructor = Horse; Horse.prototype.constructor = Horse;
Horse.prototype.move = function move() {
alert("Galloping...");
return Horse.__superClass__.move.call(this, 45);
};
sam = new Snake("Sammy the Python"); sam = new Snake("Sammy the Python");
tom = new Horse("Tommy the Palomino"); tom = new Horse("Tommy the Palomino");
sam.move(); sam.move();

View File

@ -1058,12 +1058,12 @@ speed <span class="Keyword">?</span><span class="Keyword">=</span> <span class="
</pre><pre class="idle"><span class="Storage">var</span> solipsism, speed; </pre><pre class="idle"><span class="Storage">var</span> solipsism, speed;
<span class="Keyword">if</span> ((<span class="Keyword">typeof</span> mind <span class="Keyword">!</span><span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>undefined<span class="String">&quot;</span></span> <span class="Keyword">&amp;</span><span class="Keyword">&amp;</span> mind <span class="Keyword">!</span><span class="Keyword">==</span> <span class="BuiltInConstant">null</span>) <span class="Keyword">&amp;</span><span class="Keyword">&amp;</span> (<span class="Keyword">typeof</span> <span class="Keyword">!</span>world <span class="Keyword">!</span><span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>undefined<span class="String">&quot;</span></span> <span class="Keyword">&amp;</span><span class="Keyword">&amp;</span> <span class="Keyword">!</span>world <span class="Keyword">!</span><span class="Keyword">==</span> <span class="BuiltInConstant">null</span>)) { <span class="Keyword">if</span> ((<span class="Keyword">typeof</span> mind <span class="Keyword">!</span><span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>undefined<span class="String">&quot;</span></span> <span class="Keyword">&amp;</span><span class="Keyword">&amp;</span> mind <span class="Keyword">!</span><span class="Keyword">==</span> <span class="BuiltInConstant">null</span>) <span class="Keyword">&amp;</span><span class="Keyword">&amp;</span> <span class="Keyword">!</span>(<span class="Keyword">typeof</span> world <span class="Keyword">!</span><span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>undefined<span class="String">&quot;</span></span> <span class="Keyword">&amp;</span><span class="Keyword">&amp;</span> world <span class="Keyword">!</span><span class="Keyword">==</span> <span class="BuiltInConstant">null</span>)) {
solipsism <span class="Keyword">=</span> <span class="BuiltInConstant">true</span>; solipsism <span class="Keyword">=</span> <span class="BuiltInConstant">true</span>;
} }
speed <span class="Keyword">=</span> (<span class="Keyword">typeof</span> speed <span class="Keyword">!</span><span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>undefined<span class="String">&quot;</span></span> <span class="Keyword">&amp;</span><span class="Keyword">&amp;</span> speed <span class="Keyword">!</span><span class="Keyword">==</span> <span class="BuiltInConstant">null</span>) ? speed : <span class="Number">140</span>; speed <span class="Keyword">=</span> (<span class="Keyword">typeof</span> speed <span class="Keyword">!</span><span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>undefined<span class="String">&quot;</span></span> <span class="Keyword">&amp;</span><span class="Keyword">&amp;</span> speed <span class="Keyword">!</span><span class="Keyword">==</span> <span class="BuiltInConstant">null</span>) ? speed : <span class="Number">140</span>;
</pre><button onclick='javascript: var solipsism, speed; </pre><button onclick='javascript: var solipsism, speed;
if ((typeof mind !== "undefined" && mind !== null) && (typeof !world !== "undefined" && !world !== null)) { if ((typeof mind !== "undefined" && mind !== null) && !(typeof world !== "undefined" && world !== null)) {
solipsism = true; solipsism = true;
} }
speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140; speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140;
@ -1108,21 +1108,30 @@ speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140;
the immediate ancestor's method of the same name. the immediate ancestor's method of the same name.
</p> </p>
<div class='code'><pre class="idle"><span class="FunctionName">Animal</span><span class="Keyword">:</span> <span class="Storage">-&gt;</span> <div class='code'><pre class="idle"><span class="FunctionName">Animal</span><span class="Keyword">:</span> <span class="Storage">-&gt;</span>
<span class="FunctionName">Animal::move</span><span class="Keyword">:</span> <span class="FunctionArgument">(</span><span class="FunctionArgument">meters</span><span class="FunctionArgument">)</span> <span class="Storage">-&gt;</span> <span class="FunctionName">Animal::move</span><span class="Keyword">:</span> <span class="FunctionArgument">(</span><span class="FunctionArgument">meters</span><span class="FunctionArgument">)</span> <span class="Storage">-&gt;</span>
alert <span class="Variable">@name</span> <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span> moved <span class="String">&quot;</span></span> <span class="Keyword">+</span> meters <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span>m.<span class="String">&quot;</span></span> alert <span class="Variable">@name</span> <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span> moved <span class="String">&quot;</span></span> <span class="Keyword">+</span> meters <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span>m.<span class="String">&quot;</span></span>
<span class="FunctionName">Snake</span><span class="Keyword">:</span> <span class="FunctionArgument">(</span><span class="FunctionArgument">name</span><span class="FunctionArgument">)</span> <span class="Storage">-&gt;</span> <span class="Variable">@name</span><span class="Keyword">:</span> name <span class="FunctionName">Snake</span><span class="Keyword">:</span> <span class="FunctionArgument">(</span><span class="FunctionArgument">name</span><span class="FunctionArgument">)</span> <span class="Storage">-&gt;</span>
Snake <span class="Variable">extends</span> Animal <span class="Variable">@name</span><span class="Keyword">:</span> name
<span class="Variable">this</span>
<span class="FunctionName">Snake::move</span><span class="Keyword">:</span> <span class="Storage">-&gt;</span> <span class="FunctionName">Snake::move</span><span class="Keyword">:</span> <span class="Storage">-&gt;</span>
alert <span class="String"><span class="String">&quot;</span>Slithering...<span class="String">&quot;</span></span> alert <span class="String"><span class="String">&quot;</span>Slithering...<span class="String">&quot;</span></span>
<span class="Variable">super</span> <span class="Number">5</span> <span class="Variable">super</span> <span class="Number">5</span>
<span class="FunctionName">Horse</span><span class="Keyword">:</span> <span class="FunctionArgument">(</span><span class="FunctionArgument">name</span><span class="FunctionArgument">)</span> <span class="Storage">-&gt;</span> <span class="Variable">@name</span><span class="Keyword">:</span> name Snake <span class="Variable">extends</span> Animal
Horse <span class="Variable">extends</span> Animal
<span class="FunctionName">Horse</span><span class="Keyword">:</span> <span class="FunctionArgument">(</span><span class="FunctionArgument">name</span><span class="FunctionArgument">)</span> <span class="Storage">-&gt;</span>
<span class="Variable">@name</span><span class="Keyword">:</span> name
<span class="Variable">this</span>
<span class="FunctionName">Horse::move</span><span class="Keyword">:</span> <span class="Storage">-&gt;</span> <span class="FunctionName">Horse::move</span><span class="Keyword">:</span> <span class="Storage">-&gt;</span>
alert <span class="String"><span class="String">&quot;</span>Galloping...<span class="String">&quot;</span></span> alert <span class="String"><span class="String">&quot;</span>Galloping...<span class="String">&quot;</span></span>
<span class="Variable">super</span> <span class="Number">45</span> <span class="Variable">super</span> <span class="Number">45</span>
Horse <span class="Variable">extends</span> Animal
<span class="FunctionName">sam</span><span class="Keyword">:</span> <span class="Keyword">new</span> <span class="TypeName">Snake</span> <span class="String"><span class="String">&quot;</span>Sammy the Python<span class="String">&quot;</span></span> <span class="FunctionName">sam</span><span class="Keyword">:</span> <span class="Keyword">new</span> <span class="TypeName">Snake</span> <span class="String"><span class="String">&quot;</span>Sammy the Python<span class="String">&quot;</span></span>
<span class="FunctionName">tom</span><span class="Keyword">:</span> <span class="Keyword">new</span> <span class="TypeName">Horse</span> <span class="String"><span class="String">&quot;</span>Tommy the Palomino<span class="String">&quot;</span></span> <span class="FunctionName">tom</span><span class="Keyword">:</span> <span class="Keyword">new</span> <span class="TypeName">Horse</span> <span class="String"><span class="String">&quot;</span>Tommy the Palomino<span class="String">&quot;</span></span>
@ -1138,33 +1147,31 @@ Animal <span class="Keyword">=</span> <span class="Storage">function</span> <spa
<span class="Keyword">return</span> <span class="LibraryFunction">alert</span>(<span class="Variable">this</span>.<span class="LibraryConstant">name</span> <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span> moved <span class="String">&quot;</span></span> <span class="Keyword">+</span> meters <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span>m.<span class="String">&quot;</span></span>); <span class="Keyword">return</span> <span class="LibraryFunction">alert</span>(<span class="Variable">this</span>.<span class="LibraryConstant">name</span> <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span> moved <span class="String">&quot;</span></span> <span class="Keyword">+</span> meters <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span>m.<span class="String">&quot;</span></span>);
}; };
Snake <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">Snake</span>(<span class="FunctionArgument">name</span>) { Snake <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">Snake</span>(<span class="FunctionArgument">name</span>) {
<span class="Storage">var</span> __a; <span class="Variable">this</span>.<span class="LibraryConstant">name</span> <span class="Keyword">=</span> name;
__a <span class="Keyword">=</span> <span class="Variable">this</span>.<span class="LibraryConstant">name</span> <span class="Keyword">=</span> name; <span class="Keyword">return</span> <span class="Variable">this</span>;
<span class="Keyword">return</span> Snake <span class="Keyword">===</span> <span class="Variable">this</span>.<span class="LibraryConstant">constructor</span> ? <span class="Variable">this</span> : __a; };
<span class="LibraryClassType">Snake</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">move</span> = <span class="Storage">function</span> <span class="FunctionName">move</span>() {
<span class="LibraryFunction">alert</span>(<span class="String"><span class="String">&quot;</span>Slithering...<span class="String">&quot;</span></span>);
<span class="Keyword">return</span> Snake.__superClass__.move.<span class="LibraryFunction">call</span>(<span class="Variable">this</span>, <span class="Number">5</span>);
}; };
<span class="FunctionName">__a</span> = <span class="Storage">function</span>(){}; <span class="FunctionName">__a</span> = <span class="Storage">function</span>(){};
<span class="LibraryClassType">__a</span>.<span class="LibraryConstant">prototype</span> = Animal.<span class="LibraryConstant">prototype</span>; <span class="LibraryClassType">__a</span>.<span class="LibraryConstant">prototype</span> = Animal.<span class="LibraryConstant">prototype</span>;
Snake.__superClass__ <span class="Keyword">=</span> Animal.<span class="LibraryConstant">prototype</span>; Snake.__superClass__ <span class="Keyword">=</span> Animal.<span class="LibraryConstant">prototype</span>;
<span class="LibraryClassType">Snake</span>.<span class="LibraryConstant">prototype</span> = <span class="Keyword">new</span> <span class="TypeName">__a</span>(); <span class="LibraryClassType">Snake</span>.<span class="LibraryConstant">prototype</span> = <span class="Keyword">new</span> <span class="TypeName">__a</span>();
<span class="LibraryClassType">Snake</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">constructor</span> = Snake; <span class="LibraryClassType">Snake</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">constructor</span> = Snake;
<span class="LibraryClassType">Snake</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">move</span> = <span class="Storage">function</span> <span class="FunctionName">move</span>() {
<span class="LibraryFunction">alert</span>(<span class="String"><span class="String">&quot;</span>Slithering...<span class="String">&quot;</span></span>);
<span class="Keyword">return</span> Snake.__superClass__.move.<span class="LibraryFunction">call</span>(<span class="Variable">this</span>, <span class="Number">5</span>);
};
Horse <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">Horse</span>(<span class="FunctionArgument">name</span>) { Horse <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">Horse</span>(<span class="FunctionArgument">name</span>) {
<span class="Storage">var</span> __b; <span class="Variable">this</span>.<span class="LibraryConstant">name</span> <span class="Keyword">=</span> name;
__b <span class="Keyword">=</span> <span class="Variable">this</span>.<span class="LibraryConstant">name</span> <span class="Keyword">=</span> name; <span class="Keyword">return</span> <span class="Variable">this</span>;
<span class="Keyword">return</span> Horse <span class="Keyword">===</span> <span class="Variable">this</span>.<span class="LibraryConstant">constructor</span> ? <span class="Variable">this</span> : __b; };
<span class="LibraryClassType">Horse</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">move</span> = <span class="Storage">function</span> <span class="FunctionName">move</span>() {
<span class="LibraryFunction">alert</span>(<span class="String"><span class="String">&quot;</span>Galloping...<span class="String">&quot;</span></span>);
<span class="Keyword">return</span> Horse.__superClass__.move.<span class="LibraryFunction">call</span>(<span class="Variable">this</span>, <span class="Number">45</span>);
}; };
<span class="FunctionName">__b</span> = <span class="Storage">function</span>(){}; <span class="FunctionName">__b</span> = <span class="Storage">function</span>(){};
<span class="LibraryClassType">__b</span>.<span class="LibraryConstant">prototype</span> = Animal.<span class="LibraryConstant">prototype</span>; <span class="LibraryClassType">__b</span>.<span class="LibraryConstant">prototype</span> = Animal.<span class="LibraryConstant">prototype</span>;
Horse.__superClass__ <span class="Keyword">=</span> Animal.<span class="LibraryConstant">prototype</span>; Horse.__superClass__ <span class="Keyword">=</span> Animal.<span class="LibraryConstant">prototype</span>;
<span class="LibraryClassType">Horse</span>.<span class="LibraryConstant">prototype</span> = <span class="Keyword">new</span> <span class="TypeName">__b</span>(); <span class="LibraryClassType">Horse</span>.<span class="LibraryConstant">prototype</span> = <span class="Keyword">new</span> <span class="TypeName">__b</span>();
<span class="LibraryClassType">Horse</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">constructor</span> = Horse; <span class="LibraryClassType">Horse</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">constructor</span> = Horse;
<span class="LibraryClassType">Horse</span>.<span class="LibraryConstant">prototype</span>.<span class="FunctionName">move</span> = <span class="Storage">function</span> <span class="FunctionName">move</span>() {
<span class="LibraryFunction">alert</span>(<span class="String"><span class="String">&quot;</span>Galloping...<span class="String">&quot;</span></span>);
<span class="Keyword">return</span> Horse.__superClass__.move.<span class="LibraryFunction">call</span>(<span class="Variable">this</span>, <span class="Number">45</span>);
};
sam <span class="Keyword">=</span> <span class="Keyword">new</span> <span class="TypeName">Snake</span>(<span class="String"><span class="String">&quot;</span>Sammy the Python<span class="String">&quot;</span></span>); sam <span class="Keyword">=</span> <span class="Keyword">new</span> <span class="TypeName">Snake</span>(<span class="String"><span class="String">&quot;</span>Sammy the Python<span class="String">&quot;</span></span>);
tom <span class="Keyword">=</span> <span class="Keyword">new</span> <span class="TypeName">Horse</span>(<span class="String"><span class="String">&quot;</span>Tommy the Palomino<span class="String">&quot;</span></span>); tom <span class="Keyword">=</span> <span class="Keyword">new</span> <span class="TypeName">Horse</span>(<span class="String"><span class="String">&quot;</span>Tommy the Palomino<span class="String">&quot;</span></span>);
sam.move(); sam.move();
@ -1175,33 +1182,31 @@ Animal.prototype.move = function move(meters) {
return alert(this.name + " moved " + meters + "m."); return alert(this.name + " moved " + meters + "m.");
}; };
Snake = function Snake(name) { Snake = function Snake(name) {
var __a; this.name = name;
__a = this.name = name; return this;
return Snake === this.constructor ? this : __a; };
Snake.prototype.move = function move() {
alert("Slithering...");
return Snake.__superClass__.move.call(this, 5);
}; };
__a = function(){}; __a = function(){};
__a.prototype = Animal.prototype; __a.prototype = Animal.prototype;
Snake.__superClass__ = Animal.prototype; Snake.__superClass__ = Animal.prototype;
Snake.prototype = new __a(); Snake.prototype = new __a();
Snake.prototype.constructor = Snake; Snake.prototype.constructor = Snake;
Snake.prototype.move = function move() {
alert("Slithering...");
return Snake.__superClass__.move.call(this, 5);
};
Horse = function Horse(name) { Horse = function Horse(name) {
var __b; this.name = name;
__b = this.name = name; return this;
return Horse === this.constructor ? this : __b; };
Horse.prototype.move = function move() {
alert("Galloping...");
return Horse.__superClass__.move.call(this, 45);
}; };
__b = function(){}; __b = function(){};
__b.prototype = Animal.prototype; __b.prototype = Animal.prototype;
Horse.__superClass__ = Animal.prototype; Horse.__superClass__ = Animal.prototype;
Horse.prototype = new __b(); Horse.prototype = new __b();
Horse.prototype.constructor = Horse; Horse.prototype.constructor = Horse;
Horse.prototype.move = function move() {
alert("Galloping...");
return Horse.__superClass__.move.call(this, 45);
};
sam = new Snake("Sammy the Python"); sam = new Snake("Sammy the Python");
tom = new Horse("Tommy the Palomino"); tom = new Horse("Tommy the Palomino");
sam.move(); sam.move();
@ -1329,10 +1334,9 @@ city = __c[1];
<span class="Variable">@customer</span>.purchase <span class="Variable">@cart</span> <span class="Variable">@customer</span>.purchase <span class="Variable">@cart</span>
</pre><pre class="idle"><span class="Storage">var</span> Account; </pre><pre class="idle"><span class="Storage">var</span> Account;
Account <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">Account</span>(<span class="FunctionArgument">customer, cart</span>) { Account <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">Account</span>(<span class="FunctionArgument">customer, cart</span>) {
<span class="Storage">var</span> __a;
<span class="Variable">this</span>.customer <span class="Keyword">=</span> customer; <span class="Variable">this</span>.customer <span class="Keyword">=</span> customer;
<span class="Variable">this</span>.cart <span class="Keyword">=</span> cart; <span class="Variable">this</span>.cart <span class="Keyword">=</span> cart;
__a <span class="Keyword">=</span> <span class="Keyword">$</span>(<span class="String"><span class="String">'</span>.shopping_cart<span class="String">'</span></span>).bind(<span class="String"><span class="String">'</span>click<span class="String">'</span></span>, (<span class="Storage">function</span>(__this) { <span class="Keyword">return</span> <span class="Keyword">$</span>(<span class="String"><span class="String">'</span>.shopping_cart<span class="String">'</span></span>).bind(<span class="String"><span class="String">'</span>click<span class="String">'</span></span>, (<span class="Storage">function</span>(__this) {
<span class="Storage">var</span> <span class="FunctionName">__func</span> = <span class="Storage">function</span>(<span class="FunctionArgument">event</span>) { <span class="Storage">var</span> <span class="FunctionName">__func</span> = <span class="Storage">function</span>(<span class="FunctionArgument">event</span>) {
<span class="Keyword">return</span> <span class="Variable">this</span>.customer.purchase(<span class="Variable">this</span>.cart); <span class="Keyword">return</span> <span class="Variable">this</span>.customer.purchase(<span class="Variable">this</span>.cart);
}; };
@ -1340,7 +1344,6 @@ Account <span class="Keyword">=</span> <span class="Storage">function</span> <sp
<span class="Keyword">return</span> __func.<span class="LibraryFunction">apply</span>(__this, arguments); <span class="Keyword">return</span> __func.<span class="LibraryFunction">apply</span>(__this, arguments);
}); });
})(<span class="Variable">this</span>)); })(<span class="Variable">this</span>));
<span class="Keyword">return</span> Account <span class="Keyword">===</span> <span class="Variable">this</span>.<span class="LibraryConstant">constructor</span> ? <span class="Variable">this</span> : __a;
}; };
</pre><br class='clear' /></div> </pre><br class='clear' /></div>
@ -1692,5 +1695,13 @@ html <span class="Keyword">=</span> <span class="String"><span class="String">&q
</div> </div>
<script type="text/javascript" src="lib/coffee_script/underscore.js"></script>
<script type="text/javascript" src="lib/coffee_script/rewriter.js"></script>
<script type="text/javascript" src="lib/coffee_script/lexer.js"></script>
<script type="text/javascript" src="lib/coffee_script/parser.js"></script>
<script type="text/javascript" src="lib/coffee_script/scope.js"></script>
<script type="text/javascript" src="lib/coffee_script/nodes.js"></script>
<script type="text/javascript" src="lib/coffee_script/coffee-script.js"></script>
</body> </body>
</html> </html>

View File

@ -1,8 +1,15 @@
(function(){ (function(){
var compiler, lexer, parser, path; var compiler, lexer, parser, path;
process.mixin(require('./nodes')); if ((typeof process !== "undefined" && process !== null)) {
lexer = new (require('./lexer').Lexer)(); process.mixin(require('./nodes'));
parser = require('./parser').parser; path = require('path');
lexer = new (require('./lexer').Lexer)();
parser = require('./parser').parser;
} else {
this.exports = this;
lexer = new Lexer();
parser = exports.parser;
}
// Thin wrapper for Jison compatibility around the real lexer. // Thin wrapper for Jison compatibility around the real lexer.
parser.lexer = { parser.lexer = {
lex: function lex() { lex: function lex() {
@ -38,15 +45,15 @@
return parser.parse(lexer.tokenize(code)); return parser.parse(lexer.tokenize(code));
}; };
//---------- Below this line is obsolete, for the Ruby compiler. ---------------- //---------- Below this line is obsolete, for the Ruby compiler. ----------------
// Executes the `coffee` Ruby program to convert from CoffeeScript to JavaScript.
path = require('path');
// The path to the CoffeeScript executable. // The path to the CoffeeScript executable.
compiler = path.normalize(path.dirname(__filename) + '/../../bin/coffee'); compiler = function compiler() {
return path.normalize(path.dirname(__filename) + '/../../bin/coffee');
};
// Compile a string over stdin, with global variables, for the REPL. // Compile a string over stdin, with global variables, for the REPL.
exports.ruby_compile = function ruby_compile(code, callback) { exports.ruby_compile = function ruby_compile(code, callback) {
var coffee, js; var coffee, js;
js = ''; js = '';
coffee = process.createChildProcess(compiler, ['--eval', '--no-wrap', '--globals']); coffee = process.createChildProcess(compiler(), ['--eval', '--no-wrap', '--globals']);
coffee.addListener('output', function(results) { coffee.addListener('output', function(results) {
if ((typeof results !== "undefined" && results !== null)) { if ((typeof results !== "undefined" && results !== null)) {
return js += results; return js += results;
@ -62,7 +69,7 @@
exports.ruby_compile_files = function ruby_compile_files(paths, callback) { exports.ruby_compile_files = function ruby_compile_files(paths, callback) {
var coffee, exit_ran, js; var coffee, exit_ran, js;
js = ''; js = '';
coffee = process.createChildProcess(compiler, ['--print'].concat(paths)); coffee = process.createChildProcess(compiler(), ['--print'].concat(paths));
coffee.addListener('output', function(results) { coffee.addListener('output', function(results) {
if ((typeof results !== "undefined" && results !== null)) { if ((typeof results !== "undefined" && results !== null)) {
return js += results; return js += results;

View File

@ -1,6 +1,11 @@
(function(){ (function(){
var ASSIGNMENT, BEFORE_WHEN, CALLABLE, CODE, COMMENT, COMMENT_CLEANER, HEREDOC, HEREDOC_INDENT, IDENTIFIER, JS, JS_CLEANER, KEYWORDS, LAST_DENT, LAST_DENTS, MULTILINER, MULTI_DENT, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, Rewriter, STRING, STRING_NEWLINES, WHITESPACE, lex; var ASSIGNMENT, BEFORE_WHEN, CALLABLE, CODE, COMMENT, COMMENT_CLEANER, HEREDOC, HEREDOC_INDENT, IDENTIFIER, JS, JS_CLEANER, KEYWORDS, LAST_DENT, LAST_DENTS, MULTILINER, MULTI_DENT, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, Rewriter, STRING, STRING_NEWLINES, WHITESPACE, lex;
Rewriter = require('./rewriter').Rewriter; if ((typeof process !== "undefined" && process !== null)) {
Rewriter = require('./rewriter').Rewriter;
} else {
this.exports = this;
Rewriter = this.Rewriter;
}
// The lexer reads a stream of CoffeeScript and divvys it up into tagged // The lexer reads a stream of CoffeeScript and divvys it up into tagged
// tokens. A minor bit of the ambiguity in the grammar has been avoided by // tokens. A minor bit of the ambiguity in the grammar has been avoided by
// pushing some extra smarts into the Lexer. // pushing some extra smarts into the Lexer.

View File

@ -1,8 +1,13 @@
(function(){ (function(){
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IfNode, IndexNode, LiteralNode, Node, ObjectNode, OpNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ThrowNode, TryNode, ValueNode, WhileNode, _, del, inherit, merge, statement; var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IfNode, IndexNode, LiteralNode, Node, ObjectNode, OpNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ThrowNode, TryNode, ValueNode, WhileNode, _, del, inherit, merge, statement;
var __hasProp = Object.prototype.hasOwnProperty; var __hasProp = Object.prototype.hasOwnProperty;
process.mixin(require('./scope')); if ((typeof process !== "undefined" && process !== null)) {
_ = require('./underscore')._; process.mixin(require('./scope'));
_ = require('./underscore')._;
} else {
this.exports = this;
_ = this._;
}
// Some helper functions // Some helper functions
// Tabs are two spaces for pretty printing. // Tabs are two spaces for pretty printing.
TAB = ' '; TAB = ' ';

View File

@ -1,6 +1,9 @@
(function(){ (function(){
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, __a, __b, __c, __d, __e, __f, __g, __h, pair, re; var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, __a, __b, __c, __d, __e, __f, __g, __h, pair, re;
var __hasProp = Object.prototype.hasOwnProperty; var __hasProp = Object.prototype.hasOwnProperty;
if (!((typeof process !== "undefined" && process !== null))) {
this.exports = this;
}
// In order to keep the grammar simple, the stream of tokens that the Lexer // In order to keep the grammar simple, the stream of tokens that the Lexer
// emits is rewritten by the Rewriter, smoothing out ambiguities, mis-nested // emits is rewritten by the Rewriter, smoothing out ambiguities, mis-nested
// indentation, and single-line flavors of expressions. // indentation, and single-line flavors of expressions.

View File

@ -1,6 +1,9 @@
(function(){ (function(){
var Scope, succ; var Scope, succ;
var __hasProp = Object.prototype.hasOwnProperty; var __hasProp = Object.prototype.hasOwnProperty;
if (!((typeof process !== "undefined" && process !== null))) {
this.exports = this;
}
// Scope objects form a tree corresponding to the shape of the function // Scope objects form a tree corresponding to the shape of the function
// definitions present in the script. They provide lexical scope, to determine // definitions present in the script. They provide lexical scope, to determine
// whether a variable has been seen before or if it needs to be declared. // whether a variable has been seen before or if it needs to be declared.

View File

@ -1,6 +1,12 @@
process.mixin require './nodes' if process?
lexer: new (require('./lexer').Lexer)() process.mixin require './nodes'
parser: require('./parser').parser path: require('path')
lexer: new (require('./lexer').Lexer)()
parser: require('./parser').parser
else
this.exports: this
lexer: new Lexer()
parser: exports.parser
# Thin wrapper for Jison compatibility around the real lexer. # Thin wrapper for Jison compatibility around the real lexer.
parser.lexer: { parser.lexer: {
@ -34,16 +40,14 @@ exports.tree: (code) ->
#---------- Below this line is obsolete, for the Ruby compiler. ---------------- #---------- Below this line is obsolete, for the Ruby compiler. ----------------
# Executes the `coffee` Ruby program to convert from CoffeeScript to JavaScript.
path: require('path')
# The path to the CoffeeScript executable. # The path to the CoffeeScript executable.
compiler: path.normalize(path.dirname(__filename) + '/../../bin/coffee') compiler: ->
path.normalize(path.dirname(__filename) + '/../../bin/coffee')
# Compile a string over stdin, with global variables, for the REPL. # Compile a string over stdin, with global variables, for the REPL.
exports.ruby_compile: (code, callback) -> exports.ruby_compile: (code, callback) ->
js: '' js: ''
coffee: process.createChildProcess compiler, ['--eval', '--no-wrap', '--globals'] coffee: process.createChildProcess compiler(), ['--eval', '--no-wrap', '--globals']
coffee.addListener 'output', (results) -> coffee.addListener 'output', (results) ->
js += results if results? js += results if results?
@ -58,7 +62,7 @@ exports.ruby_compile: (code, callback) ->
# Compile a list of CoffeeScript files on disk. # Compile a list of CoffeeScript files on disk.
exports.ruby_compile_files: (paths, callback) -> exports.ruby_compile_files: (paths, callback) ->
js: '' js: ''
coffee: process.createChildProcess compiler, ['--print'].concat(paths) coffee: process.createChildProcess compiler(), ['--print'].concat(paths)
coffee.addListener 'output', (results) -> coffee.addListener 'output', (results) ->
js += results if results? js += results if results?

View File

@ -1,4 +1,8 @@
Rewriter: require('./rewriter').Rewriter if process?
Rewriter: require('./rewriter').Rewriter
else
this.exports: this
Rewriter: this.Rewriter
# The lexer reads a stream of CoffeeScript and divvys it up into tagged # The lexer reads a stream of CoffeeScript and divvys it up into tagged
# tokens. A minor bit of the ambiguity in the grammar has been avoided by # tokens. A minor bit of the ambiguity in the grammar has been avoided by

View File

@ -1,5 +1,9 @@
process.mixin require './scope' if process?
_: require('./underscore')._ process.mixin require './scope'
_: require('./underscore')._
else
this.exports: this
_: this._
# Some helper functions # Some helper functions

View File

@ -1,3 +1,5 @@
this.exports: this unless process?
# In order to keep the grammar simple, the stream of tokens that the Lexer # In order to keep the grammar simple, the stream of tokens that the Lexer
# emits is rewritten by the Rewriter, smoothing out ambiguities, mis-nested # emits is rewritten by the Rewriter, smoothing out ambiguities, mis-nested
# indentation, and single-line flavors of expressions. # indentation, and single-line flavors of expressions.

View File

@ -1,3 +1,5 @@
this.exports: this unless process?
# Scope objects form a tree corresponding to the shape of the function # Scope objects form a tree corresponding to the shape of the function
# definitions present in the script. They provide lexical scope, to determine # definitions present in the script. They provide lexical scope, to determine
# whether a variable has been seen before or if it needs to be declared. # whether a variable has been seen before or if it needs to be declared.