Merge pull request #3611 from lydell/release-1.8.0

Release 1.8.0
This commit is contained in:
Jeremy Ashkenas 2014-08-26 12:20:18 -04:00
commit 9177676979
18 changed files with 2892 additions and 1916 deletions

View File

@ -120,7 +120,8 @@ We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
<div class="content"><div class='highlight'><pre>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
CoffeeScript.<span class="hljs-built_in">require</span> = <span class="hljs-built_in">require</span>
compile = CoffeeScript.compile</pre></div></div>
@ -168,7 +169,7 @@ compile = CoffeeScript.compile</pre></div></div>
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>If we&#39;re not in a browser environment, we&#39;re finished with the public API.</p>
<p>If were not in a browser environment, were finished with the public API.</p>
</div>
@ -183,8 +184,8 @@ compile = CoffeeScript.compile</pre></div></div>
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Include source maps where possible. If we&#39;ve got a base64 encoder, a
JSON serializer, and tools for escaping unicode characters, we&#39;re good to go.
<p>Include source maps where possible. If weve got a base64 encoder, a
JSON serializer, and tools for escaping unicode characters, were good to go.
Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">https://developer.mozilla.org/en-US/docs/DOM/window.btoa</a></p>
</div>

View File

@ -118,8 +118,20 @@
for CoffeeScript. You define tasks with names and descriptions in a Cakefile,
and can call them from the command line, or invoke them from other tasks.</p>
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the
current directory&#39;s Cakefile.</p>
<p>External dependencies.</p>
current directorys Cakefile.</p>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>External dependencies.</p>
</div>
@ -132,11 +144,26 @@ CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-stri
</li>
<li id="section-2">
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Register .coffee extension</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.register()</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Keep track of the list of defined tasks, the accepted options, and so on.</p>
@ -150,11 +177,11 @@ oparse = <span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-3">
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Mixin the top-level Cake functions for Cakefiles to use directly.</p>
@ -165,11 +192,11 @@ oparse = <span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-4">
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Define a Cake task with a short name, an optional sentence description,
and the function to run as the action itself.</p>
@ -183,11 +210,11 @@ and the function to run as the action itself.</p>
</li>
<li id="section-5">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Define an option that the Cakefile accepts. The parsed options hash,
containing all of the command-line options passed, will be made available
@ -201,11 +228,11 @@ as the first argument to the action.</p>
</li>
<li id="section-6">
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Invoke another task in the current Cakefile.</p>
@ -218,14 +245,14 @@ as the first argument to the action.</p>
</li>
<li id="section-7">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Node&#39;s
asynchrony may cause tasks to execute in a different order than you&#39;d expect.
<p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Nodes
asynchrony may cause tasks to execute in a different order than youd expect.
If no tasks are passed, print the help screen. Keep a reference to the
original directory name, when running Cake tasks from subdirectories.</p>
@ -247,11 +274,11 @@ original directory name, when running Cake tasks from subdirectories.</p>
</li>
<li id="section-8">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Display the list of Cake tasks in a format similar to <code>rake -T</code></p>
@ -271,11 +298,11 @@ original directory name, when running Cake tasks from subdirectories.</p>
</li>
<li id="section-9">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Print an error and exit when attempting to use an invalid task/option.</p>
@ -291,11 +318,11 @@ original directory name, when running Cake tasks from subdirectories.</p>
</li>
<li id="section-10">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>When <code>cake</code> is invoked, search in the current and all parent directories
to find the relevant Cakefile.</p>

View File

@ -120,7 +120,8 @@ source CoffeeScript into JavaScript.</p>
</div>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
<div class="content"><div class='highlight'><pre>
fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
{Lexer} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./lexer'</span>
@ -466,7 +467,27 @@ The CoffeeScript REPL uses this to run the input.</p>
<span class="hljs-keyword">else</span>
vm.runInContext js, sandbox
<span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">register</span> = -&gt;</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</span>
<span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">register</span> = -&gt;</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</span></pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Throw error with deprecation warning when depending upon implicit <code>require.extensions</code> registration</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.extensions
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> <span class="hljs-property">@FILE_EXTENSIONS</span>
<span class="hljs-built_in">require</span>.extensions[ext] ?=<span class="hljs-function"> -&gt;</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"""
Use CoffeeScript.register() or require the coffee-script/register module to require <span class="hljs-subst">#{ext}</span> files.
"""</span>
<span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">_compileFile</span> = <span class="hljs-params">(filename, sourceMap = <span class="hljs-literal">no</span>)</span> -&gt;</span>
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span>
@ -479,11 +500,11 @@ The CoffeeScript REPL uses this to run the input.</p>
</li>
<li id="section-18">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>As the filename and code of a dynamically loaded file will be different
from the original file compiled with CoffeeScript.run, add that
@ -498,11 +519,11 @@ information to error so it can be pretty-printed later.</p>
</li>
<li id="section-19">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Instantiate a Lexer for our use here.</p>
@ -513,15 +534,15 @@ information to error so it can be pretty-printed later.</p>
</li>
<li id="section-20">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>The real Lexer produces a generic stream of tokens. This object provides a
thin wrapper around it, compatible with the Jison API. We can then pass it
directly as a &quot;Jison lexer&quot;.</p>
directly as a “Jison lexer”.</p>
</div>
@ -544,11 +565,11 @@ directly as a &quot;Jison lexer&quot;.</p>
</li>
<li id="section-21">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Make all the AST nodes visible to the parser.</p>
@ -559,13 +580,13 @@ directly as a &quot;Jison lexer&quot;.</p>
</li>
<li id="section-22">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Override Jison&#39;s default error handling function.</p>
<p>Override Jisons default error handling function.</p>
</div>
@ -574,13 +595,13 @@ directly as a &quot;Jison lexer&quot;.</p>
</li>
<li id="section-23">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Disregard Jison&#39;s message, it contains redundant line numer information.
<p>Disregard Jisons message, it contains redundant line numer information.
Disregard the token, we take its value directly from the lexer in case
the error is caused by a generated token which might refer to its origin.</p>
@ -599,11 +620,11 @@ the error is caused by a generated token which might refer to its origin.</p>
</li>
<li id="section-24">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>The second argument has a <code>loc</code> property, which should have the location
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
@ -617,11 +638,11 @@ from the lexer.</p>
</li>
<li id="section-25">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
Modified to handle sourceMap</p>
@ -649,11 +670,11 @@ Modified to handle sourceMap</p>
</li>
<li id="section-26">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Check for a sourceMap position</p>
@ -694,11 +715,11 @@ Modified to handle sourceMap</p>
</li>
<li id="section-27">
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>Map of filenames -&gt; sourceMap object.</p>
@ -709,11 +730,11 @@ Modified to handle sourceMap</p>
</li>
<li id="section-28">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>Generates the source map for a coffee file and stores it in the local cache variable.</p>
@ -728,11 +749,11 @@ Modified to handle sourceMap</p>
</li>
<li id="section-29">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
NodeJS / V8 have no support for transforming positions in stack traces using
@ -751,7 +772,7 @@ positions.</p>
<span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> frame.getFunction() <span class="hljs-keyword">is</span> <span class="hljs-built_in">exports</span>.run
<span class="hljs-string">" at <span class="hljs-subst">#{formatSourcePosition frame, getSourceMapping}</span>"</span>
<span class="hljs-string">"<span class="hljs-subst">#{err.name}</span>: <span class="hljs-subst">#{err.message ? <span class="hljs-string">''</span>}</span>\n<span class="hljs-subst">#{frames.join <span class="hljs-string">'\n'</span>}</span>\n"</span></pre></div></div>
<span class="hljs-string">"<span class="hljs-subst">#{err.toString()}</span>\n<span class="hljs-subst">#{frames.join <span class="hljs-string">'\n'</span>}</span>\n"</span></pre></div></div>
</li>

View File

@ -118,7 +118,19 @@ into various forms: saved into <code>.js</code> files or printed to stdout
or recompiled every time the source is saved,
printed as a token stream or as the syntax tree, or launch an
interactive REPL.</p>
<p>External dependencies.</p>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>External dependencies.</p>
</div>
@ -136,11 +148,11 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
</li>
<li id="section-2">
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Allow CoffeeScript to emit Node.js events.</p>
@ -156,11 +168,11 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
</li>
<li id="section-3">
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>The help banner that is printed in conjunction with <code>-h</code>/<code>--help</code>.</p>
@ -175,11 +187,11 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
</li>
<li id="section-4">
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>The list of all the valid option flags that <code>coffee</code> knows how to handle.</p>
@ -208,11 +220,11 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
</li>
<li id="section-5">
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Top-level objects shared by all the functions.</p>
@ -228,11 +240,11 @@ optionParser = <span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-6">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Run <code>coffee</code> by parsing passed options and determining what action to take.
Many flags cause us to divert before compiling anything. Flags passed after
@ -246,15 +258,15 @@ Many flags cause us to divert before compiling anything. Flags passed after
</li>
<li id="section-7">
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Make the REPL <em>CLI</em> use the global context so as to (a) be consistent with the
<p>Make the REPL <em>CLI</em> use the global context so as to (a) be consistent with the
<code>node</code> REPL CLI and, therefore, (b) make packages that modify native prototypes
(such as &#39;colors&#39; and &#39;sugar&#39;) work as expected.</p>
(such as colors and sugar) work as expected.</p>
</div>
@ -271,7 +283,22 @@ Many flags cause us to divert before compiling anything. Flags passed after
process.argv[<span class="hljs-number">0</span>] = <span class="hljs-string">'coffee'</span>
opts.output = path.resolve opts.output <span class="hljs-keyword">if</span> opts.output
opts.join = path.resolve opts.join <span class="hljs-keyword">if</span> opts.join
<span class="hljs-keyword">if</span> opts.join
opts.join = path.resolve opts.join
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
The --join option is deprecated and will be removed in a future version.
If for some reason it's necessary to share local variables between files,
replace...
$ coffee --compile --join bundle.js -- a.coffee b.coffee c.coffee
with...
$ cat a.coffee b.coffee c.coffee | coffee --compile --stdio &gt; bundle.js
'''</span>
<span class="hljs-keyword">for</span> source <span class="hljs-keyword">in</span> opts.arguments
source = path.resolve source
compilePath source, <span class="hljs-literal">yes</span>, source</pre></div></div>
@ -279,14 +306,14 @@ Many flags cause us to divert before compiling anything. Flags passed after
</li>
<li id="section-8">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Compile a path, which could be a script or a directory. If a directory
is passed, recursively compile all &#39;.coffee&#39;, &#39;.litcoffee&#39;, and &#39;.coffee.md&#39;
is passed, recursively compile all .coffee, .litcoffee, and .coffee.md
extension source files in it and all subdirectories.</p>
</div>
@ -342,15 +369,15 @@ extension source files in it and all subdirectories.</p>
</li>
<li id="section-9">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Compile a single source script, containing the given code, according to the
requested options. If evaluating the script directly sets <code>__filename</code>,
<code>__dirname</code> and <code>module.filename</code> to be correct relative to the script&#39;s path.</p>
<code>__dirname</code> and <code>module.filename</code> to be correct relative to the scripts path.</p>
</div>
@ -396,11 +423,11 @@ requested options. If evaluating the script directly sets <code>__filename</code
</li>
<li id="section-10">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>,
and write them back to <strong>stdout</strong>.</p>
@ -418,11 +445,11 @@ and write them back to <strong>stdout</strong>.</p>
</li>
<li id="section-11">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>If all of the source files are done being read, concatenate and compile
them together.</p>
@ -440,11 +467,11 @@ them together.</p>
</li>
<li id="section-12">
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Watch a source CoffeeScript file using <code>fs.watch</code>, recompiling it every
time the file is updated. May be used in combination with other options,
@ -500,11 +527,11 @@ such as <code>--print</code>.</p>
</li>
<li id="section-13">
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Watch a directory of files for new additions.</p>
@ -551,11 +578,11 @@ such as <code>--print</code>.</p>
</li>
<li id="section-14">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Remove a file from our source list, and source code cache. Optionally remove
the compiled JS version as well.</p>
@ -580,11 +607,11 @@ the compiled JS version as well.</p>
</li>
<li id="section-15">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Get the corresponding output JavaScript path for a source file.</p>
@ -604,11 +631,11 @@ the compiled JS version as well.</p>
</li>
<li id="section-16">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Write out a JavaScript source file with the compiled code. By default, files
are written out in <code>cwd</code> as <code>.js</code> files with the same name, but the output
@ -628,45 +655,31 @@ same directory as the <code>.js</code> file.</p>
fs.writeFile jsPath, js, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">if</span> err
printLine err.message
process.exit <span class="hljs-number">1</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.compile <span class="hljs-keyword">and</span> opts.watch
timeLog <span class="hljs-string">"compiled <span class="hljs-subst">#{sourcePath}</span>"</span>
<span class="hljs-keyword">if</span> generatedSourceMap
fs.writeFile sourceMapPath, generatedSourceMap, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">if</span> err
printLine <span class="hljs-string">"Could not write source map: <span class="hljs-subst">#{err.message}</span>"</span>
process.exit <span class="hljs-number">1</span>
fs.exists jsDir, <span class="hljs-function"><span class="hljs-params">(itExists)</span> -&gt;</span>
<span class="hljs-keyword">if</span> itExists <span class="hljs-keyword">then</span> compile() <span class="hljs-keyword">else</span> mkdirp jsDir, compile</pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Convenience for cleaner setTimeouts.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">wait</span> = <span class="hljs-params">(milliseconds, func)</span> -&gt;</span> setTimeout func, milliseconds</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>When watching scripts, it&#39;s useful to log changes with the timestamp.</p>
<p>Convenience for cleaner setTimeouts.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">timeLog</span> = <span class="hljs-params">(message)</span> -&gt;</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"<span class="hljs-subst">#{(<span class="hljs-keyword">new</span> Date).toLocaleTimeString()}</span> - <span class="hljs-subst">#{message}</span>"</span></pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">wait</span> = <span class="hljs-params">(milliseconds, func)</span> -&gt;</span> setTimeout func, milliseconds</pre></div></div>
</li>
@ -677,6 +690,22 @@ same directory as the <code>.js</code> file.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>When watching scripts, its useful to log changes with the timestamp.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">timeLog</span> = <span class="hljs-params">(message)</span> -&gt;</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"<span class="hljs-subst">#{(<span class="hljs-keyword">new</span> Date).toLocaleTimeString()}</span> - <span class="hljs-subst">#{message}</span>"</span></pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Pretty-print a stream of tokens, sans location data.</p>
</div>
@ -691,11 +720,11 @@ same directory as the <code>.js</code> file.</p>
</li>
<li id="section-20">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Use the <a href="optparse.html">OptionParser module</a> to extract all options from
<code>process.argv</code> that are specified in <code>SWITCHES</code>.</p>
@ -712,11 +741,11 @@ same directory as the <code>.js</code> file.</p>
</li>
<li id="section-21">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>The compile-time options to pass to the CoffeeScript compiler.</p>
@ -751,11 +780,11 @@ same directory as the <code>.js</code> file.</p>
</li>
<li id="section-22">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Start up a new Node.js instance with the arguments in <code>--nodejs</code> passed to
the <code>node</code> binary, preserving the other options.</p>
@ -775,11 +804,11 @@ the <code>node</code> binary, preserving the other options.</p>
</li>
<li id="section-23">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Print the <code>--help</code> usage message and exit. Deprecated switches are not
shown.</p>
@ -792,11 +821,11 @@ shown.</p>
</li>
<li id="section-24">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Print the <code>--version</code> message and exit.</p>

View File

@ -51,9 +51,17 @@ b, strong {
font-family: "aller-bold";
}
p, ul, ol {
p {
margin: 15px 0 0px;
}
.annotation ul, .annotation ol {
margin: 25px 0;
}
.annotation ul li, .annotation ol li {
font-size: 14px;
line-height: 18px;
margin: 10px 0;
}
h1, h2, h3, h4, h5, h6 {
color: #112233;
@ -70,7 +78,7 @@ h1 {
hr {
border: 0;
background: 1px solid #ddd;
background: 1px #ddd;
height: 1px;
margin: 20px 0;
}
@ -205,7 +213,6 @@ ul.sections > li > div {
}
ul.sections > li > div.content {
background: #f5f5ff;
overflow-x:auto;
-webkit-box-shadow: inset 0 0 5px #e5e5ee;
box-shadow: inset 0 0 5px #e5e5ee;
@ -306,7 +313,6 @@ ul.sections > li > div {
ul.sections > li > div.content {
padding: 13px;
vertical-align: top;
background: #f5f5ff;
border: none;
-webkit-box-shadow: none;
box-shadow: none;
@ -376,125 +382,125 @@ pre code {
background: #f8f8ff
}
pre .comment,
pre .template_comment,
pre .diff .header,
pre .javadoc {
pre .hljs-comment,
pre .hljs-template_comment,
pre .hljs-diff .hljs-header,
pre .hljs-javadoc {
color: #408080;
font-style: italic
}
pre .keyword,
pre .assignment,
pre .literal,
pre .css .rule .keyword,
pre .winutils,
pre .javascript .title,
pre .lisp .title,
pre .subst {
pre .hljs-keyword,
pre .hljs-assignment,
pre .hljs-literal,
pre .hljs-css .hljs-rule .hljs-keyword,
pre .hljs-winutils,
pre .hljs-javascript .hljs-title,
pre .hljs-lisp .hljs-title,
pre .hljs-subst {
color: #954121;
/*font-weight: bold*/
}
pre .number,
pre .hexcolor {
pre .hljs-number,
pre .hljs-hexcolor {
color: #40a070
}
pre .string,
pre .tag .value,
pre .phpdoc,
pre .tex .formula {
pre .hljs-string,
pre .hljs-tag .hljs-value,
pre .hljs-phpdoc,
pre .hljs-tex .hljs-formula {
color: #219161;
}
pre .title,
pre .id {
pre .hljs-title,
pre .hljs-id {
color: #19469D;
}
pre .params {
pre .hljs-params {
color: #00F;
}
pre .javascript .title,
pre .lisp .title,
pre .subst {
pre .hljs-javascript .hljs-title,
pre .hljs-lisp .hljs-title,
pre .hljs-subst {
font-weight: normal
}
pre .class .title,
pre .haskell .label,
pre .tex .command {
pre .hljs-class .hljs-title,
pre .hljs-haskell .hljs-label,
pre .hljs-tex .hljs-command {
color: #458;
font-weight: bold
}
pre .tag,
pre .tag .title,
pre .rules .property,
pre .django .tag .keyword {
pre .hljs-tag,
pre .hljs-tag .hljs-title,
pre .hljs-rules .hljs-property,
pre .hljs-django .hljs-tag .hljs-keyword {
color: #000080;
font-weight: normal
}
pre .attribute,
pre .variable,
pre .instancevar,
pre .lisp .body {
pre .hljs-attribute,
pre .hljs-variable,
pre .hljs-instancevar,
pre .hljs-lisp .hljs-body {
color: #008080
}
pre .regexp {
pre .hljs-regexp {
color: #B68
}
pre .class {
pre .hljs-class {
color: #458;
font-weight: bold
}
pre .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .lisp .keyword,
pre .tex .special,
pre .input_number {
pre .hljs-symbol,
pre .hljs-ruby .hljs-symbol .hljs-string,
pre .hljs-ruby .hljs-symbol .hljs-keyword,
pre .hljs-ruby .hljs-symbol .hljs-keymethods,
pre .hljs-lisp .hljs-keyword,
pre .hljs-tex .hljs-special,
pre .hljs-input_number {
color: #990073
}
pre .builtin,
pre .constructor,
pre .built_in,
pre .lisp .title {
pre .hljs-builtin,
pre .hljs-constructor,
pre .hljs-built_in,
pre .hljs-lisp .hljs-title {
color: #0086b3
}
pre .preprocessor,
pre .pi,
pre .doctype,
pre .shebang,
pre .cdata {
pre .hljs-preprocessor,
pre .hljs-pi,
pre .hljs-doctype,
pre .hljs-shebang,
pre .hljs-cdata {
color: #999;
font-weight: bold
}
pre .deletion {
pre .hljs-deletion {
background: #fdd
}
pre .addition {
pre .hljs-addition {
background: #dfd
}
pre .diff .change {
pre .hljs-diff .hljs-change {
background: #0086b3
}
pre .chunk {
pre .hljs-chunk {
color: #aaa
}
pre .tex .formula {
pre .hljs-tex .hljs-formula {
opacity: 0.5;
}

View File

@ -127,12 +127,9 @@ reduces into the <a href="http://en.wikipedia.org/wiki/Terminal_and_nonterminal_
(the enclosing name at the top), and we proceed from there.</p>
<p>If you run the <code>cake build:parser</code> command, Jison constructs a parse table
from our rules and saves it into <code>lib/parser.js</code>.</p>
<p>The only dependency is on the <strong>Jison.Parser</strong>.</p>
</div>
<div class="content"><div class='highlight'><pre>{Parser} = <span class="hljs-built_in">require</span> <span class="hljs-string">'jison'</span></pre></div></div>
</li>
@ -142,10 +139,12 @@ from our rules and saves it into <code>lib/parser.js</code>.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<h2 id="jison-dsl">Jison DSL</h2>
<p>The only dependency is on the <strong>Jison.Parser</strong>.</p>
</div>
<div class="content"><div class='highlight'><pre>{Parser} = <span class="hljs-built_in">require</span> <span class="hljs-string">'jison'</span></pre></div></div>
</li>
@ -155,7 +154,32 @@ from our rules and saves it into <code>lib/parser.js</code>.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Since we&#39;re going to be wrapped in a function by Jison in any case, if our
<h2 id="jison-dsl">Jison DSL</h2>
</div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
</div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Since were going to be wrapped in a function by Jison in any case, if our
action immediately returns a value, we can optimize by removing the function
wrapper and just returning the value directly.</p>
@ -166,11 +190,11 @@ wrapper and just returning the value directly.</p>
</li>
<li id="section-4">
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Our handy DSL for Jison grammar generation, thanks to
<a href="http://github.com/creationix">Tim Caswell</a>. For every rule in the grammar,
@ -189,13 +213,13 @@ previous nonterminal.</p>
</li>
<li id="section-5">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>All runtime functions we need are defined on &quot;yy&quot;</p>
<p>All runtime functions we need are defined on “yy”</p>
</div>
@ -205,11 +229,11 @@ previous nonterminal.</p>
</li>
<li id="section-6">
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Returns a function which adds location data to the first parameter passed
in, and returns the parameter. If the parameter is not a node, it will
@ -231,11 +255,11 @@ just be passed through unaffected.</p>
</li>
<li id="section-7">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<h2 id="grammatical-rules">Grammatical Rules</h2>
@ -244,17 +268,29 @@ just be passed through unaffected.</p>
</li>
<li id="section-8">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>In all of the rules that follow, you&#39;ll see the name of the nonterminal as
the key to a list of alternative matches. With each match&#39;s action, the
</div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>In all of the rules that follow, youll see the name of the nonterminal as
the key to a list of alternative matches. With each matchs action, the
dollar-sign variables are provided by Jison as references to the value of
their numeric position, so in this rule:</p>
<pre><code>&quot;Expression UNLESS Expression&quot;
<pre><code><span class="hljs-string">"Expression UNLESS Expression"</span>
</code></pre><p><code>$1</code> would be the value of the first <code>Expression</code>, <code>$2</code> would be the token
for the <code>UNLESS</code> terminal, and <code>$3</code> would be the value of the second
<code>Expression</code>.</p>
@ -266,11 +302,11 @@ for the <code>UNLESS</code> terminal, and <code>$3</code> would be the value of
</li>
<li id="section-9">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>The <strong>Root</strong> is the top-level node in the syntax tree. Since we parse bottom-up,
all parsing must end here.</p>
@ -285,11 +321,11 @@ all parsing must end here.</p>
</li>
<li id="section-10">
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Any list of statements and expressions, separated by line breaks or semicolons.</p>
@ -304,11 +340,11 @@ all parsing must end here.</p>
</li>
<li id="section-11">
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Block and statements, which make up a line in a body.</p>
@ -322,11 +358,11 @@ all parsing must end here.</p>
</li>
<li id="section-12">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Pure statements which cannot be expressions.</p>
@ -341,14 +377,14 @@ all parsing must end here.</p>
</li>
<li id="section-13">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>All the different types of expressions in our language. The basic unit of
CoffeeScript is the <strong>Expression</strong> -- everything that can be an expression
CoffeeScript is the <strong>Expression</strong> everything that can be an expression
is one. Blocks serve as the building blocks of many other rules, making
them somewhat circular.</p>
@ -372,11 +408,11 @@ them somewhat circular.</p>
</li>
<li id="section-14">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>An indented block of expressions. Note that the <a href="rewriter.html">Rewriter</a>
will convert some postfix forms into blocks for us, by adjusting the
@ -392,11 +428,11 @@ token stream.</p>
</li>
<li id="section-15">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>A literal identifier, a variable name or property.</p>
@ -409,11 +445,11 @@ token stream.</p>
</li>
<li id="section-16">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Alphanumerics are separated from the other <strong>Literal</strong> matchers because
they can also serve as keys in object literals.</p>
@ -428,11 +464,11 @@ they can also serve as keys in object literals.</p>
</li>
<li id="section-17">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>All of our immediate values. Generally these can be passed straight
through and printed to JavaScript.</p>
@ -452,11 +488,11 @@ through and printed to JavaScript.</p>
</li>
<li id="section-18">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Assignment of a variable, property, or index to a value.</p>
@ -471,11 +507,11 @@ through and printed to JavaScript.</p>
</li>
<li id="section-19">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Assignment when it happens within an object literal. The difference from
the ordinary <strong>Assign</strong> is that these allow numbers and strings as keys.</p>
@ -499,11 +535,11 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
</li>
<li id="section-20">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>A return statement from a function body.</p>
@ -517,11 +553,11 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
</li>
<li id="section-21">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>A block comment.</p>
@ -534,13 +570,13 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
</li>
<li id="section-22">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>The <strong>Code</strong> node is the function literal. It&#39;s defined by an indented block
<p>The <strong>Code</strong> node is the function literal. Its defined by an indented block
of <strong>Block</strong> preceded by a function arrow, with an optional parameter
list.</p>
@ -554,11 +590,11 @@ list.</p>
</li>
<li id="section-23">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>CoffeeScript has two different symbols for functions. <code>-&gt;</code> is for ordinary
functions, and <code>=&gt;</code> is for functions bound to the current value of <em>this</em>.</p>
@ -573,11 +609,11 @@ functions, and <code>=&gt;</code> is for functions bound to the current value of
</li>
<li id="section-24">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>An optional, trailing comma.</p>
@ -591,11 +627,11 @@ functions, and <code>=&gt;</code> is for functions bound to the current value of
</li>
<li id="section-25">
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>The list of parameters that a function accepts can be of any length.</p>
@ -612,11 +648,11 @@ functions, and <code>=&gt;</code> is for functions bound to the current value of
</li>
<li id="section-26">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>A single parameter in a function definition can be ordinary, or a splat
that hoovers up the remaining arguments.</p>
@ -633,11 +669,11 @@ that hoovers up the remaining arguments.</p>
</li>
<li id="section-27">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Function Parameters</p>
@ -653,11 +689,11 @@ that hoovers up the remaining arguments.</p>
</li>
<li id="section-28">
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<a class="pilcrow" href="#section-31">&#182;</a>
</div>
<p>A splat that occurs outside of a parameter list.</p>
@ -670,11 +706,11 @@ that hoovers up the remaining arguments.</p>
</li>
<li id="section-29">
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<a class="pilcrow" href="#section-32">&#182;</a>
</div>
<p>Variables and properties that can be assigned to.</p>
@ -690,11 +726,11 @@ that hoovers up the remaining arguments.</p>
</li>
<li id="section-30">
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<a class="pilcrow" href="#section-33">&#182;</a>
</div>
<p>Everything that can be assigned to.</p>
@ -709,13 +745,13 @@ that hoovers up the remaining arguments.</p>
</li>
<li id="section-31">
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<a class="pilcrow" href="#section-34">&#182;</a>
</div>
<p>The types of things that can be treated as values -- assigned to, invoked
<p>The types of things that can be treated as values assigned to, invoked
as functions, indexed into, named as a class, etc.</p>
</div>
@ -731,11 +767,11 @@ as functions, indexed into, named as a class, etc.</p>
</li>
<li id="section-32">
<li id="section-35">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<a class="pilcrow" href="#section-35">&#182;</a>
</div>
<p>The general group of accessors into an object, by property, by prototype
or by array index or slice.</p>
@ -754,11 +790,11 @@ or by array index or slice.</p>
</li>
<li id="section-33">
<li id="section-36">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<a class="pilcrow" href="#section-36">&#182;</a>
</div>
<p>Indexing into an object or array using bracket notation.</p>
@ -777,11 +813,11 @@ or by array index or slice.</p>
</li>
<li id="section-34">
<li id="section-37">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<a class="pilcrow" href="#section-37">&#182;</a>
</div>
<p>In CoffeeScript, an object literal is simply a list of assignments.</p>
@ -794,11 +830,11 @@ or by array index or slice.</p>
</li>
<li id="section-35">
<li id="section-38">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a>
<a class="pilcrow" href="#section-38">&#182;</a>
</div>
<p>Assignment of properties within an object literal can be separated by
comma, as in JavaScript, or simply by newline.</p>
@ -816,11 +852,11 @@ comma, as in JavaScript, or simply by newline.</p>
</li>
<li id="section-36">
<li id="section-39">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a>
<a class="pilcrow" href="#section-39">&#182;</a>
</div>
<p>Class definitions have optional bodies of prototype property assignments,
and optional references to the superclass.</p>
@ -841,11 +877,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-37">
<li id="section-40">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-37">&#182;</a>
<a class="pilcrow" href="#section-40">&#182;</a>
</div>
<p>Ordinary function invocation, or a chained series of calls.</p>
@ -861,11 +897,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-38">
<li id="section-41">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-38">&#182;</a>
<a class="pilcrow" href="#section-41">&#182;</a>
</div>
<p>An optional existence check on a function.</p>
@ -879,11 +915,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-39">
<li id="section-42">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-39">&#182;</a>
<a class="pilcrow" href="#section-42">&#182;</a>
</div>
<p>The list of arguments to a function call.</p>
@ -897,11 +933,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-40">
<li id="section-43">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-40">&#182;</a>
<a class="pilcrow" href="#section-43">&#182;</a>
</div>
<p>A reference to the <em>this</em> current object.</p>
@ -915,11 +951,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-41">
<li id="section-44">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a>
<a class="pilcrow" href="#section-44">&#182;</a>
</div>
<p>A reference to a property on <em>this</em>.</p>
@ -932,11 +968,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-42">
<li id="section-45">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-42">&#182;</a>
<a class="pilcrow" href="#section-45">&#182;</a>
</div>
<p>The array literal.</p>
@ -950,11 +986,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-43">
<li id="section-46">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-43">&#182;</a>
<a class="pilcrow" href="#section-46">&#182;</a>
</div>
<p>Inclusive and exclusive range dots.</p>
@ -968,11 +1004,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-44">
<li id="section-47">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-44">&#182;</a>
<a class="pilcrow" href="#section-47">&#182;</a>
</div>
<p>The CoffeeScript range literal.</p>
@ -985,11 +1021,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-45">
<li id="section-48">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-45">&#182;</a>
<a class="pilcrow" href="#section-48">&#182;</a>
</div>
<p>Array slice literals.</p>
@ -1005,11 +1041,11 @@ and optional references to the superclass.</p>
</li>
<li id="section-46">
<li id="section-49">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-46">&#182;</a>
<a class="pilcrow" href="#section-49">&#182;</a>
</div>
<p>The <strong>ArgList</strong> is both the list of objects passed into a function call,
as well as the contents of an array literal
@ -1028,11 +1064,11 @@ as well as the contents of an array literal
</li>
<li id="section-47">
<li id="section-50">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-47">&#182;</a>
<a class="pilcrow" href="#section-50">&#182;</a>
</div>
<p>Valid arguments are Blocks or Splats.</p>
@ -1047,15 +1083,15 @@ as well as the contents of an array literal
</li>
<li id="section-48">
<li id="section-51">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-48">&#182;</a>
<a class="pilcrow" href="#section-51">&#182;</a>
</div>
<p>Just simple, comma-separated, required arguments (no fancy syntax). We need
this to be separate from the <strong>ArgList</strong> for use in <strong>Switch</strong> blocks, where
having the newlines wouldn&#39;t make sense.</p>
having the newlines wouldnt make sense.</p>
</div>
@ -1067,11 +1103,11 @@ having the newlines wouldn&#39;t make sense.</p>
</li>
<li id="section-49">
<li id="section-52">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-49">&#182;</a>
<a class="pilcrow" href="#section-52">&#182;</a>
</div>
<p>The variants of <em>try/catch/finally</em> exception handling blocks.</p>
@ -1087,11 +1123,11 @@ having the newlines wouldn&#39;t make sense.</p>
</li>
<li id="section-50">
<li id="section-53">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-50">&#182;</a>
<a class="pilcrow" href="#section-53">&#182;</a>
</div>
<p>A catch clause names its error and runs a block of code.</p>
@ -1106,11 +1142,11 @@ having the newlines wouldn&#39;t make sense.</p>
</li>
<li id="section-51">
<li id="section-54">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-51">&#182;</a>
<a class="pilcrow" href="#section-54">&#182;</a>
</div>
<p>Throw an exception object.</p>
@ -1123,11 +1159,11 @@ having the newlines wouldn&#39;t make sense.</p>
</li>
<li id="section-52">
<li id="section-55">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-52">&#182;</a>
<a class="pilcrow" href="#section-55">&#182;</a>
</div>
<p>Parenthetical expressions. Note that the <strong>Parenthetical</strong> is a <strong>Value</strong>,
not an <strong>Expression</strong>, so if you need to use an expression in a place
@ -1144,11 +1180,11 @@ the trick.</p>
</li>
<li id="section-53">
<li id="section-56">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-53">&#182;</a>
<a class="pilcrow" href="#section-56">&#182;</a>
</div>
<p>The condition portion of a while loop.</p>
@ -1164,11 +1200,11 @@ the trick.</p>
</li>
<li id="section-54">
<li id="section-57">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-54">&#182;</a>
<a class="pilcrow" href="#section-57">&#182;</a>
</div>
<p>The while loop can either be normal, with a block of expressions to execute,
or postfix, with a single expression. There is no do..while.</p>
@ -1190,11 +1226,11 @@ or postfix, with a single expression. There is no do..while.</p>
</li>
<li id="section-55">
<li id="section-58">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-55">&#182;</a>
<a class="pilcrow" href="#section-58">&#182;</a>
</div>
<p>Array, object, and range comprehensions, at the most generic level.
Comprehensions can either be normal, with a block of expressions to execute,
@ -1221,11 +1257,11 @@ or postfix, with a single expression.</p>
</li>
<li id="section-56">
<li id="section-59">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-56">&#182;</a>
<a class="pilcrow" href="#section-59">&#182;</a>
</div>
<p>An array of all accepted values for a variable inside the loop.
This enables support for pattern matching.</p>
@ -1242,11 +1278,11 @@ This enables support for pattern matching.</p>
</li>
<li id="section-57">
<li id="section-60">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-57">&#182;</a>
<a class="pilcrow" href="#section-60">&#182;</a>
</div>
<p>An array or range comprehension has variables for the current element
and (optional) reference to the current index. Or, <em>key, value</em>, in the case
@ -1262,14 +1298,14 @@ of object comprehensions.</p>
</li>
<li id="section-58">
<li id="section-61">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-58">&#182;</a>
<a class="pilcrow" href="#section-61">&#182;</a>
</div>
<p>The source of a comprehension is an array or object with an optional guard
clause. If it&#39;s an array comprehension, you can also choose to step through
clause. If its an array comprehension, you can also choose to step through
in fixed-size increments.</p>
</div>
@ -1299,11 +1335,11 @@ in fixed-size increments.</p>
</li>
<li id="section-59">
<li id="section-62">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-59">&#182;</a>
<a class="pilcrow" href="#section-62">&#182;</a>
</div>
<p>An individual <strong>When</strong> clause, with action.</p>
@ -1317,11 +1353,11 @@ in fixed-size increments.</p>
</li>
<li id="section-60">
<li id="section-63">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-60">&#182;</a>
<a class="pilcrow" href="#section-63">&#182;</a>
</div>
<p>The most basic form of <em>if</em> is a condition and an action. The following
if-related rules are broken up along these lines in order to avoid
@ -1337,11 +1373,11 @@ ambiguity.</p>
</li>
<li id="section-61">
<li id="section-64">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-61">&#182;</a>
<a class="pilcrow" href="#section-64">&#182;</a>
</div>
<p>The full complement of <em>if</em> expressions, including postfix one-liner
<em>if</em> and <em>unless</em>.</p>
@ -1358,11 +1394,11 @@ ambiguity.</p>
</li>
<li id="section-62">
<li id="section-65">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-62">&#182;</a>
<a class="pilcrow" href="#section-65">&#182;</a>
</div>
<p>Arithmetic and logical operators, working on one or more operands.
Here they are grouped by order of precedence. The actual precedence rules
@ -1387,11 +1423,11 @@ rules are necessary.</p>
</li>
<li id="section-63">
<li id="section-66">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-63">&#182;</a>
<a class="pilcrow" href="#section-66">&#182;</a>
</div>
<p><a href="http://jashkenas.github.com/coffee-script/#existence">The existential operator</a>.</p>
@ -1425,11 +1461,11 @@ rules are necessary.</p>
</li>
<li id="section-64">
<li id="section-67">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-64">&#182;</a>
<a class="pilcrow" href="#section-67">&#182;</a>
</div>
<h2 id="precedence">Precedence</h2>
@ -1438,17 +1474,29 @@ rules are necessary.</p>
</li>
<li id="section-65">
<li id="section-68">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-65">&#182;</a>
<a class="pilcrow" href="#section-68">&#182;</a>
</div>
</div>
</li>
<li id="section-69">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-69">&#182;</a>
</div>
<p>Operators at the top of this list have higher precedence than the ones lower
down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:</p>
<pre><code>2 + (3 * 4)
<pre><code><span class="hljs-number">2</span> + (<span class="hljs-number">3</span> * <span class="hljs-number">4</span>)
</code></pre><p>And not:</p>
<pre><code>(2 + 3) * 4
<pre><code>(<span class="hljs-number">2</span> + <span class="hljs-number">3</span>) * <span class="hljs-number">4</span>
</code></pre>
</div>
@ -1476,11 +1524,11 @@ down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:</p>
</li>
<li id="section-66">
<li id="section-70">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-66">&#182;</a>
<a class="pilcrow" href="#section-70">&#182;</a>
</div>
<h2 id="wrapping-up">Wrapping Up</h2>
@ -1489,16 +1537,28 @@ down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:</p>
</li>
<li id="section-67">
<li id="section-71">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-67">&#182;</a>
<a class="pilcrow" href="#section-71">&#182;</a>
</div>
</div>
</li>
<li id="section-72">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-72">&#182;</a>
</div>
<p>Finally, now that we have our <strong>grammar</strong> and our <strong>operators</strong>, we can create
our <strong>Jison.Parser</strong>. We do this by processing all of our rules, recording all
terminals (every symbol which does not appear as the name of a rule above)
as &quot;tokens&quot;.</p>
as “tokens”.</p>
</div>
@ -1513,11 +1573,11 @@ as &quot;tokens&quot;.</p>
</li>
<li id="section-68">
<li id="section-73">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-68">&#182;</a>
<a class="pilcrow" href="#section-73">&#182;</a>
</div>
<p>Initialize the <strong>Parser</strong> with our list of terminal <strong>tokens</strong>, our <strong>grammar</strong>
rules, and the name of the root. Reverse the operators because Jison orders

View File

@ -113,16 +113,12 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>This file contains the common helper functions that we&#39;d like to share among
<p>This file contains the common helper functions that wed like to share among
the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten
arrays, count characters, that sort of thing.</p>
<p>Peek at the beginning of a given string to see if it matches a sequence.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">starts</span> = <span class="hljs-params">(string, literal, start)</span> -&gt;</span>
literal <span class="hljs-keyword">is</span> string.substr start, literal.length</pre></div></div>
</li>
@ -132,6 +128,22 @@ arrays, count characters, that sort of thing.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Peek at the beginning of a given string to see if it matches a sequence.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">starts</span> = <span class="hljs-params">(string, literal, start)</span> -&gt;</span>
literal <span class="hljs-keyword">is</span> string.substr start, literal.length</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Peek at the end of a given string to see if it matches a sequence.</p>
</div>
@ -143,11 +155,11 @@ arrays, count characters, that sort of thing.</p>
</li>
<li id="section-3">
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Repeat a string <code>n</code> times.</p>
@ -158,11 +170,11 @@ arrays, count characters, that sort of thing.</p>
</li>
<li id="section-4">
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Use clever algorithm to have O(log(n)) string concatenation operations.</p>
@ -178,11 +190,11 @@ arrays, count characters, that sort of thing.</p>
</li>
<li id="section-5">
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Trim out all falsy values from an array.</p>
@ -194,11 +206,11 @@ arrays, count characters, that sort of thing.</p>
</li>
<li id="section-6">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Count the number of occurrences of a string in a string.</p>
@ -213,11 +225,11 @@ arrays, count characters, that sort of thing.</p>
</li>
<li id="section-7">
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Merge objects, returning a fresh copy with attributes from both sides.
Used every time <code>Base#compile</code> is called, to allow properties in the
@ -231,11 +243,11 @@ options hash to propagate down the tree without polluting other branches.</p>
</li>
<li id="section-8">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Extend a source object with the properties of another object (shallow copy).</p>
@ -249,11 +261,11 @@ options hash to propagate down the tree without polluting other branches.</p>
</li>
<li id="section-9">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Return a flattened version of an array.
Handy for getting a list of <code>children</code> from the nodes.</p>
@ -272,11 +284,11 @@ Handy for getting a list of <code>children</code> from the nodes.</p>
</li>
<li id="section-10">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Delete a key from an object, returning the value. Useful when a node is
looking for a particular method in an options hash.</p>
@ -291,11 +303,11 @@ looking for a particular method in an options hash.</p>
</li>
<li id="section-11">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Gets the last item of an array(-like) object.</p>
@ -306,11 +318,11 @@ looking for a particular method in an options hash.</p>
</li>
<li id="section-12">
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Typical Array::some</p>
@ -323,15 +335,15 @@ looking for a particular method in an options hash.</p>
</li>
<li id="section-13">
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Simple function for inverting Literate CoffeeScript code by putting the
documentation in comments, producing a string of CoffeeScript code that
can be compiled &quot;normally&quot;.</p>
can be compiled “normally”.</p>
</div>
@ -349,11 +361,11 @@ can be compiled &quot;normally&quot;.</p>
</li>
<li id="section-14">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Merge two jison-style location data objects together.
If <code>last</code> is not provided, this will simply return <code>first</code>.</p>
@ -372,14 +384,14 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
</li>
<li id="section-15">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>This returns a function which takes an object as a parameter, and if that
object is an AST node, updates that object&#39;s locationData.
object is an AST node, updates that objects locationData.
The object is returned either way.</p>
</div>
@ -394,11 +406,11 @@ The object is returned either way.</p>
</li>
<li id="section-16">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Convert jison location data to a string.
<code>obj</code> can be a token, or a locationData.</p>
@ -418,11 +430,11 @@ The object is returned either way.</p>
</li>
<li id="section-17">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.</p>
@ -441,11 +453,11 @@ The object is returned either way.</p>
</li>
<li id="section-18">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Determine if a filename represents a CoffeeScript file.</p>
@ -456,11 +468,11 @@ The object is returned either way.</p>
</li>
<li id="section-19">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
@ -471,14 +483,14 @@ The object is returned either way.</p>
</li>
<li id="section-20">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Throws a SyntaxError from a given location.
The error&#39;s <code>toString</code> will return an error message following the &quot;standard&quot;
The errors <code>toString</code> will return an error message following the “standard”
format <filename>:<line>:<col>: <message> plus the line with the error and a
marker showing where the error is.</p>
@ -492,13 +504,13 @@ marker showing where the error is.</p>
</li>
<li id="section-21">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Instead of showing the compiler&#39;s stacktrace, show our custom error message
<p>Instead of showing the compilers stacktrace, show our custom error message
(this is useful when the error bubbles up in Node.js applications that
compile CoffeeScript for example).</p>
@ -511,13 +523,13 @@ compile CoffeeScript for example).</p>
</li>
<li id="section-22">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Update a compiler SyntaxError with source code information if it didn&#39;t have
<p>Update a compiler SyntaxError with source code information if it didnt have
it already.</p>
</div>
@ -527,11 +539,11 @@ it already.</p>
</li>
<li id="section-23">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Avoid screwing up the <code>stack</code> property of other errors (i.e. possible bugs).</p>
@ -557,29 +569,29 @@ it already.</p>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Show only the first line on multi-line errors.</p>
</div>
<div class="content"><div class='highlight'><pre> end = <span class="hljs-keyword">if</span> first_line <span class="hljs-keyword">is</span> last_line <span class="hljs-keyword">then</span> last_column + <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> codeLine.length
marker = repeat(<span class="hljs-string">' '</span>, start) + repeat(<span class="hljs-string">'^'</span>, end - start)</pre></div></div>
</li>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Check to see if we&#39;re running on a color-enabled TTY.</p>
<p>Show only the first line on multi-line errors.</p>
</div>
<div class="content"><div class='highlight'><pre> end = <span class="hljs-keyword">if</span> first_line <span class="hljs-keyword">is</span> last_line <span class="hljs-keyword">then</span> last_column + <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> codeLine.length
marker = codeLine[...start].replace(<span class="hljs-regexp">/[^\s]/g</span>, <span class="hljs-string">' '</span>) + repeat(<span class="hljs-string">'^'</span>, end - start)</pre></div></div>
</li>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Check to see if were running on a color-enabled TTY.</p>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -129,7 +129,7 @@
</div>
<p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
Use it like so:</p>
<pre><code>parser = new OptionParser switches, helpBanner
<pre><code>parser = <span class="hljs-keyword">new</span> OptionParser switches, helpBanner
options = parser.parse process.argv
</code></pre><p>The first non-option is considered to be the start of the file (and file
option) list, and all subsequent arguments are left unparsed.</p>
@ -170,7 +170,7 @@ specified options, and return it. Options after the first non-option
argument are treated as arguments. <code>options.arguments</code> will be an array
containing the remaining arguments. This is a simpler API than many option
parsers that allow you to attach callback actions for every flag. Instead,
you&#39;re responsible for interpreting the options object.</p>
youre responsible for interpreting the options object.</p>
</div>
@ -266,6 +266,18 @@ of the valid options, for <code>--help</code> and such.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
</div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Regex matchers for option flags.</p>
</div>
@ -278,11 +290,11 @@ OPTIONAL = <span class="hljs-regexp">/\[(\w+(\*?))\]/</span></pre></div></div>
</li>
<li id="section-9">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Build and return the list of option rules. If the optional <em>short-flag</em> is
unspecified, leave it out by padding with <code>null</code>.</p>
@ -297,11 +309,11 @@ unspecified, leave it out by padding with <code>null</code>.</p>
</li>
<li id="section-10">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Build a rule from a <code>-o</code> short flag, a <code>--output [DIR]</code> long flag, and the
description of what the option does.</p>
@ -323,11 +335,11 @@ description of what the option does.</p>
</li>
<li id="section-11">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Normalize arguments by expanding merged flags into multiple flags. This allows
you to have <code>-wl</code> be the same as <code>--watch --lint</code>.</p>

View File

@ -165,10 +165,8 @@ CoffeeScript as an extension.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Patch Node&#39;s module loader to be able to handle mult-dot extensions.
This is a horrible thing that should not be required. Perhaps, one day,
when a truly benevolent dictator comes to rule over the Republik of Node,
it won&#39;t be.</p>
<p>Patch Nodes module loader to be able to handle multi-dot extensions.
This is a horrible thing that should not be required.</p>
</div>
@ -226,7 +224,7 @@ it won&#39;t be.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>If we&#39;re on Node, patch <code>child_process.fork</code> so that Coffee scripts are able
<p>If were on Node, patch <code>child_process.fork</code> so that Coffee scripts are able
to fork both CoffeeScript files, and JavaScript files, directly.</p>
</div>

View File

@ -153,7 +153,7 @@ replDefaults =
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Node&#39;s REPL sends the input ending with a newline and then wrapped in
<p>Nodes REPL sends the input ending with a newline and then wrapped in
parens. Unwrap all that.</p>
</div>
@ -210,7 +210,7 @@ parens. Unwrap all that.</p>
]
js = ast.compile <span class="hljs-attribute">bare</span>: <span class="hljs-literal">yes</span>, <span class="hljs-attribute">locals</span>: Object.keys(context)
result = <span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
vm.runInThisContext js, filename
vm.runInThisContext js, filename
<span class="hljs-keyword">else</span>
vm.runInContext js, context, filename
cb <span class="hljs-literal">null</span>, result
@ -225,7 +225,7 @@ parens. Unwrap all that.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>AST&#39;s <code>compile</code> does not add source code information to syntax errors.</p>
<p>ASTs <code>compile</code> does not add source code information to syntax errors.</p>
</div>
@ -233,13 +233,7 @@ parens. Unwrap all that.</p>
cb err
<span class="hljs-function"><span class="hljs-title">addMultilineHandler</span> = <span class="hljs-params">(repl)</span> -&gt;</span>
{rli, inputStream, outputStream} = repl
multiline =
<span class="hljs-attribute">enabled</span>: <span class="hljs-literal">off</span>
<span class="hljs-attribute">initialPrompt</span>: repl.prompt.replace <span class="hljs-regexp">/^[^&gt; ]*/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'-'</span>
<span class="hljs-attribute">prompt</span>: repl.prompt.replace <span class="hljs-regexp">/^[^&gt; ]*&gt;?/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'.'</span>
<span class="hljs-attribute">buffer</span>: <span class="hljs-string">''</span></pre></div></div>
{rli, inputStream, outputStream} = repl</pre></div></div>
</li>
@ -250,7 +244,28 @@ parens. Unwrap all that.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Proxy node&#39;s line listener</p>
<p>Node 0.11.12 changed API, prompt is now _prompt.</p>
</div>
<div class="content"><div class='highlight'><pre> origPrompt = repl._prompt ? repl.prompt
multiline =
<span class="hljs-attribute">enabled</span>: <span class="hljs-literal">off</span>
<span class="hljs-attribute">initialPrompt</span>: origPrompt.replace <span class="hljs-regexp">/^[^&gt; ]*/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'-'</span>
<span class="hljs-attribute">prompt</span>: origPrompt.replace <span class="hljs-regexp">/^[^&gt; ]*&gt;?/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'.'</span>
<span class="hljs-attribute">buffer</span>: <span class="hljs-string">''</span></pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Proxy nodes line listener</p>
</div>
@ -262,17 +277,18 @@ parens. Unwrap all that.</p>
rli.setPrompt multiline.prompt
rli.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">else</span>
rli.setPrompt origPrompt
nodeLineListener cmd
<span class="hljs-keyword">return</span></pre></div></div>
</li>
<li id="section-9">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Handle Ctrl-v</p>
@ -285,11 +301,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-10">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>allow arbitrarily switching between modes any time before multiple lines are entered</p>
@ -297,18 +313,18 @@ parens. Unwrap all that.</p>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> multiline.buffer.match <span class="hljs-regexp">/\n/</span>
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
rli.setPrompt repl.prompt
rli.setPrompt origPrompt
rli.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">return</span></pre></div></div>
</li>
<li id="section-11">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>no-op unless the current line is empty</p>
@ -319,11 +335,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-12">
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>eval, print, loop</p>
@ -338,11 +354,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-13">
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>XXX: multiline hack</p>
@ -360,11 +376,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-14">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Store and load command history from a file</p>
@ -377,11 +393,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-15">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Get file info and at most maxSize of command history</p>
@ -393,11 +409,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-16">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Read last <code>size</code> bytes from the file</p>
@ -410,11 +426,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-17">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Set the history on the interpreter</p>
@ -425,11 +441,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-18">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>If the history file was truncated we should pop off a potential partial line</p>
@ -440,11 +456,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-19">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Shift off the final blank newline</p>
@ -462,11 +478,11 @@ parens. Unwrap all that.</p>
</li>
<li id="section-20">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Save the latest command in the file</p>
@ -480,22 +496,40 @@ parens. Unwrap all that.</p>
</li>
<li id="section-21">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Add a command to show the history stack</p>
</div>
<div class="content"><div class='highlight'><pre> repl.commands[<span class="hljs-string">'.history'</span>] =
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'history'</span>)] =
<span class="hljs-attribute">help</span>: <span class="hljs-string">'Show command history'</span>
<span class="hljs-attribute">action</span>:<span class="hljs-function"> -&gt;</span>
repl.outputStream.write <span class="hljs-string">"<span class="hljs-subst">#{repl.rli.history[..].reverse().join <span class="hljs-string">'\n'</span>}</span>\n"</span>
repl.displayPrompt()
<span class="hljs-function"><span class="hljs-title">getCommandId</span> = <span class="hljs-params">(repl, commandName)</span> -&gt;</span></pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Node 0.11 changed API, a command such as .help is now stored as help</p>
</div>
<div class="content"><div class='highlight'><pre> commandsHaveLeadingDot = repl.commands[<span class="hljs-string">'.help'</span>]?
<span class="hljs-keyword">if</span> commandsHaveLeadingDot <span class="hljs-keyword">then</span> <span class="hljs-string">".<span class="hljs-subst">#{commandName}</span>"</span> <span class="hljs-keyword">else</span> commandName
<span class="hljs-built_in">module</span>.<span class="hljs-built_in">exports</span> =
<span class="hljs-attribute">start</span>: <span class="hljs-function"><span class="hljs-params">(opts = {})</span> -&gt;</span>
[major, minor, build] = process.versions.node.split<span class="hljs-function"><span class="hljs-params">(<span class="hljs-string">'.'</span>)</span>.<span class="hljs-title">map</span> <span class="hljs-params">(n)</span> -&gt;</span> parseInt(n)
@ -510,7 +544,22 @@ parens. Unwrap all that.</p>
repl = nodeREPL.start opts
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>,<span class="hljs-function"> -&gt;</span> repl.outputStream.write <span class="hljs-string">'\n'</span>
addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile</pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Adapt help inherited from the node REPL</p>
</div>
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'load'</span>)].help = <span class="hljs-string">'Load code from a file into this REPL session'</span>
repl</pre></div></div>
</li>

View File

@ -119,7 +119,19 @@ the resulting parse table. Instead of making the parser handle it all, we take
a series of passes over the token stream, using this <strong>Rewriter</strong> to convert
shorthand into the unambiguous long form, add implicit indentation and
parentheses, and generally clean things up.</p>
<p>Create a generated token: one that exists due to a use of implicit syntax.</p>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Create a generated token: one that exists due to a use of implicit syntax.</p>
</div>
@ -132,11 +144,11 @@ parentheses, and generally clean things up.</p>
</li>
<li id="section-2">
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>The <strong>Rewriter</strong> class is used by the <a href="lexer.html">Lexer</a>, directly against
its internal array of tokens.</p>
@ -148,18 +160,30 @@ its internal array of tokens.</p>
</li>
<li id="section-3">
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Helpful snippet for debugging:</p>
<pre><code>console.log (t[0] + &#39;/&#39; + t[1] for t in @tokens).join &#39; &#39;
</code></pre><p>Rewrite the token stream in multiple passes, one logical filter at
<pre><code><span class="hljs-built_in">console</span>.log (t[<span class="hljs-number">0</span>] + <span class="hljs-string">'/'</span> + t[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> <span class="hljs-property">@tokens</span>).join <span class="hljs-string">' '</span>
</code></pre>
</div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Rewrite the token stream in multiple passes, one logical filter at
a time. This could certainly be changed into a single pass through the
stream, with a big ol&#39; efficient switch, but it&#39;s much nicer to work with
like this. The order of these passes matters -- indentation must be
stream, with a big ol efficient switch, but its much nicer to work with
like this. The order of these passes matters indentation must be
corrected before implicit parentheses can be wrapped around blocks of code.</p>
</div>
@ -177,15 +201,15 @@ corrected before implicit parentheses can be wrapped around blocks of code.</p>
</li>
<li id="section-4">
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Rewrite the token stream, looking one token ahead and behind.
Allow the return value of the block to tell us how many tokens to move
forwards (or backwards) in the stream, to make sure we don&#39;t miss anything
forwards (or backwards) in the stream, to make sure we dont miss anything
as tokens are inserted and removed, and the stream changes length under
our feet.</p>
@ -213,11 +237,11 @@ our feet.</p>
</li>
<li id="section-5">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Leading newlines would introduce an ambiguity in the grammar, so we
dispatch them here.</p>
@ -231,11 +255,11 @@ dispatch them here.</p>
</li>
<li id="section-6">
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>The lexer has tagged the opening parenthesis of a method call. Match it with
its paired close. We have the mis-nested outdent case included here for
@ -258,11 +282,11 @@ calls that close on the same line, just before their outdent.</p>
</li>
<li id="section-7">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>The lexer has tagged the opening parenthesis of an indexing operation call.
Match it with its paired close.</p>
@ -283,11 +307,11 @@ Match it with its paired close.</p>
</li>
<li id="section-8">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Match tags in token stream starting at i with pattern, skipping HERECOMMENTs
Pattern may consist of strings (equality), an array of strings (one of)
@ -307,14 +331,14 @@ or null (wildcard)</p>
</li>
<li id="section-9">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>yes iff standing in front of something looking like
@<x>: or <x>:, skipping over &#39;HERECOMMENT&#39;s</p>
@<x>: or <x>:, skipping over HERECOMMENTs</p>
</div>
@ -324,11 +348,11 @@ or null (wildcard)</p>
</li>
<li id="section-10">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>yes iff current line of tokens contain an element of tags on same
expression level. Stop searching at LINEBREAKS or explicit start of
@ -350,11 +374,11 @@ containing balanced expression.</p>
</li>
<li id="section-11">
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Look for signs of implicit calls and objects in the token stream and
add them.</p>
@ -366,11 +390,11 @@ add them.</p>
</li>
<li id="section-12">
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Track current balancing depth (both implicit and explicit) on stack.</p>
@ -388,11 +412,11 @@ add them.</p>
</li>
<li id="section-13">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Helper function, used for keeping track of the number of tokens consumed
and spliced, when returning for getting a new token.</p>
@ -404,11 +428,11 @@ and spliced, when returning for getting a new token.</p>
</li>
<li id="section-14">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Helper functions</p>
@ -421,11 +445,11 @@ and spliced, when returning for getting a new token.</p>
</li>
<li id="section-15">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Unclosed control statement inside implicit parens (like
class declaration or if-conditionals)</p>
@ -460,13 +484,13 @@ class declaration or if-conditionals)</p>
</li>
<li id="section-16">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Don&#39;t end an implicit call on next indent if any of these are in an argument</p>
<p>Dont end an implicit call on next indent if any of these are in an argument</p>
</div>
@ -480,11 +504,11 @@ class declaration or if-conditionals)</p>
</li>
<li id="section-17">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>An <code>INDENT</code> closes an implicit call unless</p>
<ol>
@ -503,11 +527,11 @@ class declaration or if-conditionals)</p>
</li>
<li id="section-18">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Straightforward start of explicit expression</p>
@ -520,11 +544,11 @@ class declaration or if-conditionals)</p>
</li>
<li id="section-19">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Close all implicit expressions inside of explicitly closed expressions.</p>
@ -543,11 +567,11 @@ class declaration or if-conditionals)</p>
</li>
<li id="section-20">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Recognize standard implicit calls like
f a, f() b, f? c, h[0] d etc.</p>
@ -566,29 +590,29 @@ f a, f() b, f? c, h[0] d etc.</p>
</li>
<li id="section-21">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Implicit call taking an implicit indented object as first argument.</p>
<pre><code>f
a: b
c: d
<span class="hljs-attribute">a</span>: b
<span class="hljs-attribute">c</span>: d
</code></pre><p>and</p>
<pre><code>f
1
a: b
b: c
</code></pre><p>Don&#39;t accept implicit calls of this type, when on the same line
<span class="hljs-number">1</span>
<span class="hljs-attribute">a</span>: b
<span class="hljs-attribute">b</span>: c
</code></pre><p>Dont accept implicit calls of this type, when on the same line
as the control strucutures below as that may misinterpret constructs like:</p>
<pre><code>if f
a: 1
<pre><code><span class="hljs-keyword">if</span> f
<span class="hljs-attribute">a</span>: <span class="hljs-number">1</span>
</code></pre><p>as</p>
<pre><code>if f(a: 1)
<pre><code><span class="hljs-keyword">if</span> f(<span class="hljs-attribute">a</span>: <span class="hljs-number">1</span>)
</code></pre><p>which is probably always unintended.
Furthermore don&#39;t allow this in literal arrays, as
Furthermore dont allow this in literal arrays, as
that creates grammatical ambiguities.</p>
</div>
@ -603,11 +627,11 @@ that creates grammatical ambiguities.</p>
</li>
<li id="section-22">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Implicit objects start here</p>
@ -618,11 +642,11 @@ that creates grammatical ambiguities.</p>
</li>
<li id="section-23">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Go back to the (implicit) start of the object</p>
@ -634,11 +658,11 @@ that creates grammatical ambiguities.</p>
</li>
<li id="section-24">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Mark if the value is a for loop</p>
@ -651,11 +675,11 @@ that creates grammatical ambiguities.</p>
</li>
<li id="section-25">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Are we just continuing an already declared object?</p>
@ -673,17 +697,17 @@ that creates grammatical ambiguities.</p>
</li>
<li id="section-26">
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>End implicit calls when chaining method calls
like e.g.:</p>
<pre><code>f -&gt;
<pre><code>f<span class="hljs-function"> -&gt;</span>
a
.g b, -&gt;
.g b,<span class="hljs-function"> -&gt;</span>
c
.h a
</code></pre><p>and also</p>
@ -693,7 +717,8 @@ like e.g.:</p>
</code></pre>
</div>
<div class="content"><div class='highlight'><pre> stackTop()[<span class="hljs-number">2</span>].sameLine = <span class="hljs-literal">no</span> <span class="hljs-keyword">if</span> inImplicitObject() <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">in</span> LINEBREAKS
<div class="content"><div class='highlight'><pre>
stackTop()[<span class="hljs-number">2</span>].sameLine = <span class="hljs-literal">no</span> <span class="hljs-keyword">if</span> inImplicitObject() <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">in</span> LINEBREAKS
newLine = prevTag <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">or</span> prevToken.newLine
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> IMPLICIT_END <span class="hljs-keyword">or</span> tag <span class="hljs-keyword">in</span> CALL_CLOSERS <span class="hljs-keyword">and</span> newLine
@ -703,11 +728,11 @@ like e.g.:</p>
</li>
<li id="section-27">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>Close implicit calls when reached end of argument list</p>
@ -719,11 +744,11 @@ like e.g.:</p>
</li>
<li id="section-28">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Close implicit objects such as:
return a: 1, b: 2 unless true</p>
@ -737,14 +762,14 @@ return a: 1, b: 2 unless true</p>
</li>
<li id="section-29">
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<a class="pilcrow" href="#section-31">&#182;</a>
</div>
<p>Close implicit objects when at end of line, line didn&#39;t end with a comma
and the implicit object didn&#39;t start the line or the next line doesn&#39;t look like
<p>Close implicit objects when at end of line, line didnt end with a comma
and the implicit object didnt start the line or the next line doesnt look like
the continuation of an object.</p>
</div>
@ -758,21 +783,21 @@ the continuation of an object.</p>
</li>
<li id="section-30">
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<a class="pilcrow" href="#section-32">&#182;</a>
</div>
<p>Close implicit object if comma is the last character
and what comes after doesn&#39;t look like it belongs.
and what comes after doesnt look like it belongs.
This is used for trailing commas and calls, like:</p>
<pre><code>x =
a: b,
c: d,
e = 2
<span class="hljs-attribute">a</span>: b,
<span class="hljs-attribute">c</span>: d,
e = <span class="hljs-number">2</span>
</code></pre><p>and</p>
<pre><code>f a, b: c, d: e, f, g: h: i, j
<pre><code>f a, <span class="hljs-attribute">b</span>: c, <span class="hljs-attribute">d</span>: e, f, <span class="hljs-attribute">g</span>: <span class="hljs-attribute">h</span>: i, j
</code></pre>
</div>
@ -783,20 +808,21 @@ e = 2
</li>
<li id="section-31">
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<a class="pilcrow" href="#section-33">&#182;</a>
</div>
<p>When nextTag is OUTDENT the comma is insignificant and
should just be ignored so embed it in the implicit object.</p>
<p>When it isn&#39;t the comma go on to play a role in a call or
<p>When it isnt the comma go on to play a role in a call or
array further up the stack, so give it a chance.</p>
</div>
<div class="content"><div class='highlight'><pre> offset = <span class="hljs-keyword">if</span> nextTag <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">then</span> <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span>
<div class="content"><div class='highlight'><pre>
offset = <span class="hljs-keyword">if</span> nextTag <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">then</span> <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span>
<span class="hljs-keyword">while</span> inImplicitObject()
endImplicitObject i + offset
<span class="hljs-keyword">return</span> forward(<span class="hljs-number">1</span>)</pre></div></div>
@ -804,11 +830,11 @@ array further up the stack, so give it a chance.</p>
</li>
<li id="section-32">
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<a class="pilcrow" href="#section-34">&#182;</a>
</div>
<p>Add location data to all tokens generated by the rewriter.</p>
@ -834,15 +860,15 @@ array further up the stack, so give it a chance.</p>
</li>
<li id="section-33">
<li id="section-35">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<a class="pilcrow" href="#section-35">&#182;</a>
</div>
<p>Because our grammar is LALR(1), it can&#39;t handle some single-line
<p>Because our grammar is LALR(1), it cant handle some single-line
expressions that lack ending delimiters. The <strong>Rewriter</strong> adds the implicit
blocks, so it doesn&#39;t need to. To keep the grammar clean and tidy, trailing
blocks, so it doesnt need to. To keep the grammar clean and tidy, trailing
newlines within expressions are removed and the indentation tokens of empty
blocks are added.</p>
@ -888,11 +914,11 @@ blocks are added.</p>
</li>
<li id="section-34">
<li id="section-36">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<a class="pilcrow" href="#section-36">&#182;</a>
</div>
<p>Tag postfix conditionals as such, so that we can parse them with a
different precedence.</p>
@ -921,11 +947,11 @@ different precedence.</p>
</li>
<li id="section-35">
<li id="section-37">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a>
<a class="pilcrow" href="#section-37">&#182;</a>
</div>
<p>Generate the indentation tokens, based on another token on the same line.</p>
@ -946,11 +972,11 @@ different precedence.</p>
</li>
<li id="section-36">
<li id="section-38">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a>
<a class="pilcrow" href="#section-38">&#182;</a>
</div>
<p>Look up a tag by token index.</p>
@ -961,11 +987,11 @@ different precedence.</p>
</li>
<li id="section-37">
<li id="section-39">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-37">&#182;</a>
<a class="pilcrow" href="#section-39">&#182;</a>
</div>
<h2 id="constants">Constants</h2>
@ -974,11 +1000,23 @@ different precedence.</p>
</li>
<li id="section-38">
<li id="section-40">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-38">&#182;</a>
<a class="pilcrow" href="#section-40">&#182;</a>
</div>
</div>
</li>
<li id="section-41">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a>
</div>
<p>List of the token pairs that must be balanced.</p>
@ -997,13 +1035,13 @@ different precedence.</p>
</li>
<li id="section-39">
<li id="section-42">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-39">&#182;</a>
<a class="pilcrow" href="#section-42">&#182;</a>
</div>
<p>The inverse mappings of <code>BALANCED_PAIRS</code> we&#39;re trying to fix up, so we can
<p>The inverse mappings of <code>BALANCED_PAIRS</code> were trying to fix up, so we can
look things up from either end.</p>
</div>
@ -1013,11 +1051,11 @@ look things up from either end.</p>
</li>
<li id="section-40">
<li id="section-43">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-40">&#182;</a>
<a class="pilcrow" href="#section-43">&#182;</a>
</div>
<p>The tokens that signal the start/end of a balanced pair.</p>
@ -1033,11 +1071,11 @@ EXPRESSION_END = []
</li>
<li id="section-41">
<li id="section-44">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a>
<a class="pilcrow" href="#section-44">&#182;</a>
</div>
<p>Tokens that indicate the close of a clause of an expression.</p>
@ -1048,11 +1086,11 @@ EXPRESSION_END = []
</li>
<li id="section-42">
<li id="section-45">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-42">&#182;</a>
<a class="pilcrow" href="#section-45">&#182;</a>
</div>
<p>Tokens that, if followed by an <code>IMPLICIT_CALL</code>, indicate a function invocation.</p>
@ -1063,11 +1101,11 @@ EXPRESSION_END = []
</li>
<li id="section-43">
<li id="section-46">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-43">&#182;</a>
<a class="pilcrow" href="#section-46">&#182;</a>
</div>
<p>If preceded by an <code>IMPLICIT_FUNC</code>, indicates a function invocation.</p>
@ -1084,11 +1122,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="hljs-string">'+'</span>, <span class="hlj
</li>
<li id="section-44">
<li id="section-47">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-44">&#182;</a>
<a class="pilcrow" href="#section-47">&#182;</a>
</div>
<p>Tokens that always mark the end of an implicit call for single-liners.</p>
@ -1100,14 +1138,14 @@ IMPLICIT_UNSPACED_CALL = [<span class="hljs-string">'+'</span>, <span class="hlj
</li>
<li id="section-45">
<li id="section-48">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-45">&#182;</a>
<a class="pilcrow" href="#section-48">&#182;</a>
</div>
<p>Single-line flavors of block expressions that have unclosed endings.
The grammar can&#39;t disambiguate them, so we insert the implicit indentation.</p>
The grammar cant disambiguate them, so we insert the implicit indentation.</p>
</div>
@ -1117,11 +1155,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
</li>
<li id="section-46">
<li id="section-49">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-46">&#182;</a>
<a class="pilcrow" href="#section-49">&#182;</a>
</div>
<p>Tokens that end a line.</p>
@ -1132,11 +1170,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
</li>
<li id="section-47">
<li id="section-50">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-47">&#182;</a>
<a class="pilcrow" href="#section-50">&#182;</a>
</div>
<p>Tokens that close open calls when they follow a newline.</p>

View File

@ -192,7 +192,7 @@ it belongs to.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>When <code>super</code> is called, we need to find the name of the current method we&#39;re
<p>When <code>super</code> is called, we need to find the name of the current method were
in, so that we know how to invoke the same method of the parent class. This
can get complicated if super is being called from an inner function.
<code>namedMethod</code> will walk up the scope tree until it either finds the first
@ -304,7 +304,7 @@ walks up to the root scope.</p>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>If we need to store an intermediate result, find an available name for a
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...</p>
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on</p>
</div>

View File

@ -115,7 +115,7 @@
</div>
<p>Source maps allow JavaScript runtimes to match running JavaScript back to
the original source code that corresponds to it. This can be minified
JavaScript, but in our case, we&#39;re concerned with mapping pretty-printed
JavaScript, but in our case, were concerned with mapping pretty-printed
JavaScript back to CoffeeScript.</p>
<p>In order to produce maps, we must keep track of positions (line number, column number)
that originated every node in the syntax tree, and be able to generate a
@ -178,7 +178,7 @@ positions for a single line of output JavaScript code.
<p>Maps locations in a single generated JavaScript file back to locations in
the original CoffeeScript source file.</p>
<p>This is intentionally agnostic towards how a source map might be represented on
disk. Once the compiler is ready to produce a &quot;v3&quot;-style source map, we can walk
disk. Once the compiler is ready to produce a “v3”-style source map, we can walk
through the arrays of line and column buffer to produce it.</p>
</div>
@ -251,7 +251,7 @@ code.</p>
<p>Builds up a V3 source map, returning the generated JSON as a string.
<code>options.sourceRoot</code> may be used to specify the sourceRoot written to the source
map. Also, <code>options.sourceFiles</code> and <code>options.generatedFile</code> may be passed to
set &quot;sources&quot; and &quot;file&quot;, respectively.</p>
set “sources” and “file”, respectively.</p>
</div>
@ -280,7 +280,7 @@ set &quot;sources&quot; and &quot;file&quot;, respectively.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Write a comma if we&#39;ve already written a segment on this line.</p>
<p>Write a comma if weve already written a segment on this line.</p>
</div>
@ -298,7 +298,7 @@ set &quot;sources&quot; and &quot;file&quot;, respectively.</p>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Write the next segment. Segments can be 1, 4, or 5 values. If just one, then it
is a generated column which doesn&#39;t match anything in the source code.</p>
is a generated column which doesnt match anything in the source code.</p>
<p>The starting column in the generated source, relative to any previous recorded
column for the current line:</p>
@ -364,7 +364,7 @@ column for the current line:</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Produce the canonical JSON object format for a &quot;v3&quot; source map.</p>
<p>Produce the canonical JSON object format for a “v3” source map.</p>
</div>
@ -402,7 +402,7 @@ column for the current line:</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Note that SourceMap VLQ encoding is &quot;backwards&quot;. MIDI-style VLQ encoding puts
<p>Note that SourceMap VLQ encoding is “backwards”. MIDI-style VLQ encoding puts
the most-significant-bit (MSB) from the original value into the MSB of the VLQ
encoded value (see <a href="http://en.wikipedia.org/wiki/File:Uintvar_coding.svg">Wikipedia</a>).
SourceMap VLQ does things the other way around, with the least significat four

File diff suppressed because it is too large Load Diff

View File

@ -1192,6 +1192,45 @@ Expressions
Change Log
</h2>
<p>
<%= releaseHeader('2014-08-26', '1.8.0', '1.7.1') %>
<ul>
<li>
The <tt>--join</tt> option of the CLI is now deprecated.
</li>
<li>
Source maps now use <tt>.js.map</tt> as file extension, instead of just <tt>.map</tt>.
</li>
<li>
The CLI now exits with the exit code 1 when it fails to write a file to disk.
</li>
<li>
The compiler no longer crashes on unterminated, single-quoted strings.
</li>
<li>
Fixed location data for string interpolations, which made source maps out of sync.
</li>
<li>
The error marker in error messages is now correctly positioned if the code is indented with tabs.
</li>
<li>
Fixed a slight formatting error in CoffeeScripts source map-patched stack traces.
</li>
<li>
The <tt>%%</tt> operator now coerces its right operand only once.
</li>
<li>
It is now possible to require CoffeeScript files from Cakefiles without having to register the compiler first.
</li>
<li>
The CoffeeScript REPL is now exported and can be required using <tt>require 'coffee-script/repl'</tt>.
</li>
<li>
Fixes for the REPL in Node 0.11.
</li>
</ul>
</p>
<p>
<%= releaseHeader('2014-01-29', '1.7.1', '1.7.0') %>
<ul>

View File

@ -87,7 +87,6 @@
<a href="documentation/docs/sourcemap.html">Source Maps &mdash; src/sourcemap</a>
</div>
</div>
<div id="error" style="display:none;"></div>
</div>
<div class="container">
@ -114,8 +113,7 @@
<a href="http://github.com/jashkenas/coffeescript/tarball/1.7.1">1.7.1</a>
</p>
<pre>
sudo npm install -g coffee-script</pre>
<pre>npm install -g coffee-script</pre>
<h2>
<span id="overview" class="bookmark"></span>
@ -261,27 +259,30 @@ cubes = (function() {
<p>
To install, first make sure you have a working copy of the latest stable version of
<a href="http://nodejs.org/">Node.js</a>, and <a href="http://npmjs.org">npm</a>
(the Node Package Manager). You can then install CoffeeScript with npm:
(the Node Package Manager). You can then install CoffeeScript globally with npm:
</p>
<pre>
npm install -g coffee-script</pre>
<p>
(Leave off the <tt>-g</tt> if you don't wish to install globally.)
When you need CoffeeScript as a dependency, install it locally:
</p>
<pre>
npm install --save coffee-script</pre>
<p>
If you'd prefer to install the latest <b>master</b> version of CoffeeScript, you
can clone the CoffeeScript
<a href="http://github.com/jashkenas/coffeescript">source repository</a>
from GitHub, or download
<a href="http://github.com/jashkenas/coffeescript/tarball/master">the source</a> directly.
To install the lastest master CoffeeScript compiler with npm:
To install the latest master CoffeeScript compiler with npm:
</p>
<pre>
npm install -g http://github.com/jashkenas/coffeescript/tarball/master</pre>
npm install -g jashkenas/coffeescript</pre>
<p>
Or, if you want to install to <tt>/usr/local</tt>, and don't want to use
@ -1742,7 +1743,7 @@ futurists = {
};
_ref = futurists.poet, name = _ref.name, (_ref1 = _ref.address, street = _ref1[0], city = _ref1[1]);
;alert("name + "-" + street");'>run: "name + "-" + street"</div><br class='clear' /></div>
;alert(name + "-" + street);'>run: name + "-" + street</div><br class='clear' /></div>
<p>
Destructuring assignment can even be combined with splats.
</p>
@ -1788,7 +1789,7 @@ _ref = text.split(<span class="string">" "</span>), first = _ref[<span class="nu
text = "Every literary critic believes he will outwit history and have the last word";
_ref = text.split(" "), first = _ref[0], last = _ref[_ref.length - 1];
;alert("first + " " + last");'>run: "first + " " + last"</div><br class='clear' /></div>
;alert(first + " " + last);'>run: first + " " + last</div><br class='clear' /></div>
<p>
Destructuring assignment is also useful when combined with class constructors
to assign properties to your instance from an options object passed to the constructor.
@ -2339,7 +2340,7 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</h2>
<p>
The <a href="https://github.com/trending?l=coffeescript&since=monthly">best list of
The <a href="https://github.com/trending?l=coffeescript&amp;since=monthly">best list of
open-source CoffeeScript examples</a> can be found on GitHub. But just
to throw out few more:
</p>
@ -2449,10 +2450,54 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</h2>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.7.0...1.7.1">1.7.1</a>
<span class="timestamp"> &ndash; <small>January 29, 2014</small></span>
</b>
<div class="anchor" id="1.8.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.7.1...1.8.0">1.8.0</a>
<span class="timestamp"> &mdash; <time datetime="2014-08-26">August 26, 2014</time></span>
</b>
<ul>
<li>
The <tt>--join</tt> option of the CLI is now deprecated.
</li>
<li>
Source maps now use <tt>.js.map</tt> as file extension, instead of just <tt>.map</tt>.
</li>
<li>
The CLI now exits with the exit code 1 when it fails to write a file to disk.
</li>
<li>
The compiler no longer crashes on unterminated, single-quoted strings.
</li>
<li>
Fixed location data for string interpolations, which made source maps out of sync.
</li>
<li>
The error marker in error messages is now correctly positioned if the code is indented with tabs.
</li>
<li>
Fixed a slight formatting error in CoffeeScripts source map-patched stack traces.
</li>
<li>
The <tt>%%</tt> operator now coerces its right operand only once.
</li>
<li>
It is now possible to require CoffeeScript files from Cakefiles without having to register the compiler first.
</li>
<li>
The CoffeeScript REPL is now exported and can be required using <tt>require 'coffee-script/repl'</tt>.
</li>
<li>
Fixes for the REPL in Node 0.11.
</li>
</ul>
</p>
<p>
<div class="anchor" id="1.7.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.7.0...1.7.1">1.7.1</a>
<span class="timestamp"> &mdash; <time datetime="2014-01-29">January 29, 2014</time></span>
</b>
<ul>
<li>
Fixed a typo that broke node module lookup when running a script directly with the <tt>coffee</tt> binary.
@ -2460,10 +2505,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</ul>
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.6.3...1.7.0">1.7.0</a>
<span class="timestamp"> &ndash; <small>January 28, 2014</small></span>
</b>
<div class="anchor" id="1.7.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.6.3...1.7.0">1.7.0</a>
<span class="timestamp"> &mdash; <time datetime="2014-01-28">January 28, 2014</time></span>
</b>
<ul>
<li>
When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with <tt>require 'coffee-script/register'</tt> or <tt>CoffeeScript.register()</tt>. Also for configuration such as Mocha's, use <b>coffee-script/register</b>.
@ -2498,7 +2544,7 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
Closing brackets can now be indented and therefore no longer cause unexpected error.
</li>
<li>
Several breaking compilation fixes. Non-callable literals (strings, numbers etc.) don't compile in a call now and multiple postfix conditionals compile properly. Postfix conditionals and loops always bind object literals. Conditional assignment compiles properly in subexpressions. <tt>super</tt> is disallowed outside of methods and works correctly inside <tt>for</tt> loops.
Several breaking compilation fixes. Non-callable literals (strings, numbers etc.) don't compile in a call now and multiple postfix conditionals compile properly. Postfix conditionals and loops always bind object literals. Conditional assignment compiles properly in subexpressions. <tt>super</tt> is disallowed outside of methods and works correctly inside <tt>for</tt> loops.
</li>
<li>
Formatting of compiled block comments has been improved.
@ -2512,10 +2558,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</ul>
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.6.2...1.6.3">1.6.3</a>
<span class="timestamp"> &ndash; <small>June 2, 2013</small></span>
</b>
<div class="anchor" id="1.6.3"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.6.2...1.6.3">1.6.3</a>
<span class="timestamp"> &mdash; <time datetime="2013-06-02">June 2, 2013</time></span>
</b>
<ul>
<li>
The CoffeeScript REPL now remembers your history between sessions.
@ -2541,10 +2588,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.6.1...1.6.2">1.6.2</a>
<span class="timestamp"> &ndash; <small>March 18, 2013</small></span>
</b>
<div class="anchor" id="1.6.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.6.1...1.6.2">1.6.2</a>
<span class="timestamp"> &mdash; <time datetime="2013-03-18">March 18, 2013</time></span>
</b>
<ul>
<li>
Source maps have been used to provide automatic line-mapping when
@ -2570,10 +2618,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.5.0...1.6.1">1.6.1</a>
<span class="timestamp"> &ndash; <small>March 5, 2013</small></span>
</b>
<div class="anchor" id="1.6.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.5.0...1.6.1">1.6.1</a>
<span class="timestamp"> &mdash; <time datetime="2013-03-05">March 5, 2013</time></span>
</b>
<ul>
<li>
First release of <a href="#source-maps">source maps</a>. Pass the
@ -2599,10 +2648,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.4.0...1.5.0">1.5.0</a>
<span class="timestamp"> &ndash; <small>Feb 25, 2013</small></span>
</b>
<div class="anchor" id="1.5.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.4.0...1.5.0">1.5.0</a>
<span class="timestamp"> &mdash; <time datetime="2013-02-25">February 25, 2013</time></span>
</b>
<ul>
<li>
First release of <a href="#literate">Literate CoffeeScript</a>.
@ -2627,10 +2677,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.3.3...1.4.0">1.4.0</a>
<span class="timestamp"> &ndash; <small>Oct 23, 2012</small></span>
</b>
<div class="anchor" id="1.4.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.3.3...1.4.0">1.4.0</a>
<span class="timestamp"> &mdash; <time datetime="2012-10-23">October 23, 2012</time></span>
</b>
<ul>
<li>
The CoffeeScript compiler now strips Microsoft's UTF-8 BOM if it
@ -2648,10 +2699,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.3.1...1.3.3">1.3.3</a>
<span class="timestamp"> &ndash; <small>May 15, 2012</small></span>
</b>
<div class="anchor" id="1.3.3"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.3.1...1.3.3">1.3.3</a>
<span class="timestamp"> &mdash; <time datetime="2012-05-15">May 15, 2012</time></span>
</b>
<ul>
<li>
Due to the new semantics of JavaScript's strict mode, CoffeeScript no
@ -2677,10 +2729,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.2.0...1.3.1">1.3.1</a>
<span class="timestamp"> &ndash; <small>April 10, 2012</small></span>
</b>
<div class="anchor" id="1.3.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.2.0...1.3.1">1.3.1</a>
<span class="timestamp"> &mdash; <time datetime="2012-04-10">April 10, 2012</time></span>
</b>
<ul>
<li>
CoffeeScript now enforces all of JavaScript's <b>Strict Mode</b> early syntax
@ -2727,10 +2780,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.1.3...1.2.0">1.2.0</a>
<span class="timestamp"> &ndash; <small>Dec. 18, 2011</small></span>
</b>
<div class="anchor" id="1.2.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.1.3...1.2.0">1.2.0</a>
<span class="timestamp"> &mdash; <time datetime="2011-12-18">December 18, 2011</time></span>
</b>
<ul>
<li>
Multiple improvements to <tt>coffee --watch</tt> and <tt>--join</tt>.
@ -2754,10 +2808,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.1.2...1.1.3">1.1.3</a>
<span class="timestamp"> &ndash; <small>Nov. 8, 2011</small></span>
</b>
<div class="anchor" id="1.1.3"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.1.2...1.1.3">1.1.3</a>
<span class="timestamp"> &mdash; <time datetime="2011-11-08">November 8, 2011</time></span>
</b>
<ul>
<li>
Ahh, whitespace. CoffeeScript's compiled JS now tries to space things
@ -2797,10 +2852,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffeescript/compare/1.1.1...1.1.2">1.1.2</a>
<span class="timestamp"> &ndash; <small>August 4, 2011</small></span>
</b>
<div class="anchor" id="1.1.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.1.1...1.1.2">1.1.2</a>
<span class="timestamp"> &mdash; <time datetime="2011-08-04">August 4, 2011</time></span>
</b>
Fixes for block comment formatting, <tt>?=</tt> compilation, implicit calls
against control structures, implicit invocation of a try/catch block,
variadic arguments leaking from local scope, line numbers in syntax errors
@ -2811,17 +2867,21 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">1.1.1
<span class="timestamp"> &ndash; <small>May 10, 2011</small></span>
</b>
<div class="anchor" id="1.1.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.1.0...1.1.1">1.1.1</a>
<span class="timestamp"> &mdash; <time datetime="2011-05-10">May 10, 2011</time></span>
</b>
Bugfix release for classes with external constructor functions, see
issue #1182.
</p>
<p>
<b class="header" style="margin-top: 20px;">1.1.0
<span class="timestamp"> &ndash; <small>May 1, 2011</small></span>
</b>
<div class="anchor" id="1.1.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.0.1...1.1.0">1.1.0</a>
<span class="timestamp"> &mdash; <time datetime="2011-05-01">May 1, 2011</time></span>
</b>
When running via the <tt>coffee</tt> executable, <tt>process.argv</tt> and
friends now report <tt>coffee</tt> instead of <tt>node</tt>.
Better compatibility with <b>Node.js 0.4.x</b> module lookup changes.
@ -2837,9 +2897,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">1.0.1
<span class="timestamp"> &ndash; <small>Jan 31, 2011</small></span>
</b>
<div class="anchor" id="1.0.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.0.0...1.0.1">1.0.1</a>
<span class="timestamp"> &mdash; <time datetime="2011-01-31">January 31, 2011</time></span>
</b>
Fixed a lexer bug with Unicode identifiers. Updated REPL for compatibility
with Node.js 0.3.7. Fixed requiring relative paths in the REPL. Trailing
<tt>return</tt> and <tt>return undefined</tt> are now optimized away.
@ -2850,9 +2912,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">1.0.0
<span class="timestamp"> &ndash; <small>Dec 24, 2010</small></span>
</b>
<div class="anchor" id="1.0.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.6...1.0.0">1.0.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-12-24">December 24, 2010</time></span>
</b>
CoffeeScript loops no longer try to preserve block scope when functions
are being generated within the loop body. Instead, you can use the
<tt>do</tt> keyword to create a convenient closure wrapper.
@ -2864,9 +2928,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.9.6
<span class="timestamp"> &ndash; <small>Dec 6, 2010</small></span>
</b>
<div class="anchor" id="0.9.6"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.5...0.9.6">0.9.6</a>
<span class="timestamp"> &mdash; <time datetime="2010-12-06">December 6, 2010</time></span>
</b>
The REPL now properly formats stacktraces, and stays alive through
asynchronous exceptions. Using <tt>--watch</tt> now prints timestamps as
files are compiled. Fixed some accidentally-leaking variables within
@ -2878,9 +2944,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.9.5
<span class="timestamp"> &ndash; <small>Nov 21, 2010</small></span>
</b>
<div class="anchor" id="0.9.5"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.4...0.9.5">0.9.5</a>
<span class="timestamp"> &mdash; <time datetime="2010-11-21">November 21, 2010</time></span>
</b>
0.9.5 should be considered the first release candidate for CoffeeScript 1.0.
There have been a large number of internal changes since the previous release,
many contributed from <b>satyr</b>'s <a href="http://github.com/satyr/coco">Coco</a>
@ -2894,9 +2962,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.9.4
<span class="timestamp"> &ndash; <small>Sep 21, 2010</small></span>
</b>
<div class="anchor" id="0.9.4"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.3...0.9.4">0.9.4</a>
<span class="timestamp"> &mdash; <time datetime="2010-09-21">September 21, 2010</time></span>
</b>
CoffeeScript now uses appropriately-named temporary variables, and recycles
their references after use. Added <tt>require.extensions</tt> support for
<b>Node.js 0.3</b>. Loading CoffeeScript in the browser now adds just a
@ -2905,9 +2975,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.9.3
<span class="timestamp"> &ndash; <small>Sep 16, 2010</small></span>
</b>
<div class="anchor" id="0.9.3"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.2...0.9.3">0.9.3</a>
<span class="timestamp"> &mdash; <time datetime="2010-09-16">September 16, 2010</time></span>
</b>
CoffeeScript <tt>switch</tt> statements now compile into JS <tt>switch</tt>
statements &mdash; they previously compiled into <tt>if/else</tt> chains
for JavaScript 1.3 compatibility.
@ -2916,9 +2988,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.9.2
<span class="timestamp"> &ndash; <small>Aug 23, 2010</small></span>
</b>
<div class="anchor" id="0.9.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.1...0.9.2">0.9.2</a>
<span class="timestamp"> &mdash; <time datetime="2010-08-23">August 23, 2010</time></span>
</b>
Specifying the start and end of a range literal is now optional, eg. <tt>array[3..]</tt>.
You can now say <tt>a not instanceof b</tt>.
Fixed important bugs with nested significant and non-significant indentation (Issue #637).
@ -2932,9 +3006,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.9.1
<span class="timestamp"> &ndash; <small>Aug 11, 2010</small></span>
</b>
<div class="anchor" id="0.9.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.0...0.9.1">0.9.1</a>
<span class="timestamp"> &mdash; <time datetime="2010-08-11">August 11, 2010</time></span>
</b>
Bugfix release for <b>0.9.1</b>. Greatly improves the handling of mixed
implicit objects, implicit function calls, and implicit indentation.
String and regex interpolation is now strictly <tt>#{ ... }</tt> (Ruby style).
@ -2943,9 +3019,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.9.0
<span class="timestamp"> &ndash; <small>Aug 4, 2010</small></span>
</b>
<div class="anchor" id="0.9.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.7.2...0.9.0">0.9.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-08-04">August 4, 2010</time></span>
</b>
The CoffeeScript <b>0.9</b> series is considered to be a release candidate
for <b>1.0</b>; let's give her a shakedown cruise. <b>0.9.0</b> introduces a massive
backwards-incompatible change: Assignment now uses <tt>=</tt>, and object
@ -2969,17 +3047,21 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.7.2
<span class="timestamp"> &ndash; <small>Jul 12, 2010</small></span>
</b>
<div class="anchor" id="0.7.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.7.1...0.7.2">0.7.2</a>
<span class="timestamp"> &mdash; <time datetime="2010-07-12">July 12, 2010</time></span>
</b>
Quick bugfix (right after 0.7.1) for a problem that prevented <tt>coffee</tt>
command-line options from being parsed in some circumstances.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.7.1
<span class="timestamp"> &ndash; <small>Jul 11, 2010</small></span>
</b>
<div class="anchor" id="0.7.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.7.0...0.7.1">0.7.1</a>
<span class="timestamp"> &mdash; <time datetime="2010-07-11">July 11, 2010</time></span>
</b>
Block-style comments are now passed through and printed as JavaScript block
comments -- making them useful for licenses and copyright headers. Better
support for running coffee scripts standalone via hashbangs.
@ -2987,9 +3069,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.7.0
<span class="timestamp"> &ndash; <small>Jun 28, 2010</small></span>
</b>
<div class="anchor" id="0.7.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.6.2...0.7.0">0.7.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-06-28">June 28, 2010</time></span>
</b>
Official CoffeeScript variable style is now camelCase, as in JavaScript.
Reserved words are now allowed as object keys, and will be quoted for you.
Range comprehensions now generate cleaner code, but you have to specify <tt>by -1</tt>
@ -3006,9 +3090,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.6.2
<span class="timestamp"> &ndash; <small>May 15, 2010</small></span>
</b>
<div class="anchor" id="0.6.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.6.1...0.6.2">0.6.2</a>
<span class="timestamp"> &mdash; <time datetime="2010-05-15">May 15, 2010</time></span>
</b>
The <tt>coffee</tt> command will now preserve directory structure when
compiling a directory full of scripts. Fixed two omissions that were preventing
the CoffeeScript compiler from running live within Internet Explorer.
@ -3023,26 +3109,32 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.6.1
<span class="timestamp"> &ndash; <small>Apr 12, 2010</small></span>
</b>
<div class="anchor" id="0.6.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.6.0...0.6.1">0.6.1</a>
<span class="timestamp"> &mdash; <time datetime="2010-04-12">April 12, 2010</time></span>
</b>
Upgraded CoffeeScript for compatibility with the new Node.js <b>v0.1.90</b>
series.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.6.0
<span class="timestamp"> &ndash; <small>Apr 3, 2010</small></span>
</b>
<div class="anchor" id="0.6.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.6...0.6.0">0.6.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-04-03">April 3, 2010</time></span>
</b>
Trailing commas are now allowed, a-la Python. Static
properties may be assigned directly within class definitions,
using <tt>@property</tt> notation.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.5.6
<span class="timestamp"> &ndash; <small>Mar 23, 2010</small></span>
</b>
<div class="anchor" id="0.5.6"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.5...0.5.6">0.5.6</a>
<span class="timestamp"> &mdash; <time datetime="2010-03-23">March 23, 2010</time></span>
</b>
Interpolation can now be used within regular expressions and heredocs, as well as
strings. Added the <tt>&lt;-</tt> bind operator.
Allowing assignment to half-expressions instead of special <tt>||=</tt>-style
@ -3053,9 +3145,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.5.5
<span class="timestamp"> &ndash; <small>Mar 8, 2010</small></span>
</b>
<div class="anchor" id="0.5.5"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.4...0.5.5">0.5.5</a>
<span class="timestamp"> &mdash; <time datetime="2010-03-08">March 8, 2010</time></span>
</b>
String interpolation, contributed by
<a href="http://github.com/StanAngeloff">Stan Angeloff</a>.
Since <tt>--run</tt> has been the default since <b>0.5.3</b>, updating
@ -3064,18 +3158,22 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.5.4
<span class="timestamp"> &ndash; <small>Mar 3, 2010</small></span>
</b>
<div class="anchor" id="0.5.4"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.3...0.5.4">0.5.4</a>
<span class="timestamp"> &mdash; <time datetime="2010-03-03">March 3, 2010</time></span>
</b>
Bugfix that corrects the Node.js global constants <tt>__filename</tt> and
<tt>__dirname</tt>. Tweaks for more flexible parsing of nested function
literals and improperly-indented comments. Updates for the latest Node.js API.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.5.3
<span class="timestamp"> &ndash; <small>Feb 27, 2010</small></span>
</b>
<div class="anchor" id="0.5.3"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.2...0.5.3">0.5.3</a>
<span class="timestamp"> &mdash; <time datetime="2010-02-27">February 27, 2010</time></span>
</b>
CoffeeScript now has a syntax for defining classes. Many of the core
components (Nodes, Lexer, Rewriter, Scope, Optparse) are using them.
Cakefiles can use <tt>optparse.coffee</tt> to define options for tasks.
@ -3085,9 +3183,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.5.2
<span class="timestamp"> &ndash; <small>Feb 25, 2010</small></span>
</b>
<div class="anchor" id="0.5.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.1...0.5.2">0.5.2</a>
<span class="timestamp"> &mdash; <time datetime="2010-02-25">February 25, 2010</time></span>
</b>
Added a compressed version of the compiler for inclusion in web pages as
<br /><tt>extras/coffee-script.js</tt>. It'll automatically run any script tags
with type <tt>text/coffeescript</tt> for you. Added a <tt>--stdio</tt> option
@ -3096,9 +3196,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
<p>
<b class="header" style="margin-top: 20px;">0.5.1
<span class="timestamp"> &ndash; <small>Feb 24, 2010</small></span>
</b>
<div class="anchor" id="0.5.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.0...0.5.1">0.5.1</a>
<span class="timestamp"> &mdash; <time datetime="2010-02-24">February 24, 2010</time></span>
</b>
Improvements to null soaking with the existential operator, including
soaks on indexed properties. Added conditions to <tt>while</tt> loops,
so you can use them as filters with <tt>when</tt>, in the same manner as
@ -3106,27 +3208,33 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.5.0
<span class="timestamp"> &ndash; <small>Feb 21, 2010</small></span>
</b>
<div class="anchor" id="0.5.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.3.2...0.5.0">0.5.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-02-21">February 21, 2010</time></span>
</b>
CoffeeScript 0.5.0 is a major release, While there are no language changes,
the Ruby compiler has been removed in favor of a self-hosting
compiler written in pure CoffeeScript.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.3.2
<span class="timestamp"> &ndash; <small>Feb 8, 2010</small></span>
</b>
<div class="anchor" id="0.3.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.3.0...0.3.2">0.3.2</a>
<span class="timestamp"> &mdash; <time datetime="2010-02-08">February 8, 2010</time></span>
</b>
<tt>@property</tt> is now a shorthand for <tt>this.property</tt>.<br />
Switched the default JavaScript engine from Narwhal to Node.js. Pass
the <tt>--narwhal</tt> flag if you'd like to continue using it.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.3.0
<span class="timestamp"> &ndash; <small>Jan 26, 2010</small></span>
</b>
<div class="anchor" id="0.3.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.2.6...0.3.0">0.3.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-26">January 26, 2010</time></span>
</b>
CoffeeScript 0.3 includes major syntax changes:
<br />
The function symbol was changed to
@ -3142,9 +3250,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.2.6
<span class="timestamp"> &ndash; <small>Jan 17, 2010</small></span>
</b>
<div class="anchor" id="0.2.6"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.2.5...0.2.6">0.2.6</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-17">January 17, 2010</time></span>
</b>
Added Python-style chained comparisons, the conditional existence
operator <tt>?=</tt>, and some examples from <i>Beautiful Code</i>.
Bugfixes relating to statement-to-expression conversion, arguments-to-array
@ -3152,9 +3262,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.2.5
<span class="timestamp"> &ndash; <small>Jan 13, 2010</small></span>
</b>
<div class="anchor" id="0.2.5"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.2.4...0.2.5">0.2.5</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-13">January 13, 2010</time></span>
</b>
The conditions in switch statements can now take multiple values at once &mdash;
If any of them are true, the case will run. Added the long arrow <tt>==></tt>,
which defines and immediately binds a function to <tt>this</tt>. While loops can
@ -3163,26 +3275,32 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.2.4
<span class="timestamp"> &ndash; <small>Jan 12, 2010</small></span>
</b>
<div class="anchor" id="0.2.4"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.2.3...0.2.4">0.2.4</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-12">January 12, 2010</time></span>
</b>
Added ECMAScript Harmony style destructuring assignment, for dealing with
extracting values from nested arrays and objects. Added indentation-sensitive
heredocs for nicely formatted strings or chunks of code.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.2.3
<span class="timestamp"> &ndash; <small>Jan 11, 2010</small></span>
</b>
<div class="anchor" id="0.2.3"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.2.2...0.2.3">0.2.3</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-11">January 11, 2010</time></span>
</b>
Axed the unsatisfactory <tt>ino</tt> keyword, replacing it with <tt>of</tt> for
object comprehensions. They now look like: <tt>for prop, value of object</tt>.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.2.2
<span class="timestamp"> &ndash; <small>Jan 10, 2010</small></span>
</b>
<div class="anchor" id="0.2.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.2.1...0.2.2">0.2.2</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-10">January 10, 2010</time></span>
</b>
When performing a comprehension over an object, use <tt>ino</tt>, instead
of <tt>in</tt>, which helps us generate smaller, more efficient code at
compile time.
@ -3203,16 +3321,20 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.2.1
<span class="timestamp"> &ndash; <small>Jan 5, 2010</small></span>
</b>
<div class="anchor" id="0.2.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.2.0...0.2.1">0.2.1</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-05">January 5, 2010</time></span>
</b>
Arguments objects are now converted into real arrays when referenced.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.2.0
<span class="timestamp"> &ndash; <small>Jan 5, 2010</small></span>
</b>
<div class="anchor" id="0.2.0"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.6...0.2.0">0.2.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-05">January 5, 2010</time></span>
</b>
Major release. Significant whitespace. Better statement-to-expression
conversion. Splats. Splice literals. Object comprehensions. Blocks.
The existential operator. Many thanks to all the folks who posted issues,
@ -3222,18 +3344,22 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.1.6
<span class="timestamp"> &ndash; <small>Dec 27, 2009</small></span>
</b>
<div class="anchor" id="0.1.6"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.5...0.1.6">0.1.6</a>
<span class="timestamp"> &mdash; <time datetime="2009-12-27">December 27, 2009</time></span>
</b>
Bugfix for running <tt>coffee --interactive</tt> and <tt>--run</tt>
from outside of the CoffeeScript directory. Bugfix for nested
function/if-statements.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.1.5
<span class="timestamp"> &ndash; <small>Dec 26, 2009</small></span>
</b>
<div class="anchor" id="0.1.5"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.4...0.1.5">0.1.5</a>
<span class="timestamp"> &mdash; <time datetime="2009-12-26">December 26, 2009</time></span>
</b>
Array slice literals and array comprehensions can now both take Ruby-style
ranges to specify the start and end. JavaScript variable declaration is
now pushed up to the top of the scope, making all assignment statements into
@ -3242,9 +3368,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.1.4
<span class="timestamp"> &ndash; <small>Dec 25, 2009</small></span>
</b>
<div class="anchor" id="0.1.4"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.3...0.1.4">0.1.4</a>
<span class="timestamp"> &mdash; <time datetime="2009-12-25">December 25, 2009</time></span>
</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>.
@ -3256,9 +3384,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.1.3
<span class="timestamp"> &ndash; <small>Dec 25, 2009</small></span>
</b>
<div class="anchor" id="0.1.3"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.2...0.1.3">0.1.3</a>
<span class="timestamp"> &mdash; <time datetime="2009-12-25">December 25, 2009</time></span>
</b>
The <tt>coffee</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
@ -3272,9 +3402,11 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.1.2
<span class="timestamp"> &ndash; <small>Dec 24, 2009</small></span>
</b>
<div class="anchor" id="0.1.2"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.1...0.1.2">0.1.2</a>
<span class="timestamp"> &mdash; <time datetime="2009-12-24">December 24, 2009</time></span>
</b>
Fixed a bug with calling <tt>super()</tt> through more than one level of
inheritance, with the re-addition of the <tt>extends</tt> keyword.
Added experimental <a href="http://narwhaljs.org/">Narwhal</a>
@ -3286,16 +3418,20 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
</p>
<p>
<b class="header" style="margin-top: 20px;">0.1.1
<span class="timestamp"> &ndash; <small>Dec 24, 2009</small></span>
</b>
<div class="anchor" id="0.1.1"></div>
<b class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.0...0.1.1">0.1.1</a>
<span class="timestamp"> &mdash; <time datetime="2009-12-24">December 24, 2009</time></span>
</b>
Added <tt>instanceof</tt> and <tt>typeof</tt> as operators.
</p>
<p>
<b class="header" style="margin-top: 20px;">0.1.0
<span class="timestamp"> &ndash; <small>Dec 24, 2009</small></span>
</b>
<div class="anchor" id="0.1.0"></div>
<b class="header">
0.1.0
<span class="timestamp"> &mdash; <time datetime="2009-12-24">December 24, 2009</time></span>
</b>
Initial CoffeeScript release.
</p>
@ -3307,19 +3443,22 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
# Set up the compilation function, to run when you stop typing.
compileSource = ->
source = $('#repl_source').val()
results = $('#repl_results')
window.compiledJS = ''
try
window.compiledJS = CoffeeScript.compile source, bare: on
el = $('#repl_results')[0]
el = results[0]
if el.innerText
el.innerText = window.compiledJS
else
$(el).text window.compiledJS
$('#error').hide()
results.text(window.compiledJS)
results.removeClass 'error'
$('.minibutton.run').removeClass 'error'
catch {location, message}
if location?
message = "Error on line #{location.first_line + 1}: #{message}"
$('#error').text(message).show()
results.text(message).addClass 'error'
$('.minibutton.run').addClass 'error'
# Update permalink
$('#repl_permalink').attr 'href', "##{sourceFragment}#{encodeURIComponent source}"