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.
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.
</p>
</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
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;
options.bare = <span class="literal">on</span>
options.shiftLine = <span class="literal">on</span>
Function(compile code, options)()</pre></div></div>
</li>
@ -182,18 +183,19 @@ compile = CoffeeScript.compile</pre></div></div>
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Include source maps where possible. If we&#39;ve got a base64 encoder, and a
JSON serializer, we&#39;re good to go.
<p>Include source maps where possible. If we&#39;ve got a base64 encoder, a
JSON serializer, and tools for escaping unicode characters, we&#39;re good to go.
Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">https://developer.mozilla.org/en-US/docs/DOM/window.btoa</a>
</p>
</div>
<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;
options.sourceMap = <span class="literal">true</span>
options.inline = <span class="literal">true</span>
{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>
@ -214,7 +216,7 @@ JSON serializer, we&#39;re good to go.
xhr = <span class="keyword">if</span> window.ActiveXObject
<span class="keyword">new</span> window.ActiveXObject(<span class="string">'Microsoft.XMLHTTP'</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.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;
@ -243,7 +245,7 @@ This happens on page load.
</div>
<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>]
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>
@ -276,9 +278,9 @@ This happens on page load.
</div>
<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>
attachEvent <span class="string">'onload'</span>, runScripts</pre></div></div>
window.attachEvent <span class="string">'onload'</span>, runScripts</pre></div></div>
</li>

View File

@ -116,9 +116,20 @@ and can call them from the command line, or invoke them from other tasks.
</p>
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the
current directory&#39;s Cakefile.
</p>
<p>External dependencies.
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>External dependencies.
</p>
</div>
@ -134,11 +145,11 @@ existsSync = fs.existsSync <span class="keyword">or</span> path.existsSync</pr
</li>
<li id="section-2">
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Keep track of the list of defined tasks, the accepted options, and so on.
</p>
@ -153,11 +164,11 @@ oparse = <span class="literal">null</span></pre></div></div>
</li>
<li id="section-3">
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Mixin the top-level Cake functions for Cakefiles to use directly.
</p>
@ -169,11 +180,11 @@ oparse = <span class="literal">null</span></pre></div></div>
</li>
<li id="section-4">
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Define a Cake task with a short name, an optional sentence description,
and the function to run as the action itself.
@ -188,11 +199,11 @@ and the function to run as the action itself.
</li>
<li id="section-5">
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Define an option that the Cakefile accepts. The parsed options hash,
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 id="section-6">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Invoke another task in the current Cakefile.
</p>
@ -225,11 +236,11 @@ as the first argument to the action.
</li>
<li id="section-7">
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>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.
@ -255,11 +266,11 @@ original directory name, when running Cake tasks from subdirectories.
</li>
<li id="section-8">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Display the list of Cake tasks in a format similar to <code>rake -T</code>
</p>
@ -280,11 +291,11 @@ original directory name, when running Cake tasks from subdirectories.
</li>
<li id="section-9">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Print an error and exit when attempting to use an invalid task/option.
</p>
@ -301,11 +312,11 @@ original directory name, when running Cake tasks from subdirectories.
</li>
<li id="section-10">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>When <code>cake</code> is invoked, search in the current and all parent directories
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
contains the main entry functions for tokenizing, parsing, and compiling
source CoffeeScript into JavaScript.
</p>
</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>
path = require <span class="string">'path'</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 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>
@ -175,7 +175,7 @@ options that can be passed to <code>SourceMap#generate</code> may also be passed
</p>
<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
lookups.
</p>
@ -183,15 +183,16 @@ lookups.
</div>
<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
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">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>
js = <span class="string">""</span>
<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
<span class="keyword">if</span> fragment.locationData
map.add(
[fragment.locationData.first_line, fragment.locationData.first_column],
[currentLine, currentColumn],
[fragment.locationData.first_line, fragment.locationData.first_column]
[currentLine, currentColumn]
{noReplace: <span class="literal">true</span>})
newLines = helpers.count fragment.code, <span class="string">"\n"</span>
currentLine += newLines
@ -321,7 +322,7 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
</div>
<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>
@ -381,14 +382,14 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</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.
</p>
</div>
<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
<span class="keyword">else</span>
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;
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
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>
@ -517,6 +520,70 @@ CoffeeScript as an extension.
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Patch Node&#39;s module loader to be able to handle mult-dot extensions.
This is a horrible thing that should not be required. Perhaps, one day,
when a truly benevolent dictator comes to rule over the Republik of Node,
it won&#39;t be.
</p>
</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
to fork both CoffeeScript files, and JavaScript files, directly.
</p>
@ -536,11 +603,11 @@ to fork both CoffeeScript files, and JavaScript files, directly.
</li>
<li id="section-21">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Instantiate a Lexer for our use here.
</p>
@ -552,11 +619,11 @@ to fork both CoffeeScript files, and JavaScript files, directly.
</li>
<li id="section-22">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>The 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
@ -583,11 +650,11 @@ directly as a &quot;Jison lexer&quot;.
</li>
<li id="section-23">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Make all the AST nodes visible to the parser.
</p>
@ -599,11 +666,11 @@ directly as a &quot;Jison lexer&quot;.
</li>
<li id="section-24">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Override Jison&#39;s default error handling function.
</p>
@ -615,11 +682,11 @@ directly as a &quot;Jison lexer&quot;.
</li>
<li id="section-25">
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>Disregard Jison&#39;s message, it contains redundant line numer information.
</p>
@ -631,11 +698,11 @@ directly as a &quot;Jison lexer&quot;.
</li>
<li id="section-26">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>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>
@ -650,22 +717,39 @@ from the lexer.
</li>
<li id="section-27">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
NodeJS / V8 have no support for transforming positions in stack traces using
sourceMap, so we must monkey-patch Error to display CoffeeScript source
positions.
</p>
</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="keyword">return</span> <span class="keyword">if</span> patched
patched = <span class="literal">true</span>
@ -674,41 +758,25 @@ positions.
</li>
<li id="section-28">
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#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>
<a class="pilcrow" href="#section-32">&#182;</a>
</div>
<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
exception is thrown in the module body.)
</p>
</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 = {}
<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
<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 id="section-30">
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<a class="pilcrow" href="#section-33">&#182;</a>
</div>
<p>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
@ -754,11 +822,11 @@ Modified to handle sourceMap
</li>
<li id="section-31">
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<a class="pilcrow" href="#section-34">&#182;</a>
</div>
<p>Check for a sourceMap position
</p>

View File

@ -109,13 +109,24 @@
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<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
<a href="http://javascriptlint.com/">JavaScript Lint</a> or recompiled every time the source is
saved, printed as a token stream or as the syntax tree, or launch an
into various forms: saved into <code>.js</code> files or printed to stdout
or recompiled every time the source is saved,
printed as a token stream or as the syntax tree, or launch an
interactive REPL.
</p>
<p>External dependencies.
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>External dependencies.
</p>
</div>
@ -128,16 +139,17 @@ CoffeeScript = require <span class="string">'./coffee-script'</span>
{spawn, exec} = require <span class="string">'child_process'</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 id="section-2">
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Allow CoffeeScript to emit Node.js events.
</p>
@ -154,11 +166,11 @@ exists = fs.exists <span class="keyword">or</span> path.exists</pre></di
</li>
<li id="section-3">
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>The help banner that is printed when <code>coffee</code> is called without arguments.
</p>
@ -174,11 +186,11 @@ exists = fs.exists <span class="keyword">or</span> path.exists</pre></di
</li>
<li id="section-4">
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>The list of all the valid option flags that <code>coffee</code> knows how to handle.
</p>
@ -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">'-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">'-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">'-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">'-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">'-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">'-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>]
@ -207,11 +219,11 @@ exists = fs.exists <span class="keyword">or</span> path.exists</pre></di
</li>
<li id="section-5">
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Top-level objects shared by all the functions.
</p>
@ -228,11 +240,11 @@ optionParser = <span class="literal">null</span></pre></div></div>
</li>
<li id="section-6">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Run <code>coffee</code> by parsing passed options and determining what action to take.
Many flags cause us to divert before compiling anything. Flags passed after
@ -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> 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">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> 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
@ -261,11 +273,11 @@ Many flags cause us to divert before compiling anything. Flags passed after
</li>
<li id="section-7">
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>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;
@ -304,11 +316,11 @@ extension source files in it and all subdirectories.
</li>
<li id="section-8">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Compile a single source script, containing the given code, according to the
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
<span class="keyword">if</span> o.print
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
<span class="keyword">else</span> <span class="keyword">if</span> o.lint
lint t.file, t.output
<span class="keyword">catch</span> err
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
@ -358,11 +368,11 @@ requested options. If evaluating the script directly sets <code>__filename</code
</li>
<li id="section-9">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>,
and write them back to <strong>stdout</strong>.
@ -381,11 +391,11 @@ and write them back to <strong>stdout</strong>.
</li>
<li id="section-10">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>If all of the source files are done being read, concatenate and compile
them together.
@ -404,15 +414,15 @@ them together.
</li>
<li id="section-11">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>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,
such as <code>--lint</code> or <code>--print</code>.
such as <code>--print</code>.
</p>
</div>
@ -458,11 +468,11 @@ such as <code>--lint</code> or <code>--print</code>.
</li>
<li id="section-12">
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Watch a directory of files for new additions.
</p>
@ -499,11 +509,11 @@ such as <code>--lint</code> or <code>--print</code>.
</li>
<li id="section-13">
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Remove a file from our source list, and source code cache. Optionally remove
the compiled JS version as well.
@ -526,11 +536,11 @@ the compiled JS version as well.
</li>
<li id="section-14">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Get the corresponding output JavaScript path for a source file.
</p>
@ -538,7 +548,7 @@ the compiled JS version as well.
</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;
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
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
@ -547,11 +557,11 @@ the compiled JS version as well.
</li>
<li id="section-15">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>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
@ -570,7 +580,7 @@ same directory as the <code>.js</code> file.
<span class="function"><span class="title">compile</span></span> = -&gt;
<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>
<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;
<span class="keyword">if</span> err
printLine err.message
@ -586,11 +596,11 @@ same directory as the <code>.js</code> file.
</li>
<li id="section-16">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Convenience for cleaner setTimeouts.
</p>
@ -602,11 +612,11 @@ same directory as the <code>.js</code> file.
</li>
<li id="section-17">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>When watching scripts, it&#39;s useful to log changes with the timestamp.
</p>
@ -619,30 +629,6 @@ same directory as the <code>.js</code> file.
</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">
<div class="annotation">
@ -680,7 +666,7 @@ any errors or warnings that arise.
optionParser = <span class="keyword">new</span> optparse.OptionParser SWITCHES, BANNER
o = opts = optionParser.parse process.argv[<span class="number">2.</span>.]
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))
sources = o.arguments
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;
answer = {
filename
literate: helpers.isLiterate(filename)
literate: opts.literate <span class="keyword">or</span> helpers.isLiterate(filename)
bare: opts.bare
header: opts.compile
sourceMap: opts.map
@ -717,13 +703,13 @@ any errors or warnings that arise.
jsPath
sourceRoot: path.relative jsDir, cwd
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>
answer = helpers.merge answer,
sourceRoot: <span class="string">""</span>
sourceFiles: [helpers.baseFileName filename, <span class="literal">no</span>, path.sep]
generatedFile: helpers.baseFileName(filename, <span class="literal">yes</span>, path.sep) + <span class="string">".js"</span>
sourceFiles: [helpers.baseFileName filename, <span class="literal">no</span>, useWinPathSep]
generatedFile: helpers.baseFileName(filename, <span class="literal">yes</span>, useWinPathSep) + <span class="string">".js"</span>
answer</pre></div></div>
</li>

View File

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

View File

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

View File

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

View File

@ -111,13 +111,17 @@
</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>
CoffeeScript = require <span class="string">'./coffee-script'</span>
{merge, prettyErrorMessage} = require <span class="string">'./helpers'</span>
replDefaults =
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>
</li>
@ -214,8 +218,8 @@ parens. Unwrap all that.
multiline =
enabled: <span class="literal">off</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>)
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>
buffer: <span class="string">''</span></pre></div></div>
</li>
@ -338,7 +342,154 @@ parens. Unwrap all that.
multiline.enabled = <span class="keyword">not</span> multiline.enabled
rli.setPrompt multiline.initialPrompt
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 =
start: (opts = {}) -&gt;
@ -352,6 +503,7 @@ module.exports =
repl = nodeREPL.start opts
repl.<span class="literal">on</span> <span class="string">'exit'</span>, -&gt; repl.outputStream.write <span class="string">'\n'</span>
addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="keyword">if</span> opts.historyFile
repl</pre></div></div>
</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
shorthand into the unambiguous long form, add implicit indentation and
parentheses, and generally clean things up.
</p>
<p>Create a generated token: one that exists due to a use of implicit syntax.
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Create a generated token: one that exists due to a use of implicit syntax.
</p>
</div>
@ -129,11 +140,11 @@ parentheses, and generally clean things up.
</li>
<li id="section-2">
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>The <strong>Rewriter</strong> class is used by the <a href="lexer.html">Lexer</a>, directly against
its internal array of tokens.
@ -146,17 +157,29 @@ its internal array of tokens.
</li>
<li id="section-3">
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Helpful snippet for debugging:
</p>
<pre><code>console.log (t[0] + &#39;/&#39; + t[1] for t in @tokens).join &#39; &#39;</code></pre>
<p>Rewrite the token stream in multiple passes, one logical filter at
</div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Rewrite the token stream in multiple passes, one logical filter at
a time. This could certainly be changed into a single pass through the
stream, with a big ol&#39; efficient switch, but it&#39;s much nicer to work with
like this. The order of these passes matters -- indentation must be
@ -179,11 +202,11 @@ corrected before implicit parentheses can be wrapped around blocks of code.
</li>
<li id="section-4">
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Rewrite the token stream, looking one token ahead and behind.
Allow the return value of the block to tell us how many tokens to move
@ -216,11 +239,11 @@ our feet.
</li>
<li id="section-5">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Leading newlines would introduce an ambiguity in the grammar, so we
dispatch them here.
@ -235,11 +258,11 @@ dispatch them here.
</li>
<li id="section-6">
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Some blocks occur in the middle of expressions -- when we&#39;re expecting
this, remove their trailing newlines.
@ -256,11 +279,11 @@ this, remove their trailing newlines.
</li>
<li id="section-7">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>The lexer has tagged the opening parenthesis of a method call. Match it with
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 id="section-8">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>The lexer has tagged the opening parenthesis of an indexing operation call.
Match it with its paired close.
@ -310,11 +333,11 @@ Match it with its paired close.
</li>
<li id="section-9">
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Match tags in token stream starting at i with pattern, skipping HERECOMMENTs
Pattern may consist of strings (equality), an array of strings (one of)
@ -335,11 +358,11 @@ or null (wildcard)
</li>
<li id="section-10">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>yes iff standing in front of something looking like
@<x>: or <x>:, skipping over &#39;HERECOMMENT&#39;s
@ -353,11 +376,11 @@ or null (wildcard)
</li>
<li id="section-11">
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>yes iff current line of tokens contain an element of tags on same
expression level. Stop searching at LINEBREAKS or explicit start of
@ -380,11 +403,11 @@ containing balanced expression.
</li>
<li id="section-12">
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Look for signs of implicit calls and objects in the token stream and
add them.
@ -397,11 +420,11 @@ add them.
</li>
<li id="section-13">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Track current balancing depth (both implicit and explicit) on stack.
</p>
@ -420,11 +443,11 @@ add them.
</li>
<li id="section-14">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Helper function, used for keeping track of the number of tokens consumed
and spliced, when returning for getting a new token.
@ -437,11 +460,11 @@ and spliced, when returning for getting a new token.
</li>
<li id="section-15">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Helper functions
</p>
@ -455,11 +478,11 @@ and spliced, when returning for getting a new token.
</li>
<li id="section-16">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Unclosed control statement inside implicit parens (like
class declaration or if-conditionals)
@ -495,11 +518,11 @@ class declaration or if-conditionals)
</li>
<li id="section-17">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Don&#39;t end an implicit call on next indent if any of these are in an argument
</p>
@ -516,11 +539,11 @@ class declaration or if-conditionals)
</li>
<li id="section-18">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>An <code>INDENT</code> closes an implicit call unless
@ -541,11 +564,11 @@ class declaration or if-conditionals)
</li>
<li id="section-19">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Straightforward start of explicit expression
</p>
@ -559,11 +582,11 @@ class declaration or if-conditionals)
</li>
<li id="section-20">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Close all implicit expressions inside of explicitly closed expressions.
</p>
@ -583,11 +606,11 @@ class declaration or if-conditionals)
</li>
<li id="section-21">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Recognize standard implicit calls like
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 id="section-22">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Implicit call taking an implicit indented object as first argument.
@ -643,7 +666,7 @@ that creates grammatical ambiguities.
</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="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>
@ -653,11 +676,11 @@ that creates grammatical ambiguities.
</li>
<li id="section-23">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Implicit objects start here
</p>
@ -669,11 +692,11 @@ that creates grammatical ambiguities.
</li>
<li id="section-24">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Go back to the (implicit) start of the object
</p>
@ -688,11 +711,11 @@ that creates grammatical ambiguities.
</li>
<li id="section-25">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Are we just continuing an already declared object?
</p>
@ -711,11 +734,11 @@ that creates grammatical ambiguities.
</li>
<li id="section-26">
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>End implicit calls when chaining method calls
like e.g.:
@ -742,11 +765,11 @@ like e.g.:
</li>
<li id="section-27">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>Close implicit calls when reached end of argument list
</p>
@ -759,11 +782,11 @@ like e.g.:
</li>
<li id="section-28">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Close implicit objects such as:
return a: 1, b: 2 unless true
@ -777,11 +800,11 @@ return a: 1, b: 2 unless true
</li>
<li id="section-29">
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<a class="pilcrow" href="#section-31">&#182;</a>
</div>
<p>Close implicit objects when at end of line, line didn&#39;t end with a comma
and the implicit object didn&#39;t start the line or the next line doesn&#39;t look like
@ -799,11 +822,11 @@ the continuation of an object.
</li>
<li id="section-30">
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<a class="pilcrow" href="#section-32">&#182;</a>
</div>
<p>Close implicit object if comma is the last character
and what comes after doesn&#39;t look like it belongs.
@ -827,11 +850,11 @@ e = 2</code></pre>
</li>
<li id="section-31">
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<a class="pilcrow" href="#section-33">&#182;</a>
</div>
<p>When nextTag is OUTDENT the comma is insignificant and
should just be ignored so embed it in the implicit object.
@ -839,12 +862,12 @@ should just be ignored so embed it in the implicit object.
</p>
<p>When it isn&#39;t the comma go on to play a role in a call or
array further up the stack, so give it a chance.
</p>
</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()
endImplicitObject i + offset
<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 id="section-32">
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<a class="pilcrow" href="#section-34">&#182;</a>
</div>
<p>Add location data to all tokens generated by the rewriter.
</p>
@ -878,16 +901,16 @@ array further up the stack, so give it a chance.
first_column: column
last_line: line
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 id="section-33">
<li id="section-35">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<a class="pilcrow" href="#section-35">&#182;</a>
</div>
<p>Because our grammar is LALR(1), it can&#39;t handle some single-line
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;
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="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>
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">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>]
tokens.splice i + <span class="number">2</span>, <span class="number">0</span>, <span class="property">@indentation</span>()...
<span class="keyword">return</span> <span class="number">4</span>
<span class="keyword">if</span> tag <span class="keyword">is</span> <span class="string">'CATCH'</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>]
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">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
@ -932,11 +957,11 @@ but we need to make sure it&#39;s balanced.
</li>
<li id="section-34">
<li id="section-36">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<a class="pilcrow" href="#section-36">&#182;</a>
</div>
<p>Tag postfix conditionals as such, so that we can parse them with a
different precedence.
@ -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>
original = token
<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 id="section-35">
<li id="section-37">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a>
<a class="pilcrow" href="#section-37">&#182;</a>
</div>
<p>Generate the indentation tokens, based on another token on the same line.
</p>
@ -989,11 +1014,11 @@ different precedence.
</li>
<li id="section-36">
<li id="section-38">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a>
<a class="pilcrow" href="#section-38">&#182;</a>
</div>
<p>Look up a tag by token index.
</p>
@ -1005,11 +1030,11 @@ different precedence.
</li>
<li id="section-37">
<li id="section-39">
<div class="annotation">
<div class="pilwrap for-h2">
<a class="pilcrow" href="#section-37">&#182;</a>
<a class="pilcrow" href="#section-39">&#182;</a>
</div>
<h2>Constants</h2>
@ -1018,11 +1043,23 @@ different precedence.
</li>
<li id="section-38">
<li id="section-40">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-38">&#182;</a>
<a class="pilcrow" href="#section-40">&#182;</a>
</div>
</div>
</li>
<li id="section-41">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a>
</div>
<p>List of the token pairs that must be balanced.
</p>
@ -1042,11 +1079,11 @@ different precedence.
</li>
<li id="section-39">
<li id="section-42">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-39">&#182;</a>
<a class="pilcrow" href="#section-42">&#182;</a>
</div>
<p>The inverse mappings of <code>BALANCED_PAIRS</code> we&#39;re trying to fix up, so we can
look things up from either end.
@ -1059,11 +1096,11 @@ look things up from either end.
</li>
<li id="section-40">
<li id="section-43">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-40">&#182;</a>
<a class="pilcrow" href="#section-43">&#182;</a>
</div>
<p>The tokens that signal the start/end of a balanced pair.
</p>
@ -1080,11 +1117,11 @@ EXPRESSION_END = []
</li>
<li id="section-41">
<li id="section-44">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a>
<a class="pilcrow" href="#section-44">&#182;</a>
</div>
<p>Tokens that indicate the close of a clause of an expression.
</p>
@ -1096,11 +1133,11 @@ EXPRESSION_END = []
</li>
<li id="section-42">
<li id="section-45">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-42">&#182;</a>
<a class="pilcrow" href="#section-45">&#182;</a>
</div>
<p>Tokens that, if followed by an <code>IMPLICIT_CALL</code>, indicate a function invocation.
</p>
@ -1112,11 +1149,11 @@ EXPRESSION_END = []
</li>
<li id="section-43">
<li id="section-46">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-43">&#182;</a>
<a class="pilcrow" href="#section-46">&#182;</a>
</div>
<p>If preceded by an <code>IMPLICIT_FUNC</code>, indicates a function invocation.
</p>
@ -1134,27 +1171,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="string">'+'</span>, <span class="string">
</li>
<li id="section-44">
<li id="section-47">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-44">&#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>
<a class="pilcrow" href="#section-47">&#182;</a>
</div>
<p>Tokens that always mark the end of an implicit call for single-liners.
</p>
@ -1167,11 +1188,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="string">'+'</span>, <span class="string">
</li>
<li id="section-46">
<li id="section-48">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-46">&#182;</a>
<a class="pilcrow" href="#section-48">&#182;</a>
</div>
<p>Single-line flavors of block expressions that have unclosed endings.
The grammar can&#39;t disambiguate them, so we insert the implicit indentation.
@ -1185,11 +1206,11 @@ SINGLE_CLOSERS = [<span class="string">'TERMINATOR'</span>, <span class="strin
</li>
<li id="section-47">
<li id="section-49">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-47">&#182;</a>
<a class="pilcrow" href="#section-49">&#182;</a>
</div>
<p>Tokens that end a line.
</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
variables are new and need to be declared with <code>var</code>, and which are shared
with external scopes.
</p>
<p>Import the helpers we plan to use.
</p>
</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>
@ -135,13 +127,15 @@ exports.Scope = <span class="class"><span class="keyword">class</span> <span cla
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</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>
</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>
@ -152,19 +146,13 @@ exports.Scope = <span class="class"><span class="keyword">class</span> <span cla
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<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>The <code>root</code> is the top-level <strong>Scope</strong> object for a given file.
</p>
</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;
<span class="property">@variables</span> = [{name: <span class="string">'arguments'</span>, type: <span class="string">'arguments'</span>}]
<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>
<div class="content"><div class='highlight'><pre>
<span class="property">@root</span>: <span class="literal">null</span></pre></div></div>
</li>
@ -175,18 +163,19 @@ it belongs to.
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</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>
</div>
<div class="content"><div class='highlight'><pre> add: (name, type, immediate) -&gt;
<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>
<div class="content"><div class='highlight'><pre>
constructor: (<span class="property">@parent</span>, <span class="property">@expressions</span>, <span class="property">@method</span>) -&gt;
<span class="property">@variables</span> = [{name: <span class="string">'arguments'</span>, type: <span class="string">'arguments'</span>}]
<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>
@ -197,19 +186,18 @@ it belongs to.
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>When <code>super</code> is called, we need to find the name of the current method we&#39;re
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>Adds a new variable or overrides an existing one.
</p>
</div>
<div class="content"><div class='highlight'><pre> namedMethod: -&gt;
<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="property">@parent</span>.namedMethod()</pre></div></div>
<div class="content"><div class='highlight'><pre>
add: (name, type, immediate) -&gt;
<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>
@ -220,17 +208,19 @@ function object that has a name filled in, or bottoms out.
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Look up a variable name in lexical scope, and declare it if it does not
already exist.
<p>When <code>super</code> is called, we need to find the name of the current method we&#39;re
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>
</div>
<div class="content"><div class='highlight'><pre> find: (name) -&gt;
<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>
<div class="content"><div class='highlight'><pre>
namedMethod: -&gt;
<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="property">@parent</span>.namedMethod()</pre></div></div>
</li>
@ -241,16 +231,17 @@ already exist.
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Reserve a variable name as originating from a function parameter for this
scope. No <code>var</code> required for internal references.
<p>Look up a variable name in lexical scope, and declare it if it does not
already exist.
</p>
</div>
<div class="content"><div class='highlight'><pre> 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>
<div class="content"><div class='highlight'><pre>
find: (name) -&gt;
<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>
@ -261,15 +252,16 @@ scope. No <code>var</code> required for internal references.
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Just check to see if a variable has already been declared, without reserving,
walks up to the root scope.
<p>Reserve a variable name as originating from a function parameter for this
scope. No <code>var</code> required for internal references.
</p>
</div>
<div class="content"><div class='highlight'><pre> check: (name) -&gt;
!!(<span class="property">@type</span>(name) <span class="keyword">or</span> <span class="property">@parent</span>?.check(name))</pre></div></div>
<div class="content"><div class='highlight'><pre>
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>
@ -280,17 +272,15 @@ walks up to the root scope.
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</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>
</div>
<div class="content"><div class='highlight'><pre> temporary: (name, index) -&gt;
<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>
<div class="content"><div class='highlight'><pre>
check: (name) -&gt;
!!(<span class="property">@type</span>(name) <span class="keyword">or</span> <span class="property">@parent</span>?.check(name))</pre></div></div>
</li>
@ -301,15 +291,17 @@ walks up to the root scope.
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Gets the type of a variable.
<p>Generate a temporary variable name at the given index.
</p>
</div>
<div class="content"><div class='highlight'><pre> type: (name) -&gt;
<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="literal">null</span></pre></div></div>
<div class="content"><div class='highlight'><pre>
temporary: (name, index) -&gt;
<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>
@ -320,18 +312,15 @@ walks up to the root scope.
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>If we need to store an intermediate result, find an available name for a
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<p>Gets the type of a variable.
</p>
</div>
<div class="content"><div class='highlight'><pre> freeVariable: (name, reserve=<span class="literal">true</span>) -&gt;
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>
<div class="content"><div class='highlight'><pre>
type: (name) -&gt;
<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="literal">null</span></pre></div></div>
</li>
@ -342,16 +331,18 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Ensure that an assignment is made at the top of this scope
(or at the top-level scope, if requested).
<p>If we need to store an intermediate result, find an available name for a
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
</p>
</div>
<div class="content"><div class='highlight'><pre> 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>
<div class="content"><div class='highlight'><pre>
freeVariable: (name, reserve=<span class="literal">true</span>) -&gt;
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>
@ -362,14 +353,16 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</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>
</div>
<div class="content"><div class='highlight'><pre> hasDeclarations: -&gt;
!!<span class="property">@declaredVariables</span>().length</pre></div></div>
<div class="content"><div class='highlight'><pre>
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>
@ -380,18 +373,14 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Return the list of variables first declared in this scope.
<p>Does this scope have any declared variables?
</p>
</div>
<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>
<div class="content"><div class='highlight'><pre>
hasDeclarations: -&gt;
!!<span class="property">@declaredVariables</span>().length</pre></div></div>
</li>
@ -402,14 +391,36 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Return the list of assignments that are supposed to be made at the top
of this scope.
<p>Return the list of variables first declared in this scope.
</p>
</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>
</li>

View File

@ -112,17 +112,7 @@
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 back to CoffeeScript.
</p>
<p>In order to produce maps, we must keep track of positions (line number, column number)
that originated every node in the syntax tree, and be able to generate a
<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>
@ -135,15 +125,58 @@ of this information — to write out alongside the generated JavaScript.
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#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>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>
</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;
<span class="property">@columns</span> = []
@ -158,11 +191,11 @@ positions for a single line of output JavaScript code.
</li>
<li id="section-3">
<li id="section-6">
<div class="annotation">
<div class="pilwrap for-h2">
<a class="pilcrow" href="#section-3">&#182;</a>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<h2>SourceMap</h2>
@ -171,82 +204,13 @@ positions for a single line of output JavaScript code.
</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">
<div class="annotation">
<div class="pilwrap for-h2">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<h2>V3 SourceMap Generation</h2>
</div>
</li>
@ -258,16 +222,120 @@ code.
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#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>Maps locations in a single generated JavaScript file back to locations in
the original CoffeeScript source file.
</p>
</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>
lastColumn = <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 id="section-9">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Write a comma if we&#39;ve already written a segment on this line.
</p>
</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>
needComma = <span class="literal">no</span></pre></div></div>
</li>
<li id="section-10">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Write the next segment. Segments can be 1, 4, or 5 values. If just one, then it
is a generated column which doesn&#39;t match anything in the source code.
</p>
<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
</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>
</li>
<li id="section-11">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>The index into the list of sources:
</p>
</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 id="section-12">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>The starting line in the original source, relative to the previous source line.
</p>
</div>
<div class="content"><div class='highlight'><pre> buffer += <span class="property">@encodeVlq</span> mapping.sourceLine - lastSourceLine
<span class="keyword">if</span> lastSourceLine <span class="keyword">isnt</span> mapping.sourceLine
lastSourceLine = mapping.sourceLine
lastSourceColumn = <span class="number">0</span></pre></div></div>
<div class="content"><div class='highlight'><pre>
buffer += <span class="property">@encodeVlq</span> mapping.sourceLine - lastSourceLine
lastSourceLine = mapping.sourceLine</pre></div></div>
</li>
<li id="section-13">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>The starting column in the original source, relative to the previous column.
</p>
</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
needComma = <span class="literal">yes</span></pre></div></div>
</li>
<li id="section-14">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Produce the canonical JSON object format for a &quot;v3&quot; source map.
</p>
</div>
<div class="content"><div class='highlight'><pre> v3 =
<div class="content"><div class='highlight'><pre>
v3 =
version: <span class="number">3</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>
@ -411,11 +488,11 @@ column for the current line:
</li>
<li id="section-15">
<li id="section-22">
<div class="annotation">
<div class="pilwrap for-h2">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<h2>Base64 VLQ Encoding</h2>
@ -424,23 +501,35 @@ column for the current line:
</li>
<li id="section-16">
<li id="section-23">
<div class="annotation">
<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>
<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
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
bits of the original value encoded into the first byte of the VLQ encoded value.
</p>
</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_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 id="section-17">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Least significant bit represents the sign.
</p>
@ -466,11 +555,11 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li>
<li id="section-18">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>The next bits are the actual value.
</p>
@ -482,11 +571,11 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li>
<li id="section-19">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Make sure we encode at least one character, even if valueToEncode is 0.
</p>
@ -504,11 +593,11 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
</li>
<li id="section-20">
<li id="section-28">
<div class="annotation">
<div class="pilwrap for-h2">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<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 id="section-21">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-29">&#182;</a>
</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;
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 id="section-22">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Our API for source maps is just the <code>SourceMap</code> class.
</p>
</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>

View File

@ -137,7 +137,7 @@
<p>
<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>
<pre>
@ -264,12 +264,6 @@ sudo bin/cake install</pre>
directly to <b>stdout</b>.
</td>
</tr>
<tr>
<td><code>-l, --literate</code></td>
<td>
Parses the code as Literate CoffeeScript.
</td>
</tr>
<tr>
<td><code>-s, --stdio</code></td>
<td>
@ -278,6 +272,14 @@ sudo bin/cake install</pre>
<tt>cat src/cake.coffee | coffee -sc</tt>
</td>
</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>
<td><code>-e, --eval</code></td>
<td>
@ -1196,6 +1198,35 @@ Expressions
Change Log
</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>
<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>

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var fill;
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;
_fn = function(filename) {

View File

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

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var footprints, solipsism, speed;
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;
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;
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;
globals = ((function() {
var _results;
_results = [];
for (name in window) {
_results.push(name);

View File

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

View File

@ -1,9 +1,8 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var Account;
Account = function(customer, cart) {
var _this = this;
this.customer = customer;
this.cart = cart;
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;
square = function(x) {

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var html;
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;
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;
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;
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;
yearsOld = {
@ -9,7 +9,6 @@ yearsOld = {
ages = (function() {
var _results;
_results = [];
for (child in yearsOld) {
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;
futurists = {

View File

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

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
String.prototype.dasherize = function() {
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;
countdown = (function() {
var _i, _results;
_results = [];
for (num = _i = 10; _i >= 1; num = --_i) {
_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;
outer = 1;
changeNumbers = function() {
var inner;
inner = -1;
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;
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;
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,
__slice = [].slice;
@ -6,7 +6,6 @@ gold = silver = rest = "unknown";
awardMedals = function() {
var first, others, second;
first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
gold = first;
silver = second;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var numbers, _ref;
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;
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) {
case "Mon":
go(work);

View File

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

View File

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

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var lyrics, num;
if (this.studyingEconomics) {
@ -14,7 +14,6 @@ num = 6;
lyrics = (function() {
var _results;
_results = [];
while (num -= 1) {
_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
no interpretation at runtime. You can use any existing JavaScript library
seamlessly from CoffeeScript (and vice-versa). The compiled output is
readable and pretty-printed, passes through
<a href="http://www.javascriptlint.com/">JavaScript Lint</a>
without warnings, will work in every JavaScript runtime, and tends
readable and pretty-printed, will work in every JavaScript runtime, and tends
to run as fast or faster than the equivalent handwritten JavaScript.
</p>
<p>
<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>
<pre>
@ -184,7 +182,6 @@ math <span class="Keyword">=</span> {
<span class="FunctionName">race</span> = <span class="Storage">function</span>() {
<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>) : [];
<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>() {
<span class="Storage">var</span> _i, _len, _results;
_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>) {
num <span class="Keyword">=</span> list[_i];
@ -230,7 +226,6 @@ math = {
race = function() {
var runners, winner;
winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return print(winner, runners);
};
@ -241,7 +236,6 @@ if (typeof elvis !== "undefined" && elvis !== null) {
cubes = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) {
num = list[_i];
@ -363,12 +357,6 @@ sudo bin/cake install</pre>
directly to <b>stdout</b>.
</td>
</tr>
<tr>
<td><code>-l, --literate</code></td>
<td>
Parses the code as Literate CoffeeScript.
</td>
</tr>
<tr>
<td><code>-s, --stdio</code></td>
<td>
@ -377,6 +365,14 @@ sudo bin/cake install</pre>
<tt>cat src/cake.coffee | coffee -sc</tt>
</td>
</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>
<td><code>-e, --eval</code></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="Storage">var</span> inner;
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>;
};
@ -701,7 +696,6 @@ outer = 1;
changeNumbers = function() {
var inner;
inner = -1;
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="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>) : [];
gold <span class="Keyword">=</span> first;
silver <span class="Keyword">=</span> second;
@ -845,7 +838,6 @@ gold = silver = rest = "unknown";
awardMedals = function() {
var first, others, second;
first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
gold = first;
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>() {
<span class="Storage">var</span> _i, _results;
_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) {
_results.<span class="LibraryFunction">push</span>(num);
@ -931,7 +922,6 @@ countdown <span class="Keyword">=</span> (<span class="Storage">function</span>(
countdown = (function() {
var _i, _results;
_results = [];
for (num = _i = 10; _i >= 1; num = --_i) {
_results.push(num);
@ -972,7 +962,6 @@ yearsOld <span class="Keyword">=</span> {
ages <span class="Keyword">=</span> (<span class="Storage">function</span>() {
<span class="Storage">var</span> _results;
_results <span class="Keyword">=</span> [];
<span class="Keyword">for</span> (child <span class="Keyword">in</span> yearsOld) {
age <span class="Keyword">=</span> yearsOld[child];
@ -990,7 +979,6 @@ yearsOld = {
ages = (function() {
var _results;
_results = [];
for (child in yearsOld) {
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>() {
<span class="Storage">var</span> _results;
_results <span class="Keyword">=</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>);
@ -1058,7 +1045,6 @@ num = 6;
lyrics = (function() {
var _results;
_results = [];
while (num -= 1) {
_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>() {
<span class="Storage">var</span> _results;
_results <span class="Keyword">=</span> [];
<span class="Keyword">for</span> (name <span class="Keyword">in</span> <span class="LibraryClassType">window</span>) {
_results.<span class="LibraryFunction">push</span>(name);
@ -1257,7 +1242,6 @@ globals <span class="Keyword">=</span> ((<span class="Storage">function</span>()
globals = ((function() {
var _results;
_results = [];
for (name in window) {
_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>
<p>
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>
<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>
@ -1849,7 +1833,6 @@ Person = (function() {
<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="Variable">this</span>.customer <span class="Keyword">=</span> customer;
<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>) {
@ -2114,6 +2097,7 @@ html = "<strong>\n cup of coffeescript\n</strong>";
<span class="Comment">Released under the MIT License</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>
<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) {
<span class="Storage">var</span> code, dir;
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();
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
</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>
<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>

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
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; };

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
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() {
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;
@ -19,7 +19,7 @@
SourceMap = require('./sourcemap');
exports.VERSION = '1.6.2';
exports.VERSION = '1.6.3';
exports.helpers = helpers;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(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;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
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() {
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() {
var key, val, _ref;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(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,
__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() {
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,

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
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() {
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() {
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; },

View File

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

View File

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

View File

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

View File

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