1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

CoffeeScript 1.6.3

This commit is contained in:
Jeremy Ashkenas 2013-06-02 09:37:45 +04:00
parent 7b14a6aad2
commit 84b8b5ccee
74 changed files with 2279 additions and 1346 deletions

View file

@ -112,12 +112,12 @@
to make things work smoothly when compiling code directly in the browser. to make things work smoothly when compiling code directly in the browser.
We add support for loading remote Coffee scripts via <strong>XHR</strong>, and We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
<code>text/coffeescript</code> script tags, source maps via data-URLs, and so on. <code>text/coffeescript</code> script tags, source maps via data-URLs, and so on.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre>CoffeeScript = require <span class="string">'./coffee-script'</span> <div class="content"><div class='highlight'><pre>
CoffeeScript = require <span class="string">'./coffee-script'</span>
CoffeeScript.require = require CoffeeScript.require = require
compile = CoffeeScript.compile</pre></div></div> compile = CoffeeScript.compile</pre></div></div>
@ -155,6 +155,7 @@ compile = CoffeeScript.compile</pre></div></div>
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="function"><span class="title">run</span></span> = (code, options = {}) -&gt; <div class="content"><div class='highlight'><pre>CoffeeScript.<span class="function"><span class="title">run</span></span> = (code, options = {}) -&gt;
options.bare = <span class="literal">on</span> options.bare = <span class="literal">on</span>
options.shiftLine = <span class="literal">on</span>
Function(compile code, options)()</pre></div></div> Function(compile code, options)()</pre></div></div>
</li> </li>
@ -182,18 +183,19 @@ compile = CoffeeScript.compile</pre></div></div>
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a> <a class="pilcrow" href="#section-5">&#182;</a>
</div> </div>
<p>Include source maps where possible. If we&#39;ve got a base64 encoder, and a <p>Include source maps where possible. If we&#39;ve got a base64 encoder, a
JSON serializer, we&#39;re good to go. JSON serializer, and tools for escaping unicode characters, we&#39;re 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> </p>
</div> </div>
<div class="content"><div class='highlight'><pre><span class="keyword">if</span> btoa? <span class="keyword">and</span> JSON? <div class="content"><div class='highlight'><pre><span class="keyword">if</span> btoa? <span class="keyword">and</span> JSON? <span class="keyword">and</span> unescape? <span class="keyword">and</span> encodeURIComponent?
<span class="function"><span class="title">compile</span></span> = (code, options = {}) -&gt; <span class="function"><span class="title">compile</span></span> = (code, options = {}) -&gt;
options.sourceMap = <span class="literal">true</span> options.sourceMap = <span class="literal">true</span>
options.inline = <span class="literal">true</span> options.inline = <span class="literal">true</span>
{js, v3SourceMap} = CoffeeScript.compile code, options {js, v3SourceMap} = CoffeeScript.compile code, options
<span class="string">"<span class="subst">#{js}</span>\n//@ sourceMappingURL=data:application/json;base64,<span class="subst">#{btoa v3SourceMap}</span>\n//@ sourceURL=coffeescript"</span></pre></div></div> <span class="string">"<span class="subst">#{js}</span>\n//@ sourceMappingURL=data:application/json;base64,<span class="subst">#{btoa unescape encodeURIComponent v3SourceMap}</span>\n//@ sourceURL=coffeescript"</span></pre></div></div>
</li> </li>
@ -214,7 +216,7 @@ JSON serializer, we&#39;re good to go.
xhr = <span class="keyword">if</span> window.ActiveXObject xhr = <span class="keyword">if</span> window.ActiveXObject
<span class="keyword">new</span> window.ActiveXObject(<span class="string">'Microsoft.XMLHTTP'</span>) <span class="keyword">new</span> window.ActiveXObject(<span class="string">'Microsoft.XMLHTTP'</span>)
<span class="keyword">else</span> <span class="keyword">else</span>
<span class="keyword">new</span> XMLHttpRequest() <span class="keyword">new</span> window.XMLHttpRequest()
xhr.open <span class="string">'GET'</span>, url, <span class="literal">true</span> xhr.open <span class="string">'GET'</span>, url, <span class="literal">true</span>
xhr.overrideMimeType <span class="string">'text/plain'</span> <span class="keyword">if</span> <span class="string">'overrideMimeType'</span> <span class="keyword">of</span> xhr xhr.overrideMimeType <span class="string">'text/plain'</span> <span class="keyword">if</span> <span class="string">'overrideMimeType'</span> <span class="keyword">of</span> xhr
xhr.<span class="function"><span class="title">onreadystatechange</span></span> = -&gt; xhr.<span class="function"><span class="title">onreadystatechange</span></span> = -&gt;
@ -243,7 +245,7 @@ This happens on page load.
</div> </div>
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">runScripts</span></span> = -&gt; <div class="content"><div class='highlight'><pre><span class="function"><span class="title">runScripts</span></span> = -&gt;
scripts = document.getElementsByTagName <span class="string">'script'</span> scripts = window.document.getElementsByTagName <span class="string">'script'</span>
coffeetypes = [<span class="string">'text/coffeescript'</span>, <span class="string">'text/literate-coffeescript'</span>] coffeetypes = [<span class="string">'text/coffeescript'</span>, <span class="string">'text/literate-coffeescript'</span>]
coffees = (s <span class="keyword">for</span> s <span class="keyword">in</span> scripts <span class="keyword">when</span> s.type <span class="keyword">in</span> coffeetypes) coffees = (s <span class="keyword">for</span> s <span class="keyword">in</span> scripts <span class="keyword">when</span> s.type <span class="keyword">in</span> coffeetypes)
index = <span class="number">0</span> index = <span class="number">0</span>
@ -276,9 +278,9 @@ This happens on page load.
</div> </div>
<div class="content"><div class='highlight'><pre><span class="keyword">if</span> window.addEventListener <div class="content"><div class='highlight'><pre><span class="keyword">if</span> window.addEventListener
addEventListener <span class="string">'DOMContentLoaded'</span>, runScripts, <span class="literal">no</span> window.addEventListener <span class="string">'DOMContentLoaded'</span>, runScripts, <span class="literal">no</span>
<span class="keyword">else</span> <span class="keyword">else</span>
attachEvent <span class="string">'onload'</span>, runScripts</pre></div></div> window.attachEvent <span class="string">'onload'</span>, runScripts</pre></div></div>
</li> </li>

View file

@ -116,9 +116,20 @@ and can call them from the command line, or invoke them from other tasks.
</p> </p>
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the <p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the
current directory&#39;s Cakefile. current directory&#39;s Cakefile.
</p> </p>
<p>External dependencies.
</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> </p>
</div> </div>
@ -134,11 +145,11 @@ existsSync = fs.existsSync <span class="keyword">or</span> path.existsSync</pr
</li> </li>
<li id="section-2"> <li id="section-3">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a> <a class="pilcrow" href="#section-3">&#182;</a>
</div> </div>
<p>Keep track of the list of defined tasks, the accepted options, and so on. <p>Keep track of the list of defined tasks, the accepted options, and so on.
</p> </p>
@ -153,11 +164,11 @@ oparse = <span class="literal">null</span></pre></div></div>
</li> </li>
<li id="section-3"> <li id="section-4">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a> <a class="pilcrow" href="#section-4">&#182;</a>
</div> </div>
<p>Mixin the top-level Cake functions for Cakefiles to use directly. <p>Mixin the top-level Cake functions for Cakefiles to use directly.
</p> </p>
@ -169,11 +180,11 @@ oparse = <span class="literal">null</span></pre></div></div>
</li> </li>
<li id="section-4"> <li id="section-5">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a> <a class="pilcrow" href="#section-5">&#182;</a>
</div> </div>
<p>Define a Cake task with a short name, an optional sentence description, <p>Define a Cake task with a short name, an optional sentence description,
and the function to run as the action itself. and the function to run as the action itself.
@ -188,11 +199,11 @@ and the function to run as the action itself.
</li> </li>
<li id="section-5"> <li id="section-6">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a> <a class="pilcrow" href="#section-6">&#182;</a>
</div> </div>
<p>Define an option that the Cakefile accepts. The parsed options hash, <p>Define an option that the Cakefile accepts. The parsed options hash,
containing all of the command-line options passed, will be made available containing all of the command-line options passed, will be made available
@ -207,11 +218,11 @@ as the first argument to the action.
</li> </li>
<li id="section-6"> <li id="section-7">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a> <a class="pilcrow" href="#section-7">&#182;</a>
</div> </div>
<p>Invoke another task in the current Cakefile. <p>Invoke another task in the current Cakefile.
</p> </p>
@ -225,11 +236,11 @@ as the first argument to the action.
</li> </li>
<li id="section-7"> <li id="section-8">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a> <a class="pilcrow" href="#section-8">&#182;</a>
</div> </div>
<p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Node&#39;s <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. asynchrony may cause tasks to execute in a different order than you&#39;d expect.
@ -255,11 +266,11 @@ original directory name, when running Cake tasks from subdirectories.
</li> </li>
<li id="section-8"> <li id="section-9">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a> <a class="pilcrow" href="#section-9">&#182;</a>
</div> </div>
<p>Display the list of Cake tasks in a format similar to <code>rake -T</code> <p>Display the list of Cake tasks in a format similar to <code>rake -T</code>
</p> </p>
@ -280,11 +291,11 @@ original directory name, when running Cake tasks from subdirectories.
</li> </li>
<li id="section-9"> <li id="section-10">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a> <a class="pilcrow" href="#section-10">&#182;</a>
</div> </div>
<p>Print an error and exit when attempting to use an invalid task/option. <p>Print an error and exit when attempting to use an invalid task/option.
</p> </p>
@ -301,11 +312,11 @@ original directory name, when running Cake tasks from subdirectories.
</li> </li>
<li id="section-10"> <li id="section-11">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a> <a class="pilcrow" href="#section-11">&#182;</a>
</div> </div>
<p>When <code>cake</code> is invoked, search in the current and all parent directories <p>When <code>cake</code> is invoked, search in the current and all parent directories
to find the relevant Cakefile. to find the relevant Cakefile.

View file

@ -112,12 +112,12 @@
on Node.js/V8, or to run CoffeeScript directly in the browser. This module on Node.js/V8, or to run CoffeeScript directly in the browser. This module
contains the main entry functions for tokenizing, parsing, and compiling contains the main entry functions for tokenizing, parsing, and compiling
source CoffeeScript into JavaScript. source CoffeeScript into JavaScript.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre>fs = require <span class="string">'fs'</span> <div class="content"><div class='highlight'><pre>
fs = require <span class="string">'fs'</span>
vm = require <span class="string">'vm'</span> vm = require <span class="string">'vm'</span>
path = require <span class="string">'path'</span> path = require <span class="string">'path'</span>
child_process = require <span class="string">'child_process'</span> child_process = require <span class="string">'child_process'</span>
@ -140,7 +140,7 @@ SourceMap = require <span class="string">'./sourcemap'</span></pre></div></d
</div> </div>
<div class="content"><div class='highlight'><pre>exports.VERSION = <span class="string">'1.6.2'</span></pre></div></div> <div class="content"><div class='highlight'><pre>exports.VERSION = <span class="string">'1.6.3'</span></pre></div></div>
</li> </li>
@ -175,7 +175,7 @@ options that can be passed to <code>SourceMap#generate</code> may also be passed
</p> </p>
<p>This returns a javascript string, unless <code>options.sourceMap</code> is passed, <p>This returns a javascript string, unless <code>options.sourceMap</code> is passed,
in which case this returns a `{js, v3SourceMap, sourceMap} in which case this returns a <code>{js, v3SourceMap, sourceMap}</code>
object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic
lookups. lookups.
</p> </p>
@ -183,15 +183,16 @@ lookups.
</div> </div>
<div class="content"><div class='highlight'><pre>exports.compile = <span class="function"><span class="title">compile</span></span> = (code, options = {}) -&gt; <div class="content"><div class='highlight'><pre>exports.compile = <span class="function"><span class="title">compile</span></span> = (code, options = {}) -&gt;
{merge} = exports.helpers {merge} = helpers
<span class="keyword">if</span> options.sourceMap <span class="keyword">if</span> options.sourceMap
map = <span class="keyword">new</span> SourceMap map = <span class="keyword">new</span> SourceMap
fragments = (parser.parse lexer.tokenize(code, options)).compileToFragments options fragments = parser.parse(lexer.tokenize code, options).compileToFragments options
currentLine = <span class="number">0</span> currentLine = <span class="number">0</span>
currentLine += <span class="number">1</span> <span class="keyword">if</span> options.header <span class="keyword">or</span> options.inline currentLine += <span class="number">1</span> <span class="keyword">if</span> options.header
currentLine += <span class="number">1</span> <span class="keyword">if</span> options.shiftLine
currentColumn = <span class="number">0</span> currentColumn = <span class="number">0</span>
js = <span class="string">""</span> js = <span class="string">""</span>
<span class="keyword">for</span> fragment <span class="keyword">in</span> fragments</pre></div></div> <span class="keyword">for</span> fragment <span class="keyword">in</span> fragments</pre></div></div>
@ -213,8 +214,8 @@ lookups.
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> options.sourceMap <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> options.sourceMap
<span class="keyword">if</span> fragment.locationData <span class="keyword">if</span> fragment.locationData
map.add( map.add(
[fragment.locationData.first_line, fragment.locationData.first_column], [fragment.locationData.first_line, fragment.locationData.first_column]
[currentLine, currentColumn], [currentLine, currentColumn]
{noReplace: <span class="literal">true</span>}) {noReplace: <span class="literal">true</span>})
newLines = helpers.count fragment.code, <span class="string">"\n"</span> newLines = helpers.count fragment.code, <span class="string">"\n"</span>
currentLine += newLines currentLine += newLines
@ -321,7 +322,7 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
</div> </div>
<div class="content"><div class='highlight'><pre> mainModule.filename = process.argv[<span class="number">1</span>] = <div class="content"><div class='highlight'><pre> mainModule.filename = process.argv[<span class="number">1</span>] =
<span class="keyword">if</span> options.filename <span class="keyword">then</span> fs.realpathSync(options.filename) <span class="keyword">else</span> <span class="string">'.'</span></pre></div></div> <span class="keyword">if</span> options.filename <span class="keyword">then</span> fs.realpathSync(options.filename) <span class="keyword">else</span> <span class="string">'.'</span></pre></div></div>
</li> </li>
@ -381,14 +382,14 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a> <a class="pilcrow" href="#section-14">&#182;</a>
</div> </div>
<p>Attach sourceMap object to mainModule._sourceMaps[options.filename] so that <p>Attach sourceMap object to sourceMaps[options.filename] so that
it is accessible by Error.prepareStackTrace. it is accessible by Error.prepareStackTrace.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> <span class="keyword">do</span> patchStackTrace <div class="content"><div class='highlight'><pre> <span class="keyword">do</span> patchStackTrace
mainModule._sourceMaps[mainModule.filename] = answer.sourceMap sourceMaps[mainModule.filename] = answer.sourceMap
mainModule._compile answer.js, mainModule.filename mainModule._compile answer.js, mainModule.filename
<span class="keyword">else</span> <span class="keyword">else</span>
mainModule._compile code, mainModule.filename</pre></div></div> mainModule._compile code, mainModule.filename</pre></div></div>
@ -487,7 +488,9 @@ The CoffeeScript REPL uses this to run the input.
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">loadFile</span></span> = (module, filename) -&gt; <div class="content"><div class='highlight'><pre><span class="function"><span class="title">loadFile</span></span> = (module, filename) -&gt;
raw = fs.readFileSync filename, <span class="string">'utf8'</span> raw = fs.readFileSync filename, <span class="string">'utf8'</span>
stripped = <span class="keyword">if</span> raw.charCodeAt(<span class="number">0</span>) <span class="keyword">is</span> <span class="number">0xFEFF</span> <span class="keyword">then</span> raw.substring <span class="number">1</span> <span class="keyword">else</span> raw stripped = <span class="keyword">if</span> raw.charCodeAt(<span class="number">0</span>) <span class="keyword">is</span> <span class="number">0xFEFF</span> <span class="keyword">then</span> raw.substring <span class="number">1</span> <span class="keyword">else</span> raw
module._compile compile(stripped, {filename, literate: helpers.isLiterate filename}), filename</pre></div></div> answer = compile(stripped, {filename, sourceMap: <span class="literal">true</span>, literate: helpers.isLiterate filename})
sourceMaps[filename] = answer.sourceMap
module._compile answer.js, filename</pre></div></div>
</li> </li>
@ -517,6 +520,70 @@ CoffeeScript as an extension.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a> <a class="pilcrow" href="#section-20">&#182;</a>
</div> </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>
</div>
<div class="content"><div class='highlight'><pre> Module = require <span class="string">'module'</span>
<span class="function"><span class="title">findExtension</span></span> = (filename) -&gt;
extensions = path.basename(filename).split <span class="string">'.'</span></pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Remove the initial dot from dotfiles.
</p>
</div>
<div class="content"><div class='highlight'><pre> extensions.shift() <span class="keyword">if</span> extensions[<span class="number">0</span>] <span class="keyword">is</span> <span class="string">''</span></pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Start with the longest possible extension and work our way shortwards.
</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="keyword">while</span> extensions.shift()
curExtension = <span class="string">'.'</span> + extensions.join <span class="string">'.'</span>
<span class="keyword">return</span> curExtension <span class="keyword">if</span> Module._extensions[curExtension]
<span class="string">'.js'</span>
Module::<span class="function"><span class="title">load</span></span> = (filename) -&gt;
<span class="property">@filename</span> = filename
<span class="property">@paths</span> = Module._nodeModulePaths path.dirname filename
extension = findExtension filename
Module._extensions[extension](<span class="keyword">this</span>, filename)
<span class="property">@loaded</span> = <span class="literal">true</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>If we&#39;re on Node, patch <code>child_process.fork</code> so that Coffee scripts are able <p>If we&#39;re on Node, patch <code>child_process.fork</code> so that Coffee scripts are able
to fork both CoffeeScript files, and JavaScript files, directly. to fork both CoffeeScript files, and JavaScript files, directly.
</p> </p>
@ -536,11 +603,11 @@ to fork both CoffeeScript files, and JavaScript files, directly.
</li> </li>
<li id="section-21"> <li id="section-24">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a> <a class="pilcrow" href="#section-24">&#182;</a>
</div> </div>
<p>Instantiate a Lexer for our use here. <p>Instantiate a Lexer for our use here.
</p> </p>
@ -552,11 +619,11 @@ to fork both CoffeeScript files, and JavaScript files, directly.
</li> </li>
<li id="section-22"> <li id="section-25">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a> <a class="pilcrow" href="#section-25">&#182;</a>
</div> </div>
<p>The real Lexer produces a generic stream of tokens. This object provides a <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 thin wrapper around it, compatible with the Jison API. We can then pass it
@ -583,11 +650,11 @@ directly as a &quot;Jison lexer&quot;.
</li> </li>
<li id="section-23"> <li id="section-26">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a> <a class="pilcrow" href="#section-26">&#182;</a>
</div> </div>
<p>Make all the AST nodes visible to the parser. <p>Make all the AST nodes visible to the parser.
</p> </p>
@ -599,11 +666,11 @@ directly as a &quot;Jison lexer&quot;.
</li> </li>
<li id="section-24"> <li id="section-27">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a> <a class="pilcrow" href="#section-27">&#182;</a>
</div> </div>
<p>Override Jison&#39;s default error handling function. <p>Override Jison&#39;s default error handling function.
</p> </p>
@ -615,11 +682,11 @@ directly as a &quot;Jison lexer&quot;.
</li> </li>
<li id="section-25"> <li id="section-28">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a> <a class="pilcrow" href="#section-28">&#182;</a>
</div> </div>
<p>Disregard Jison&#39;s message, it contains redundant line numer information. <p>Disregard Jison&#39;s message, it contains redundant line numer information.
</p> </p>
@ -631,11 +698,11 @@ directly as a &quot;Jison lexer&quot;.
</li> </li>
<li id="section-26"> <li id="section-29">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a> <a class="pilcrow" href="#section-29">&#182;</a>
</div> </div>
<p>The second argument has a <code>loc</code> property, which should have the location <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> data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
@ -650,22 +717,39 @@ from the lexer.
</li> </li>
<li id="section-27"> <li id="section-30">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a> <a class="pilcrow" href="#section-30">&#182;</a>
</div> </div>
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a> <p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
NodeJS / V8 have no support for transforming positions in stack traces using NodeJS / V8 have no support for transforming positions in stack traces using
sourceMap, so we must monkey-patch Error to display CoffeeScript source sourceMap, so we must monkey-patch Error to display CoffeeScript source
positions. positions.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre>patched = <span class="literal">false</span> <div class="content"><div class='highlight'><pre>
patched = <span class="literal">false</span></pre></div></div>
</li>
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
</div>
<p>Map of filenames -&gt; sourceMap object.
</p>
</div>
<div class="content"><div class='highlight'><pre>sourceMaps = {}
<span class="function"><span class="title">patchStackTrace</span></span> = -&gt; <span class="function"><span class="title">patchStackTrace</span></span> = -&gt;
<span class="keyword">return</span> <span class="keyword">if</span> patched <span class="keyword">return</span> <span class="keyword">if</span> patched
patched = <span class="literal">true</span> patched = <span class="literal">true</span>
@ -674,41 +758,25 @@ positions.
</li> </li>
<li id="section-28"> <li id="section-32">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a> <a class="pilcrow" href="#section-32">&#182;</a>
</div>
<p>Map of filenames -&gt; sourceMap object.
</p>
</div>
<div class="content"><div class='highlight'><pre> mainModule._sourceMaps = {}</pre></div></div>
</li>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
</div> </div>
<p>(Assigning to a property of the Module object in the normal module cache is <p>(Assigning to a property of the Module object in the normal module cache is
unsuitable, because node deletes those objects from the cache if an unsuitable, because node deletes those objects from the cache if an
exception is thrown in the module body.) exception is thrown in the module body.)
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> Error.<span class="function"><span class="title">prepareStackTrace</span></span> = (err, stack) -&gt; <div class="content"><div class='highlight'><pre>
Error.<span class="function"><span class="title">prepareStackTrace</span></span> = (err, stack) -&gt;
sourceFiles = {} sourceFiles = {}
<span class="function"><span class="title">getSourceMapping</span></span> = (filename, line, column) -&gt; <span class="function"><span class="title">getSourceMapping</span></span> = (filename, line, column) -&gt;
sourceMap = mainModule._sourceMaps[filename] sourceMap = sourceMaps[filename]
answer = sourceMap.sourceLocation [line - <span class="number">1</span>, column - <span class="number">1</span>] <span class="keyword">if</span> sourceMap answer = sourceMap.sourceLocation [line - <span class="number">1</span>, column - <span class="number">1</span>] <span class="keyword">if</span> sourceMap
<span class="keyword">if</span> answer <span class="keyword">then</span> [answer[<span class="number">0</span>] + <span class="number">1</span>, answer[<span class="number">1</span>] + <span class="number">1</span>] <span class="keyword">else</span> <span class="literal">null</span> <span class="keyword">if</span> answer <span class="keyword">then</span> [answer[<span class="number">0</span>] + <span class="number">1</span>, answer[<span class="number">1</span>] + <span class="number">1</span>] <span class="keyword">else</span> <span class="literal">null</span>
@ -721,11 +789,11 @@ exception is thrown in the module body.)
</li> </li>
<li id="section-30"> <li id="section-33">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a> <a class="pilcrow" href="#section-33">&#182;</a>
</div> </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> <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 Modified to handle sourceMap
@ -754,11 +822,11 @@ Modified to handle sourceMap
</li> </li>
<li id="section-31"> <li id="section-34">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a> <a class="pilcrow" href="#section-34">&#182;</a>
</div> </div>
<p>Check for a sourceMap position <p>Check for a sourceMap position
</p> </p>

View file

@ -109,13 +109,24 @@
<a class="pilcrow" href="#section-1">&#182;</a> <a class="pilcrow" href="#section-1">&#182;</a>
</div> </div>
<p>The <code>coffee</code> utility. Handles command-line compilation of CoffeeScript <p>The <code>coffee</code> utility. Handles command-line compilation of CoffeeScript
into various forms: saved into <code>.js</code> files or printed to stdout, piped to into various forms: saved into <code>.js</code> files or printed to stdout
<a href="http://javascriptlint.com/">JavaScript Lint</a> or recompiled every time the source is or recompiled every time the source is saved,
saved, printed as a token stream or as the syntax tree, or launch an printed as a token stream or as the syntax tree, or launch an
interactive REPL. interactive REPL.
</p> </p>
<p>External dependencies.
</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> </p>
</div> </div>
@ -128,16 +139,17 @@ CoffeeScript = require <span class="string">'./coffee-script'</span>
{spawn, exec} = require <span class="string">'child_process'</span> {spawn, exec} = require <span class="string">'child_process'</span>
{EventEmitter} = require <span class="string">'events'</span> {EventEmitter} = require <span class="string">'events'</span>
exists = fs.exists <span class="keyword">or</span> path.exists</pre></div></div> exists = fs.exists <span class="keyword">or</span> path.exists
useWinPathSep = path.sep <span class="keyword">is</span> <span class="string">'\\'</span></pre></div></div>
</li> </li>
<li id="section-2"> <li id="section-3">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a> <a class="pilcrow" href="#section-3">&#182;</a>
</div> </div>
<p>Allow CoffeeScript to emit Node.js events. <p>Allow CoffeeScript to emit Node.js events.
</p> </p>
@ -154,11 +166,11 @@ exists = fs.exists <span class="keyword">or</span> path.exists</pre></di
</li> </li>
<li id="section-3"> <li id="section-4">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a> <a class="pilcrow" href="#section-4">&#182;</a>
</div> </div>
<p>The help banner that is printed when <code>coffee</code> is called without arguments. <p>The help banner that is printed when <code>coffee</code> is called without arguments.
</p> </p>
@ -174,11 +186,11 @@ exists = fs.exists <span class="keyword">or</span> path.exists</pre></di
</li> </li>
<li id="section-4"> <li id="section-5">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a> <a class="pilcrow" href="#section-5">&#182;</a>
</div> </div>
<p>The list of all the valid option flags that <code>coffee</code> knows how to handle. <p>The list of all the valid option flags that <code>coffee</code> knows how to handle.
</p> </p>
@ -192,13 +204,13 @@ exists = fs.exists <span class="keyword">or</span> path.exists</pre></di
[<span class="string">'-h'</span>, <span class="string">'--help'</span>, <span class="string">'display this help message'</span>] [<span class="string">'-h'</span>, <span class="string">'--help'</span>, <span class="string">'display this help message'</span>]
[<span class="string">'-i'</span>, <span class="string">'--interactive'</span>, <span class="string">'run an interactive CoffeeScript REPL'</span>] [<span class="string">'-i'</span>, <span class="string">'--interactive'</span>, <span class="string">'run an interactive CoffeeScript REPL'</span>]
[<span class="string">'-j'</span>, <span class="string">'--join [FILE]'</span>, <span class="string">'concatenate the source CoffeeScript before compiling'</span>] [<span class="string">'-j'</span>, <span class="string">'--join [FILE]'</span>, <span class="string">'concatenate the source CoffeeScript before compiling'</span>]
[<span class="string">'-l'</span>, <span class="string">'--lint'</span>, <span class="string">'pipe the compiled JavaScript through JavaScript Lint'</span>]
[<span class="string">'-m'</span>, <span class="string">'--map'</span>, <span class="string">'generate source map and save as .map files'</span>] [<span class="string">'-m'</span>, <span class="string">'--map'</span>, <span class="string">'generate source map and save as .map files'</span>]
[<span class="string">'-n'</span>, <span class="string">'--nodes'</span>, <span class="string">'print out the parse tree that the parser produces'</span>] [<span class="string">'-n'</span>, <span class="string">'--nodes'</span>, <span class="string">'print out the parse tree that the parser produces'</span>]
[ <span class="string">'--nodejs [ARGS]'</span>, <span class="string">'pass options directly to the "node" binary'</span>] [ <span class="string">'--nodejs [ARGS]'</span>, <span class="string">'pass options directly to the "node" binary'</span>]
[<span class="string">'-o'</span>, <span class="string">'--output [DIR]'</span>, <span class="string">'set the output directory for compiled JavaScript'</span>] [<span class="string">'-o'</span>, <span class="string">'--output [DIR]'</span>, <span class="string">'set the output directory for compiled JavaScript'</span>]
[<span class="string">'-p'</span>, <span class="string">'--print'</span>, <span class="string">'print out the compiled JavaScript'</span>] [<span class="string">'-p'</span>, <span class="string">'--print'</span>, <span class="string">'print out the compiled JavaScript'</span>]
[<span class="string">'-s'</span>, <span class="string">'--stdio'</span>, <span class="string">'listen for and compile scripts over stdio'</span>] [<span class="string">'-s'</span>, <span class="string">'--stdio'</span>, <span class="string">'listen for and compile scripts over stdio'</span>]
[<span class="string">'-l'</span>, <span class="string">'--literate'</span>, <span class="string">'treat stdio as literate style coffee-script'</span>]
[<span class="string">'-t'</span>, <span class="string">'--tokens'</span>, <span class="string">'print out the tokens that the lexer/rewriter produce'</span>] [<span class="string">'-t'</span>, <span class="string">'--tokens'</span>, <span class="string">'print out the tokens that the lexer/rewriter produce'</span>]
[<span class="string">'-v'</span>, <span class="string">'--version'</span>, <span class="string">'display the version number'</span>] [<span class="string">'-v'</span>, <span class="string">'--version'</span>, <span class="string">'display the version number'</span>]
[<span class="string">'-w'</span>, <span class="string">'--watch'</span>, <span class="string">'watch scripts for changes and rerun commands'</span>] [<span class="string">'-w'</span>, <span class="string">'--watch'</span>, <span class="string">'watch scripts for changes and rerun commands'</span>]
@ -207,11 +219,11 @@ exists = fs.exists <span class="keyword">or</span> path.exists</pre></di
</li> </li>
<li id="section-5"> <li id="section-6">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a> <a class="pilcrow" href="#section-6">&#182;</a>
</div> </div>
<p>Top-level objects shared by all the functions. <p>Top-level objects shared by all the functions.
</p> </p>
@ -228,11 +240,11 @@ optionParser = <span class="literal">null</span></pre></div></div>
</li> </li>
<li id="section-6"> <li id="section-7">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a> <a class="pilcrow" href="#section-7">&#182;</a>
</div> </div>
<p>Run <code>coffee</code> by parsing passed options and determining what action to take. <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 Many flags cause us to divert before compiling anything. Flags passed after
@ -247,7 +259,7 @@ Many flags cause us to divert before compiling anything. Flags passed after
<span class="keyword">return</span> usage() <span class="keyword">if</span> opts.help <span class="keyword">return</span> usage() <span class="keyword">if</span> opts.help
<span class="keyword">return</span> version() <span class="keyword">if</span> opts.version <span class="keyword">return</span> version() <span class="keyword">if</span> opts.version
<span class="keyword">return</span> require(<span class="string">'./repl'</span>).start() <span class="keyword">if</span> opts.interactive <span class="keyword">return</span> require(<span class="string">'./repl'</span>).start() <span class="keyword">if</span> opts.interactive
<span class="keyword">if</span> opts.watch <span class="keyword">and</span> !fs.watch <span class="keyword">if</span> opts.watch <span class="keyword">and</span> <span class="keyword">not</span> fs.watch
<span class="keyword">return</span> printWarn <span class="string">"The --watch feature depends on Node v0.6.0+. You are running <span class="subst">#{process.version}</span>."</span> <span class="keyword">return</span> printWarn <span class="string">"The --watch feature depends on Node v0.6.0+. You are running <span class="subst">#{process.version}</span>."</span>
<span class="keyword">return</span> compileStdio() <span class="keyword">if</span> opts.stdio <span class="keyword">return</span> compileStdio() <span class="keyword">if</span> opts.stdio
<span class="keyword">return</span> compileScript <span class="literal">null</span>, sources[<span class="number">0</span>] <span class="keyword">if</span> opts.eval <span class="keyword">return</span> compileScript <span class="literal">null</span>, sources[<span class="number">0</span>] <span class="keyword">if</span> opts.eval
@ -261,11 +273,11 @@ Many flags cause us to divert before compiling anything. Flags passed after
</li> </li>
<li id="section-7"> <li id="section-8">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a> <a class="pilcrow" href="#section-8">&#182;</a>
</div> </div>
<p>Compile a path, which could be a script or a directory. If a directory <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 &#39;.coffee&#39;, &#39;.litcoffee&#39;, and &#39;.coffee.md&#39;
@ -304,11 +316,11 @@ extension source files in it and all subdirectories.
</li> </li>
<li id="section-8"> <li id="section-9">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a> <a class="pilcrow" href="#section-9">&#182;</a>
</div> </div>
<p>Compile a single source script, containing the given code, according to the <p>Compile a single source script, containing the given code, according to the
requested options. If evaluating the script directly sets <code>__filename</code>, requested options. If evaluating the script directly sets <code>__filename</code>,
@ -340,10 +352,8 @@ requested options. If evaluating the script directly sets <code>__filename</code
CoffeeScript.emit <span class="string">'success'</span>, task CoffeeScript.emit <span class="string">'success'</span>, task
<span class="keyword">if</span> o.print <span class="keyword">if</span> o.print
printLine t.output.trim() printLine t.output.trim()
<span class="keyword">else</span> <span class="keyword">if</span> o.compile || o.map <span class="keyword">else</span> <span class="keyword">if</span> o.compile <span class="keyword">or</span> o.map
writeJs base, t.file, t.output, options.jsPath, t.sourceMap writeJs base, t.file, t.output, options.jsPath, t.sourceMap
<span class="keyword">else</span> <span class="keyword">if</span> o.lint
lint t.file, t.output
<span class="keyword">catch</span> err <span class="keyword">catch</span> err
CoffeeScript.emit <span class="string">'failure'</span>, err, task CoffeeScript.emit <span class="string">'failure'</span>, err, task
<span class="keyword">return</span> <span class="keyword">if</span> CoffeeScript.listeners(<span class="string">'failure'</span>).length <span class="keyword">return</span> <span class="keyword">if</span> CoffeeScript.listeners(<span class="string">'failure'</span>).length
@ -358,11 +368,11 @@ requested options. If evaluating the script directly sets <code>__filename</code
</li> </li>
<li id="section-9"> <li id="section-10">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a> <a class="pilcrow" href="#section-10">&#182;</a>
</div> </div>
<p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>, <p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>,
and write them back to <strong>stdout</strong>. and write them back to <strong>stdout</strong>.
@ -381,11 +391,11 @@ and write them back to <strong>stdout</strong>.
</li> </li>
<li id="section-10"> <li id="section-11">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a> <a class="pilcrow" href="#section-11">&#182;</a>
</div> </div>
<p>If all of the source files are done being read, concatenate and compile <p>If all of the source files are done being read, concatenate and compile
them together. them together.
@ -404,15 +414,15 @@ them together.
</li> </li>
<li id="section-11"> <li id="section-12">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a> <a class="pilcrow" href="#section-12">&#182;</a>
</div> </div>
<p>Watch a source CoffeeScript file using <code>fs.watch</code>, recompiling it every <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, time the file is updated. May be used in combination with other options,
such as <code>--lint</code> or <code>--print</code>. such as <code>--print</code>.
</p> </p>
</div> </div>
@ -458,11 +468,11 @@ such as <code>--lint</code> or <code>--print</code>.
</li> </li>
<li id="section-12"> <li id="section-13">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a> <a class="pilcrow" href="#section-13">&#182;</a>
</div> </div>
<p>Watch a directory of files for new additions. <p>Watch a directory of files for new additions.
</p> </p>
@ -499,11 +509,11 @@ such as <code>--lint</code> or <code>--print</code>.
</li> </li>
<li id="section-13"> <li id="section-14">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a> <a class="pilcrow" href="#section-14">&#182;</a>
</div> </div>
<p>Remove a file from our source list, and source code cache. Optionally remove <p>Remove a file from our source list, and source code cache. Optionally remove
the compiled JS version as well. the compiled JS version as well.
@ -526,11 +536,11 @@ the compiled JS version as well.
</li> </li>
<li id="section-14"> <li id="section-15">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a> <a class="pilcrow" href="#section-15">&#182;</a>
</div> </div>
<p>Get the corresponding output JavaScript path for a source file. <p>Get the corresponding output JavaScript path for a source file.
</p> </p>
@ -538,7 +548,7 @@ the compiled JS version as well.
</div> </div>
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">outputPath</span></span> = (source, base, extension=<span class="string">".js"</span>) -&gt; <div class="content"><div class='highlight'><pre><span class="function"><span class="title">outputPath</span></span> = (source, base, extension=<span class="string">".js"</span>) -&gt;
basename = helpers.baseFileName source, <span class="literal">yes</span>, path.sep basename = helpers.baseFileName source, <span class="literal">yes</span>, useWinPathSep
srcDir = path.dirname source srcDir = path.dirname source
baseDir = <span class="keyword">if</span> base <span class="keyword">is</span> <span class="string">'.'</span> <span class="keyword">then</span> srcDir <span class="keyword">else</span> srcDir.substring base.length baseDir = <span class="keyword">if</span> base <span class="keyword">is</span> <span class="string">'.'</span> <span class="keyword">then</span> srcDir <span class="keyword">else</span> srcDir.substring base.length
dir = <span class="keyword">if</span> opts.output <span class="keyword">then</span> path.join opts.output, baseDir <span class="keyword">else</span> srcDir dir = <span class="keyword">if</span> opts.output <span class="keyword">then</span> path.join opts.output, baseDir <span class="keyword">else</span> srcDir
@ -547,11 +557,11 @@ the compiled JS version as well.
</li> </li>
<li id="section-15"> <li id="section-16">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a> <a class="pilcrow" href="#section-16">&#182;</a>
</div> </div>
<p>Write out a JavaScript source file with the compiled code. By default, files <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 are written out in <code>cwd</code> as <code>.js</code> files with the same name, but the output
@ -570,7 +580,7 @@ same directory as the <code>.js</code> file.
<span class="function"><span class="title">compile</span></span> = -&gt; <span class="function"><span class="title">compile</span></span> = -&gt;
<span class="keyword">if</span> opts.compile <span class="keyword">if</span> opts.compile
js = <span class="string">' '</span> <span class="keyword">if</span> js.length &lt;= <span class="number">0</span> js = <span class="string">' '</span> <span class="keyword">if</span> js.length &lt;= <span class="number">0</span>
<span class="keyword">if</span> generatedSourceMap <span class="keyword">then</span> js = <span class="string">"<span class="subst">#{js}</span>\n/*\n//@ sourceMappingURL=<span class="subst">#{helpers.baseFileName sourceMapPath, <span class="literal">no</span>, path.sep}</span>\n*/\n"</span> <span class="keyword">if</span> generatedSourceMap <span class="keyword">then</span> js = <span class="string">"<span class="subst">#{js}</span>\n/*\n//@ sourceMappingURL=<span class="subst">#{helpers.baseFileName sourceMapPath, <span class="literal">no</span>, useWinPathSep}</span>\n*/\n"</span>
fs.writeFile jsPath, js, (err) -&gt; fs.writeFile jsPath, js, (err) -&gt;
<span class="keyword">if</span> err <span class="keyword">if</span> err
printLine err.message printLine err.message
@ -586,11 +596,11 @@ same directory as the <code>.js</code> file.
</li> </li>
<li id="section-16"> <li id="section-17">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a> <a class="pilcrow" href="#section-17">&#182;</a>
</div> </div>
<p>Convenience for cleaner setTimeouts. <p>Convenience for cleaner setTimeouts.
</p> </p>
@ -602,11 +612,11 @@ same directory as the <code>.js</code> file.
</li> </li>
<li id="section-17"> <li id="section-18">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a> <a class="pilcrow" href="#section-18">&#182;</a>
</div> </div>
<p>When watching scripts, it&#39;s useful to log changes with the timestamp. <p>When watching scripts, it&#39;s useful to log changes with the timestamp.
</p> </p>
@ -619,30 +629,6 @@ same directory as the <code>.js</code> file.
</li> </li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Pipe compiled JS through JSLint (requires a working <code>jsl</code> command), printing
any errors or warnings that arise.
</p>
</div>
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">lint</span></span> = (file, js) -&gt;
<span class="function"><span class="title">printIt</span></span> = (buffer) -&gt; printLine file + <span class="string">':\t'</span> + buffer.toString().trim()
conf = __dirname + <span class="string">'/../../extras/jsl.conf'</span>
jsl = spawn <span class="string">'jsl'</span>, [<span class="string">'-nologo'</span>, <span class="string">'-stdin'</span>, <span class="string">'-conf'</span>, conf]
jsl.stdout.<span class="literal">on</span> <span class="string">'data'</span>, printIt
jsl.stderr.<span class="literal">on</span> <span class="string">'data'</span>, printIt
jsl.stdin.write js
jsl.stdin.end()</pre></div></div>
</li>
<li id="section-19"> <li id="section-19">
<div class="annotation"> <div class="annotation">
@ -680,7 +666,7 @@ any errors or warnings that arise.
optionParser = <span class="keyword">new</span> optparse.OptionParser SWITCHES, BANNER optionParser = <span class="keyword">new</span> optparse.OptionParser SWITCHES, BANNER
o = opts = optionParser.parse process.argv[<span class="number">2.</span>.] o = opts = optionParser.parse process.argv[<span class="number">2.</span>.]
o.compile <span class="keyword">or</span>= !!o.output o.compile <span class="keyword">or</span>= !!o.output
o.run = <span class="keyword">not</span> (o.compile <span class="keyword">or</span> o.print <span class="keyword">or</span> o.lint <span class="keyword">or</span> o.map) o.run = <span class="keyword">not</span> (o.compile <span class="keyword">or</span> o.print <span class="keyword">or</span> o.map)
o.print = !! (o.print <span class="keyword">or</span> (o.eval <span class="keyword">or</span> o.stdio <span class="keyword">and</span> o.compile)) o.print = !! (o.print <span class="keyword">or</span> (o.eval <span class="keyword">or</span> o.stdio <span class="keyword">and</span> o.compile))
sources = o.arguments sources = o.arguments
sourceCode[i] = <span class="literal">null</span> <span class="keyword">for</span> source, i <span class="keyword">in</span> sources sourceCode[i] = <span class="literal">null</span> <span class="keyword">for</span> source, i <span class="keyword">in</span> sources
@ -703,7 +689,7 @@ any errors or warnings that arise.
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">compileOptions</span></span> = (filename, base) -&gt; <div class="content"><div class='highlight'><pre><span class="function"><span class="title">compileOptions</span></span> = (filename, base) -&gt;
answer = { answer = {
filename filename
literate: helpers.isLiterate(filename) literate: opts.literate <span class="keyword">or</span> helpers.isLiterate(filename)
bare: opts.bare bare: opts.bare
header: opts.compile header: opts.compile
sourceMap: opts.map sourceMap: opts.map
@ -717,13 +703,13 @@ any errors or warnings that arise.
jsPath jsPath
sourceRoot: path.relative jsDir, cwd sourceRoot: path.relative jsDir, cwd
sourceFiles: [path.relative cwd, filename] sourceFiles: [path.relative cwd, filename]
generatedFile: helpers.baseFileName(jsPath, <span class="literal">no</span>, path.sep) generatedFile: helpers.baseFileName(jsPath, <span class="literal">no</span>, useWinPathSep)
} }
<span class="keyword">else</span> <span class="keyword">else</span>
answer = helpers.merge answer, answer = helpers.merge answer,
sourceRoot: <span class="string">""</span> sourceRoot: <span class="string">""</span>
sourceFiles: [helpers.baseFileName filename, <span class="literal">no</span>, path.sep] sourceFiles: [helpers.baseFileName filename, <span class="literal">no</span>, useWinPathSep]
generatedFile: helpers.baseFileName(filename, <span class="literal">yes</span>, path.sep) + <span class="string">".js"</span> generatedFile: helpers.baseFileName(filename, <span class="literal">yes</span>, useWinPathSep) + <span class="string">".js"</span>
answer</pre></div></div> answer</pre></div></div>
</li> </li>

View file

@ -399,7 +399,8 @@ pre .css .rule .keyword,
pre .winutils, pre .winutils,
pre .javascript .title, pre .javascript .title,
pre .lisp .title, pre .lisp .title,
pre .subst { pre .subst,
pre .reserved {
color: #954121; color: #954121;
/*font-weight: bold*/ /*font-weight: bold*/
} }

View file

@ -124,9 +124,20 @@ reduces into the <a href="http://en.wikipedia.org/wiki/Terminal_and_nonterminal_
</p> </p>
<p>If you run the <code>cake build:parser</code> command, Jison constructs a parse table <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>. from our rules and saves it into <code>lib/parser.js</code>.
</p> </p>
<p>The only dependency is on the <strong>Jison.Parser</strong>.
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>The only dependency is on the <strong>Jison.Parser</strong>.
</p> </p>
</div> </div>
@ -136,11 +147,11 @@ from our rules and saves it into <code>lib/parser.js</code>.
</li> </li>
<li id="section-2"> <li id="section-3">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-2">&#182;</a> <a class="pilcrow" href="#section-3">&#182;</a>
</div> </div>
<h2>Jison DSL</h2> <h2>Jison DSL</h2>
@ -149,11 +160,23 @@ from our rules and saves it into <code>lib/parser.js</code>.
</li> </li>
<li id="section-3"> <li id="section-4">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a> <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> </div>
<p>Since we&#39;re going to be wrapped in a function by Jison in any case, if our <p>Since we&#39;re 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 action immediately returns a value, we can optimize by removing the function
@ -167,11 +190,11 @@ wrapper and just returning the value directly.
</li> </li>
<li id="section-4"> <li id="section-6">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a> <a class="pilcrow" href="#section-6">&#182;</a>
</div> </div>
<p>Our handy DSL for Jison grammar generation, thanks to <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, <a href="http://github.com/creationix">Tim Caswell</a>. For every rule in the grammar,
@ -191,11 +214,11 @@ previous nonterminal.
</li> </li>
<li id="section-5"> <li id="section-7">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a> <a class="pilcrow" href="#section-7">&#182;</a>
</div> </div>
<p>All runtime functions we need are defined on &quot;yy&quot; <p>All runtime functions we need are defined on &quot;yy&quot;
</p> </p>
@ -208,11 +231,11 @@ previous nonterminal.
</li> </li>
<li id="section-6"> <li id="section-8">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a> <a class="pilcrow" href="#section-8">&#182;</a>
</div> </div>
<p>Returns a function which adds location data to the first parameter passed <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 in, and returns the parameter. If the parameter is not a node, it will
@ -235,11 +258,11 @@ just be passed through unaffected.
</li> </li>
<li id="section-7"> <li id="section-9">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-7">&#182;</a> <a class="pilcrow" href="#section-9">&#182;</a>
</div> </div>
<h2>Grammatical Rules</h2> <h2>Grammatical Rules</h2>
@ -248,11 +271,23 @@ just be passed through unaffected.
</li> </li>
<li id="section-8"> <li id="section-10">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a> <a class="pilcrow" href="#section-10">&#182;</a>
</div>
</div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div> </div>
<p>In all of the rules that follow, you&#39;ll see the name of the nonterminal as <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 the key to a list of alternative matches. With each match&#39;s action, the
@ -273,11 +308,11 @@ for the <code>UNLESS</code> terminal, and <code>$3</code> would be the value of
</li> </li>
<li id="section-9"> <li id="section-12">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a> <a class="pilcrow" href="#section-12">&#182;</a>
</div> </div>
<p>The <strong>Root</strong> is the top-level node in the syntax tree. Since we parse bottom-up, <p>The <strong>Root</strong> is the top-level node in the syntax tree. Since we parse bottom-up,
all parsing must end here. all parsing must end here.
@ -294,11 +329,11 @@ all parsing must end here.
</li> </li>
<li id="section-10"> <li id="section-13">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a> <a class="pilcrow" href="#section-13">&#182;</a>
</div> </div>
<p>Any list of statements and expressions, separated by line breaks or semicolons. <p>Any list of statements and expressions, separated by line breaks or semicolons.
</p> </p>
@ -314,11 +349,11 @@ all parsing must end here.
</li> </li>
<li id="section-11"> <li id="section-14">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a> <a class="pilcrow" href="#section-14">&#182;</a>
</div> </div>
<p>Block and statements, which make up a line in a body. <p>Block and statements, which make up a line in a body.
</p> </p>
@ -333,11 +368,11 @@ all parsing must end here.
</li> </li>
<li id="section-12"> <li id="section-15">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a> <a class="pilcrow" href="#section-15">&#182;</a>
</div> </div>
<p>Pure statements which cannot be expressions. <p>Pure statements which cannot be expressions.
</p> </p>
@ -353,11 +388,11 @@ all parsing must end here.
</li> </li>
<li id="section-13"> <li id="section-16">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a> <a class="pilcrow" href="#section-16">&#182;</a>
</div> </div>
<p>All the different types of expressions in our language. The basic unit of <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
@ -385,11 +420,11 @@ them somewhat circular.
</li> </li>
<li id="section-14"> <li id="section-17">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a> <a class="pilcrow" href="#section-17">&#182;</a>
</div> </div>
<p>An indented block of expressions. Note that the <a href="rewriter.html">Rewriter</a> <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 will convert some postfix forms into blocks for us, by adjusting the
@ -406,11 +441,11 @@ token stream.
</li> </li>
<li id="section-15"> <li id="section-18">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a> <a class="pilcrow" href="#section-18">&#182;</a>
</div> </div>
<p>A literal identifier, a variable name or property. <p>A literal identifier, a variable name or property.
</p> </p>
@ -424,11 +459,11 @@ token stream.
</li> </li>
<li id="section-16"> <li id="section-19">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a> <a class="pilcrow" href="#section-19">&#182;</a>
</div> </div>
<p>Alphanumerics are separated from the other <strong>Literal</strong> matchers because <p>Alphanumerics are separated from the other <strong>Literal</strong> matchers because
they can also serve as keys in object literals. they can also serve as keys in object literals.
@ -444,11 +479,11 @@ they can also serve as keys in object literals.
</li> </li>
<li id="section-17"> <li id="section-20">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a> <a class="pilcrow" href="#section-20">&#182;</a>
</div> </div>
<p>All of our immediate values. Generally these can be passed straight <p>All of our immediate values. Generally these can be passed straight
through and printed to JavaScript. through and printed to JavaScript.
@ -469,11 +504,11 @@ through and printed to JavaScript.
</li> </li>
<li id="section-18"> <li id="section-21">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a> <a class="pilcrow" href="#section-21">&#182;</a>
</div> </div>
<p>Assignment of a variable, property, or index to a value. <p>Assignment of a variable, property, or index to a value.
</p> </p>
@ -489,11 +524,11 @@ through and printed to JavaScript.
</li> </li>
<li id="section-19"> <li id="section-22">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a> <a class="pilcrow" href="#section-22">&#182;</a>
</div> </div>
<p>Assignment when it happens within an object literal. The difference from <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. the ordinary <strong>Assign</strong> is that these allow numbers and strings as keys.
@ -518,11 +553,11 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
</li> </li>
<li id="section-20"> <li id="section-23">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a> <a class="pilcrow" href="#section-23">&#182;</a>
</div> </div>
<p>A return statement from a function body. <p>A return statement from a function body.
</p> </p>
@ -537,11 +572,11 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
</li> </li>
<li id="section-21"> <li id="section-24">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a> <a class="pilcrow" href="#section-24">&#182;</a>
</div> </div>
<p>A block comment. <p>A block comment.
</p> </p>
@ -555,11 +590,11 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
</li> </li>
<li id="section-22"> <li id="section-25">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a> <a class="pilcrow" href="#section-25">&#182;</a>
</div> </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. It&#39;s defined by an indented block
of <strong>Block</strong> preceded by a function arrow, with an optional parameter of <strong>Block</strong> preceded by a function arrow, with an optional parameter
@ -576,11 +611,11 @@ list.
</li> </li>
<li id="section-23"> <li id="section-26">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a> <a class="pilcrow" href="#section-26">&#182;</a>
</div> </div>
<p>CoffeeScript has two different symbols for functions. <code>-&gt;</code> is for ordinary <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>. functions, and <code>=&gt;</code> is for functions bound to the current value of <em>this</em>.
@ -596,11 +631,11 @@ functions, and <code>=&gt;</code> is for functions bound to the current value of
</li> </li>
<li id="section-24"> <li id="section-27">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a> <a class="pilcrow" href="#section-27">&#182;</a>
</div> </div>
<p>An optional, trailing comma. <p>An optional, trailing comma.
</p> </p>
@ -615,11 +650,11 @@ functions, and <code>=&gt;</code> is for functions bound to the current value of
</li> </li>
<li id="section-25"> <li id="section-28">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a> <a class="pilcrow" href="#section-28">&#182;</a>
</div> </div>
<p>The list of parameters that a function accepts can be of any length. <p>The list of parameters that a function accepts can be of any length.
</p> </p>
@ -637,11 +672,11 @@ functions, and <code>=&gt;</code> is for functions bound to the current value of
</li> </li>
<li id="section-26"> <li id="section-29">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a> <a class="pilcrow" href="#section-29">&#182;</a>
</div> </div>
<p>A single parameter in a function definition can be ordinary, or a splat <p>A single parameter in a function definition can be ordinary, or a splat
that hoovers up the remaining arguments. that hoovers up the remaining arguments.
@ -658,11 +693,11 @@ that hoovers up the remaining arguments.
</li> </li>
<li id="section-27"> <li id="section-30">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a> <a class="pilcrow" href="#section-30">&#182;</a>
</div> </div>
<p>Function Parameters <p>Function Parameters
</p> </p>
@ -679,11 +714,11 @@ that hoovers up the remaining arguments.
</li> </li>
<li id="section-28"> <li id="section-31">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a> <a class="pilcrow" href="#section-31">&#182;</a>
</div> </div>
<p>A splat that occurs outside of a parameter list. <p>A splat that occurs outside of a parameter list.
</p> </p>
@ -697,11 +732,11 @@ that hoovers up the remaining arguments.
</li> </li>
<li id="section-29"> <li id="section-32">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a> <a class="pilcrow" href="#section-32">&#182;</a>
</div> </div>
<p>Variables and properties that can be assigned to. <p>Variables and properties that can be assigned to.
</p> </p>
@ -718,11 +753,11 @@ that hoovers up the remaining arguments.
</li> </li>
<li id="section-30"> <li id="section-33">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a> <a class="pilcrow" href="#section-33">&#182;</a>
</div> </div>
<p>Everything that can be assigned to. <p>Everything that can be assigned to.
</p> </p>
@ -738,11 +773,11 @@ that hoovers up the remaining arguments.
</li> </li>
<li id="section-31"> <li id="section-34">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a> <a class="pilcrow" href="#section-34">&#182;</a>
</div> </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. as functions, indexed into, named as a class, etc.
@ -761,11 +796,11 @@ as functions, indexed into, named as a class, etc.
</li> </li>
<li id="section-32"> <li id="section-35">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a> <a class="pilcrow" href="#section-35">&#182;</a>
</div> </div>
<p>The general group of accessors into an object, by property, by prototype <p>The general group of accessors into an object, by property, by prototype
or by array index or slice. or by array index or slice.
@ -785,11 +820,11 @@ or by array index or slice.
</li> </li>
<li id="section-33"> <li id="section-36">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a> <a class="pilcrow" href="#section-36">&#182;</a>
</div> </div>
<p>Indexing into an object or array using bracket notation. <p>Indexing into an object or array using bracket notation.
</p> </p>
@ -809,11 +844,11 @@ or by array index or slice.
</li> </li>
<li id="section-34"> <li id="section-37">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a> <a class="pilcrow" href="#section-37">&#182;</a>
</div> </div>
<p>In CoffeeScript, an object literal is simply a list of assignments. <p>In CoffeeScript, an object literal is simply a list of assignments.
</p> </p>
@ -827,11 +862,11 @@ or by array index or slice.
</li> </li>
<li id="section-35"> <li id="section-38">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a> <a class="pilcrow" href="#section-38">&#182;</a>
</div> </div>
<p>Assignment of properties within an object literal can be separated by <p>Assignment of properties within an object literal can be separated by
comma, as in JavaScript, or simply by newline. comma, as in JavaScript, or simply by newline.
@ -850,11 +885,11 @@ comma, as in JavaScript, or simply by newline.
</li> </li>
<li id="section-36"> <li id="section-39">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a> <a class="pilcrow" href="#section-39">&#182;</a>
</div> </div>
<p>Class definitions have optional bodies of prototype property assignments, <p>Class definitions have optional bodies of prototype property assignments,
and optional references to the superclass. and optional references to the superclass.
@ -876,11 +911,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-37"> <li id="section-40">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-37">&#182;</a> <a class="pilcrow" href="#section-40">&#182;</a>
</div> </div>
<p>Ordinary function invocation, or a chained series of calls. <p>Ordinary function invocation, or a chained series of calls.
</p> </p>
@ -897,11 +932,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-38"> <li id="section-41">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-38">&#182;</a> <a class="pilcrow" href="#section-41">&#182;</a>
</div> </div>
<p>An optional existence check on a function. <p>An optional existence check on a function.
</p> </p>
@ -916,11 +951,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-39"> <li id="section-42">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-39">&#182;</a> <a class="pilcrow" href="#section-42">&#182;</a>
</div> </div>
<p>The list of arguments to a function call. <p>The list of arguments to a function call.
</p> </p>
@ -935,11 +970,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-40"> <li id="section-43">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-40">&#182;</a> <a class="pilcrow" href="#section-43">&#182;</a>
</div> </div>
<p>A reference to the <em>this</em> current object. <p>A reference to the <em>this</em> current object.
</p> </p>
@ -954,11 +989,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-41"> <li id="section-44">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a> <a class="pilcrow" href="#section-44">&#182;</a>
</div> </div>
<p>A reference to a property on <em>this</em>. <p>A reference to a property on <em>this</em>.
</p> </p>
@ -972,11 +1007,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-42"> <li id="section-45">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-42">&#182;</a> <a class="pilcrow" href="#section-45">&#182;</a>
</div> </div>
<p>The array literal. <p>The array literal.
</p> </p>
@ -991,11 +1026,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-43"> <li id="section-46">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-43">&#182;</a> <a class="pilcrow" href="#section-46">&#182;</a>
</div> </div>
<p>Inclusive and exclusive range dots. <p>Inclusive and exclusive range dots.
</p> </p>
@ -1010,11 +1045,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-44"> <li id="section-47">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-44">&#182;</a> <a class="pilcrow" href="#section-47">&#182;</a>
</div> </div>
<p>The CoffeeScript range literal. <p>The CoffeeScript range literal.
</p> </p>
@ -1028,11 +1063,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-45"> <li id="section-48">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-45">&#182;</a> <a class="pilcrow" href="#section-48">&#182;</a>
</div> </div>
<p>Array slice literals. <p>Array slice literals.
</p> </p>
@ -1049,11 +1084,11 @@ and optional references to the superclass.
</li> </li>
<li id="section-46"> <li id="section-49">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-46">&#182;</a> <a class="pilcrow" href="#section-49">&#182;</a>
</div> </div>
<p>The <strong>ArgList</strong> is both the list of objects passed into a function call, <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 as well as the contents of an array literal
@ -1073,11 +1108,11 @@ as well as the contents of an array literal
</li> </li>
<li id="section-47"> <li id="section-50">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-47">&#182;</a> <a class="pilcrow" href="#section-50">&#182;</a>
</div> </div>
<p>Valid arguments are Blocks or Splats. <p>Valid arguments are Blocks or Splats.
</p> </p>
@ -1092,11 +1127,11 @@ as well as the contents of an array literal
</li> </li>
<li id="section-48"> <li id="section-51">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-48">&#182;</a> <a class="pilcrow" href="#section-51">&#182;</a>
</div> </div>
<p>Just simple, comma-separated, required arguments (no fancy syntax). We need <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 this to be separate from the <strong>ArgList</strong> for use in <strong>Switch</strong> blocks, where
@ -1113,11 +1148,11 @@ having the newlines wouldn&#39;t make sense.
</li> </li>
<li id="section-49"> <li id="section-52">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-49">&#182;</a> <a class="pilcrow" href="#section-52">&#182;</a>
</div> </div>
<p>The variants of <em>try/catch/finally</em> exception handling blocks. <p>The variants of <em>try/catch/finally</em> exception handling blocks.
</p> </p>
@ -1134,11 +1169,11 @@ having the newlines wouldn&#39;t make sense.
</li> </li>
<li id="section-50"> <li id="section-53">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-50">&#182;</a> <a class="pilcrow" href="#section-53">&#182;</a>
</div> </div>
<p>A catch clause names its error and runs a block of code. <p>A catch clause names its error and runs a block of code.
</p> </p>
@ -1148,16 +1183,17 @@ having the newlines wouldn&#39;t make sense.
<div class="content"><div class='highlight'><pre> Catch: [ <div class="content"><div class='highlight'><pre> Catch: [
o <span class="string">'CATCH Identifier Block'</span>, -&gt; [$<span class="number">2</span>, $<span class="number">3</span>] o <span class="string">'CATCH Identifier Block'</span>, -&gt; [$<span class="number">2</span>, $<span class="number">3</span>]
o <span class="string">'CATCH Object Block'</span>, -&gt; [LOC(<span class="number">2</span>)(<span class="keyword">new</span> Value($<span class="number">2</span>)), $<span class="number">3</span>] o <span class="string">'CATCH Object Block'</span>, -&gt; [LOC(<span class="number">2</span>)(<span class="keyword">new</span> Value($<span class="number">2</span>)), $<span class="number">3</span>]
o <span class="string">'CATCH Block'</span>, -&gt; [<span class="literal">null</span>, $<span class="number">2</span>]
]</pre></div></div> ]</pre></div></div>
</li> </li>
<li id="section-51"> <li id="section-54">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-51">&#182;</a> <a class="pilcrow" href="#section-54">&#182;</a>
</div> </div>
<p>Throw an exception object. <p>Throw an exception object.
</p> </p>
@ -1171,11 +1207,11 @@ having the newlines wouldn&#39;t make sense.
</li> </li>
<li id="section-52"> <li id="section-55">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-52">&#182;</a> <a class="pilcrow" href="#section-55">&#182;</a>
</div> </div>
<p>Parenthetical expressions. Note that the <strong>Parenthetical</strong> is a <strong>Value</strong>, <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 not an <strong>Expression</strong>, so if you need to use an expression in a place
@ -1193,11 +1229,11 @@ the trick.
</li> </li>
<li id="section-53"> <li id="section-56">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-53">&#182;</a> <a class="pilcrow" href="#section-56">&#182;</a>
</div> </div>
<p>The condition portion of a while loop. <p>The condition portion of a while loop.
</p> </p>
@ -1214,11 +1250,11 @@ the trick.
</li> </li>
<li id="section-54"> <li id="section-57">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-54">&#182;</a> <a class="pilcrow" href="#section-57">&#182;</a>
</div> </div>
<p>The while loop can either be normal, with a block of expressions to execute, <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. or postfix, with a single expression. There is no do..while.
@ -1241,11 +1277,11 @@ or postfix, with a single expression. There is no do..while.
</li> </li>
<li id="section-55"> <li id="section-58">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-55">&#182;</a> <a class="pilcrow" href="#section-58">&#182;</a>
</div> </div>
<p>Array, object, and range comprehensions, at the most generic level. <p>Array, object, and range comprehensions, at the most generic level.
Comprehensions can either be normal, with a block of expressions to execute, Comprehensions can either be normal, with a block of expressions to execute,
@ -1273,11 +1309,11 @@ or postfix, with a single expression.
</li> </li>
<li id="section-56"> <li id="section-59">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-56">&#182;</a> <a class="pilcrow" href="#section-59">&#182;</a>
</div> </div>
<p>An array of all accepted values for a variable inside the loop. <p>An array of all accepted values for a variable inside the loop.
This enables support for pattern matching. This enables support for pattern matching.
@ -1295,11 +1331,11 @@ This enables support for pattern matching.
</li> </li>
<li id="section-57"> <li id="section-60">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-57">&#182;</a> <a class="pilcrow" href="#section-60">&#182;</a>
</div> </div>
<p>An array or range comprehension has variables for the current element <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 and (optional) reference to the current index. Or, <em>key, value</em>, in the case
@ -1316,11 +1352,11 @@ of object comprehensions.
</li> </li>
<li id="section-58"> <li id="section-61">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-58">&#182;</a> <a class="pilcrow" href="#section-61">&#182;</a>
</div> </div>
<p>The source of a comprehension is an array or object with an optional guard <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 it&#39;s an array comprehension, you can also choose to step through
@ -1354,11 +1390,11 @@ in fixed-size increments.
</li> </li>
<li id="section-59"> <li id="section-62">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-59">&#182;</a> <a class="pilcrow" href="#section-62">&#182;</a>
</div> </div>
<p>An individual <strong>When</strong> clause, with action. <p>An individual <strong>When</strong> clause, with action.
</p> </p>
@ -1373,11 +1409,11 @@ in fixed-size increments.
</li> </li>
<li id="section-60"> <li id="section-63">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-60">&#182;</a> <a class="pilcrow" href="#section-63">&#182;</a>
</div> </div>
<p>The most basic form of <em>if</em> is a condition and an action. The following <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 if-related rules are broken up along these lines in order to avoid
@ -1394,11 +1430,11 @@ ambiguity.
</li> </li>
<li id="section-61"> <li id="section-64">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-61">&#182;</a> <a class="pilcrow" href="#section-64">&#182;</a>
</div> </div>
<p>The full complement of <em>if</em> expressions, including postfix one-liner <p>The full complement of <em>if</em> expressions, including postfix one-liner
<em>if</em> and <em>unless</em>. <em>if</em> and <em>unless</em>.
@ -1416,11 +1452,11 @@ ambiguity.
</li> </li>
<li id="section-62"> <li id="section-65">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-62">&#182;</a> <a class="pilcrow" href="#section-65">&#182;</a>
</div> </div>
<p>Arithmetic and logical operators, working on one or more operands. <p>Arithmetic and logical operators, working on one or more operands.
Here they are grouped by order of precedence. The actual precedence rules Here they are grouped by order of precedence. The actual precedence rules
@ -1445,11 +1481,11 @@ rules are necessary.
</li> </li>
<li id="section-63"> <li id="section-66">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-63">&#182;</a> <a class="pilcrow" href="#section-66">&#182;</a>
</div> </div>
<p><a href="http://jashkenas.github.com/coffee-script/#existence">The existential operator</a>. <p><a href="http://jashkenas.github.com/coffee-script/#existence">The existential operator</a>.
</p> </p>
@ -1483,11 +1519,11 @@ rules are necessary.
</li> </li>
<li id="section-64"> <li id="section-67">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-64">&#182;</a> <a class="pilcrow" href="#section-67">&#182;</a>
</div> </div>
<h2>Precedence</h2> <h2>Precedence</h2>
@ -1496,11 +1532,23 @@ rules are necessary.
</li> </li>
<li id="section-65"> <li id="section-68">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <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> </div>
<p>Operators at the top of this list have higher precedence than the ones lower <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: down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:
@ -1536,11 +1584,11 @@ down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:
</li> </li>
<li id="section-66"> <li id="section-70">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-66">&#182;</a> <a class="pilcrow" href="#section-70">&#182;</a>
</div> </div>
<h2>Wrapping Up</h2> <h2>Wrapping Up</h2>
@ -1549,11 +1597,23 @@ down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:
</li> </li>
<li id="section-67"> <li id="section-71">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <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> </div>
<p>Finally, now that we have our <strong>grammar</strong> and our <strong>operators</strong>, we can create <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 our <strong>Jison.Parser</strong>. We do this by processing all of our rules, recording all
@ -1574,11 +1634,11 @@ as &quot;tokens&quot;.
</li> </li>
<li id="section-68"> <li id="section-73">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-68">&#182;</a> <a class="pilcrow" href="#section-73">&#182;</a>
</div> </div>
<p>Initialize the <strong>Parser</strong> with our list of terminal <strong>tokens</strong>, our <strong>grammar</strong> <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 rules, and the name of the root. Reverse the operators because Jison orders

View file

@ -111,9 +111,20 @@
<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 we&#39;d like to share among
the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten
arrays, count characters, that sort of thing. arrays, count characters, that sort of thing.
</p> </p>
<p>Peek at the beginning of a given string to see if it matches a sequence.
</div>
</li>
<li id="section-2">
<div class="annotation">
<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> </p>
</div> </div>
@ -124,11 +135,11 @@ arrays, count characters, that sort of thing.
</li> </li>
<li id="section-2"> <li id="section-3">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a> <a class="pilcrow" href="#section-3">&#182;</a>
</div> </div>
<p>Peek at the end of a given string to see if it matches a sequence. <p>Peek at the end of a given string to see if it matches a sequence.
</p> </p>
@ -142,11 +153,11 @@ arrays, count characters, that sort of thing.
</li> </li>
<li id="section-3"> <li id="section-4">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a> <a class="pilcrow" href="#section-4">&#182;</a>
</div> </div>
<p>Repeat a string <code>n</code> times. <p>Repeat a string <code>n</code> times.
</p> </p>
@ -158,11 +169,11 @@ arrays, count characters, that sort of thing.
</li> </li>
<li id="section-4"> <li id="section-5">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a> <a class="pilcrow" href="#section-5">&#182;</a>
</div> </div>
<p>Use clever algorithm to have O(log(n)) string concatenation operations. <p>Use clever algorithm to have O(log(n)) string concatenation operations.
</p> </p>
@ -179,11 +190,11 @@ arrays, count characters, that sort of thing.
</li> </li>
<li id="section-5"> <li id="section-6">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a> <a class="pilcrow" href="#section-6">&#182;</a>
</div> </div>
<p>Trim out all falsy values from an array. <p>Trim out all falsy values from an array.
</p> </p>
@ -196,11 +207,11 @@ arrays, count characters, that sort of thing.
</li> </li>
<li id="section-6"> <li id="section-7">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a> <a class="pilcrow" href="#section-7">&#182;</a>
</div> </div>
<p>Count the number of occurrences of a string in a string. <p>Count the number of occurrences of a string in a string.
</p> </p>
@ -216,11 +227,11 @@ arrays, count characters, that sort of thing.
</li> </li>
<li id="section-7"> <li id="section-8">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a> <a class="pilcrow" href="#section-8">&#182;</a>
</div> </div>
<p>Merge objects, returning a fresh copy with attributes from both sides. <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 Used every time <code>Base#compile</code> is called, to allow properties in the
@ -235,11 +246,11 @@ options hash to propagate down the tree without polluting other branches.
</li> </li>
<li id="section-8"> <li id="section-9">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a> <a class="pilcrow" href="#section-9">&#182;</a>
</div> </div>
<p>Extend a source object with the properties of another object (shallow copy). <p>Extend a source object with the properties of another object (shallow copy).
</p> </p>
@ -254,11 +265,11 @@ options hash to propagate down the tree without polluting other branches.
</li> </li>
<li id="section-9"> <li id="section-10">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a> <a class="pilcrow" href="#section-10">&#182;</a>
</div> </div>
<p>Return a flattened version of an array. <p>Return a flattened version of an array.
Handy for getting a list of <code>children</code> from the nodes. Handy for getting a list of <code>children</code> from the nodes.
@ -278,11 +289,11 @@ Handy for getting a list of <code>children</code> from the nodes.
</li> </li>
<li id="section-10"> <li id="section-11">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a> <a class="pilcrow" href="#section-11">&#182;</a>
</div> </div>
<p>Delete a key from an object, returning the value. Useful when a node is <p>Delete a key from an object, returning the value. Useful when a node is
looking for a particular method in an options hash. looking for a particular method in an options hash.
@ -298,11 +309,11 @@ looking for a particular method in an options hash.
</li> </li>
<li id="section-11"> <li id="section-12">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a> <a class="pilcrow" href="#section-12">&#182;</a>
</div> </div>
<p>Gets the last item of an array(-like) object. <p>Gets the last item of an array(-like) object.
</p> </p>
@ -314,11 +325,11 @@ looking for a particular method in an options hash.
</li> </li>
<li id="section-12"> <li id="section-13">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a> <a class="pilcrow" href="#section-13">&#182;</a>
</div> </div>
<p>Typical Array::some <p>Typical Array::some
</p> </p>
@ -332,11 +343,11 @@ looking for a particular method in an options hash.
</li> </li>
<li id="section-13"> <li id="section-14">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a> <a class="pilcrow" href="#section-14">&#182;</a>
</div> </div>
<p>Simple function for inverting Literate CoffeeScript code by putting the <p>Simple function for inverting Literate CoffeeScript code by putting the
documentation in comments, producing a string of CoffeeScript code that documentation in comments, producing a string of CoffeeScript code that
@ -359,11 +370,11 @@ can be compiled &quot;normally&quot;.
</li> </li>
<li id="section-14"> <li id="section-15">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a> <a class="pilcrow" href="#section-15">&#182;</a>
</div> </div>
<p>Merge two jison-style location data objects together. <p>Merge two jison-style location data objects together.
If <code>last</code> is not provided, this will simply return <code>first</code>. If <code>last</code> is not provided, this will simply return <code>first</code>.
@ -383,11 +394,11 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
</li> </li>
<li id="section-15"> <li id="section-16">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a> <a class="pilcrow" href="#section-16">&#182;</a>
</div> </div>
<p>This returns a function which takes an object as a parameter, and if that <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 object&#39;s locationData.
@ -406,11 +417,11 @@ The object is returned either way.
</li> </li>
<li id="section-16"> <li id="section-17">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a> <a class="pilcrow" href="#section-17">&#182;</a>
</div> </div>
<p>Convert jison location data to a string. <p>Convert jison location data to a string.
<code>obj</code> can be a token, or a locationData. <code>obj</code> can be a token, or a locationData.
@ -431,18 +442,19 @@ The object is returned either way.
</li> </li>
<li id="section-17"> <li id="section-18">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a> <a class="pilcrow" href="#section-18">&#182;</a>
</div> </div>
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension. <p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">baseFileName</span></span> = (file, stripExt = <span class="literal">no</span>, pathSep = <span class="string">'/'</span>) -&gt; <div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">baseFileName</span></span> = (file, stripExt = <span class="literal">no</span>, useWinPathSep = <span class="literal">no</span>) -&gt;
pathSep = <span class="keyword">if</span> useWinPathSep <span class="keyword">then</span> <span class="regexp">/\\|\// else /\//</span>
parts = file.split(pathSep) parts = file.split(pathSep)
file = parts[parts.length - <span class="number">1</span>] file = parts[parts.length - <span class="number">1</span>]
<span class="keyword">return</span> file <span class="keyword">unless</span> stripExt <span class="keyword">return</span> file <span class="keyword">unless</span> stripExt
@ -454,11 +466,11 @@ The object is returned either way.
</li> </li>
<li id="section-18"> <li id="section-19">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a> <a class="pilcrow" href="#section-19">&#182;</a>
</div> </div>
<p>Determine if a filename represents a CoffeeScript file. <p>Determine if a filename represents a CoffeeScript file.
</p> </p>
@ -470,11 +482,11 @@ The object is returned either way.
</li> </li>
<li id="section-19"> <li id="section-20">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a> <a class="pilcrow" href="#section-20">&#182;</a>
</div> </div>
<p>Determine if a filename represents a Literate CoffeeScript file. <p>Determine if a filename represents a Literate CoffeeScript file.
</p> </p>
@ -486,11 +498,11 @@ The object is returned either way.
</li> </li>
<li id="section-20"> <li id="section-21">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a> <a class="pilcrow" href="#section-21">&#182;</a>
</div> </div>
<p>Throws a SyntaxError with a source file location data attached to it in a <p>Throws a SyntaxError with a source file location data attached to it in a
property called <code>location</code>. property called <code>location</code>.
@ -508,11 +520,11 @@ property called <code>location</code>.
</li> </li>
<li id="section-21"> <li id="section-22">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a> <a class="pilcrow" href="#section-22">&#182;</a>
</div> </div>
<p>Creates a nice error message like, following the &quot;standard&quot; format <p>Creates a nice error message like, following the &quot;standard&quot; format
</p> </p>
@ -532,11 +544,11 @@ showing where the error is.
</li> </li>
<li id="section-22"> <li id="section-23">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a> <a class="pilcrow" href="#section-23">&#182;</a>
</div> </div>
<p>Show only the first line on multi-line errors. <p>Show only the first line on multi-line errors.
</p> </p>
@ -560,20 +572,20 @@ showing where the error is.
</li> </li>
<li id="section-23"> <li id="section-24">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a> <a class="pilcrow" href="#section-24">&#182;</a>
</div> </div>
<p>Uncomment to add stacktrace. <p>Uncomment to add stacktrace.
message += &quot;\n#{error.stack}&quot; message += &quot;\n#{error.stack}&quot;
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> message</pre></div></div> <div class="content"><div class='highlight'><pre>
message</pre></div></div>
</li> </li>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -108,6 +108,20 @@
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a> <a class="pilcrow" href="#section-1">&#182;</a>
</div> </div>
</div>
<div class="content"><div class='highlight'><pre>{repeat} = require <span class="string">'./helpers'</span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line. <p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
Use it like so: Use it like so:
@ -125,11 +139,11 @@ option) list, and all subsequent arguments are left unparsed.
</li> </li>
<li id="section-2"> <li id="section-3">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a> <a class="pilcrow" href="#section-3">&#182;</a>
</div> </div>
<p>Initialize with a list of valid options, in the form: <p>Initialize with a list of valid options, in the form:
@ -146,11 +160,11 @@ option) list, and all subsequent arguments are left unparsed.
</li> </li>
<li id="section-3"> <li id="section-4">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a> <a class="pilcrow" href="#section-4">&#182;</a>
</div> </div>
<p>Parse the list of arguments, populating an <code>options</code> object with all of the <p>Parse the list of arguments, populating an <code>options</code> object with all of the
specified options, and return it. Options after the first non-option specified options, and return it. Options after the first non-option
@ -180,11 +194,11 @@ you&#39;re responsible for interpreting the options object.
</li> </li>
<li id="section-4"> <li id="section-5">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a> <a class="pilcrow" href="#section-5">&#182;</a>
</div> </div>
<p>the CS option parser is a little odd; options after the first <p>the CS option parser is a little odd; options after the first
non-option argument are treated as non-option arguments themselves non-option argument are treated as non-option arguments themselves
@ -212,11 +226,11 @@ non-option argument are treated as non-option arguments themselves
</li> </li>
<li id="section-5"> <li id="section-6">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a> <a class="pilcrow" href="#section-6">&#182;</a>
</div> </div>
<p>Return the help text for this <strong>OptionParser</strong>, listing and describing all <p>Return the help text for this <strong>OptionParser</strong>, listing and describing all
of the valid options, for <code>--help</code> and such. of the valid options, for <code>--help</code> and such.
@ -229,7 +243,7 @@ of the valid options, for <code>--help</code> and such.
lines.unshift <span class="string">"<span class="subst">#{@banner}</span>\n"</span> <span class="keyword">if</span> <span class="property">@banner</span> lines.unshift <span class="string">"<span class="subst">#{@banner}</span>\n"</span> <span class="keyword">if</span> <span class="property">@banner</span>
<span class="keyword">for</span> rule <span class="keyword">in</span> <span class="property">@rules</span> <span class="keyword">for</span> rule <span class="keyword">in</span> <span class="property">@rules</span>
spaces = <span class="number">15</span> - rule.longFlag.length spaces = <span class="number">15</span> - rule.longFlag.length
spaces = <span class="keyword">if</span> spaces &gt; <span class="number">0</span> <span class="keyword">then</span> Array(spaces + <span class="number">1</span>).join(<span class="string">' '</span>) <span class="keyword">else</span> <span class="string">''</span> spaces = <span class="keyword">if</span> spaces &gt; <span class="number">0</span> <span class="keyword">then</span> repeat <span class="string">' '</span>, spaces <span class="keyword">else</span> <span class="string">''</span>
letPart = <span class="keyword">if</span> rule.shortFlag <span class="keyword">then</span> rule.shortFlag + <span class="string">', '</span> <span class="keyword">else</span> <span class="string">' '</span> letPart = <span class="keyword">if</span> rule.shortFlag <span class="keyword">then</span> rule.shortFlag + <span class="string">', '</span> <span class="keyword">else</span> <span class="string">' '</span>
lines.push <span class="string">' '</span> + letPart + rule.longFlag + spaces + rule.description lines.push <span class="string">' '</span> + letPart + rule.longFlag + spaces + rule.description
<span class="string">"\n<span class="subst">#{ lines.join('\n') }</span>\n"</span></pre></div></div> <span class="string">"\n<span class="subst">#{ lines.join('\n') }</span>\n"</span></pre></div></div>
@ -237,11 +251,11 @@ of the valid options, for <code>--help</code> and such.
</li> </li>
<li id="section-6"> <li id="section-7">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-6">&#182;</a> <a class="pilcrow" href="#section-7">&#182;</a>
</div> </div>
<h2>Helpers</h2> <h2>Helpers</h2>
@ -250,11 +264,23 @@ of the valid options, for <code>--help</code> and such.
</li> </li>
<li id="section-7"> <li id="section-8">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a> <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> </div>
<p>Regex matchers for option flags. <p>Regex matchers for option flags.
</p> </p>
@ -269,11 +295,11 @@ OPTIONAL = <span class="regexp">/\[(\w+(\*?))\]/</span></pre></div></div>
</li> </li>
<li id="section-8"> <li id="section-10">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a> <a class="pilcrow" href="#section-10">&#182;</a>
</div> </div>
<p>Build and return the list of option rules. If the optional <em>short-flag</em> is <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>. unspecified, leave it out by padding with <code>null</code>.
@ -289,11 +315,11 @@ unspecified, leave it out by padding with <code>null</code>.
</li> </li>
<li id="section-9"> <li id="section-11">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a> <a class="pilcrow" href="#section-11">&#182;</a>
</div> </div>
<p>Build a rule from a <code>-o</code> short flag, a <code>--output [DIR]</code> long flag, and the <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. description of what the option does.
@ -316,11 +342,11 @@ description of what the option does.
</li> </li>
<li id="section-10"> <li id="section-12">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a> <a class="pilcrow" href="#section-12">&#182;</a>
</div> </div>
<p>Normalize arguments by expanding merged flags into multiple flags. This allows <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>. you to have <code>-wl</code> be the same as <code>--watch --lint</code>.

View file

@ -111,13 +111,17 @@
</div> </div>
<div class="content"><div class='highlight'><pre>vm = require <span class="string">'vm'</span> <div class="content"><div class='highlight'><pre>fs = require <span class="string">'fs'</span>
path = require <span class="string">'path'</span>
vm = require <span class="string">'vm'</span>
nodeREPL = require <span class="string">'repl'</span> nodeREPL = require <span class="string">'repl'</span>
CoffeeScript = require <span class="string">'./coffee-script'</span> CoffeeScript = require <span class="string">'./coffee-script'</span>
{merge, prettyErrorMessage} = require <span class="string">'./helpers'</span> {merge, prettyErrorMessage} = require <span class="string">'./helpers'</span>
replDefaults = replDefaults =
prompt: <span class="string">'coffee&gt; '</span>, prompt: <span class="string">'coffee&gt; '</span>,
historyFile: path.join process.env.HOME, <span class="string">'.coffee_history'</span> <span class="keyword">if</span> process.env.HOME
historyMaxInputSize: <span class="number">10240</span>
eval: (input, context, filename, cb) -&gt;</pre></div></div> eval: (input, context, filename, cb) -&gt;</pre></div></div>
</li> </li>
@ -214,8 +218,8 @@ parens. Unwrap all that.
multiline = multiline =
enabled: <span class="literal">off</span> enabled: <span class="literal">off</span>
initialPrompt: repl.prompt.replace(<span class="regexp">/^[^&gt; ]*/, (x) -&gt; x.replace /./g</span>, <span class="string">'-'</span>) initialPrompt: repl.prompt.replace <span class="regexp">/^[^&gt; ]*/, (x) -&gt; x.replace /./g</span>, <span class="string">'-'</span>
prompt: repl.prompt.replace(<span class="regexp">/^[^&gt; ]*&gt;?/, (x) -&gt; x.replace /./g</span>, <span class="string">'.'</span>) prompt: repl.prompt.replace <span class="regexp">/^[^&gt; ]*&gt;?/, (x) -&gt; x.replace /./g</span>, <span class="string">'.'</span>
buffer: <span class="string">''</span></pre></div></div> buffer: <span class="string">''</span></pre></div></div>
</li> </li>
@ -338,7 +342,154 @@ parens. Unwrap all that.
multiline.enabled = <span class="keyword">not</span> multiline.enabled multiline.enabled = <span class="keyword">not</span> multiline.enabled
rli.setPrompt multiline.initialPrompt rli.setPrompt multiline.initialPrompt
rli.prompt <span class="literal">true</span> rli.prompt <span class="literal">true</span>
<span class="keyword">return</span> <span class="keyword">return</span></pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Store and load command history from a file
</p>
</div>
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">addHistory</span></span> = (repl, filename, maxSize) -&gt;
lastLine = <span class="literal">null</span>
<span class="keyword">try</span></pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Get file info and at most maxSize of command history
</p>
</div>
<div class="content"><div class='highlight'><pre> stat = fs.statSync filename
size = Math.min maxSize, stat.size</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Read last <code>size</code> bytes from the file
</p>
</div>
<div class="content"><div class='highlight'><pre> readFd = fs.openSync filename, <span class="string">'r'</span>
buffer = <span class="keyword">new</span> Buffer(size)
fs.readSync readFd, buffer, <span class="number">0</span>, size, stat.size - size</pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Set the history on the interpreter
</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history = buffer.toString().split(<span class="string">'\n'</span>).reverse()</pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>If the history file was truncated we should pop off a potential partial line
</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history.pop() <span class="keyword">if</span> stat.size &gt; maxSize</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Shift off the final blank newline
</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history.shift() <span class="keyword">if</span> repl.rli.history[<span class="number">0</span>] <span class="keyword">is</span> <span class="string">''</span>
repl.rli.historyIndex = -<span class="number">1</span>
lastLine = repl.rli.history[<span class="number">0</span>]
fd = fs.openSync filename, <span class="string">'a'</span>
repl.rli.addListener <span class="string">'line'</span>, (code) -&gt;
<span class="keyword">if</span> code <span class="keyword">and</span> code.length <span class="keyword">and</span> code <span class="keyword">isnt</span> <span class="string">'.history'</span> <span class="keyword">and</span> lastLine <span class="keyword">isnt</span> code</pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Save the latest command in the file
</p>
</div>
<div class="content"><div class='highlight'><pre> fs.write fd, <span class="string">"<span class="subst">#{code}</span>\n"</span>
lastLine = code
repl.rli.<span class="literal">on</span> <span class="string">'exit'</span>, -&gt; fs.close fd</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#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="string">'.history'</span>] =
help: <span class="string">'Show command history'</span>
action: -&gt;
repl.outputStream.write <span class="string">"<span class="subst">#{repl.rli.history[..].reverse().join '\n'}</span>\n"</span>
repl.displayPrompt()
module.exports = module.exports =
start: (opts = {}) -&gt; start: (opts = {}) -&gt;
@ -352,6 +503,7 @@ module.exports =
repl = nodeREPL.start opts repl = nodeREPL.start opts
repl.<span class="literal">on</span> <span class="string">'exit'</span>, -&gt; repl.outputStream.write <span class="string">'\n'</span> repl.<span class="literal">on</span> <span class="string">'exit'</span>, -&gt; repl.outputStream.write <span class="string">'\n'</span>
addMultilineHandler repl addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="keyword">if</span> opts.historyFile
repl</pre></div></div> repl</pre></div></div>
</li> </li>

View file

@ -114,9 +114,20 @@ 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 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 shorthand into the unambiguous long form, add implicit indentation and
parentheses, and generally clean things up. parentheses, and generally clean things up.
</p> </p>
<p>Create a generated token: one that exists due to a use of implicit syntax.
</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> </p>
</div> </div>
@ -129,11 +140,11 @@ parentheses, and generally clean things up.
</li> </li>
<li id="section-2"> <li id="section-3">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a> <a class="pilcrow" href="#section-3">&#182;</a>
</div> </div>
<p>The <strong>Rewriter</strong> class is used by the <a href="lexer.html">Lexer</a>, directly against <p>The <strong>Rewriter</strong> class is used by the <a href="lexer.html">Lexer</a>, directly against
its internal array of tokens. its internal array of tokens.
@ -146,17 +157,29 @@ its internal array of tokens.
</li> </li>
<li id="section-3"> <li id="section-4">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a> <a class="pilcrow" href="#section-4">&#182;</a>
</div> </div>
<p>Helpful snippet for debugging: <p>Helpful snippet for debugging:
</p> </p>
<pre><code>console.log (t[0] + &#39;/&#39; + t[1] for t in @tokens).join &#39; &#39;</code></pre> <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
</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 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 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 like this. The order of these passes matters -- indentation must be
@ -179,11 +202,11 @@ corrected before implicit parentheses can be wrapped around blocks of code.
</li> </li>
<li id="section-4"> <li id="section-6">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a> <a class="pilcrow" href="#section-6">&#182;</a>
</div> </div>
<p>Rewrite the token stream, looking one token ahead and behind. <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 Allow the return value of the block to tell us how many tokens to move
@ -216,11 +239,11 @@ our feet.
</li> </li>
<li id="section-5"> <li id="section-7">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a> <a class="pilcrow" href="#section-7">&#182;</a>
</div> </div>
<p>Leading newlines would introduce an ambiguity in the grammar, so we <p>Leading newlines would introduce an ambiguity in the grammar, so we
dispatch them here. dispatch them here.
@ -235,11 +258,11 @@ dispatch them here.
</li> </li>
<li id="section-6"> <li id="section-8">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a> <a class="pilcrow" href="#section-8">&#182;</a>
</div> </div>
<p>Some blocks occur in the middle of expressions -- when we&#39;re expecting <p>Some blocks occur in the middle of expressions -- when we&#39;re expecting
this, remove their trailing newlines. this, remove their trailing newlines.
@ -256,11 +279,11 @@ this, remove their trailing newlines.
</li> </li>
<li id="section-7"> <li id="section-9">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a> <a class="pilcrow" href="#section-9">&#182;</a>
</div> </div>
<p>The lexer has tagged the opening parenthesis of a method call. Match it with <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 its paired close. We have the mis-nested outdent case included here for
@ -284,11 +307,11 @@ calls that close on the same line, just before their outdent.
</li> </li>
<li id="section-8"> <li id="section-10">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a> <a class="pilcrow" href="#section-10">&#182;</a>
</div> </div>
<p>The lexer has tagged the opening parenthesis of an indexing operation call. <p>The lexer has tagged the opening parenthesis of an indexing operation call.
Match it with its paired close. Match it with its paired close.
@ -310,11 +333,11 @@ Match it with its paired close.
</li> </li>
<li id="section-9"> <li id="section-11">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a> <a class="pilcrow" href="#section-11">&#182;</a>
</div> </div>
<p>Match tags in token stream starting at i with pattern, skipping HERECOMMENTs <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) Pattern may consist of strings (equality), an array of strings (one of)
@ -335,11 +358,11 @@ or null (wildcard)
</li> </li>
<li id="section-10"> <li id="section-12">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a> <a class="pilcrow" href="#section-12">&#182;</a>
</div> </div>
<p>yes iff standing in front of something looking like <p>yes iff standing in front of something looking like
@<x>: or <x>:, skipping over &#39;HERECOMMENT&#39;s @<x>: or <x>:, skipping over &#39;HERECOMMENT&#39;s
@ -353,11 +376,11 @@ or null (wildcard)
</li> </li>
<li id="section-11"> <li id="section-13">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a> <a class="pilcrow" href="#section-13">&#182;</a>
</div> </div>
<p>yes iff current line of tokens contain an element of tags on same <p>yes iff current line of tokens contain an element of tags on same
expression level. Stop searching at LINEBREAKS or explicit start of expression level. Stop searching at LINEBREAKS or explicit start of
@ -380,11 +403,11 @@ containing balanced expression.
</li> </li>
<li id="section-12"> <li id="section-14">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a> <a class="pilcrow" href="#section-14">&#182;</a>
</div> </div>
<p>Look for signs of implicit calls and objects in the token stream and <p>Look for signs of implicit calls and objects in the token stream and
add them. add them.
@ -397,11 +420,11 @@ add them.
</li> </li>
<li id="section-13"> <li id="section-15">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a> <a class="pilcrow" href="#section-15">&#182;</a>
</div> </div>
<p>Track current balancing depth (both implicit and explicit) on stack. <p>Track current balancing depth (both implicit and explicit) on stack.
</p> </p>
@ -420,11 +443,11 @@ add them.
</li> </li>
<li id="section-14"> <li id="section-16">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a> <a class="pilcrow" href="#section-16">&#182;</a>
</div> </div>
<p>Helper function, used for keeping track of the number of tokens consumed <p>Helper function, used for keeping track of the number of tokens consumed
and spliced, when returning for getting a new token. and spliced, when returning for getting a new token.
@ -437,11 +460,11 @@ and spliced, when returning for getting a new token.
</li> </li>
<li id="section-15"> <li id="section-17">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a> <a class="pilcrow" href="#section-17">&#182;</a>
</div> </div>
<p>Helper functions <p>Helper functions
</p> </p>
@ -455,11 +478,11 @@ and spliced, when returning for getting a new token.
</li> </li>
<li id="section-16"> <li id="section-18">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a> <a class="pilcrow" href="#section-18">&#182;</a>
</div> </div>
<p>Unclosed control statement inside implicit parens (like <p>Unclosed control statement inside implicit parens (like
class declaration or if-conditionals) class declaration or if-conditionals)
@ -495,11 +518,11 @@ class declaration or if-conditionals)
</li> </li>
<li id="section-17"> <li id="section-19">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a> <a class="pilcrow" href="#section-19">&#182;</a>
</div> </div>
<p>Don&#39;t end an implicit call on next indent if any of these are in an argument <p>Don&#39;t end an implicit call on next indent if any of these are in an argument
</p> </p>
@ -516,11 +539,11 @@ class declaration or if-conditionals)
</li> </li>
<li id="section-18"> <li id="section-20">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a> <a class="pilcrow" href="#section-20">&#182;</a>
</div> </div>
<p>An <code>INDENT</code> closes an implicit call unless <p>An <code>INDENT</code> closes an implicit call unless
@ -541,11 +564,11 @@ class declaration or if-conditionals)
</li> </li>
<li id="section-19"> <li id="section-21">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a> <a class="pilcrow" href="#section-21">&#182;</a>
</div> </div>
<p>Straightforward start of explicit expression <p>Straightforward start of explicit expression
</p> </p>
@ -559,11 +582,11 @@ class declaration or if-conditionals)
</li> </li>
<li id="section-20"> <li id="section-22">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a> <a class="pilcrow" href="#section-22">&#182;</a>
</div> </div>
<p>Close all implicit expressions inside of explicitly closed expressions. <p>Close all implicit expressions inside of explicitly closed expressions.
</p> </p>
@ -583,11 +606,11 @@ class declaration or if-conditionals)
</li> </li>
<li id="section-21"> <li id="section-23">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a> <a class="pilcrow" href="#section-23">&#182;</a>
</div> </div>
<p>Recognize standard implicit calls like <p>Recognize standard implicit calls like
f a, f() b, f? c, h[0] d etc. f a, f() b, f? c, h[0] d etc.
@ -607,11 +630,11 @@ f a, f() b, f? c, h[0] d etc.
</li> </li>
<li id="section-22"> <li id="section-24">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a> <a class="pilcrow" href="#section-24">&#182;</a>
</div> </div>
<p>Implicit call taking an implicit indented object as first argument. <p>Implicit call taking an implicit indented object as first argument.
@ -643,7 +666,7 @@ that creates grammatical ambiguities.
</div> </div>
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> <span class="property">@matchTags</span>(i, IMPLICIT_FUNC, <span class="string">'INDENT'</span>, <span class="literal">null</span>, <span class="string">':'</span>) <span class="keyword">and</span> <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> tag <span class="keyword">in</span> IMPLICIT_FUNC <span class="keyword">and</span> <span class="property">@matchTags</span>(i + <span class="number">1</span>, <span class="string">'INDENT'</span>, <span class="literal">null</span>, <span class="string">':'</span>) <span class="keyword">and</span>
<span class="keyword">not</span> <span class="property">@findTagsBackwards</span>(i, [<span class="string">'CLASS'</span>, <span class="string">'EXTENDS'</span>, <span class="string">'IF'</span>, <span class="string">'CATCH'</span>, <span class="keyword">not</span> <span class="property">@findTagsBackwards</span>(i, [<span class="string">'CLASS'</span>, <span class="string">'EXTENDS'</span>, <span class="string">'IF'</span>, <span class="string">'CATCH'</span>,
<span class="string">'SWITCH'</span>, <span class="string">'LEADING_WHEN'</span>, <span class="string">'FOR'</span>, <span class="string">'WHILE'</span>, <span class="string">'UNTIL'</span>]) <span class="string">'SWITCH'</span>, <span class="string">'LEADING_WHEN'</span>, <span class="string">'FOR'</span>, <span class="string">'WHILE'</span>, <span class="string">'UNTIL'</span>])
startImplicitCall i + <span class="number">1</span> startImplicitCall i + <span class="number">1</span>
@ -653,11 +676,11 @@ that creates grammatical ambiguities.
</li> </li>
<li id="section-23"> <li id="section-25">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a> <a class="pilcrow" href="#section-25">&#182;</a>
</div> </div>
<p>Implicit objects start here <p>Implicit objects start here
</p> </p>
@ -669,11 +692,11 @@ that creates grammatical ambiguities.
</li> </li>
<li id="section-24"> <li id="section-26">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a> <a class="pilcrow" href="#section-26">&#182;</a>
</div> </div>
<p>Go back to the (implicit) start of the object <p>Go back to the (implicit) start of the object
</p> </p>
@ -688,11 +711,11 @@ that creates grammatical ambiguities.
</li> </li>
<li id="section-25"> <li id="section-27">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a> <a class="pilcrow" href="#section-27">&#182;</a>
</div> </div>
<p>Are we just continuing an already declared object? <p>Are we just continuing an already declared object?
</p> </p>
@ -711,11 +734,11 @@ that creates grammatical ambiguities.
</li> </li>
<li id="section-26"> <li id="section-28">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a> <a class="pilcrow" href="#section-28">&#182;</a>
</div> </div>
<p>End implicit calls when chaining method calls <p>End implicit calls when chaining method calls
like e.g.: like e.g.:
@ -742,11 +765,11 @@ like e.g.:
</li> </li>
<li id="section-27"> <li id="section-29">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a> <a class="pilcrow" href="#section-29">&#182;</a>
</div> </div>
<p>Close implicit calls when reached end of argument list <p>Close implicit calls when reached end of argument list
</p> </p>
@ -759,11 +782,11 @@ like e.g.:
</li> </li>
<li id="section-28"> <li id="section-30">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a> <a class="pilcrow" href="#section-30">&#182;</a>
</div> </div>
<p>Close implicit objects such as: <p>Close implicit objects such as:
return a: 1, b: 2 unless true return a: 1, b: 2 unless true
@ -777,11 +800,11 @@ return a: 1, b: 2 unless true
</li> </li>
<li id="section-29"> <li id="section-31">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a> <a class="pilcrow" href="#section-31">&#182;</a>
</div> </div>
<p>Close implicit objects when at end of line, line didn&#39;t end with a comma <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 and the implicit object didn&#39;t start the line or the next line doesn&#39;t look like
@ -799,11 +822,11 @@ the continuation of an object.
</li> </li>
<li id="section-30"> <li id="section-32">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a> <a class="pilcrow" href="#section-32">&#182;</a>
</div> </div>
<p>Close implicit object if comma is the last character <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 doesn&#39;t look like it belongs.
@ -827,11 +850,11 @@ e = 2</code></pre>
</li> </li>
<li id="section-31"> <li id="section-33">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a> <a class="pilcrow" href="#section-33">&#182;</a>
</div> </div>
<p>When nextTag is OUTDENT the comma is insignificant and <p>When nextTag is OUTDENT the comma is insignificant and
should just be ignored so embed it in the implicit object. should just be ignored so embed it in the implicit object.
@ -839,12 +862,12 @@ should just be ignored so embed it in the implicit object.
</p> </p>
<p>When it isn&#39;t the comma go on to play a role in a call or <p>When it isn&#39;t the comma go on to play a role in a call or
array further up the stack, so give it a chance. array further up the stack, so give it a chance.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> offset = <span class="keyword">if</span> nextTag <span class="keyword">is</span> <span class="string">'OUTDENT'</span> <span class="keyword">then</span> <span class="number">1</span> <span class="keyword">else</span> <span class="number">0</span> <div class="content"><div class='highlight'><pre>
offset = <span class="keyword">if</span> nextTag <span class="keyword">is</span> <span class="string">'OUTDENT'</span> <span class="keyword">then</span> <span class="number">1</span> <span class="keyword">else</span> <span class="number">0</span>
<span class="keyword">while</span> inImplicitObject() <span class="keyword">while</span> inImplicitObject()
endImplicitObject i + offset endImplicitObject i + offset
<span class="keyword">return</span> forward(<span class="number">1</span>)</pre></div></div> <span class="keyword">return</span> forward(<span class="number">1</span>)</pre></div></div>
@ -852,11 +875,11 @@ array further up the stack, so give it a chance.
</li> </li>
<li id="section-32"> <li id="section-34">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a> <a class="pilcrow" href="#section-34">&#182;</a>
</div> </div>
<p>Add location data to all tokens generated by the rewriter. <p>Add location data to all tokens generated by the rewriter.
</p> </p>
@ -878,16 +901,16 @@ array further up the stack, so give it a chance.
first_column: column first_column: column
last_line: line last_line: line
last_column: column last_column: column
<span class="number">1</span></pre></div></div> <span class="keyword">return</span> <span class="number">1</span></pre></div></div>
</li> </li>
<li id="section-33"> <li id="section-35">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a> <a class="pilcrow" href="#section-35">&#182;</a>
</div> </div>
<p>Because our grammar is LALR(1), it can&#39;t handle some single-line <p>Because our grammar is LALR(1), it can&#39;t handle some single-line
expressions that lack ending delimiters. The <strong>Rewriter</strong> adds the implicit expressions that lack ending delimiters. The <strong>Rewriter</strong> adds the implicit
@ -902,7 +925,8 @@ but we need to make sure it&#39;s balanced.
<span class="function"><span class="title">condition</span></span> = (token, i) -&gt; <span class="function"><span class="title">condition</span></span> = (token, i) -&gt;
token[<span class="number">1</span>] <span class="keyword">isnt</span> <span class="string">';'</span> <span class="keyword">and</span> token[<span class="number">0</span>] <span class="keyword">in</span> SINGLE_CLOSERS <span class="keyword">and</span> token[<span class="number">1</span>] <span class="keyword">isnt</span> <span class="string">';'</span> <span class="keyword">and</span> token[<span class="number">0</span>] <span class="keyword">in</span> SINGLE_CLOSERS <span class="keyword">and</span>
<span class="keyword">not</span> (token[<span class="number">0</span>] <span class="keyword">is</span> <span class="string">'ELSE'</span> <span class="keyword">and</span> starter <span class="keyword">not</span> <span class="keyword">in</span> [<span class="string">'IF'</span>, <span class="string">'THEN'</span>]) <span class="keyword">not</span> (token[<span class="number">0</span>] <span class="keyword">is</span> <span class="string">'ELSE'</span> <span class="keyword">and</span> starter <span class="keyword">isnt</span> <span class="string">'THEN'</span>) <span class="keyword">and</span>
<span class="keyword">not</span> (token[<span class="number">0</span>] <span class="keyword">in</span> [<span class="string">'CATCH'</span>, <span class="string">'FINALLY'</span>] <span class="keyword">and</span> starter <span class="keyword">in</span> [<span class="string">'-&gt;'</span>, <span class="string">'=&gt;'</span>])
<span class="function"><span class="title">action</span></span> = (token, i) -&gt; <span class="function"><span class="title">action</span></span> = (token, i) -&gt;
<span class="property">@tokens</span>.splice (<span class="keyword">if</span> <span class="property">@tag</span>(i - <span class="number">1</span>) <span class="keyword">is</span> <span class="string">','</span> <span class="keyword">then</span> i - <span class="number">1</span> <span class="keyword">else</span> i), <span class="number">0</span>, outdent <span class="property">@tokens</span>.splice (<span class="keyword">if</span> <span class="property">@tag</span>(i - <span class="number">1</span>) <span class="keyword">is</span> <span class="string">','</span> <span class="keyword">then</span> i - <span class="number">1</span> <span class="keyword">else</span> i), <span class="number">0</span>, outdent
@ -915,9 +939,10 @@ but we need to make sure it&#39;s balanced.
<span class="keyword">if</span> tag <span class="keyword">is</span> <span class="string">'ELSE'</span> <span class="keyword">and</span> <span class="property">@tag</span>(i - <span class="number">1</span>) <span class="keyword">isnt</span> <span class="string">'OUTDENT'</span> <span class="keyword">if</span> tag <span class="keyword">is</span> <span class="string">'ELSE'</span> <span class="keyword">and</span> <span class="property">@tag</span>(i - <span class="number">1</span>) <span class="keyword">isnt</span> <span class="string">'OUTDENT'</span>
tokens.splice i, <span class="number">0</span>, <span class="property">@indentation</span>()... tokens.splice i, <span class="number">0</span>, <span class="property">@indentation</span>()...
<span class="keyword">return</span> <span class="number">2</span> <span class="keyword">return</span> <span class="number">2</span>
<span class="keyword">if</span> tag <span class="keyword">is</span> <span class="string">'CATCH'</span> <span class="keyword">and</span> <span class="property">@tag</span>(i + <span class="number">2</span>) <span class="keyword">in</span> [<span class="string">'OUTDENT'</span>, <span class="string">'TERMINATOR'</span>, <span class="string">'FINALLY'</span>] <span class="keyword">if</span> tag <span class="keyword">is</span> <span class="string">'CATCH'</span>
tokens.splice i + <span class="number">2</span>, <span class="number">0</span>, <span class="property">@indentation</span>()... <span class="keyword">for</span> j <span class="keyword">in</span> [<span class="number">1.</span><span class="number">.2</span>] <span class="keyword">when</span> <span class="property">@tag</span>(i + j) <span class="keyword">in</span> [<span class="string">'OUTDENT'</span>, <span class="string">'TERMINATOR'</span>, <span class="string">'FINALLY'</span>]
<span class="keyword">return</span> <span class="number">4</span> tokens.splice i + j, <span class="number">0</span>, <span class="property">@indentation</span>()...
<span class="keyword">return</span> <span class="number">2</span> + j
<span class="keyword">if</span> tag <span class="keyword">in</span> SINGLE_LINERS <span class="keyword">and</span> <span class="property">@tag</span>(i + <span class="number">1</span>) <span class="keyword">isnt</span> <span class="string">'INDENT'</span> <span class="keyword">and</span> <span class="keyword">if</span> tag <span class="keyword">in</span> SINGLE_LINERS <span class="keyword">and</span> <span class="property">@tag</span>(i + <span class="number">1</span>) <span class="keyword">isnt</span> <span class="string">'INDENT'</span> <span class="keyword">and</span>
<span class="keyword">not</span> (tag <span class="keyword">is</span> <span class="string">'ELSE'</span> <span class="keyword">and</span> <span class="property">@tag</span>(i + <span class="number">1</span>) <span class="keyword">is</span> <span class="string">'IF'</span>) <span class="keyword">not</span> (tag <span class="keyword">is</span> <span class="string">'ELSE'</span> <span class="keyword">and</span> <span class="property">@tag</span>(i + <span class="number">1</span>) <span class="keyword">is</span> <span class="string">'IF'</span>)
starter = tag starter = tag
@ -932,11 +957,11 @@ but we need to make sure it&#39;s balanced.
</li> </li>
<li id="section-34"> <li id="section-36">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a> <a class="pilcrow" href="#section-36">&#182;</a>
</div> </div>
<p>Tag postfix conditionals as such, so that we can parse them with a <p>Tag postfix conditionals as such, so that we can parse them with a
different precedence. different precedence.
@ -961,16 +986,16 @@ different precedence.
<span class="keyword">return</span> <span class="number">1</span> <span class="keyword">unless</span> token[<span class="number">0</span>] <span class="keyword">is</span> <span class="string">'IF'</span> <span class="keyword">return</span> <span class="number">1</span> <span class="keyword">unless</span> token[<span class="number">0</span>] <span class="keyword">is</span> <span class="string">'IF'</span>
original = token original = token
<span class="property">@detectEnd</span> i + <span class="number">1</span>, condition, action <span class="property">@detectEnd</span> i + <span class="number">1</span>, condition, action
<span class="number">1</span></pre></div></div> <span class="keyword">return</span> <span class="number">1</span></pre></div></div>
</li> </li>
<li id="section-35"> <li id="section-37">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a> <a class="pilcrow" href="#section-37">&#182;</a>
</div> </div>
<p>Generate the indentation tokens, based on another token on the same line. <p>Generate the indentation tokens, based on another token on the same line.
</p> </p>
@ -989,11 +1014,11 @@ different precedence.
</li> </li>
<li id="section-36"> <li id="section-38">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a> <a class="pilcrow" href="#section-38">&#182;</a>
</div> </div>
<p>Look up a tag by token index. <p>Look up a tag by token index.
</p> </p>
@ -1005,11 +1030,11 @@ different precedence.
</li> </li>
<li id="section-37"> <li id="section-39">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-37">&#182;</a> <a class="pilcrow" href="#section-39">&#182;</a>
</div> </div>
<h2>Constants</h2> <h2>Constants</h2>
@ -1018,11 +1043,23 @@ different precedence.
</li> </li>
<li id="section-38"> <li id="section-40">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <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> </div>
<p>List of the token pairs that must be balanced. <p>List of the token pairs that must be balanced.
</p> </p>
@ -1042,11 +1079,11 @@ different precedence.
</li> </li>
<li id="section-39"> <li id="section-42">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-39">&#182;</a> <a class="pilcrow" href="#section-42">&#182;</a>
</div> </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> we&#39;re trying to fix up, so we can
look things up from either end. look things up from either end.
@ -1059,11 +1096,11 @@ look things up from either end.
</li> </li>
<li id="section-40"> <li id="section-43">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-40">&#182;</a> <a class="pilcrow" href="#section-43">&#182;</a>
</div> </div>
<p>The tokens that signal the start/end of a balanced pair. <p>The tokens that signal the start/end of a balanced pair.
</p> </p>
@ -1080,11 +1117,11 @@ EXPRESSION_END = []
</li> </li>
<li id="section-41"> <li id="section-44">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a> <a class="pilcrow" href="#section-44">&#182;</a>
</div> </div>
<p>Tokens that indicate the close of a clause of an expression. <p>Tokens that indicate the close of a clause of an expression.
</p> </p>
@ -1096,11 +1133,11 @@ EXPRESSION_END = []
</li> </li>
<li id="section-42"> <li id="section-45">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-42">&#182;</a> <a class="pilcrow" href="#section-45">&#182;</a>
</div> </div>
<p>Tokens that, if followed by an <code>IMPLICIT_CALL</code>, indicate a function invocation. <p>Tokens that, if followed by an <code>IMPLICIT_CALL</code>, indicate a function invocation.
</p> </p>
@ -1112,11 +1149,11 @@ EXPRESSION_END = []
</li> </li>
<li id="section-43"> <li id="section-46">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-43">&#182;</a> <a class="pilcrow" href="#section-46">&#182;</a>
</div> </div>
<p>If preceded by an <code>IMPLICIT_FUNC</code>, indicates a function invocation. <p>If preceded by an <code>IMPLICIT_FUNC</code>, indicates a function invocation.
</p> </p>
@ -1134,27 +1171,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="string">'+'</span>, <span class="string">
</li> </li>
<li id="section-44"> <li id="section-47">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-44">&#182;</a> <a class="pilcrow" href="#section-47">&#182;</a>
</div>
<p>Tokens indicating that the implicit call must enclose a block of expressions.
</p>
</div>
<div class="content"><div class='highlight'><pre>IMPLICIT_BLOCK = [<span class="string">'-&gt;'</span>, <span class="string">'=&gt;'</span>, <span class="string">'{'</span>, <span class="string">'['</span>, <span class="string">','</span>]</pre></div></div>
</li>
<li id="section-45">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-45">&#182;</a>
</div> </div>
<p>Tokens that always mark the end of an implicit call for single-liners. <p>Tokens that always mark the end of an implicit call for single-liners.
</p> </p>
@ -1167,11 +1188,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="string">'+'</span>, <span class="string">
</li> </li>
<li id="section-46"> <li id="section-48">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-46">&#182;</a> <a class="pilcrow" href="#section-48">&#182;</a>
</div> </div>
<p>Single-line flavors of block expressions that have unclosed endings. <p>Single-line flavors of block expressions that have unclosed endings.
The grammar can&#39;t disambiguate them, so we insert the implicit indentation. The grammar can&#39;t disambiguate them, so we insert the implicit indentation.
@ -1185,11 +1206,11 @@ SINGLE_CLOSERS = [<span class="string">'TERMINATOR'</span>, <span class="strin
</li> </li>
<li id="section-47"> <li id="section-49">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-47">&#182;</a> <a class="pilcrow" href="#section-49">&#182;</a>
</div> </div>
<p>Tokens that end a line. <p>Tokens that end a line.
</p> </p>

View file

@ -114,18 +114,10 @@ function bodies. Each scope knows about the variables declared within it,
and has a reference to its parent enclosing scope. In this way, we know which and has a reference to its parent enclosing scope. In this way, we know which
variables are new and need to be declared with <code>var</code>, and which are shared variables are new and need to be declared with <code>var</code>, and which are shared
with external scopes. with external scopes.
</p>
<p>Import the helpers we plan to use.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre>{extend, last} = require <span class="string">'./helpers'</span>
exports.Scope = <span class="class"><span class="keyword">class</span> <span class="title">Scope</span></span></pre></div></div>
</li> </li>
@ -135,13 +127,15 @@ exports.Scope = <span class="class"><span class="keyword">class</span> <span cla
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a> <a class="pilcrow" href="#section-2">&#182;</a>
</div> </div>
<p>The <code>root</code> is the top-level <strong>Scope</strong> object for a given file. <p>Import the helpers we plan to use.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> <span class="property">@root</span>: <span class="literal">null</span></pre></div></div> <div class="content"><div class='highlight'><pre>
{extend, last} = require <span class="string">'./helpers'</span>
exports.Scope = <span class="class"><span class="keyword">class</span> <span class="title">Scope</span></span></pre></div></div>
</li> </li>
@ -152,19 +146,13 @@ exports.Scope = <span class="class"><span class="keyword">class</span> <span cla
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a> <a class="pilcrow" href="#section-3">&#182;</a>
</div> </div>
<p>Initialize a scope with its parent, for lookups up the chain, <p>The <code>root</code> is the top-level <strong>Scope</strong> object for a given file.
as well as a reference to the <strong>Block</strong> node it belongs to, which is
where it should declare its variables, and a reference to the function that
it belongs to.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> constructor: (<span class="property">@parent</span>, <span class="property">@expressions</span>, <span class="property">@method</span>) -&gt; <div class="content"><div class='highlight'><pre>
<span class="property">@variables</span> = [{name: <span class="string">'arguments'</span>, type: <span class="string">'arguments'</span>}] <span class="property">@root</span>: <span class="literal">null</span></pre></div></div>
<span class="property">@positions</span> = {}
Scope.root = <span class="keyword">this</span> <span class="keyword">unless</span> <span class="property">@parent</span></pre></div></div>
</li> </li>
@ -175,18 +163,19 @@ it belongs to.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a> <a class="pilcrow" href="#section-4">&#182;</a>
</div> </div>
<p>Adds a new variable or overrides an existing one. <p>Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the <strong>Block</strong> node it belongs to, which is
where it should declare its variables, and a reference to the function that
it belongs to.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> add: (name, type, immediate) -&gt; <div class="content"><div class='highlight'><pre>
<span class="keyword">return</span> <span class="property">@parent</span>.add name, type, immediate <span class="keyword">if</span> <span class="property">@shared</span> <span class="keyword">and</span> <span class="keyword">not</span> immediate constructor: (<span class="property">@parent</span>, <span class="property">@expressions</span>, <span class="property">@method</span>) -&gt;
<span class="keyword">if</span> Object::hasOwnProperty.call <span class="property">@positions</span>, name <span class="property">@variables</span> = [{name: <span class="string">'arguments'</span>, type: <span class="string">'arguments'</span>}]
<span class="property">@variables</span>[<span class="property">@positions</span>[name]].type = type <span class="property">@positions</span> = {}
<span class="keyword">else</span> Scope.root = <span class="keyword">this</span> <span class="keyword">unless</span> <span class="property">@parent</span></pre></div></div>
<span class="property">@positions</span>[name] = <span class="property">@variables</span>.push({name, type}) - <span class="number">1</span></pre></div></div>
</li> </li>
@ -197,19 +186,18 @@ it belongs to.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a> <a class="pilcrow" href="#section-5">&#182;</a>
</div> </div>
<p>When <code>super</code> is called, we need to find the name of the current method we&#39;re <p>Adds a new variable or overrides an existing one.
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
function object that has a name filled in, or bottoms out.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> namedMethod: -&gt; <div class="content"><div class='highlight'><pre>
<span class="keyword">return</span> <span class="property">@method</span> <span class="keyword">if</span> <span class="property">@method</span>?.name <span class="keyword">or</span> !<span class="property">@parent</span> add: (name, type, immediate) -&gt;
<span class="property">@parent</span>.namedMethod()</pre></div></div> <span class="keyword">return</span> <span class="property">@parent</span>.add name, type, immediate <span class="keyword">if</span> <span class="property">@shared</span> <span class="keyword">and</span> <span class="keyword">not</span> immediate
<span class="keyword">if</span> Object::hasOwnProperty.call <span class="property">@positions</span>, name
<span class="property">@variables</span>[<span class="property">@positions</span>[name]].type = type
<span class="keyword">else</span>
<span class="property">@positions</span>[name] = <span class="property">@variables</span>.push({name, type}) - <span class="number">1</span></pre></div></div>
</li> </li>
@ -220,17 +208,19 @@ function object that has a name filled in, or bottoms out.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a> <a class="pilcrow" href="#section-6">&#182;</a>
</div> </div>
<p>Look up a variable name in lexical scope, and declare it if it does not <p>When <code>super</code> is called, we need to find the name of the current method we&#39;re
already exist. 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
function object that has a name filled in, or bottoms out.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> find: (name) -&gt; <div class="content"><div class='highlight'><pre>
<span class="keyword">return</span> <span class="literal">yes</span> <span class="keyword">if</span> <span class="property">@check</span> name namedMethod: -&gt;
<span class="property">@add</span> name, <span class="string">'var'</span> <span class="keyword">return</span> <span class="property">@method</span> <span class="keyword">if</span> <span class="property">@method</span>?.name <span class="keyword">or</span> !<span class="property">@parent</span>
<span class="literal">no</span></pre></div></div> <span class="property">@parent</span>.namedMethod()</pre></div></div>
</li> </li>
@ -241,16 +231,17 @@ already exist.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a> <a class="pilcrow" href="#section-7">&#182;</a>
</div> </div>
<p>Reserve a variable name as originating from a function parameter for this <p>Look up a variable name in lexical scope, and declare it if it does not
scope. No <code>var</code> required for internal references. already exist.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> parameter: (name) -&gt; <div class="content"><div class='highlight'><pre>
<span class="keyword">return</span> <span class="keyword">if</span> <span class="property">@shared</span> <span class="keyword">and</span> <span class="property">@parent</span>.check name, <span class="literal">yes</span> find: (name) -&gt;
<span class="property">@add</span> name, <span class="string">'param'</span></pre></div></div> <span class="keyword">return</span> <span class="literal">yes</span> <span class="keyword">if</span> <span class="property">@check</span> name
<span class="property">@add</span> name, <span class="string">'var'</span>
<span class="literal">no</span></pre></div></div>
</li> </li>
@ -261,15 +252,16 @@ scope. No <code>var</code> required for internal references.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a> <a class="pilcrow" href="#section-8">&#182;</a>
</div> </div>
<p>Just check to see if a variable has already been declared, without reserving, <p>Reserve a variable name as originating from a function parameter for this
walks up to the root scope. scope. No <code>var</code> required for internal references.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> check: (name) -&gt; <div class="content"><div class='highlight'><pre>
!!(<span class="property">@type</span>(name) <span class="keyword">or</span> <span class="property">@parent</span>?.check(name))</pre></div></div> parameter: (name) -&gt;
<span class="keyword">return</span> <span class="keyword">if</span> <span class="property">@shared</span> <span class="keyword">and</span> <span class="property">@parent</span>.check name, <span class="literal">yes</span>
<span class="property">@add</span> name, <span class="string">'param'</span></pre></div></div>
</li> </li>
@ -280,17 +272,15 @@ walks up to the root scope.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a> <a class="pilcrow" href="#section-9">&#182;</a>
</div> </div>
<p>Generate a temporary variable name at the given index. <p>Just check to see if a variable has already been declared, without reserving,
walks up to the root scope.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> temporary: (name, index) -&gt; <div class="content"><div class='highlight'><pre>
<span class="keyword">if</span> name.length &gt; <span class="number">1</span> check: (name) -&gt;
<span class="string">'_'</span> + name + <span class="keyword">if</span> index &gt; <span class="number">1</span> <span class="keyword">then</span> index - <span class="number">1</span> <span class="keyword">else</span> <span class="string">''</span> !!(<span class="property">@type</span>(name) <span class="keyword">or</span> <span class="property">@parent</span>?.check(name))</pre></div></div>
<span class="keyword">else</span>
<span class="string">'_'</span> + (index + parseInt name, <span class="number">36</span>).toString(<span class="number">36</span>).replace <span class="regexp">/\d/g</span>, <span class="string">'a'</span></pre></div></div>
</li> </li>
@ -301,15 +291,17 @@ walks up to the root scope.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a> <a class="pilcrow" href="#section-10">&#182;</a>
</div> </div>
<p>Gets the type of a variable. <p>Generate a temporary variable name at the given index.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> type: (name) -&gt; <div class="content"><div class='highlight'><pre>
<span class="keyword">return</span> v.type <span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.name <span class="keyword">is</span> name temporary: (name, index) -&gt;
<span class="literal">null</span></pre></div></div> <span class="keyword">if</span> name.length &gt; <span class="number">1</span>
<span class="string">'_'</span> + name + <span class="keyword">if</span> index &gt; <span class="number">1</span> <span class="keyword">then</span> index - <span class="number">1</span> <span class="keyword">else</span> <span class="string">''</span>
<span class="keyword">else</span>
<span class="string">'_'</span> + (index + parseInt name, <span class="number">36</span>).toString(<span class="number">36</span>).replace <span class="regexp">/\d/g</span>, <span class="string">'a'</span></pre></div></div>
</li> </li>
@ -320,18 +312,15 @@ walks up to the root scope.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a> <a class="pilcrow" href="#section-11">&#182;</a>
</div> </div>
<p>If we need to store an intermediate result, find an available name for a <p>Gets the type of a variable.
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> freeVariable: (name, reserve=<span class="literal">true</span>) -&gt; <div class="content"><div class='highlight'><pre>
index = <span class="number">0</span> type: (name) -&gt;
index++ <span class="keyword">while</span> <span class="property">@check</span>((temp = <span class="property">@temporary</span> name, index)) <span class="keyword">return</span> v.type <span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.name <span class="keyword">is</span> name
<span class="property">@add</span> temp, <span class="string">'var'</span>, <span class="literal">yes</span> <span class="keyword">if</span> reserve <span class="literal">null</span></pre></div></div>
temp</pre></div></div>
</li> </li>
@ -342,16 +331,18 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a> <a class="pilcrow" href="#section-12">&#182;</a>
</div> </div>
<p>Ensure that an assignment is made at the top of this scope <p>If we need to store an intermediate result, find an available name for a
(or at the top-level scope, if requested). compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> assign: (name, value) -&gt; <div class="content"><div class='highlight'><pre>
<span class="property">@add</span> name, {value, assigned: <span class="literal">yes</span>}, <span class="literal">yes</span> freeVariable: (name, reserve=<span class="literal">true</span>) -&gt;
<span class="property">@hasAssignments</span> = <span class="literal">yes</span></pre></div></div> index = <span class="number">0</span>
index++ <span class="keyword">while</span> <span class="property">@check</span>((temp = <span class="property">@temporary</span> name, index))
<span class="property">@add</span> temp, <span class="string">'var'</span>, <span class="literal">yes</span> <span class="keyword">if</span> reserve
temp</pre></div></div>
</li> </li>
@ -362,14 +353,16 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a> <a class="pilcrow" href="#section-13">&#182;</a>
</div> </div>
<p>Does this scope have any declared variables? <p>Ensure that an assignment is made at the top of this scope
(or at the top-level scope, if requested).
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> hasDeclarations: -&gt; <div class="content"><div class='highlight'><pre>
!!<span class="property">@declaredVariables</span>().length</pre></div></div> assign: (name, value) -&gt;
<span class="property">@add</span> name, {value, assigned: <span class="literal">yes</span>}, <span class="literal">yes</span>
<span class="property">@hasAssignments</span> = <span class="literal">yes</span></pre></div></div>
</li> </li>
@ -380,18 +373,14 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a> <a class="pilcrow" href="#section-14">&#182;</a>
</div> </div>
<p>Return the list of variables first declared in this scope. <p>Does this scope have any declared variables?
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> declaredVariables: -&gt; <div class="content"><div class='highlight'><pre>
realVars = [] hasDeclarations: -&gt;
tempVars = [] !!<span class="property">@declaredVariables</span>().length</pre></div></div>
<span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.type <span class="keyword">is</span> <span class="string">'var'</span>
(<span class="keyword">if</span> v.name.charAt(<span class="number">0</span>) <span class="keyword">is</span> <span class="string">'_'</span> <span class="keyword">then</span> tempVars <span class="keyword">else</span> realVars).push v.name
realVars.sort().concat tempVars.sort()</pre></div></div>
</li> </li>
@ -402,14 +391,36 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a> <a class="pilcrow" href="#section-15">&#182;</a>
</div> </div>
<p>Return the list of assignments that are supposed to be made at the top <p>Return the list of variables first declared in this scope.
of this scope.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> assignedVariables: -&gt; <div class="content"><div class='highlight'><pre>
declaredVariables: -&gt;
realVars = []
tempVars = []
<span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.type <span class="keyword">is</span> <span class="string">'var'</span>
(<span class="keyword">if</span> v.name.charAt(<span class="number">0</span>) <span class="keyword">is</span> <span class="string">'_'</span> <span class="keyword">then</span> tempVars <span class="keyword">else</span> realVars).push v.name
realVars.sort().concat tempVars.sort()</pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Return the list of assignments that are supposed to be made at the top
of this scope.
</p>
</div>
<div class="content"><div class='highlight'><pre>
assignedVariables: -&gt;
<span class="string">"<span class="subst">#{v.name}</span> = <span class="subst">#{v.type.value}</span>"</span> <span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.type.assigned</pre></div></div> <span class="string">"<span class="subst">#{v.name}</span> = <span class="subst">#{v.type.value}</span>"</span> <span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.type.assigned</pre></div></div>
</li> </li>

View file

@ -112,17 +112,7 @@
the original source code that corresponds to it. This can be minified 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, we&#39;re concerned with mapping pretty-printed
JavaScript back to CoffeeScript. JavaScript back to CoffeeScript.
</p> </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
<a href="https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit">map file</a>
— which is a compact, VLQ-encoded representation of the JSON serialization
of this information — to write out alongside the generated JavaScript.
</p>
<h2>LineMap</h2>
</div> </div>
@ -135,15 +125,58 @@ of this information — to write out alongside the generated JavaScript.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a> <a class="pilcrow" href="#section-2">&#182;</a>
</div> </div>
<p>A <strong>LineMap</strong> object keeps track of information about original line and column <p>In order to produce maps, we must keep track of positions (line number, column number)
positions for a single line of output JavaScript code. that originated every node in the syntax tree, and be able to generate a
<strong>SourceMaps</strong> are implemented in terms of <strong>LineMaps</strong>. <a href="https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit">map file</a>
— which is a compact, VLQ-encoded representation of the JSON serialization
of this information — to write out alongside the generated JavaScript.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">LineMap</span></span> </li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap for-h2">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<h2>LineMap</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>A <strong>LineMap</strong> object keeps track of information about original line and column
positions for a single line of output JavaScript code.
<strong>SourceMaps</strong> are implemented in terms of <strong>LineMaps</strong>.
</p>
</div>
<div class="content"><div class='highlight'><pre>
<span class="class"><span class="keyword">class</span> <span class="title">LineMap</span></span>
constructor: (<span class="property">@line</span>) -&gt; constructor: (<span class="property">@line</span>) -&gt;
<span class="property">@columns</span> = [] <span class="property">@columns</span> = []
@ -158,11 +191,11 @@ positions for a single line of output JavaScript code.
</li> </li>
<li id="section-3"> <li id="section-6">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-3">&#182;</a> <a class="pilcrow" href="#section-6">&#182;</a>
</div> </div>
<h2>SourceMap</h2> <h2>SourceMap</h2>
@ -171,82 +204,13 @@ positions for a single line of output JavaScript code.
</li> </li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<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
through the arrays of line and column buffer to produce it.
</p>
</div>
<div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">SourceMap</span></span>
constructor: -&gt;
<span class="property">@lines</span> = []</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Adds a mapping to this SourceMap. <code>sourceLocation</code> and <code>generatedLocation</code>
are both <code>[line, column]</code> arrays. If <code>options.noReplace</code> is true, then if there
is already a mapping for the specified <code>line</code> and <code>column</code>, this will have no
effect.
</p>
</div>
<div class="content"><div class='highlight'><pre> add: (sourceLocation, generatedLocation, options = {}) -&gt;
[line, column] = generatedLocation
lineMap = (<span class="property">@lines</span>[line] <span class="keyword">or</span>= <span class="keyword">new</span> LineMap(line))
lineMap.add column, sourceLocation, options</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Look up the original position of a given <code>line</code> and <code>column</code> in the generated
code.
</p>
</div>
<div class="content"><div class='highlight'><pre> sourceLocation: ([line, column]) -&gt;
line-- <span class="keyword">until</span> (lineMap = <span class="property">@lines</span>[line]) <span class="keyword">or</span> (line &lt;= <span class="number">0</span>)
lineMap <span class="keyword">and</span> lineMap.sourceLocation column</pre></div></div>
</li>
<li id="section-7"> <li id="section-7">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a> <a class="pilcrow" href="#section-7">&#182;</a>
</div> </div>
<h2>V3 SourceMap Generation</h2>
</div> </div>
</li> </li>
@ -258,16 +222,120 @@ code.
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a> <a class="pilcrow" href="#section-8">&#182;</a>
</div> </div>
<p>Builds up a V3 source map, returning the generated JSON as a string. <p>Maps locations in a single generated JavaScript file back to locations in
<code>options.sourceRoot</code> may be used to specify the sourceRoot written to the source the original CoffeeScript source file.
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> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> generate: (options = {}, code = <span class="literal">null</span>) -&gt; </li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<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
through the arrays of line and column buffer to produce it.
</p>
</div>
<div class="content"><div class='highlight'><pre>
<span class="class"><span class="keyword">class</span> <span class="title">SourceMap</span></span>
constructor: -&gt;
<span class="property">@lines</span> = []</pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Adds a mapping to this SourceMap. <code>sourceLocation</code> and <code>generatedLocation</code>
are both <code>[line, column]</code> arrays. If <code>options.noReplace</code> is true, then if there
is already a mapping for the specified <code>line</code> and <code>column</code>, this will have no
effect.
</p>
</div>
<div class="content"><div class='highlight'><pre>
add: (sourceLocation, generatedLocation, options = {}) -&gt;
[line, column] = generatedLocation
lineMap = (<span class="property">@lines</span>[line] <span class="keyword">or</span>= <span class="keyword">new</span> LineMap(line))
lineMap.add column, sourceLocation, options</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Look up the original position of a given <code>line</code> and <code>column</code> in the generated
code.
</p>
</div>
<div class="content"><div class='highlight'><pre>
sourceLocation: ([line, column]) -&gt;
line-- <span class="keyword">until</span> (lineMap = <span class="property">@lines</span>[line]) <span class="keyword">or</span> (line &lt;= <span class="number">0</span>)
lineMap <span class="keyword">and</span> lineMap.sourceLocation column</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap for-h2">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<h2>V3 SourceMap Generation</h2>
</div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
</div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<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>
</div>
<div class="content"><div class='highlight'><pre>
generate: (options = {}, code = <span class="literal">null</span>) -&gt;
writingline = <span class="number">0</span> writingline = <span class="number">0</span>
lastColumn = <span class="number">0</span> lastColumn = <span class="number">0</span>
lastSourceLine = <span class="number">0</span> lastSourceLine = <span class="number">0</span>
@ -286,117 +354,126 @@ set &quot;sources&quot; and &quot;file&quot;, respectively.
</li> </li>
<li id="section-9"> <li id="section-15">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a> <a class="pilcrow" href="#section-15">&#182;</a>
</div> </div>
<p>Write a comma if we&#39;ve already written a segment on this line. <p>Write a comma if we&#39;ve already written a segment on this line.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> needComma <div class="content"><div class='highlight'><pre>
<span class="keyword">if</span> needComma
buffer += <span class="string">","</span> buffer += <span class="string">","</span>
needComma = <span class="literal">no</span></pre></div></div> needComma = <span class="literal">no</span></pre></div></div>
</li> </li>
<li id="section-10"> <li id="section-16">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a> <a class="pilcrow" href="#section-16">&#182;</a>
</div> </div>
<p>Write the next segment. Segments can be 1, 4, or 5 values. If just one, then it <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. is a generated column which doesn&#39;t 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> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> buffer += <span class="property">@encodeVlq</span> mapping.column - lastColumn </li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>The starting column in the generated source, relative to any previous recorded
column for the current line:
</p>
</div>
<div class="content"><div class='highlight'><pre>
buffer += <span class="property">@encodeVlq</span> mapping.column - lastColumn
lastColumn = mapping.column</pre></div></div> lastColumn = mapping.column</pre></div></div>
</li> </li>
<li id="section-11"> <li id="section-18">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a> <a class="pilcrow" href="#section-18">&#182;</a>
</div> </div>
<p>The index into the list of sources: <p>The index into the list of sources:
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> buffer += <span class="property">@encodeVlq</span> <span class="number">0</span></pre></div></div> <div class="content"><div class='highlight'><pre>
buffer += <span class="property">@encodeVlq</span> <span class="number">0</span></pre></div></div>
</li> </li>
<li id="section-12"> <li id="section-19">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a> <a class="pilcrow" href="#section-19">&#182;</a>
</div> </div>
<p>The starting line in the original source, relative to the previous source line. <p>The starting line in the original source, relative to the previous source line.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> buffer += <span class="property">@encodeVlq</span> mapping.sourceLine - lastSourceLine <div class="content"><div class='highlight'><pre>
<span class="keyword">if</span> lastSourceLine <span class="keyword">isnt</span> mapping.sourceLine buffer += <span class="property">@encodeVlq</span> mapping.sourceLine - lastSourceLine
lastSourceLine = mapping.sourceLine lastSourceLine = mapping.sourceLine</pre></div></div>
lastSourceColumn = <span class="number">0</span></pre></div></div>
</li> </li>
<li id="section-13"> <li id="section-20">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a> <a class="pilcrow" href="#section-20">&#182;</a>
</div> </div>
<p>The starting column in the original source, relative to the previous column. <p>The starting column in the original source, relative to the previous column.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> buffer += <span class="property">@encodeVlq</span> mapping.sourceColumn - lastSourceColumn <div class="content"><div class='highlight'><pre>
buffer += <span class="property">@encodeVlq</span> mapping.sourceColumn - lastSourceColumn
lastSourceColumn = mapping.sourceColumn lastSourceColumn = mapping.sourceColumn
needComma = <span class="literal">yes</span></pre></div></div> needComma = <span class="literal">yes</span></pre></div></div>
</li> </li>
<li id="section-14"> <li id="section-21">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a> <a class="pilcrow" href="#section-21">&#182;</a>
</div> </div>
<p>Produce the canonical JSON object format for a &quot;v3&quot; source map. <p>Produce the canonical JSON object format for a &quot;v3&quot; source map.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> v3 = <div class="content"><div class='highlight'><pre>
v3 =
version: <span class="number">3</span> version: <span class="number">3</span>
file: options.generatedFile <span class="keyword">or</span> <span class="string">''</span> file: options.generatedFile <span class="keyword">or</span> <span class="string">''</span>
sourceRoot: options.sourceRoot <span class="keyword">or</span> <span class="string">''</span> sourceRoot: options.sourceRoot <span class="keyword">or</span> <span class="string">''</span>
@ -411,11 +488,11 @@ column for the current line:
</li> </li>
<li id="section-15"> <li id="section-22">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-15">&#182;</a> <a class="pilcrow" href="#section-22">&#182;</a>
</div> </div>
<h2>Base64 VLQ Encoding</h2> <h2>Base64 VLQ Encoding</h2>
@ -424,23 +501,35 @@ column for the current line:
</li> </li>
<li id="section-16"> <li id="section-23">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a> <a class="pilcrow" href="#section-23">&#182;</a>
</div>
</div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div> </div>
<p>Note that SourceMap VLQ encoding is &quot;backwards&quot;. MIDI-style VLQ encoding puts <p>Note that SourceMap VLQ encoding is &quot;backwards&quot;. MIDI-style VLQ encoding puts
the most-significant-bit (MSB) from the original value into the MSB of the VLQ 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>). 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 SourceMap VLQ does things the other way around, with the least significat four
bits of the original value encoded into the first byte of the VLQ encoded value. bits of the original value encoded into the first byte of the VLQ encoded value.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre> VLQ_SHIFT = <span class="number">5</span> <div class="content"><div class='highlight'><pre>
VLQ_SHIFT = <span class="number">5</span>
VLQ_CONTINUATION_BIT = <span class="number">1</span> &lt;&lt; VLQ_SHIFT <span class="comment"># 0010 0000</span> VLQ_CONTINUATION_BIT = <span class="number">1</span> &lt;&lt; VLQ_SHIFT <span class="comment"># 0010 0000</span>
VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - <span class="number">1</span> <span class="comment"># 0001 1111</span> VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - <span class="number">1</span> <span class="comment"># 0001 1111</span>
@ -450,11 +539,11 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li> </li>
<li id="section-17"> <li id="section-25">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a> <a class="pilcrow" href="#section-25">&#182;</a>
</div> </div>
<p>Least significant bit represents the sign. <p>Least significant bit represents the sign.
</p> </p>
@ -466,11 +555,11 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li> </li>
<li id="section-18"> <li id="section-26">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a> <a class="pilcrow" href="#section-26">&#182;</a>
</div> </div>
<p>The next bits are the actual value. <p>The next bits are the actual value.
</p> </p>
@ -482,11 +571,11 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li> </li>
<li id="section-19"> <li id="section-27">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a> <a class="pilcrow" href="#section-27">&#182;</a>
</div> </div>
<p>Make sure we encode at least one character, even if valueToEncode is 0. <p>Make sure we encode at least one character, even if valueToEncode is 0.
</p> </p>
@ -504,11 +593,11 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li> </li>
<li id="section-20"> <li id="section-28">
<div class="annotation"> <div class="annotation">
<div class="pilwrap for-h2"> <div class="pilwrap for-h2">
<a class="pilcrow" href="#section-20">&#182;</a> <a class="pilcrow" href="#section-28">&#182;</a>
</div> </div>
<h2>Regular Base64 Encoding</h2> <h2>Regular Base64 Encoding</h2>
@ -517,16 +606,17 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li> </li>
<li id="section-21"> <li id="section-29">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a> <a class="pilcrow" href="#section-29">&#182;</a>
</div> </div>
</div> </div>
<div class="content"><div class='highlight'><pre> BASE64_CHARS = <span class="string">'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'</span> <div class="content"><div class='highlight'><pre>
BASE64_CHARS = <span class="string">'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'</span>
encodeBase64: (value) -&gt; encodeBase64: (value) -&gt;
BASE64_CHARS[value] <span class="keyword">or</span> <span class="keyword">throw</span> <span class="keyword">new</span> Error <span class="string">"Cannot Base64 encode value: <span class="subst">#{value}</span>"</span></pre></div></div> BASE64_CHARS[value] <span class="keyword">or</span> <span class="keyword">throw</span> <span class="keyword">new</span> Error <span class="string">"Cannot Base64 encode value: <span class="subst">#{value}</span>"</span></pre></div></div>
@ -534,19 +624,19 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li> </li>
<li id="section-22"> <li id="section-30">
<div class="annotation"> <div class="annotation">
<div class="pilwrap "> <div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a> <a class="pilcrow" href="#section-30">&#182;</a>
</div> </div>
<p>Our API for source maps is just the <code>SourceMap</code> class. <p>Our API for source maps is just the <code>SourceMap</code> class.
</p> </p>
</div> </div>
<div class="content"><div class='highlight'><pre>module.exports = SourceMap</pre></div></div> <div class="content"><div class='highlight'><pre>
module.exports = SourceMap</pre></div></div>
</li> </li>

View file

@ -137,7 +137,7 @@
<p> <p>
<b>Latest Version:</b> <b>Latest Version:</b>
<a href="http://github.com/jashkenas/coffee-script/tarball/1.6.2">1.6.2</a> <a href="http://github.com/jashkenas/coffee-script/tarball/1.6.3">1.6.3</a>
</p> </p>
<pre> <pre>
@ -264,12 +264,6 @@ sudo bin/cake install</pre>
directly to <b>stdout</b>. directly to <b>stdout</b>.
</td> </td>
</tr> </tr>
<tr>
<td><code>-l, --literate</code></td>
<td>
Parses the code as Literate CoffeeScript.
</td>
</tr>
<tr> <tr>
<td><code>-s, --stdio</code></td> <td><code>-s, --stdio</code></td>
<td> <td>
@ -278,6 +272,14 @@ sudo bin/cake install</pre>
<tt>cat src/cake.coffee | coffee -sc</tt> <tt>cat src/cake.coffee | coffee -sc</tt>
</td> </td>
</tr> </tr>
<tr>
<td><code>-l, --literate</code></td>
<td>
Parses the code as Literate CoffeeScript. You only need to specify
this when passing in code directly over <b>stdio</b>, or using some sort
of extension-less file name.
</td>
</tr>
<tr> <tr>
<td><code>-e, --eval</code></td> <td><code>-e, --eval</code></td>
<td> <td>
@ -1196,6 +1198,35 @@ Expressions
Change Log Change Log
</h2> </h2>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffee-script/compare/1.6.2...1.6.3">1.6.3</a>
<span class="timestamp"> &ndash; <small>June 2, 2013</small></span>
</b>
<ul>
<li>
The CoffeeScript REPL now remembers your history between sessions.
Just like a proper REPL should.
</li>
<li>
You can now use <tt>require</tt> in Node to load <tt>.coffee.md</tt>
Literate CoffeeScript files. In the browser,
<tt>text/literate-coffeescript</tt> script tags.
</li>
<li>
The old <tt>coffee --lint</tt> command has been removed. It was useful
while originally working on the compiler, but has been surpassed by
JSHint. You may now use <tt>-l</tt> to pass literate files in over
<b>stdio</b>.
</li>
<li>
Bugfixes for Windows path separators, <tt>catch</tt> without naming
the error, and executable-class-bodies-with-
prototypal-property-attachment.
</li>
</ul>
</p>
<p> <p>
<b class="header" style="margin-top: 20px;"> <b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffee-script/compare/1.6.1...1.6.2">1.6.2</a> <a href="https://github.com/jashkenas/coffee-script/compare/1.6.1...1.6.2">1.6.2</a>

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var volume, winner; var volume, winner;
if (ignition === true) { if (ignition === true) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var courses, dish, food, foods, i, _i, _j, _k, _len, _len1, _len2, _ref; var courses, dish, food, foods, i, _i, _j, _k, _len, _len1, _len2, _ref;
_ref = ['toast', 'cheese', 'wine']; _ref = ['toast', 'cheese', 'wine'];

View file

@ -1,6 +1,7 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
/* /*
SkinnyMochaHalfCaffScript Compiler v1.0 SkinnyMochaHalfCaffScript Compiler v1.0
Released under the MIT License Released under the MIT License
*/ */

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var fs; var fs;
fs = require('fs'); fs = require('fs');
@ -7,7 +7,6 @@ option('-o', '--output [DIR]', 'directory for compiled code');
task('build:parser', 'rebuild the Jison parser', function(options) { task('build:parser', 'rebuild the Jison parser', function(options) {
var code, dir; var code, dir;
require('jison'); require('jison');
code = require('./lib/grammar').parser.generate(); code = require('./lib/grammar').parser.generate();
dir = options.output || 'lib'; dir = options.output || 'lib';

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var Animal, Horse, Snake, sam, tom, _ref, _ref1, var Animal, Horse, Snake, sam, tom, _ref, _ref1,
__hasProp = {}.hasOwnProperty, __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var cholesterol, healthy; var cholesterol, healthy;
cholesterol = 127; cholesterol = 127;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var date, mood; var date, mood;
if (singing) { if (singing) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var Person; var Person;
Person = (function() { Person = (function() {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var fill; var fill;
fill = function(container, liquid) { fill = function(container, liquid) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var filename, _fn, _i, _len; var filename, _fn, _i, _len;
_fn = function(filename) { _fn = function(filename) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var hi; var hi;
hi = function() { hi = function() {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var footprints, solipsism, speed; var footprints, solipsism, speed;
if ((typeof mind !== "undefined" && mind !== null) && (typeof world === "undefined" || world === null)) { if ((typeof mind !== "undefined" && mind !== null) && (typeof world === "undefined" || world === null)) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var eldest, grade; var eldest, grade;
grade = function(student) { grade = function(student) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var one, six, three, two; var one, six, three, two;
six = (one = 1) + (two = 2) + (three = 3); six = (one = 1) + (two = 2) + (three = 3);

View file

@ -1,9 +1,8 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var globals, name; var globals, name;
globals = ((function() { globals = ((function() {
var _results; var _results;
_results = []; _results = [];
for (name in window) { for (name in window) {
_results.push(name); _results.push(name);

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var error; var error;
alert((function() { alert((function() {

View file

@ -1,9 +1,8 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var Account; var Account;
Account = function(customer, cart) { Account = function(customer, cart) {
var _this = this; var _this = this;
this.customer = customer; this.customer = customer;
this.cart = cart; this.cart = cart;
return $('.shopping_cart').bind('click', function(event) { return $('.shopping_cart').bind('click', function(event) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var cube, square; var cube, square;
square = function(x) { square = function(x) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var html; var html;
html = "<strong>\n cup of coffeescript\n</strong>"; html = "<strong>\n cup of coffeescript\n</strong>";

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var OPERATOR; var OPERATOR;
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/; OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var author, quote, sentence; var author, quote, sentence;
author = "Wittgenstein"; author = "Wittgenstein";

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var city, forecast, temp, weatherReport, _ref; var city, forecast, temp, weatherReport, _ref;
weatherReport = function(location) { weatherReport = function(location) {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var age, ages, child, yearsOld; var age, ages, child, yearsOld;
yearsOld = { yearsOld = {
@ -9,7 +9,6 @@ yearsOld = {
ages = (function() { ages = (function() {
var _results; var _results;
_results = []; _results = [];
for (child in yearsOld) { for (child in yearsOld) {
age = yearsOld[child]; age = yearsOld[child];

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var city, futurists, name, street, _ref, _ref1; var city, futurists, name, street, _ref, _ref1;
futurists = { futurists = {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var bitlist, kids, singers, song; var bitlist, kids, singers, song;
song = ["do", "re", "mi", "fa", "so"]; song = ["do", "re", "mi", "fa", "so"];

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
$('.account').attr({ $('.account').attr({
"class": 'active' "class": 'active'
}); });

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var cubes, list, math, num, number, opposite, race, square, var cubes, list, math, num, number, opposite, race, square,
__slice = [].slice; __slice = [].slice;
@ -26,7 +26,6 @@ math = {
race = function() { race = function() {
var runners, winner; var runners, winner;
winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : []; winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return print(winner, runners); return print(winner, runners);
}; };
@ -37,7 +36,6 @@ if (typeof elvis !== "undefined" && elvis !== null) {
cubes = (function() { cubes = (function() {
var _i, _len, _results; var _i, _len, _results;
_results = []; _results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) { for (_i = 0, _len = list.length; _i < _len; _i++) {
num = list[_i]; num = list[_i];

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var theBait, theSwitch, _ref; var theBait, theSwitch, _ref;
theBait = 1000; theBait = 1000;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var close, contents, open, tag, _i, _ref, var close, contents, open, tag, _i, _ref,
__slice = [].slice; __slice = [].slice;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
String.prototype.dasherize = function() { String.prototype.dasherize = function() {
return this.replace(/_/g, "-"); return this.replace(/_/g, "-");
}; };

View file

@ -1,9 +1,8 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var countdown, num; var countdown, num;
countdown = (function() { countdown = (function() {
var _i, _results; var _i, _results;
_results = []; _results = [];
for (num = _i = 10; _i >= 1; num = --_i) { for (num = _i = 10; _i >= 1; num = --_i) {
_results.push(num); _results.push(num);

View file

@ -1,11 +1,10 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var changeNumbers, inner, outer; var changeNumbers, inner, outer;
outer = 1; outer = 1;
changeNumbers = function() { changeNumbers = function() {
var inner; var inner;
inner = -1; inner = -1;
return outer = 10; return outer = 10;
}; };

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var copy, end, middle, numbers, start; var copy, end, middle, numbers, start;
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]; numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var zip, _ref; var zip, _ref;
zip = typeof lottery.drawWinner === "function" ? (_ref = lottery.drawWinner().address) != null ? _ref.zipcode : void 0 : void 0; zip = typeof lottery.drawWinner === "function" ? (_ref = lottery.drawWinner().address) != null ? _ref.zipcode : void 0 : void 0;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var awardMedals, contenders, gold, rest, silver, var awardMedals, contenders, gold, rest, silver,
__slice = [].slice; __slice = [].slice;
@ -6,7 +6,6 @@ gold = silver = rest = "unknown";
awardMedals = function() { awardMedals = function() {
var first, others, second; var first, others, second;
first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? __slice.call(arguments, 2) : []; first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
gold = first; gold = first;
silver = second; silver = second;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var numbers, _ref; var numbers, _ref;
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var mobyDick; var mobyDick;
mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world..."; mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world...";

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
switch (day) { switch (day) {
case "Mon": case "Mon":
go(work); go(work);

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var grade, score; var grade, score;
score = 76; score = 76;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var error; var error;
try { try {

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
var lyrics, num; var lyrics, num;
if (this.studyingEconomics) { if (this.studyingEconomics) {
@ -14,7 +14,6 @@ num = 6;
lyrics = (function() { lyrics = (function() {
var _results; var _results;
_results = []; _results = [];
while (num -= 1) { while (num -= 1) {
_results.push("" + num + " little monkeys, jumping on the bed. One fell out and bumped his head."); _results.push("" + num + " little monkeys, jumping on the bed. One fell out and bumped his head.");

File diff suppressed because one or more lines are too long

View file

@ -108,15 +108,13 @@
compiles one-to-one into the equivalent JS, and there is compiles one-to-one into the equivalent JS, and there is
no interpretation at runtime. You can use any existing JavaScript library no interpretation at runtime. You can use any existing JavaScript library
seamlessly from CoffeeScript (and vice-versa). The compiled output is seamlessly from CoffeeScript (and vice-versa). The compiled output is
readable and pretty-printed, passes through readable and pretty-printed, will work in every JavaScript runtime, and tends
<a href="http://www.javascriptlint.com/">JavaScript Lint</a>
without warnings, will work in every JavaScript runtime, and tends
to run as fast or faster than the equivalent handwritten JavaScript. to run as fast or faster than the equivalent handwritten JavaScript.
</p> </p>
<p> <p>
<b>Latest Version:</b> <b>Latest Version:</b>
<a href="http://github.com/jashkenas/coffee-script/tarball/1.6.2">1.6.2</a> <a href="http://github.com/jashkenas/coffee-script/tarball/1.6.3">1.6.3</a>
</p> </p>
<pre> <pre>
@ -184,7 +182,6 @@ math <span class="Keyword">=</span> {
<span class="FunctionName">race</span> = <span class="Storage">function</span>() { <span class="FunctionName">race</span> = <span class="Storage">function</span>() {
<span class="Storage">var</span> runners, winner; <span class="Storage">var</span> runners, winner;
winner <span class="Keyword">=</span> arguments[<span class="Number">0</span>], runners <span class="Keyword">=</span> <span class="Number">2</span> <span class="Keyword">&lt;=</span> arguments.<span class="LibraryConstant">length</span> ? __slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">1</span>) : []; winner <span class="Keyword">=</span> arguments[<span class="Number">0</span>], runners <span class="Keyword">=</span> <span class="Number">2</span> <span class="Keyword">&lt;=</span> arguments.<span class="LibraryConstant">length</span> ? __slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">1</span>) : [];
<span class="Keyword">return</span> <span class="LibraryFunction">print</span>(winner, runners); <span class="Keyword">return</span> <span class="LibraryFunction">print</span>(winner, runners);
}; };
@ -195,7 +192,6 @@ math <span class="Keyword">=</span> {
cubes <span class="Keyword">=</span> (<span class="Storage">function</span>() { cubes <span class="Keyword">=</span> (<span class="Storage">function</span>() {
<span class="Storage">var</span> _i, _len, _results; <span class="Storage">var</span> _i, _len, _results;
_results <span class="Keyword">=</span> []; _results <span class="Keyword">=</span> [];
<span class="Keyword">for</span> (_i <span class="Keyword">=</span> <span class="Number">0</span>, _len <span class="Keyword">=</span> list.<span class="LibraryConstant">length</span>; _i <span class="Keyword">&lt;</span> _len; _i<span class="Keyword">++</span>) { <span class="Keyword">for</span> (_i <span class="Keyword">=</span> <span class="Number">0</span>, _len <span class="Keyword">=</span> list.<span class="LibraryConstant">length</span>; _i <span class="Keyword">&lt;</span> _len; _i<span class="Keyword">++</span>) {
num <span class="Keyword">=</span> list[_i]; num <span class="Keyword">=</span> list[_i];
@ -230,7 +226,6 @@ math = {
race = function() { race = function() {
var runners, winner; var runners, winner;
winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : []; winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return print(winner, runners); return print(winner, runners);
}; };
@ -241,7 +236,6 @@ if (typeof elvis !== "undefined" && elvis !== null) {
cubes = (function() { cubes = (function() {
var _i, _len, _results; var _i, _len, _results;
_results = []; _results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) { for (_i = 0, _len = list.length; _i < _len; _i++) {
num = list[_i]; num = list[_i];
@ -363,12 +357,6 @@ sudo bin/cake install</pre>
directly to <b>stdout</b>. directly to <b>stdout</b>.
</td> </td>
</tr> </tr>
<tr>
<td><code>-l, --literate</code></td>
<td>
Parses the code as Literate CoffeeScript.
</td>
</tr>
<tr> <tr>
<td><code>-s, --stdio</code></td> <td><code>-s, --stdio</code></td>
<td> <td>
@ -377,6 +365,14 @@ sudo bin/cake install</pre>
<tt>cat src/cake.coffee | coffee -sc</tt> <tt>cat src/cake.coffee | coffee -sc</tt>
</td> </td>
</tr> </tr>
<tr>
<td><code>-l, --literate</code></td>
<td>
Parses the code as Literate CoffeeScript. You only need to specify
this when passing in code directly over <b>stdio</b>, or using some sort
of extension-less file name.
</td>
</tr>
<tr> <tr>
<td><code>-e, --eval</code></td> <td><code>-e, --eval</code></td>
<td> <td>
@ -689,7 +685,6 @@ outer <span class="Keyword">=</span> <span class="Number">1</span>;
<span class="FunctionName">changeNumbers</span> = <span class="Storage">function</span>() { <span class="FunctionName">changeNumbers</span> = <span class="Storage">function</span>() {
<span class="Storage">var</span> inner; <span class="Storage">var</span> inner;
inner <span class="Keyword">=</span> <span class="Keyword">-</span><span class="Number">1</span>; inner <span class="Keyword">=</span> <span class="Keyword">-</span><span class="Number">1</span>;
<span class="Keyword">return</span> outer <span class="Keyword">=</span> <span class="Number">10</span>; <span class="Keyword">return</span> outer <span class="Keyword">=</span> <span class="Number">10</span>;
}; };
@ -701,7 +696,6 @@ outer = 1;
changeNumbers = function() { changeNumbers = function() {
var inner; var inner;
inner = -1; inner = -1;
return outer = 10; return outer = 10;
}; };
@ -822,7 +816,6 @@ gold <span class="Keyword">=</span> silver <span class="Keyword">=</span> rest <
<span class="FunctionName">awardMedals</span> = <span class="Storage">function</span>() { <span class="FunctionName">awardMedals</span> = <span class="Storage">function</span>() {
<span class="Storage">var</span> first, others, second; <span class="Storage">var</span> first, others, second;
first <span class="Keyword">=</span> arguments[<span class="Number">0</span>], second <span class="Keyword">=</span> arguments[<span class="Number">1</span>], others <span class="Keyword">=</span> <span class="Number">3</span> <span class="Keyword">&lt;=</span> arguments.<span class="LibraryConstant">length</span> ? __slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">2</span>) : []; first <span class="Keyword">=</span> arguments[<span class="Number">0</span>], second <span class="Keyword">=</span> arguments[<span class="Number">1</span>], others <span class="Keyword">=</span> <span class="Number">3</span> <span class="Keyword">&lt;=</span> arguments.<span class="LibraryConstant">length</span> ? __slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">2</span>) : [];
gold <span class="Keyword">=</span> first; gold <span class="Keyword">=</span> first;
silver <span class="Keyword">=</span> second; silver <span class="Keyword">=</span> second;
@ -845,7 +838,6 @@ gold = silver = rest = "unknown";
awardMedals = function() { awardMedals = function() {
var first, others, second; var first, others, second;
first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? __slice.call(arguments, 2) : []; first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
gold = first; gold = first;
silver = second; silver = second;
@ -920,7 +912,6 @@ foods <span class="Keyword">=</span> [<span class="String"><span class="String">
countdown <span class="Keyword">=</span> (<span class="Storage">function</span>() { countdown <span class="Keyword">=</span> (<span class="Storage">function</span>() {
<span class="Storage">var</span> _i, _results; <span class="Storage">var</span> _i, _results;
_results <span class="Keyword">=</span> []; _results <span class="Keyword">=</span> [];
<span class="Keyword">for</span> (num <span class="Keyword">=</span> _i <span class="Keyword">=</span> <span class="Number">10</span>; _i <span class="Keyword">&gt;=</span> <span class="Number">1</span>; num <span class="Keyword">=</span> <span class="Keyword">--</span>_i) { <span class="Keyword">for</span> (num <span class="Keyword">=</span> _i <span class="Keyword">=</span> <span class="Number">10</span>; _i <span class="Keyword">&gt;=</span> <span class="Number">1</span>; num <span class="Keyword">=</span> <span class="Keyword">--</span>_i) {
_results.<span class="LibraryFunction">push</span>(num); _results.<span class="LibraryFunction">push</span>(num);
@ -931,7 +922,6 @@ countdown <span class="Keyword">=</span> (<span class="Storage">function</span>(
countdown = (function() { countdown = (function() {
var _i, _results; var _i, _results;
_results = []; _results = [];
for (num = _i = 10; _i >= 1; num = --_i) { for (num = _i = 10; _i >= 1; num = --_i) {
_results.push(num); _results.push(num);
@ -972,7 +962,6 @@ yearsOld <span class="Keyword">=</span> {
ages <span class="Keyword">=</span> (<span class="Storage">function</span>() { ages <span class="Keyword">=</span> (<span class="Storage">function</span>() {
<span class="Storage">var</span> _results; <span class="Storage">var</span> _results;
_results <span class="Keyword">=</span> []; _results <span class="Keyword">=</span> [];
<span class="Keyword">for</span> (child <span class="Keyword">in</span> yearsOld) { <span class="Keyword">for</span> (child <span class="Keyword">in</span> yearsOld) {
age <span class="Keyword">=</span> yearsOld[child]; age <span class="Keyword">=</span> yearsOld[child];
@ -990,7 +979,6 @@ yearsOld = {
ages = (function() { ages = (function() {
var _results; var _results;
_results = []; _results = [];
for (child in yearsOld) { for (child in yearsOld) {
age = yearsOld[child]; age = yearsOld[child];
@ -1036,7 +1024,6 @@ num <span class="Keyword">=</span> <span class="Number">6</span>;
lyrics <span class="Keyword">=</span> (<span class="Storage">function</span>() { lyrics <span class="Keyword">=</span> (<span class="Storage">function</span>() {
<span class="Storage">var</span> _results; <span class="Storage">var</span> _results;
_results <span class="Keyword">=</span> []; _results <span class="Keyword">=</span> [];
<span class="Keyword">while</span> (num <span class="Keyword">-</span><span class="Keyword">=</span> <span class="Number">1</span>) { <span class="Keyword">while</span> (num <span class="Keyword">-</span><span class="Keyword">=</span> <span class="Number">1</span>) {
_results.<span class="LibraryFunction">push</span>(<span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span> <span class="Keyword">+</span> num <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span> little monkeys, jumping on the bed. One fell out and bumped his head.<span class="String">&quot;</span></span>); _results.<span class="LibraryFunction">push</span>(<span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span> <span class="Keyword">+</span> num <span class="Keyword">+</span> <span class="String"><span class="String">&quot;</span> little monkeys, jumping on the bed. One fell out and bumped his head.<span class="String">&quot;</span></span>);
@ -1058,7 +1045,6 @@ num = 6;
lyrics = (function() { lyrics = (function() {
var _results; var _results;
_results = []; _results = [];
while (num -= 1) { while (num -= 1) {
_results.push("" + num + " little monkeys, jumping on the bed. One fell out and bumped his head."); _results.push("" + num + " little monkeys, jumping on the bed. One fell out and bumped his head.");
@ -1246,7 +1232,6 @@ globals <span class="Keyword">=</span> (name <span class="Keyword">for</span> na
globals <span class="Keyword">=</span> ((<span class="Storage">function</span>() { globals <span class="Keyword">=</span> ((<span class="Storage">function</span>() {
<span class="Storage">var</span> _results; <span class="Storage">var</span> _results;
_results <span class="Keyword">=</span> []; _results <span class="Keyword">=</span> [];
<span class="Keyword">for</span> (name <span class="Keyword">in</span> <span class="LibraryClassType">window</span>) { <span class="Keyword">for</span> (name <span class="Keyword">in</span> <span class="LibraryClassType">window</span>) {
_results.<span class="LibraryFunction">push</span>(name); _results.<span class="LibraryFunction">push</span>(name);
@ -1257,7 +1242,6 @@ globals <span class="Keyword">=</span> ((<span class="Storage">function</span>()
globals = ((function() { globals = ((function() {
var _results; var _results;
_results = []; _results = [];
for (name in window) { for (name in window) {
_results.push(name); _results.push(name);
@ -1793,7 +1777,7 @@ _ref = tag.split(""), open = _ref[0], contents = 3 <= _ref.length ? __slice.call
;alert(contents.join(""));'>run: contents.join("")</div><br class='clear' /></div> ;alert(contents.join(""));'>run: contents.join("")</div><br class='clear' /></div>
<p> <p>
Destructuring assignment is also useful when combined with class constructors Destructuring assignment is also useful when combined with class constructors
to assign propeties to your instance from an options object passed to the constructor. to assign properties to your instance from an options object passed to the constructor.
</p> </p>
<div class='code'><pre class="idle"><span class="Storage">class</span> <span class="TypeName">Person</span> <div class='code'><pre class="idle"><span class="Storage">class</span> <span class="TypeName">Person</span>
<span class="FunctionName">constructor</span><span class="Keyword">:</span> <span class="FunctionArgument">(options)</span> <span class="Storage">-&gt;</span> <span class="FunctionName">constructor</span><span class="Keyword">:</span> <span class="FunctionArgument">(options)</span> <span class="Storage">-&gt;</span>
@ -1849,7 +1833,6 @@ Person = (function() {
<span class="FunctionName">Account</span> = <span class="Storage">function</span>(<span class="FunctionArgument">customer, cart</span>) { <span class="FunctionName">Account</span> = <span class="Storage">function</span>(<span class="FunctionArgument">customer, cart</span>) {
<span class="Storage">var</span> _this <span class="Keyword">=</span> <span class="Variable">this</span>; <span class="Storage">var</span> _this <span class="Keyword">=</span> <span class="Variable">this</span>;
<span class="Variable">this</span>.customer <span class="Keyword">=</span> customer; <span class="Variable">this</span>.customer <span class="Keyword">=</span> customer;
<span class="Variable">this</span>.cart <span class="Keyword">=</span> cart; <span class="Variable">this</span>.cart <span class="Keyword">=</span> cart;
<span class="Keyword">return</span> <span class="Keyword">$</span>(<span class="String"><span class="String">'</span>.shopping_cart<span class="String">'</span></span>).bind(<span class="String"><span class="String">'</span>click<span class="String">'</span></span>, <span class="Storage">function</span>(<span class="LibraryClassType">event</span>) { <span class="Keyword">return</span> <span class="Keyword">$</span>(<span class="String"><span class="String">'</span>.shopping_cart<span class="String">'</span></span>).bind(<span class="String"><span class="String">'</span>click<span class="String">'</span></span>, <span class="Storage">function</span>(<span class="LibraryClassType">event</span>) {
@ -2114,6 +2097,7 @@ html = "<strong>\n cup of coffeescript\n</strong>";
<span class="Comment">Released under the MIT License</span> <span class="Comment">Released under the MIT License</span>
<span class="Comment"><span class="Comment">*/</span></span> <span class="Comment"><span class="Comment">*/</span></span>
</pre><script>window.example39 = "###\nSkinnyMochaHalfCaffScript Compiler v1.0\nReleased under the MIT License\n###\n\n\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example39);'>load</div><br class='clear' /></div> </pre><script>window.example39 = "###\nSkinnyMochaHalfCaffScript Compiler v1.0\nReleased under the MIT License\n###\n\n\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example39);'>load</div><br class='clear' /></div>
<p> <p>
@ -2182,7 +2166,6 @@ option(<span class="String"><span class="String">'</span>-o<span class="String">
task(<span class="String"><span class="String">'</span>build:parser<span class="String">'</span></span>, <span class="String"><span class="String">'</span>rebuild the Jison parser<span class="String">'</span></span>, <span class="Storage">function</span>(options) { task(<span class="String"><span class="String">'</span>build:parser<span class="String">'</span></span>, <span class="String"><span class="String">'</span>rebuild the Jison parser<span class="String">'</span></span>, <span class="Storage">function</span>(options) {
<span class="Storage">var</span> code, dir; <span class="Storage">var</span> code, dir;
require(<span class="String"><span class="String">'</span>jison<span class="String">'</span></span>); require(<span class="String"><span class="String">'</span>jison<span class="String">'</span></span>);
code <span class="Keyword">=</span> require(<span class="String"><span class="String">'</span>./lib/grammar<span class="String">'</span></span>).parser.generate(); code <span class="Keyword">=</span> require(<span class="String"><span class="String">'</span>./lib/grammar<span class="String">'</span></span>).parser.generate();
dir <span class="Keyword">=</span> options.output <span class="Keyword">||</span> <span class="String"><span class="String">'</span>lib<span class="String">'</span></span>; dir <span class="Keyword">=</span> options.output <span class="Keyword">||</span> <span class="String"><span class="String">'</span>lib<span class="String">'</span></span>;
@ -2435,6 +2418,35 @@ task(<span class="String"><span class="String">'</span>build:parser<span class="
Change Log Change Log
</h2> </h2>
<p>
<b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffee-script/compare/1.6.2...1.6.3">1.6.3</a>
<span class="timestamp"> &ndash; <small>June 2, 2013</small></span>
</b>
<ul>
<li>
The CoffeeScript REPL now remembers your history between sessions.
Just like a proper REPL should.
</li>
<li>
You can now use <tt>require</tt> in Node to load <tt>.coffee.md</tt>
Literate CoffeeScript files. In the browser,
<tt>text/literate-coffeescript</tt> script tags.
</li>
<li>
The old <tt>coffee --lint</tt> command has been removed. It was useful
while originally working on the compiler, but has been surpassed by
JSHint. You may now use <tt>-l</tt> to pass literate files in over
<b>stdio</b>.
</li>
<li>
Bugfixes for Windows path separators, <tt>catch</tt> without naming
the error, and executable-class-bodies-with-
prototypal-property-attachment.
</li>
</ul>
</p>
<p> <p>
<b class="header" style="margin-top: 20px;"> <b class="header" style="margin-top: 20px;">
<a href="https://github.com/jashkenas/coffee-script/compare/1.6.1...1.6.2">1.6.2</a> <a href="https://github.com/jashkenas/coffee-script/compare/1.6.1...1.6.2">1.6.2</a>

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var CoffeeScript, compile, runScripts, var CoffeeScript, compile, runScripts,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var CoffeeScript, cakefileDirectory, existsSync, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks; var CoffeeScript, cakefileDirectory, existsSync, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var Lexer, Module, SourceMap, child_process, compile, ext, findExtension, fork, formatSourcePosition, fs, helpers, lexer, loadFile, parser, patchStackTrace, patched, path, sourceMaps, vm, _i, _len, _ref, var Lexer, Module, SourceMap, child_process, compile, ext, findExtension, fork, formatSourcePosition, fs, helpers, lexer, loadFile, parser, patchStackTrace, patched, path, sourceMaps, vm, _i, _len, _ref,
__hasProp = {}.hasOwnProperty; __hasProp = {}.hasOwnProperty;
@ -19,7 +19,7 @@
SourceMap = require('./sourcemap'); SourceMap = require('./sourcemap');
exports.VERSION = '1.6.2'; exports.VERSION = '1.6.3';
exports.helpers = helpers; exports.helpers = helpers;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, useWinPathSep, version, wait, watch, watchDir, watchers, writeJs, _ref; var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, useWinPathSep, version, wait, watch, watchDir, watchers, writeJs, _ref;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var buildLocationData, extend, flatten, last, repeat, _ref; var buildLocationData, extend, flatten, last, repeat, _ref;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var key, val, _ref; var key, val, _ref;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1, var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, CodeFragment, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, last, locationDataToString, merge, multident, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, _ref2, _ref3, var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, CodeFragment, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, last, locationDataToString, merge, multident, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, _ref2, _ref3,
__hasProp = {}.hasOwnProperty, __hasProp = {}.hasOwnProperty,

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat; var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var CoffeeScript, addHistory, addMultilineHandler, fs, merge, nodeREPL, path, prettyErrorMessage, replDefaults, vm, _ref; var CoffeeScript, addHistory, addMultilineHandler, fs, merge, nodeREPL, path, prettyErrorMessage, replDefaults, vm, _ref;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref, var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var Scope, extend, last, _ref; var Scope, extend, last, _ref;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var LineMap, SourceMap; var LineMap, SourceMap;

View file

@ -3,7 +3,7 @@
"description": "Unfancy JavaScript", "description": "Unfancy JavaScript",
"keywords": ["javascript", "language", "coffeescript", "compiler"], "keywords": ["javascript", "language", "coffeescript", "compiler"],
"author": "Jeremy Ashkenas", "author": "Jeremy Ashkenas",
"version": "1.6.2", "version": "1.6.3",
"licenses": [{ "licenses": [{
"type": "MIT", "type": "MIT",
"url": "https://raw.github.com/jashkenas/coffee-script/master/LICENSE" "url": "https://raw.github.com/jashkenas/coffee-script/master/LICENSE"

View file

@ -13,7 +13,7 @@ helpers = require './helpers'
SourceMap = require './sourcemap' SourceMap = require './sourcemap'
# The current CoffeeScript version number. # The current CoffeeScript version number.
exports.VERSION = '1.6.2' exports.VERSION = '1.6.3'
# Expose helpers for testing. # Expose helpers for testing.
exports.helpers = helpers exports.helpers = helpers