[CS2] 2.0.0-beta2 (#4550)

* Breaking changes note about bound class methods

* Changelog for 2.0.0-beta2, including renaming “Change Log” to “Changelog” (the preferred spelling per Wikipedia)

* Update version to 2.0.0-beta2

* 2.0.0-beta2 generated output
This commit is contained in:
Geoffrey Booth 2017-05-16 11:53:22 -07:00 committed by GitHub
parent 8c9e24841e
commit d756bd6851
35 changed files with 813 additions and 720 deletions

View File

@ -124,7 +124,6 @@ We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
<div class="content"><div class='highlight'><pre>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
CoffeeScript.<span class="hljs-built_in">require</span> = <span class="hljs-built_in">require</span>
compile = CoffeeScript.compile</pre></div></div>
</li>
@ -171,11 +170,12 @@ compile = CoffeeScript.compile</pre></div></div>
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>If were not in a browser environment, were finished with the public API.</p>
<p>Export this more limited <code>CoffeeScript</code> than what is exported by
<code>index.coffee</code>, which is intended for a Node environment.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> <span class="hljs-built_in">window</span>?</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">module</span>.exports = CoffeeScript</pre></div></div>
</li>
@ -186,6 +186,21 @@ compile = CoffeeScript.compile</pre></div></div>
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>If were not in a browser environment, were finished with the public API.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> <span class="hljs-built_in">window</span>?</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Include source maps where possible. If weve got a base64 encoder, a
JSON serializer, and tools for escaping unicode characters, were good to go.
Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">https://developer.mozilla.org/en-US/docs/DOM/window.btoa</a></p>
@ -200,11 +215,11 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
</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>Load a remote script from the current domain via XHR.</p>
@ -231,11 +246,11 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
</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>Activate CoffeeScript in the browser by having it compile and evaluate
all script tags with a content-type of <code>text/coffeescript</code>.
@ -273,11 +288,11 @@ This happens on page load.</p>
</li>
<li id="section-8">
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p><code>options.filename</code> defines the filename the source map appears as
in Developer Tools. If a script tag has an <code>id</code>, use that as the
@ -296,11 +311,11 @@ only one CoffeeScript script block to parse.</p>
</li>
<li id="section-9">
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Listen for window load, both in decent browsers and in IE.</p>

View File

@ -141,7 +141,7 @@ current directorys Cakefile.</p>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">'./optparse'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span></pre></div></div>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./'</span></pre></div></div>
</li>

View File

@ -123,9 +123,6 @@ source CoffeeScript into JavaScript.</p>
</div>
<div class="content"><div class='highlight'><pre>
fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
{Lexer} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./lexer'</span>
{parser} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./parser'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
@ -493,13 +490,16 @@ or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Compile and execute a string of CoffeeScript (on the server), correctly
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p>
<p>This file used to export these methods; leave stubs that throw warnings
instead. These methods have been moved into <code>index.coffee</code> to provide
separate entrypoints for Node and non-Node environments, so that static
analysis tools dont choke on Node packages when compiling for a non-Node
environment.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
mainModule = <span class="hljs-built_in">require</span>.main</pre></div></div>
<div class="content"><div class='highlight'><pre>exports.run = exports.eval = exports.register = <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">'require index.coffee, not this file'</span></pre></div></div>
</li>
@ -510,221 +510,6 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Set the filename.</p>
</div>
<div class="content"><div class='highlight'><pre> mainModule.filename = process.argv[<span class="hljs-number">1</span>] =
<span class="hljs-keyword">if</span> options.filename <span class="hljs-keyword">then</span> fs.realpathSync(options.filename) <span class="hljs-keyword">else</span> <span class="hljs-string">'&lt;anonymous&gt;'</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>Clear the module cache.</p>
</div>
<div class="content"><div class='highlight'><pre> mainModule.moduleCache <span class="hljs-keyword">and</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>Assign paths for node_modules loading</p>
</div>
<div class="content"><div class='highlight'><pre> dir = <span class="hljs-keyword">if</span> options.filename?
path.dirname fs.realpathSync options.filename
<span class="hljs-keyword">else</span>
fs.realpathSync <span class="hljs-string">'.'</span>
mainModule.paths = <span class="hljs-built_in">require</span>(<span class="hljs-string">'module'</span>)._nodeModulePaths dir</pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Compile.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> helpers.isCoffee(mainModule.filename) <span class="hljs-keyword">or</span> <span class="hljs-built_in">require</span>.extensions
answer = compile code, options
code = answer.js ? answer
mainModule._compile code, mainModule.filename</pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
The CoffeeScript REPL uses this to run the input.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> code = code.trim()
createContext = vm.Script.createContext ? vm.createContext
isContext = vm.isContext ? (ctx) -&gt;
options.sandbox <span class="hljs-keyword">instanceof</span> createContext().constructor
<span class="hljs-keyword">if</span> createContext
<span class="hljs-keyword">if</span> options.sandbox?
<span class="hljs-keyword">if</span> isContext options.sandbox
sandbox = options.sandbox
<span class="hljs-keyword">else</span>
sandbox = createContext()
sandbox[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options.sandbox
sandbox.<span class="hljs-built_in">global</span> = sandbox.root = sandbox.GLOBAL = sandbox
<span class="hljs-keyword">else</span>
sandbox = <span class="hljs-built_in">global</span>
sandbox.__filename = options.filename || <span class="hljs-string">'eval'</span>
sandbox.__dirname = path.dirname sandbox.__filename</pre></div></div>
</li>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>define module/require only if they chose not to specify their own</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> sandbox <span class="hljs-keyword">isnt</span> <span class="hljs-built_in">global</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">module</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">require</span>
Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
sandbox.<span class="hljs-built_in">module</span> = _module = <span class="hljs-keyword">new</span> Module(options.modulename || <span class="hljs-string">'eval'</span>)
sandbox.<span class="hljs-built_in">require</span> = _require = <span class="hljs-function"><span class="hljs-params">(path)</span> -&gt;</span> Module._load path, _module, <span class="hljs-literal">true</span>
_module.filename = sandbox.__filename
<span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'paths'</span>, <span class="hljs-string">'arguments'</span>, <span class="hljs-string">'caller'</span>]
_require[r] = <span class="hljs-built_in">require</span>[r]</pre></div></div>
</li>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>use the same hack node currently uses for their own REPL</p>
</div>
<div class="content"><div class='highlight'><pre> _require.paths = _module.paths = Module._nodeModulePaths process.cwd()
_require.resolve = <span class="hljs-function"><span class="hljs-params">(request)</span> -&gt;</span> Module._resolveFilename request, _module
o = {}
o[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options
o.bare = <span class="hljs-literal">on</span> <span class="hljs-comment"># ensure return value</span>
js = compile code, o
<span class="hljs-keyword">if</span> sandbox <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
vm.runInThisContext js
<span class="hljs-keyword">else</span>
vm.runInContext js, sandbox
exports.register = <span class="hljs-function">-&gt;</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</span></pre></div></div>
</li>
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Throw error with deprecation warning when depending upon implicit <code>require.extensions</code> registration</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.extensions
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> @FILE_EXTENSIONS <span class="hljs-keyword">then</span> <span class="hljs-keyword">do</span> (ext) -&gt;
<span class="hljs-built_in">require</span>.extensions[ext] ?= <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"""
Use CoffeeScript.register() or require the coffeescript/register module to require <span class="hljs-subst">#{ext}</span> files.
"""</span>
exports._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, sourceMap = <span class="hljs-literal">no</span>, inlineMap = <span class="hljs-literal">no</span>)</span> -&gt;</span>
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span></pre></div></div>
</li>
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>Strip the Unicode byte order mark, if this file begins with one.</p>
</div>
<div class="content"><div class='highlight'><pre> stripped = <span class="hljs-keyword">if</span> raw.charCodeAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-number">0xFEFF</span> <span class="hljs-keyword">then</span> raw.substring <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> raw
<span class="hljs-keyword">try</span>
answer = compile stripped, {
filename, sourceMap, inlineMap
sourceFiles: [filename]
literate: helpers.isLiterate filename
}
<span class="hljs-keyword">catch</span> err</pre></div></div>
</li>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>As the filename and code of a dynamically loaded file will be different
from the original file compiled with CoffeeScript.run, add that
information to error so it can be pretty-printed later.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, stripped, filename
answer</pre></div></div>
</li>
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Instantiate a Lexer for our use here.</p>
</div>
@ -734,11 +519,11 @@ information to error so it can be pretty-printed later.</p>
</li>
<li id="section-31">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>The real Lexer produces a generic stream of tokens. This object provides a
thin wrapper around it, compatible with the Jison API. We can then pass it
@ -766,11 +551,11 @@ directly as a “Jison lexer”.</p>
</li>
<li id="section-32">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Make all the AST nodes visible to the parser.</p>
@ -781,11 +566,11 @@ directly as a “Jison lexer”.</p>
</li>
<li id="section-33">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Override Jisons default error handling function.</p>
@ -796,11 +581,11 @@ directly as a “Jison lexer”.</p>
</li>
<li id="section-34">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Disregard Jisons message, it contains redundant line number information.
Disregard the token, we take its value directly from the lexer in case
@ -824,11 +609,11 @@ the error is caused by a generated token which might refer to its origin.</p>
</li>
<li id="section-35">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>The second argument has a <code>loc</code> property, which should have the location
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
@ -842,11 +627,11 @@ from the lexer.</p>
</li>
<li id="section-36">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
Modified to handle sourceMap</p>
@ -874,11 +659,11 @@ Modified to handle sourceMap</p>
</li>
<li id="section-37">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-37">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Check for a sourceMap position</p>
@ -923,11 +708,11 @@ Modified to handle sourceMap</p>
</li>
<li id="section-38">
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-38">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>CoffeeScript compiled in a browser may get compiled with <code>options.filename</code>
of <code>&lt;anonymous&gt;</code>, but the browser may request the stack trace with the
@ -949,11 +734,11 @@ filename of the script file.</p>
</li>
<li id="section-39">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-39">&#182;</a>
<a class="pilcrow" href="#section-29">&#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

View File

@ -140,7 +140,7 @@ interactive REPL.</p>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">'./optparse'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./'</span>
{spawn, exec} = <span class="hljs-built_in">require</span> <span class="hljs-string">'child_process'</span>
{EventEmitter} = <span class="hljs-built_in">require</span> <span class="hljs-string">'events'</span>

View File

@ -221,7 +221,7 @@ previous nonterminal.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>All runtime functions we need are defined on “yy”</p>
<p>All runtime functions we need are defined on <code>yy</code></p>
</div>
@ -238,7 +238,7 @@ previous nonterminal.</p>
<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
in, and returns the parameter. If the parameter is not a node, it will
just be passed through unaffected.</p>
</div>
@ -292,7 +292,7 @@ just be passed through unaffected.</p>
the key to a list of alternative matches. With each matchs action, the
dollar-sign variables are provided by Jison as references to the value of
their numeric position, so in this rule:</p>
<pre><code><span class="hljs-string">"Expression UNLESS Expression"</span>
<pre><code><span class="hljs-string">'Expression UNLESS Expression'</span>
</code></pre><p><code>$1</code> would be the value of the first <code>Expression</code>, <code>$2</code> would be the token
for the <code>UNLESS</code> terminal, and <code>$3</code> would be the value of the second
<code>Expression</code>.</p>
@ -1590,7 +1590,6 @@ rules are necessary.</p>
INDENT Expression OUTDENT'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Assign $<span class="hljs-number">1</span>, $<span class="hljs-number">4</span>, $<span class="hljs-number">2</span>
o <span class="hljs-string">'SimpleAssignable COMPOUND_ASSIGN TERMINATOR
Expression'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Assign $<span class="hljs-number">1</span>, $<span class="hljs-number">4</span>, $<span class="hljs-number">2</span>
o <span class="hljs-string">'SimpleAssignable EXTENDS Expression'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Extends $<span class="hljs-number">1</span>, $<span class="hljs-number">3</span>
]</pre></div></div>
</li>

View File

@ -121,9 +121,6 @@ arrays, count characters, that sort of thing.</p>
</div>
<div class="content"><div class='highlight'><pre>
md = <span class="hljs-built_in">require</span>(<span class="hljs-string">'markdown-it'</span>)()</pre></div></div>
</li>
@ -331,16 +328,38 @@ looking for a particular method in an options hash.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Simple function for extracting code from Literate CoffeeScript by stripping
<p>Helper function for extracting code from Literate CoffeeScript by stripping
out all non-code blocks, producing a string of CoffeeScript code that can
be compiled “normally.” Uses <a href="https://markdown-it.github.io/">MarkdownIt</a>
to tell the difference between Markdown and code blocks.</p>
be compiled “normally.”</p>
</div>
<div class="content"><div class='highlight'><pre>exports.invertLiterate = <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
out = []
md.renderer.rules =</pre></div></div>
blankLine = <span class="hljs-regexp">/^\s*$/</span>
indented = <span class="hljs-regexp">/^[\t ]/</span>
listItemStart = <span class="hljs-regexp">/// ^
(?:\t?|\ {0,3}) <span class="hljs-comment"># Up to one tab, or up to three spaces, or neither;</span>
(?:
[\*\-\+] | <span class="hljs-comment"># followed by `*`, `-` or `+`;</span>
[0-9]{1,9}\. <span class="hljs-comment"># or by an integer up to 9 digits long, followed by a period;</span>
)
[\ \t] <span class="hljs-comment"># followed by a space or a tab.</span>
///</span>
insideComment = <span class="hljs-literal">no</span>
<span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> code.split(<span class="hljs-string">'\n'</span>)
<span class="hljs-keyword">if</span> blankLine.test(line)
insideComment = <span class="hljs-literal">no</span>
out.push line
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> insideComment <span class="hljs-keyword">or</span> listItemStart.test(line)
insideComment = <span class="hljs-literal">yes</span>
out.push <span class="hljs-string">"# <span class="hljs-subst">#{line}</span>"</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> insideComment <span class="hljs-keyword">and</span> indented.test(line)
out.push line
<span class="hljs-keyword">else</span>
insideComment = <span class="hljs-literal">yes</span>
out.push <span class="hljs-string">"# <span class="hljs-subst">#{line}</span>"</span>
out.join <span class="hljs-string">'\n'</span></pre></div></div>
</li>
@ -351,27 +370,6 @@ to tell the difference between Markdown and code blocks.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Delete all other rules, since all we want are the code blocks.</p>
</div>
<div class="content"><div class='highlight'><pre> code_block: <span class="hljs-function"><span class="hljs-params">(tokens, idx, options, env, slf)</span> -&gt;</span>
startLine = tokens[idx].map[<span class="hljs-number">0</span>]
lines = tokens[idx].content.split <span class="hljs-string">'\n'</span>
<span class="hljs-keyword">for</span> line, i <span class="hljs-keyword">in</span> lines
out[startLine + i] = line
md.render code
out.join <span class="hljs-string">'\n'</span></pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Merge two jison-style location data objects together.
If <code>last</code> is not provided, this will simply return <code>first</code>.</p>
@ -389,11 +387,11 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
</li>
<li id="section-16">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-15">&#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 objects locationData.
@ -411,11 +409,11 @@ The object is returned either way.</p>
</li>
<li id="section-17">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Convert jison location data to a string.
<code>obj</code> can be a token, or a locationData.</p>
@ -435,11 +433,11 @@ The object is returned either way.</p>
</li>
<li id="section-18">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.</p>
@ -458,11 +456,11 @@ The object is returned either way.</p>
</li>
<li id="section-19">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Determine if a filename represents a CoffeeScript file.</p>
@ -473,11 +471,11 @@ The object is returned either way.</p>
</li>
<li id="section-20">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
@ -488,11 +486,11 @@ The object is returned either way.</p>
</li>
<li id="section-21">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Throws a SyntaxError from a given location.
The errors <code>toString</code> will return an error message following the “standard”
@ -509,11 +507,11 @@ marker showing where the error is.</p>
</li>
<li id="section-22">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Instead of showing the compilers stacktrace, show our custom error message
(this is useful when the error bubbles up in Node.js applications that
@ -528,11 +526,11 @@ compile CoffeeScript for example).</p>
</li>
<li id="section-23">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Update a compiler SyntaxError with source code information if it didnt have
it already.</p>
@ -544,11 +542,11 @@ it already.</p>
</li>
<li id="section-24">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Avoid screwing up the <code>stack</code> property of other errors (i.e. possible bugs).</p>
@ -574,11 +572,11 @@ it already.</p>
</li>
<li id="section-25">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Show only the first line on multi-line errors.</p>
@ -590,11 +588,11 @@ it already.</p>
</li>
<li id="section-26">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Check to see if were running on a color-enabled TTY.</p>

View File

@ -115,11 +115,251 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>Loader for CoffeeScript as a Node.js library.</p>
<p>Node.js Implementation</p>
</div>
<div class="content"><div class='highlight'><pre>exports[key] = val <span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span></pre></div></div>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
helpers = CoffeeScript.helpers
compile = CoffeeScript.compile</pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Compile and execute a string of CoffeeScript (on the server), correctly
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.run = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
mainModule = <span class="hljs-built_in">require</span>.main</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Set the filename.</p>
</div>
<div class="content"><div class='highlight'><pre> mainModule.filename = process.argv[<span class="hljs-number">1</span>] =
<span class="hljs-keyword">if</span> options.filename <span class="hljs-keyword">then</span> fs.realpathSync(options.filename) <span class="hljs-keyword">else</span> <span class="hljs-string">'&lt;anonymous&gt;'</span></pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Clear the module cache.</p>
</div>
<div class="content"><div class='highlight'><pre> mainModule.moduleCache <span class="hljs-keyword">and</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>Assign paths for node_modules loading</p>
</div>
<div class="content"><div class='highlight'><pre> dir = <span class="hljs-keyword">if</span> options.filename?
path.dirname fs.realpathSync options.filename
<span class="hljs-keyword">else</span>
fs.realpathSync <span class="hljs-string">'.'</span>
mainModule.paths = <span class="hljs-built_in">require</span>(<span class="hljs-string">'module'</span>)._nodeModulePaths dir</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Compile.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> helpers.isCoffee(mainModule.filename) <span class="hljs-keyword">or</span> <span class="hljs-built_in">require</span>.extensions
answer = compile code, options
code = answer.js ? answer
mainModule._compile code, mainModule.filename</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
The CoffeeScript REPL uses this to run the input.</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> code = code.trim()
createContext = vm.Script.createContext ? vm.createContext
isContext = vm.isContext ? (ctx) -&gt;
options.sandbox <span class="hljs-keyword">instanceof</span> createContext().constructor
<span class="hljs-keyword">if</span> createContext
<span class="hljs-keyword">if</span> options.sandbox?
<span class="hljs-keyword">if</span> isContext options.sandbox
sandbox = options.sandbox
<span class="hljs-keyword">else</span>
sandbox = createContext()
sandbox[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options.sandbox
sandbox.<span class="hljs-built_in">global</span> = sandbox.root = sandbox.GLOBAL = sandbox
<span class="hljs-keyword">else</span>
sandbox = <span class="hljs-built_in">global</span>
sandbox.__filename = options.filename || <span class="hljs-string">'eval'</span>
sandbox.__dirname = path.dirname sandbox.__filename</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>define module/require only if they chose not to specify their own</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> sandbox <span class="hljs-keyword">isnt</span> <span class="hljs-built_in">global</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">module</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">require</span>
Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
sandbox.<span class="hljs-built_in">module</span> = _module = <span class="hljs-keyword">new</span> Module(options.modulename || <span class="hljs-string">'eval'</span>)
sandbox.<span class="hljs-built_in">require</span> = _require = <span class="hljs-function"><span class="hljs-params">(path)</span> -&gt;</span> Module._load path, _module, <span class="hljs-literal">true</span>
_module.filename = sandbox.__filename
<span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'paths'</span>, <span class="hljs-string">'arguments'</span>, <span class="hljs-string">'caller'</span>]
_require[r] = <span class="hljs-built_in">require</span>[r]</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>use the same hack node currently uses for their own REPL</p>
</div>
<div class="content"><div class='highlight'><pre> _require.paths = _module.paths = Module._nodeModulePaths process.cwd()
_require.resolve = <span class="hljs-function"><span class="hljs-params">(request)</span> -&gt;</span> Module._resolveFilename request, _module
o = {}
o[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options
o.bare = <span class="hljs-literal">on</span> <span class="hljs-comment"># ensure return value</span>
js = compile code, o
<span class="hljs-keyword">if</span> sandbox <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
vm.runInThisContext js
<span class="hljs-keyword">else</span>
vm.runInContext js, sandbox
CoffeeScript.register = <span class="hljs-function">-&gt;</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</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>Throw error with deprecation warning when depending upon implicit <code>require.extensions</code> registration</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.extensions
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> CoffeeScript.FILE_EXTENSIONS <span class="hljs-keyword">then</span> <span class="hljs-keyword">do</span> (ext) -&gt;
<span class="hljs-built_in">require</span>.extensions[ext] ?= <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"""
Use CoffeeScript.register() or require the coffeescript/register module to require <span class="hljs-subst">#{ext}</span> files.
"""</span>
CoffeeScript._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, sourceMap = <span class="hljs-literal">no</span>, inlineMap = <span class="hljs-literal">no</span>)</span> -&gt;</span>
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span></pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Strip the Unicode byte order mark, if this file begins with one.</p>
</div>
<div class="content"><div class='highlight'><pre> stripped = <span class="hljs-keyword">if</span> raw.charCodeAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-number">0xFEFF</span> <span class="hljs-keyword">then</span> raw.substring <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> raw
<span class="hljs-keyword">try</span>
answer = compile stripped, {
filename, sourceMap, inlineMap
sourceFiles: [filename]
literate: helpers.isLiterate filename
}
<span class="hljs-keyword">catch</span> err</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>As the filename and code of a dynamically loaded file will be different
from the original file compiled with CoffeeScript.run, add that
information to error so it can be pretty-printed later.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, stripped, filename
answer
<span class="hljs-built_in">module</span>.exports = CoffeeScript</pre></div></div>
</li>

View File

@ -142,8 +142,8 @@ are read by jison in the <code>parser.lexer</code> function defined in coffeescr
</div>
<div class="content"><div class='highlight'><pre>{count, starts, compact, repeat, invertLiterate,
locationDataToString, throwSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
<div class="content"><div class='highlight'><pre>{count, starts, compact, repeat, invertLiterate, merge,
locationDataToString, throwSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
</li>
@ -439,7 +439,7 @@ though <code>is</code> means <code>===</code> otherwise.</p>
</div>
<p>Throw an error on attempts to use <code>get</code> or <code>set</code> as keywords, or
what CoffeeScript would normally interpret as calls to functions named
<code>get</code> or <code>set</code>, i.e. <code>get({foo: function () {}})</code></p>
<code>get</code> or <code>set</code>, i.e. <code>get({foo: function () {}})</code>.</p>
</div>
@ -448,7 +448,8 @@ what CoffeeScript would normally interpret as calls to functions named
@error <span class="hljs-string">"'<span class="hljs-subst">#{prev[<span class="hljs-number">1</span>]}</span>' cannot be used as a keyword, or as a function call without parentheses"</span>, prev[<span class="hljs-number">2</span>]
<span class="hljs-keyword">else</span>
prevprev = @tokens[@tokens.length - <span class="hljs-number">2</span>]
<span class="hljs-keyword">if</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'@'</span>, <span class="hljs-string">'THIS'</span>] <span class="hljs-keyword">and</span> prevprev <span class="hljs-keyword">and</span> prevprev.spaced <span class="hljs-keyword">and</span> <span class="hljs-regexp">/^[gs]et$/</span>.test(prevprev[<span class="hljs-number">1</span>])
<span class="hljs-keyword">if</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'@'</span>, <span class="hljs-string">'THIS'</span>] <span class="hljs-keyword">and</span> prevprev <span class="hljs-keyword">and</span> prevprev.spaced <span class="hljs-keyword">and</span> <span class="hljs-regexp">/^[gs]et$/</span>.test(prevprev[<span class="hljs-number">1</span>]) <span class="hljs-keyword">and</span>
@tokens[@tokens.length - <span class="hljs-number">3</span>][<span class="hljs-number">0</span>] <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.'</span>
@error <span class="hljs-string">"'<span class="hljs-subst">#{prevprev[<span class="hljs-number">1</span>]}</span>' cannot be used as a keyword, or as a function call without parentheses"</span>, prevprev[<span class="hljs-number">2</span>]
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'IDENTIFIER'</span> <span class="hljs-keyword">and</span> id <span class="hljs-keyword">in</span> RESERVED
@ -488,7 +489,7 @@ what CoffeeScript would normally interpret as calls to functions named
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Matches numbers, including decimals, hex, and exponential notation.
Be careful not to interfere with ranges-in-progress.</p>
Be careful not to interfere with ranges in progress.</p>
</div>
@ -530,7 +531,7 @@ Be careful not to interfere with ranges-in-progress.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Matches strings, including multi-line strings, as well as heredocs, with or without
<p>Matches strings, including multiline strings, as well as heredocs, with or without
interpolation.</p>
</div>
@ -590,14 +591,14 @@ properly tag the <code>from</code>.</p>
indent = attempt <span class="hljs-keyword">if</span> indent <span class="hljs-keyword">is</span> <span class="hljs-literal">null</span> <span class="hljs-keyword">or</span> <span class="hljs-number">0</span> &lt; attempt.length &lt; indent.length
indentRegex = <span class="hljs-regexp">/// \n<span class="hljs-subst">#{indent}</span> ///</span>g <span class="hljs-keyword">if</span> indent
@mergeInterpolationTokens tokens, {delimiter}, <span class="hljs-function"><span class="hljs-params">(value, i)</span> =&gt;</span>
value = @formatString value
value = @formatString value, delimiter: quote
value = value.replace indentRegex, <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> indentRegex
value = value.replace LEADING_BLANK_LINE, <span class="hljs-string">''</span> <span class="hljs-keyword">if</span> i <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
value = value.replace TRAILING_BLANK_LINE, <span class="hljs-string">''</span> <span class="hljs-keyword">if</span> i <span class="hljs-keyword">is</span> $
value
<span class="hljs-keyword">else</span>
@mergeInterpolationTokens tokens, {delimiter}, <span class="hljs-function"><span class="hljs-params">(value, i)</span> =&gt;</span>
value = @formatString value
value = @formatString value, delimiter: quote
value = value.replace SIMPLE_STRING_OMIT, <span class="hljs-function"><span class="hljs-params">(match, offset)</span> -&gt;</span>
<span class="hljs-keyword">if</span> (i <span class="hljs-keyword">is</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> offset <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>) <span class="hljs-keyword">or</span>
(i <span class="hljs-keyword">is</span> $ <span class="hljs-keyword">and</span> offset + match.length <span class="hljs-keyword">is</span> value.length)
@ -727,13 +728,17 @@ borrow some basic heuristics from JavaScript and Ruby.</p>
<span class="hljs-keyword">when</span> <span class="hljs-keyword">not</span> VALID_FLAGS.test flags
@error <span class="hljs-string">"invalid regular expression flags <span class="hljs-subst">#{flags}</span>"</span>, offset: index, length: flags.length
<span class="hljs-keyword">when</span> regex <span class="hljs-keyword">or</span> tokens.length <span class="hljs-keyword">is</span> <span class="hljs-number">1</span>
body ?= @formatHeregex tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>]
<span class="hljs-keyword">if</span> body
body = @formatRegex body, { flags, delimiter: <span class="hljs-string">'/'</span> }
<span class="hljs-keyword">else</span>
body = @formatHeregex tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>], { flags }
@token <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">"<span class="hljs-subst">#{@makeDelimitedLiteral body, delimiter: <span class="hljs-string">'/'</span>}</span><span class="hljs-subst">#{flags}</span>"</span>, <span class="hljs-number">0</span>, end, origin
<span class="hljs-keyword">else</span>
@token <span class="hljs-string">'REGEX_START'</span>, <span class="hljs-string">'('</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, origin
@token <span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'RegExp'</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>
@token <span class="hljs-string">'CALL_START'</span>, <span class="hljs-string">'('</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>
@mergeInterpolationTokens tokens, {delimiter: <span class="hljs-string">'"'</span>, double: <span class="hljs-literal">yes</span>}, @formatHeregex
@mergeInterpolationTokens tokens, {delimiter: <span class="hljs-string">'"'</span>, double: <span class="hljs-literal">yes</span>}, <span class="hljs-function"><span class="hljs-params">(str)</span> =&gt;</span>
@formatHeregex str, { flags }
<span class="hljs-keyword">if</span> flags
@token <span class="hljs-string">','</span>, <span class="hljs-string">','</span>, index - <span class="hljs-number">1</span>, <span class="hljs-number">0</span>
@token <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'"'</span> + flags + <span class="hljs-string">'"'</span>, index - <span class="hljs-number">1</span>, flags.length
@ -788,7 +793,7 @@ can close multiple indents, so we need to know how far in we happen to be.</p>
<span class="hljs-keyword">return</span> indent.length
<span class="hljs-keyword">if</span> size &gt; @indent
<span class="hljs-keyword">if</span> noNewlines
<span class="hljs-keyword">if</span> noNewlines <span class="hljs-keyword">or</span> @tag() <span class="hljs-keyword">is</span> <span class="hljs-string">'RETURN'</span>
@indebt = size - @indent
@suppressNewlines()
<span class="hljs-keyword">return</span> indent.length
@ -1115,7 +1120,7 @@ ad infinitum.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a>
</div>
<p>Push a fake NEOSTRING token, which will get turned into a real string later.</p>
<p>Push a fake <code>&#39;NEOSTRING&#39;</code> token, which will get turned into a real string later.</p>
</div>
@ -1186,7 +1191,7 @@ parentheses will be removed later.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-40">&#182;</a>
</div>
<p>Remove leading TERMINATOR (if any).</p>
<p>Remove leading <code>&#39;TERMINATOR&#39;</code> (if any).</p>
</div>
@ -1201,7 +1206,7 @@ parentheses will be removed later.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a>
</div>
<p>Push a fake TOKENS token, which will get turned into real tokens later.</p>
<p>Push a fake <code>&#39;TOKENS&#39;</code> token, which will get turned into real tokens later.</p>
</div>
@ -1233,9 +1238,9 @@ parentheses will be removed later.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-42">&#182;</a>
</div>
<p>Merge the array <code>tokens</code> of the fake token types TOKENS and NEOSTRING
<p>Merge the array <code>tokens</code> of the fake token types <code>&#39;TOKENS&#39;</code> and <code>&#39;NEOSTRING&#39;</code>
(as returned by <code>matchWithInterpolations</code>) into the token stream. The value
of NEOSTRINGs are converted using <code>fn</code> and turned into strings using
of <code>&#39;NEOSTRING&#39;</code>s are converted using <code>fn</code> and turned into strings using
<code>options</code> first.</p>
</div>
@ -1274,7 +1279,7 @@ of NEOSTRINGs are converted using <code>fn</code> and turned into strings
<div class="pilwrap ">
<a class="pilcrow" href="#section-44">&#182;</a>
</div>
<p>Push all the tokens in the fake TOKENS token. These already have
<p>Push all the tokens in the fake <code>&#39;TOKENS&#39;</code> token. These already have
sane location data.</p>
</div>
@ -1292,11 +1297,11 @@ sane location data.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-45">&#182;</a>
</div>
<p>Convert NEOSTRING into STRING.</p>
<p>Convert <code>&#39;NEOSTRING&#39;</code> into <code>&#39;STRING&#39;</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> converted = fn token[<span class="hljs-number">1</span>], i</pre></div></div>
<div class="content"><div class='highlight'><pre> converted = fn.call <span class="hljs-keyword">this</span>, token[<span class="hljs-number">1</span>], i</pre></div></div>
</li>
@ -1405,7 +1410,7 @@ correctly balanced throughout the course of the token stream.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-50">&#182;</a>
</div>
<p>Auto-close INDENT to support syntax like this:</p>
<p>Auto-close <code>INDENT</code> to support syntax like this:</p>
<pre><code>el.click(<span class="hljs-function"><span class="hljs-params">(event)</span> -&gt;</span>
el.hide())
</code></pre>
@ -1451,7 +1456,7 @@ correctly balanced throughout the course of the token stream.</p>
<a class="pilcrow" href="#section-53">&#182;</a>
</div>
<p>Returns the line and column number from an offset into the current chunk.</p>
<p><code>offset</code> is a number of characters into @chunk.</p>
<p><code>offset</code> is a number of characters into <code>@chunk</code>.</p>
</div>
@ -1484,7 +1489,7 @@ correctly balanced throughout the course of the token stream.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-54">&#182;</a>
</div>
<p>Same as “token”, exception this just returns the token without adding it
<p>Same as <code>token</code>, except this just returns the token without adding it
to the results.</p>
</div>
@ -1526,8 +1531,8 @@ so if last_column == first_column, then were looking at a character of length
<a class="pilcrow" href="#section-56">&#182;</a>
</div>
<p>Add a token to the results.
<code>offset</code> is the offset into the current @chunk where the token starts.
<code>length</code> is the length of the token in the @chunk, after the offset. If
<code>offset</code> is the offset into the current <code>@chunk</code> where the token starts.
<code>length</code> is the length of the token in the <code>@chunk</code>, after the offset. If
not specified, the length of <code>value</code> will be used.</p>
<p>Returns the new token.</p>
@ -1606,13 +1611,22 @@ not specified, the length of <code>value</code> will be used.</p>
LINE_CONTINUER.test(@chunk) <span class="hljs-keyword">or</span>
@tag() <span class="hljs-keyword">in</span> [<span class="hljs-string">'\\'</span>, <span class="hljs-string">'.'</span>, <span class="hljs-string">'?.'</span>, <span class="hljs-string">'?::'</span>, <span class="hljs-string">'UNARY'</span>, <span class="hljs-string">'MATH'</span>, <span class="hljs-string">'UNARY_MATH'</span>, <span class="hljs-string">'+'</span>, <span class="hljs-string">'-'</span>,
<span class="hljs-string">'**'</span>, <span class="hljs-string">'SHIFT'</span>, <span class="hljs-string">'RELATION'</span>, <span class="hljs-string">'COMPARE'</span>, <span class="hljs-string">'&amp;'</span>, <span class="hljs-string">'^'</span>, <span class="hljs-string">'|'</span>, <span class="hljs-string">'&amp;&amp;'</span>, <span class="hljs-string">'||'</span>,
<span class="hljs-string">'BIN?'</span>, <span class="hljs-string">'THROW'</span>, <span class="hljs-string">'EXTENDS'</span>]
<span class="hljs-string">'BIN?'</span>, <span class="hljs-string">'THROW'</span>, <span class="hljs-string">'EXTENDS'</span>, <span class="hljs-string">'DEFAULT'</span>]
formatString: <span class="hljs-function"><span class="hljs-params">(str)</span> -&gt;</span>
str.replace STRING_OMIT, <span class="hljs-string">'$1'</span>
formatString: <span class="hljs-function"><span class="hljs-params">(str, options)</span> -&gt;</span>
@replaceUnicodeCodePointEscapes str.replace(STRING_OMIT, <span class="hljs-string">'$1'</span>), options
formatHeregex: <span class="hljs-function"><span class="hljs-params">(str)</span> -&gt;</span>
str.replace HEREGEX_OMIT, <span class="hljs-string">'$1$2'</span></pre></div></div>
formatHeregex: <span class="hljs-function"><span class="hljs-params">(str, options)</span> -&gt;</span>
@formatRegex str.replace(HEREGEX_OMIT, <span class="hljs-string">'$1$2'</span>), merge(options, delimiter: <span class="hljs-string">'///'</span>)
formatRegex: <span class="hljs-function"><span class="hljs-params">(str, options)</span> -&gt;</span>
@replaceUnicodeCodePointEscapes str, options
unicodeCodePointToUnicodeEscapes: <span class="hljs-function"><span class="hljs-params">(codePoint)</span> -&gt;</span>
<span class="hljs-function"> <span class="hljs-title">toUnicodeEscape</span> = <span class="hljs-params">(val)</span> -&gt;</span>
str = val.toString <span class="hljs-number">16</span>
<span class="hljs-string">"\\u<span class="hljs-subst">#{repeat <span class="hljs-string">'0'</span>, <span class="hljs-number">4</span> - str.length}</span><span class="hljs-subst">#{str}</span>"</span>
<span class="hljs-keyword">return</span> toUnicodeEscape(codePoint) <span class="hljs-keyword">if</span> codePoint &lt; <span class="hljs-number">0x10000</span></pre></div></div>
</li>
@ -1623,6 +1637,50 @@ not specified, the length of <code>value</code> will be used.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-61">&#182;</a>
</div>
<p>surrogate pair</p>
</div>
<div class="content"><div class='highlight'><pre> high = Math.floor((codePoint - <span class="hljs-number">0x10000</span>) / <span class="hljs-number">0x400</span>) + <span class="hljs-number">0xD800</span>
low = (codePoint - <span class="hljs-number">0x10000</span>) % <span class="hljs-number">0x400</span> + <span class="hljs-number">0xDC00</span>
<span class="hljs-string">"<span class="hljs-subst">#{toUnicodeEscape(high)}</span><span class="hljs-subst">#{toUnicodeEscape(low)}</span>"</span></pre></div></div>
</li>
<li id="section-62">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-62">&#182;</a>
</div>
<p>Replace <code>\u{...}</code> with <code>\uxxxx[\uxxxx]</code> in regexes without <code>u</code> flag</p>
</div>
<div class="content"><div class='highlight'><pre> replaceUnicodeCodePointEscapes: <span class="hljs-function"><span class="hljs-params">(str, options)</span> -&gt;</span>
shouldReplace = options.flags? <span class="hljs-keyword">and</span> <span class="hljs-string">'u'</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> options.flags
str.replace UNICODE_CODE_POINT_ESCAPE, <span class="hljs-function"><span class="hljs-params">(match, escapedBackslash, codePointHex, offset)</span> =&gt;</span>
<span class="hljs-keyword">return</span> escapedBackslash <span class="hljs-keyword">if</span> escapedBackslash
codePointDecimal = parseInt codePointHex, <span class="hljs-number">16</span>
<span class="hljs-keyword">if</span> codePointDecimal &gt; <span class="hljs-number">0x10ffff</span>
@error <span class="hljs-string">"unicode code point escapes greater than \\u{10ffff} are not allowed"</span>,
offset: offset + options.delimiter.length
length: codePointHex.length + <span class="hljs-number">4</span>
<span class="hljs-keyword">return</span> match <span class="hljs-keyword">unless</span> shouldReplace
@unicodeCodePointToUnicodeEscapes codePointDecimal</pre></div></div>
</li>
<li id="section-63">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-63">&#182;</a>
</div>
<p>Validates escapes in strings and regexes.</p>
</div>
@ -1635,13 +1693,13 @@ not specified, the length of <code>value</code> will be used.</p>
STRING_INVALID_ESCAPE
match = invalidEscapeRegex.exec str
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> match
[[], before, octal, hex, unicode] = match
[[], before, octal, hex, unicodeCodePoint, unicode] = match
message =
<span class="hljs-keyword">if</span> octal
<span class="hljs-string">"octal escape sequences are not allowed"</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"invalid escape sequence"</span>
invalidEscape = <span class="hljs-string">"\\<span class="hljs-subst">#{octal <span class="hljs-keyword">or</span> hex <span class="hljs-keyword">or</span> unicode}</span>"</span>
invalidEscape = <span class="hljs-string">"\\<span class="hljs-subst">#{octal <span class="hljs-keyword">or</span> hex <span class="hljs-keyword">or</span> unicodeCodePoint <span class="hljs-keyword">or</span> unicode}</span>"</span>
@error <span class="hljs-string">"<span class="hljs-subst">#{message}</span> <span class="hljs-subst">#{invalidEscape}</span>"</span>,
offset: (options.offsetInChunk ? <span class="hljs-number">0</span>) + match.index + before.length
length: invalidEscape.length</pre></div></div>
@ -1649,11 +1707,11 @@ not specified, the length of <code>value</code> will be used.</p>
</li>
<li id="section-62">
<li id="section-64">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-62">&#182;</a>
<a class="pilcrow" href="#section-64">&#182;</a>
</div>
<p>Constructs a string or regex by escaping certain characters.</p>
@ -1662,22 +1720,22 @@ not specified, the length of <code>value</code> will be used.</p>
<div class="content"><div class='highlight'><pre> makeDelimitedLiteral: <span class="hljs-function"><span class="hljs-params">(body, options = {})</span> -&gt;</span>
body = <span class="hljs-string">'(?:)'</span> <span class="hljs-keyword">if</span> body <span class="hljs-keyword">is</span> <span class="hljs-string">''</span> <span class="hljs-keyword">and</span> options.delimiter <span class="hljs-keyword">is</span> <span class="hljs-string">'/'</span>
regex = <span class="hljs-regexp">///
(\\\\) <span class="hljs-comment"># escaped backslash</span>
| (\\0(?=[1-7])) <span class="hljs-comment"># nul character mistaken as octal escape</span>
| \\?(<span class="hljs-subst">#{options.delimiter}</span>) <span class="hljs-comment"># (possibly escaped) delimiter</span>
| \\?(?: (\n)|(\r)|(\u2028)|(\u2029) ) <span class="hljs-comment"># (possibly escaped) newlines</span>
| (\\.) <span class="hljs-comment"># other escapes</span>
(\\\\) <span class="hljs-comment"># Escaped backslash.</span>
| (\\0(?=[1-7])) <span class="hljs-comment"># Null character mistaken as octal escape.</span>
| \\?(<span class="hljs-subst">#{options.delimiter}</span>) <span class="hljs-comment"># (Possibly escaped) delimiter.</span>
| \\?(?: (\n)|(\r)|(\u2028)|(\u2029) ) <span class="hljs-comment"># (Possibly escaped) newlines.</span>
| (\\.) <span class="hljs-comment"># Other escapes.</span>
///</span>g
body = body.replace regex, <span class="hljs-function"><span class="hljs-params">(match, backslash, nul, delimiter, lf, cr, ls, ps, other)</span> -&gt;</span> <span class="hljs-keyword">switch</span></pre></div></div>
</li>
<li id="section-63">
<li id="section-65">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-63">&#182;</a>
<a class="pilcrow" href="#section-65">&#182;</a>
</div>
<p>Ignore escaped backslashes.</p>
@ -1696,11 +1754,11 @@ not specified, the length of <code>value</code> will be used.</p>
</li>
<li id="section-64">
<li id="section-66">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-64">&#182;</a>
<a class="pilcrow" href="#section-66">&#182;</a>
</div>
<p>Throws an error at either a given offset from the current chunk or at the
location of a token (<code>token[2]</code>).</p>
@ -1719,11 +1777,11 @@ location of a token (<code>token[2]</code>).</p>
</li>
<li id="section-65">
<li id="section-67">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-65">&#182;</a>
<a class="pilcrow" href="#section-67">&#182;</a>
</div>
<h2 id="helper-functions">Helper functions</h2>
@ -1732,11 +1790,11 @@ location of a token (<code>token[2]</code>).</p>
</li>
<li id="section-66">
<li id="section-68">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-66">&#182;</a>
<a class="pilcrow" href="#section-68">&#182;</a>
</div>
</div>
@ -1757,11 +1815,11 @@ exports.isUnassignable = isUnassignable</pre></div></div>
</li>
<li id="section-67">
<li id="section-69">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-67">&#182;</a>
<a class="pilcrow" href="#section-69">&#182;</a>
</div>
<p><code>from</code> isnt a CoffeeScript keyword, but it behaves like one in <code>import</code> and
<code>export</code> statements (handled above) and in the declaration line of a <code>for</code>
@ -1776,11 +1834,11 @@ loop. Try to detect when <code>from</code> is a variable identifier and when it
</li>
<li id="section-68">
<li id="section-70">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-68">&#182;</a>
<a class="pilcrow" href="#section-70">&#182;</a>
</div>
<p><code>for i from from</code>, <code>for from from iterable</code></p>
@ -1793,11 +1851,11 @@ loop. Try to detect when <code>from</code> is a variable identifier and when it
</li>
<li id="section-69">
<li id="section-71">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-69">&#182;</a>
<a class="pilcrow" href="#section-71">&#182;</a>
</div>
<p><code>for i from iterable</code></p>
@ -1808,11 +1866,11 @@ loop. Try to detect when <code>from</code> is a variable identifier and when it
</li>
<li id="section-70">
<li id="section-72">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-70">&#182;</a>
<a class="pilcrow" href="#section-72">&#182;</a>
</div>
<p><code>for from…</code></p>
@ -1824,11 +1882,11 @@ loop. Try to detect when <code>from</code> is a variable identifier and when it
</li>
<li id="section-71">
<li id="section-73">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-71">&#182;</a>
<a class="pilcrow" href="#section-73">&#182;</a>
</div>
<p><code>for {from}…</code>, <code>for [from]…</code>, <code>for {a, from}…</code>, <code>for {a: from}…</code></p>
@ -1842,11 +1900,11 @@ loop. Try to detect when <code>from</code> is a variable identifier and when it
</li>
<li id="section-72">
<li id="section-74">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-72">&#182;</a>
<a class="pilcrow" href="#section-74">&#182;</a>
</div>
<h2 id="constants">Constants</h2>
@ -1855,11 +1913,11 @@ loop. Try to detect when <code>from</code> is a variable identifier and when it
</li>
<li id="section-73">
<li id="section-75">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-73">&#182;</a>
<a class="pilcrow" href="#section-75">&#182;</a>
</div>
</div>
@ -1867,11 +1925,11 @@ loop. Try to detect when <code>from</code> is a variable identifier and when it
</li>
<li id="section-74">
<li id="section-76">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-74">&#182;</a>
<a class="pilcrow" href="#section-76">&#182;</a>
</div>
<p>Keywords that CoffeeScript shares in common with JavaScript.</p>
@ -1889,11 +1947,11 @@ loop. Try to detect when <code>from</code> is a variable identifier and when it
</li>
<li id="section-75">
<li id="section-77">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-75">&#182;</a>
<a class="pilcrow" href="#section-77">&#182;</a>
</div>
<p>CoffeeScript-only keywords.</p>
@ -1921,11 +1979,11 @@ COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat COFFEE_ALIASES</pre></div></div>
</li>
<li id="section-76">
<li id="section-78">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-76">&#182;</a>
<a class="pilcrow" href="#section-78">&#182;</a>
</div>
<p>The list of keywords that are reserved by JavaScript, but not used, or are
used by CoffeeScript internally. We throw an error when these are encountered,
@ -1944,11 +2002,11 @@ STRICT_PROSCRIBED = [<span class="hljs-string">'arguments'</span>, <span class="
</li>
<li id="section-77">
<li id="section-79">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-77">&#182;</a>
<a class="pilcrow" href="#section-79">&#182;</a>
</div>
<p>The superset of both JavaScript keywords and reserved words, none of which may
be used as identifiers or properties.</p>
@ -1960,11 +2018,11 @@ be used as identifiers or properties.</p>
</li>
<li id="section-78">
<li id="section-80">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-78">&#182;</a>
<a class="pilcrow" href="#section-80">&#182;</a>
</div>
<p>The character code of the nasty Microsoft madness otherwise known as the BOM.</p>
@ -1975,11 +2033,11 @@ be used as identifiers or properties.</p>
</li>
<li id="section-79">
<li id="section-81">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-79">&#182;</a>
<a class="pilcrow" href="#section-81">&#182;</a>
</div>
<p>Token matching regexes.</p>
@ -2022,11 +2080,11 @@ HERE_JSTOKEN = <span class="hljs-regexp">///^ ``` ((?: [^`\\] | \\[\s\S] | `
</li>
<li id="section-80">
<li id="section-82">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-80">&#182;</a>
<a class="pilcrow" href="#section-82">&#182;</a>
</div>
<p>String-matching-regexes.</p>
@ -2040,8 +2098,8 @@ HEREDOC_SINGLE = ///</span> ^(?: [^\\<span class="hljs-string">'] | \\[\s\S] |
HEREDOC_DOUBLE = ///</span> ^(?: [^\\<span class="hljs-string">"#] | \\[\s\S] | "</span>(?!<span class="hljs-string">""</span>) | \<span class="hljs-comment">#(?!\{) )* ///</span>
STRING_OMIT = <span class="hljs-regexp">///
((?:\\\\)+) <span class="hljs-comment"># consume (and preserve) an even number of backslashes</span>
| \\[^\S\n]*\n\s* <span class="hljs-comment"># remove escaped newlines</span>
((?:\\\\)+) <span class="hljs-comment"># Consume (and preserve) an even number of backslashes.</span>
| \\[^\S\n]*\n\s* <span class="hljs-comment"># Remove escaped newlines.</span>
///</span>g
SIMPLE_STRING_OMIT = <span class="hljs-regexp">/\s*\n\s*/g</span>
HEREDOC_INDENT = <span class="hljs-regexp">/\n+([^\n\S]*)(?=\S)/g</span></pre></div></div>
@ -2049,11 +2107,11 @@ HEREDOC_INDENT = <span class="hljs-regexp">/\n+([^\n\S]*)(?=\S)/g</span></pr
</li>
<li id="section-81">
<li id="section-83">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-81">&#182;</a>
<a class="pilcrow" href="#section-83">&#182;</a>
</div>
<p>Regex-matching-regexes.</p>
@ -2061,23 +2119,23 @@ HEREDOC_INDENT = <span class="hljs-regexp">/\n+([^\n\S]*)(?=\S)/g</span></pr
<div class="content"><div class='highlight'><pre>REGEX = <span class="hljs-regexp">/// ^
/ (?!/) ((
?: [^ [ / \n \\ ] <span class="hljs-comment"># every other thing</span>
| \\[^\n] <span class="hljs-comment"># anything but newlines escaped</span>
| \[ <span class="hljs-comment"># character class</span>
?: [^ [ / \n \\ ] <span class="hljs-comment"># Every other thing.</span>
| \\[^\n] <span class="hljs-comment"># Anything but newlines escaped.</span>
| \[ <span class="hljs-comment"># Character class.</span>
(?: \\[^\n] | [^ \] \n \\ ] )*
\]
)*) (/)?
///</span>
REGEX_FLAGS = <span class="hljs-regexp">/^\w*/</span>
VALID_FLAGS = <span class="hljs-regexp">/^(?!.*(.).*\1)[imgy]*$/</span>
VALID_FLAGS = <span class="hljs-regexp">/^(?!.*(.).*\1)[imguy]*$/</span>
HEREGEX = <span class="hljs-regexp">/// ^(?: [^\\/<span class="hljs-comment">#] | \\[\s\S] | /(?!//) | \#(?!\{) )* ///</span>
HEREGEX_OMIT = ///</span>
((?:\\\\)+) <span class="hljs-comment"># consume (and preserve) an even number of backslashes</span>
| \\(\s) <span class="hljs-comment"># preserve escaped whitespace</span>
| \s+(?:<span class="hljs-comment">#.*)? # remove whitespace and comments</span>
((?:\\\\)+) <span class="hljs-comment"># Consume (and preserve) an even number of backslashes.</span>
| \\(\s) <span class="hljs-comment"># Preserve escaped whitespace.</span>
| \s+(?:<span class="hljs-comment">#.*)? # Remove whitespace and comments.</span>
<span class="hljs-regexp">///g
REGEX_ILLEGAL = ///</span> ^ ( / | <span class="hljs-regexp">/{3}\s*) (\*) /</span><span class="hljs-regexp">//</span>
@ -2087,11 +2145,11 @@ POSSIBLY_DIVISION = <span class="hljs-regexp">/// ^ /=?\s ///</span></pre></di
</li>
<li id="section-82">
<li id="section-84">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-82">&#182;</a>
<a class="pilcrow" href="#section-84">&#182;</a>
</div>
<p>Other regexes.</p>
@ -2102,22 +2160,30 @@ POSSIBLY_DIVISION = <span class="hljs-regexp">/// ^ /=?\s ///</span></pre></di
LINE_CONTINUER = <span class="hljs-regexp">/// ^ \s* (?: , | \??\.(?![.\d]) | :: ) ///</span>
STRING_INVALID_ESCAPE = <span class="hljs-regexp">///
( (?:^|[^\\]) (?:\\\\)* ) <span class="hljs-comment"># make sure the escape isnt escaped</span>
( (?:^|[^\\]) (?:\\\\)* ) <span class="hljs-comment"># Make sure the escape isnt escaped.</span>
\\ (
?: (0[0-7]|[1-7]) <span class="hljs-comment"># octal escape</span>
| (x(?![\da-fA-F]{2}).{0,2}) <span class="hljs-comment"># hex escape</span>
| (u(?![\da-fA-F]{4}).{0,4}) <span class="hljs-comment"># unicode escape</span>
| (u\{(?![\da-fA-F]{1,}\})[^}]*\}?) <span class="hljs-comment"># unicode code point escape</span>
| (u(?!\{|[\da-fA-F]{4}).{0,4}) <span class="hljs-comment"># unicode escape</span>
)
///</span>
REGEX_INVALID_ESCAPE = <span class="hljs-regexp">///
( (?:^|[^\\]) (?:\\\\)* ) <span class="hljs-comment"># make sure the escape isnt escaped</span>
( (?:^|[^\\]) (?:\\\\)* ) <span class="hljs-comment"># Make sure the escape isnt escaped.</span>
\\ (
?: (0[0-7]) <span class="hljs-comment"># octal escape</span>
| (x(?![\da-fA-F]{2}).{0,2}) <span class="hljs-comment"># hex escape</span>
| (u(?![\da-fA-F]{4}).{0,4}) <span class="hljs-comment"># unicode escape</span>
| (u\{(?![\da-fA-F]{1,}\})[^}]*\}?) <span class="hljs-comment"># unicode code point escape</span>
| (u(?!\{|[\da-fA-F]{4}).{0,4}) <span class="hljs-comment"># unicode escape</span>
)
///</span>
UNICODE_CODE_POINT_ESCAPE = <span class="hljs-regexp">///
( \\\\ ) <span class="hljs-comment"># Make sure the escape isnt escaped.</span>
|
\\u\{ ( [\da-fA-F]+ ) \}
///</span>g
LEADING_BLANK_LINE = <span class="hljs-regexp">/^[^\n\S]*\n/</span>
TRAILING_BLANK_LINE = <span class="hljs-regexp">/\n[^\n\S]*$/</span>
@ -2126,11 +2192,11 @@ TRAILING_SPACES = <span class="hljs-regexp">/\s+$/</span></pre></div></div>
</li>
<li id="section-83">
<li id="section-85">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-83">&#182;</a>
<a class="pilcrow" href="#section-85">&#182;</a>
</div>
<p>Compound assignment tokens.</p>
@ -2144,11 +2210,11 @@ TRAILING_SPACES = <span class="hljs-regexp">/\s+$/</span></pre></div></div>
</li>
<li id="section-84">
<li id="section-86">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-84">&#182;</a>
<a class="pilcrow" href="#section-86">&#182;</a>
</div>
<p>Unary tokens.</p>
@ -2161,11 +2227,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
</li>
<li id="section-85">
<li id="section-87">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-85">&#182;</a>
<a class="pilcrow" href="#section-87">&#182;</a>
</div>
<p>Bit-shifting tokens.</p>
@ -2176,11 +2242,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
</li>
<li id="section-86">
<li id="section-88">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-86">&#182;</a>
<a class="pilcrow" href="#section-88">&#182;</a>
</div>
<p>Comparison tokens.</p>
@ -2191,11 +2257,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
</li>
<li id="section-87">
<li id="section-89">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-87">&#182;</a>
<a class="pilcrow" href="#section-89">&#182;</a>
</div>
<p>Mathematical tokens.</p>
@ -2206,11 +2272,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
</li>
<li id="section-88">
<li id="section-90">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-88">&#182;</a>
<a class="pilcrow" href="#section-90">&#182;</a>
</div>
<p>Relational tokens that are negatable with <code>not</code> prefix.</p>
@ -2221,11 +2287,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
</li>
<li id="section-89">
<li id="section-91">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-89">&#182;</a>
<a class="pilcrow" href="#section-91">&#182;</a>
</div>
<p>Boolean tokens.</p>
@ -2236,11 +2302,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
</li>
<li id="section-90">
<li id="section-92">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-90">&#182;</a>
<a class="pilcrow" href="#section-92">&#182;</a>
</div>
<p>Tokens which could legitimately be invoked or indexed. An opening
parentheses or bracket following these tokens will be recorded as the start
@ -2257,11 +2323,11 @@ INDEXABLE = CALLABLE.concat [
</li>
<li id="section-91">
<li id="section-93">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-91">&#182;</a>
<a class="pilcrow" href="#section-93">&#182;</a>
</div>
<p>Tokens which a regular expression will never immediately follow (except spaced
CALLABLEs in some cases), but which a division operator can.</p>
@ -2274,11 +2340,11 @@ CALLABLEs in some cases), but which a division operator can.</p>
</li>
<li id="section-92">
<li id="section-94">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-92">&#182;</a>
<a class="pilcrow" href="#section-94">&#182;</a>
</div>
<p>Tokens that, when immediately preceding a <code>WHEN</code>, indicate that the <code>WHEN</code>
occurs at the start of a line. We disambiguate these from trailing whens to
@ -2291,11 +2357,11 @@ avoid an ambiguity in the grammar.</p>
</li>
<li id="section-93">
<li id="section-95">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-93">&#182;</a>
<a class="pilcrow" href="#section-95">&#182;</a>
</div>
<p>Additional indent in front of these is ignored.</p>

View File

@ -1045,7 +1045,6 @@ statement, ask the statement to do so.</p>
compiledNodes = []
<span class="hljs-keyword">for</span> node, index <span class="hljs-keyword">in</span> @expressions
node = node.unwrapAll()
node = (node.unfoldSoak(o) <span class="hljs-keyword">or</span> node)
<span class="hljs-keyword">if</span> node <span class="hljs-keyword">instanceof</span> Block</pre></div></div>
@ -1087,7 +1086,7 @@ our own</p>
fragments = node.compileToFragments o
<span class="hljs-keyword">unless</span> node.isStatement o
fragments.unshift @makeCode <span class="hljs-string">"<span class="hljs-subst">#{@tab}</span>"</span>
fragments.push @makeCode <span class="hljs-string">";"</span>
fragments.push @makeCode <span class="hljs-string">';'</span>
compiledNodes.push fragments
<span class="hljs-keyword">else</span>
compiledNodes.push node.compileToFragments o, LEVEL_LIST
@ -1440,10 +1439,10 @@ or vanilla.</p>
<div class="content"><div class='highlight'><pre>exports.Value = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Value</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Base</span></span>
constructor: <span class="hljs-function"><span class="hljs-params">(base, props, tag, isDefaultValue = <span class="hljs-literal">no</span>)</span> -&gt;</span>
<span class="hljs-keyword">return</span> base <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> props <span class="hljs-keyword">and</span> base <span class="hljs-keyword">instanceof</span> Value
<span class="hljs-keyword">super</span>()
<span class="hljs-keyword">return</span> base <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> props <span class="hljs-keyword">and</span> base <span class="hljs-keyword">instanceof</span> Value
@base = base
@properties = props <span class="hljs-keyword">or</span> []
@[tag] = <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> tag
@ -2056,10 +2055,7 @@ an access into the objects prototype.</p>
name = @name.compileToFragments o
node = @name.unwrap()
<span class="hljs-keyword">if</span> node <span class="hljs-keyword">instanceof</span> PropertyName
<span class="hljs-keyword">if</span> node.value <span class="hljs-keyword">in</span> JS_FORBIDDEN
[@makeCode(<span class="hljs-string">'["'</span>), name..., @makeCode(<span class="hljs-string">'"]'</span>)]
<span class="hljs-keyword">else</span>
[@makeCode(<span class="hljs-string">'.'</span>), name...]
[@makeCode(<span class="hljs-string">'.'</span>), name...]
<span class="hljs-keyword">else</span>
[@makeCode(<span class="hljs-string">'['</span>), name..., @makeCode(<span class="hljs-string">']'</span>)]
@ -2578,6 +2574,7 @@ are too.</p>
<span class="hljs-keyword">for</span> obj <span class="hljs-keyword">in</span> @objects
unwrappedObj = obj.unwrapAll()
unwrappedObj.lhs = <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> unwrappedObj <span class="hljs-keyword">instanceof</span> Arr <span class="hljs-keyword">or</span> unwrappedObj <span class="hljs-keyword">instanceof</span> Obj
compiledObjs = (obj.compileToFragments o, LEVEL_LIST <span class="hljs-keyword">for</span> obj <span class="hljs-keyword">in</span> @objects)
<span class="hljs-keyword">for</span> fragments, index <span class="hljs-keyword">in</span> compiledObjs
<span class="hljs-keyword">if</span> index
@ -2587,8 +2584,8 @@ are too.</p>
answer.unshift @makeCode <span class="hljs-string">"[\n<span class="hljs-subst">#{o.indent}</span>"</span>
answer.push @makeCode <span class="hljs-string">"\n<span class="hljs-subst">#{@tab}</span>]"</span>
<span class="hljs-keyword">else</span>
answer.unshift @makeCode <span class="hljs-string">"["</span>
answer.push @makeCode <span class="hljs-string">"]"</span>
answer.unshift @makeCode <span class="hljs-string">'['</span>
answer.push @makeCode <span class="hljs-string">']'</span>
answer
assigns: <span class="hljs-function"><span class="hljs-params">(name)</span> -&gt;</span>
@ -2683,11 +2680,9 @@ exports.Class = <span class="hljs-class"><span class="hljs-keyword">class</span>
result
compileClassDeclaration: <span class="hljs-function"><span class="hljs-params">(o)</span> -&gt;</span>
@ctor ?= @makeDefaultConstructor() <span class="hljs-keyword">if</span> @externalCtor <span class="hljs-keyword">or</span> @boundMethods.length
@ctor ?= @makeDefaultConstructor() <span class="hljs-keyword">if</span> @externalCtor
@ctor?.noReturn = <span class="hljs-literal">true</span>
@proxyBoundMethods o <span class="hljs-keyword">if</span> @boundMethods.length
o.indent += TAB
result = []
@ -2735,7 +2730,6 @@ exports.Class = <span class="hljs-class"><span class="hljs-keyword">class</span>
walkBody: <span class="hljs-function">-&gt;</span>
@ctor = <span class="hljs-literal">null</span>
@boundMethods = []
executableBody = <span class="hljs-literal">null</span>
initializer = []
@ -2805,11 +2799,8 @@ exports.Class = <span class="hljs-class"><span class="hljs-keyword">class</span>
<span class="hljs-keyword">if</span> method.ctor
method.error <span class="hljs-string">'Cannot define more than one constructor in a class'</span> <span class="hljs-keyword">if</span> @ctor
@ctor = method
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> method.bound <span class="hljs-keyword">and</span> method.isStatic
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> method.isStatic <span class="hljs-keyword">and</span> method.bound
method.context = @name
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> method.bound
@boundMethods.push method.name
method.bound = <span class="hljs-literal">false</span>
<span class="hljs-keyword">if</span> initializer.length <span class="hljs-keyword">isnt</span> expressions.length
@body.expressions = (expression.hoist() <span class="hljs-keyword">for</span> expression <span class="hljs-keyword">in</span> initializer)
@ -2882,7 +2873,7 @@ When additional expressions become valid, this method should be updated to handl
method.name = <span class="hljs-keyword">new</span> (<span class="hljs-keyword">if</span> methodName.shouldCache() <span class="hljs-keyword">then</span> Index <span class="hljs-keyword">else</span> Access) methodName
method.name.updateLocationDataIfMissing methodName.locationData
method.ctor = (<span class="hljs-keyword">if</span> @parent <span class="hljs-keyword">then</span> <span class="hljs-string">'derived'</span> <span class="hljs-keyword">else</span> <span class="hljs-string">'base'</span>) <span class="hljs-keyword">if</span> methodName.value <span class="hljs-keyword">is</span> <span class="hljs-string">'constructor'</span>
method.error <span class="hljs-string">'Cannot define a constructor as a bound function'</span> <span class="hljs-keyword">if</span> method.bound <span class="hljs-keyword">and</span> method.ctor
method.error <span class="hljs-string">'Methods cannot be bound functions'</span> <span class="hljs-keyword">if</span> method.bound
method
@ -2901,13 +2892,6 @@ When additional expressions become valid, this method should be updated to handl
ctor
proxyBoundMethods: <span class="hljs-function"><span class="hljs-params">(o)</span> -&gt;</span>
@ctor.thisAssignments = <span class="hljs-keyword">for</span> name <span class="hljs-keyword">in</span> @boundMethods <span class="hljs-keyword">by</span> <span class="hljs-number">-1</span>
name = <span class="hljs-keyword">new</span> Value(<span class="hljs-keyword">new</span> ThisLiteral, [ name ]).compile o
<span class="hljs-keyword">new</span> Literal <span class="hljs-string">"<span class="hljs-subst">#{name}</span> = <span class="hljs-subst">#{utility <span class="hljs-string">'bind'</span>, o}</span>(<span class="hljs-subst">#{name}</span>, this)"</span>
<span class="hljs-literal">null</span>
exports.ExecutableClassBody = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ExecutableClassBody</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Base</span></span>
children: [ <span class="hljs-string">'class'</span>, <span class="hljs-string">'body'</span> ]
@ -3441,9 +3425,6 @@ destructured variables.</p>
<span class="hljs-keyword">if</span> @variable.shouldCache()
compiledName.unshift @makeCode <span class="hljs-string">'['</span>
compiledName.push @makeCode <span class="hljs-string">']'</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> fragmentsToText(compiledName) <span class="hljs-keyword">in</span> JS_FORBIDDEN
compiledName.unshift @makeCode <span class="hljs-string">'"'</span>
compiledName.push @makeCode <span class="hljs-string">'"'</span>
<span class="hljs-keyword">return</span> compiledName.concat @makeCode(<span class="hljs-string">": "</span>), val
answer = compiledName.concat @makeCode(<span class="hljs-string">" <span class="hljs-subst">#{ @context <span class="hljs-keyword">or</span> <span class="hljs-string">'='</span> }</span> "</span>), val</pre></div></div>
@ -3676,7 +3657,7 @@ etc.</p>
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> expandedIdx <span class="hljs-keyword">and</span> obj <span class="hljs-keyword">instanceof</span> Splat
name = obj.name.unwrap().value
obj = obj.unwrap()
val = <span class="hljs-string">"<span class="hljs-subst">#{olen}</span> &lt;= <span class="hljs-subst">#{vvarText}</span>.length ? <span class="hljs-subst">#{ utility <span class="hljs-string">'slice'</span>, o }</span>.call(<span class="hljs-subst">#{vvarText}</span>, <span class="hljs-subst">#{i}</span>"</span>
val = <span class="hljs-string">"<span class="hljs-subst">#{olen}</span> &lt;= <span class="hljs-subst">#{vvarText}</span>.length ? <span class="hljs-subst">#{utility <span class="hljs-string">'slice'</span>, o}</span>.call(<span class="hljs-subst">#{vvarText}</span>, <span class="hljs-subst">#{i}</span>"</span>
rest = olen - i - <span class="hljs-number">1</span>
<span class="hljs-keyword">if</span> rest <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span>
ivar = o.scope.freeVariable <span class="hljs-string">'i'</span>, single: <span class="hljs-literal">true</span>
@ -3863,7 +3844,7 @@ extended form <code>a = a ** b</code> and then compiles that.</p>
<span class="hljs-keyword">else</span>
to = <span class="hljs-string">"9e9"</span>
[valDef, valRef] = @value.cache o, LEVEL_LIST
answer = [].concat @makeCode(<span class="hljs-string">"[].splice.apply(<span class="hljs-subst">#{name}</span>, [<span class="hljs-subst">#{fromDecl}</span>, <span class="hljs-subst">#{to}</span>].concat("</span>), valDef, @makeCode(<span class="hljs-string">")), "</span>), valRef
answer = [].concat @makeCode(<span class="hljs-string">"<span class="hljs-subst">#{utility <span class="hljs-string">'splice'</span>, o}</span>.apply(<span class="hljs-subst">#{name}</span>, [<span class="hljs-subst">#{fromDecl}</span>, <span class="hljs-subst">#{to}</span>].concat("</span>), valDef, @makeCode(<span class="hljs-string">")), "</span>), valRef
<span class="hljs-keyword">if</span> o.level &gt; LEVEL_TOP <span class="hljs-keyword">then</span> @wrapInParentheses answer <span class="hljs-keyword">else</span> answer
eachName: <span class="hljs-function"><span class="hljs-params">(iterator)</span> -&gt;</span>
@ -4906,6 +4887,8 @@ CoffeeScript operations into their JavaScript equivalents.</p>
<div class="content"><div class='highlight'><pre>exports.Op = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Op</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Base</span></span>
constructor: <span class="hljs-function"><span class="hljs-params">(op, first, second, flip)</span> -&gt;</span>
<span class="hljs-keyword">super</span>()
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> In first, second <span class="hljs-keyword">if</span> op <span class="hljs-keyword">is</span> <span class="hljs-string">'in'</span>
<span class="hljs-keyword">if</span> op <span class="hljs-keyword">is</span> <span class="hljs-string">'do'</span>
<span class="hljs-keyword">return</span> Op::generateDo first
@ -4913,8 +4896,6 @@ CoffeeScript operations into their JavaScript equivalents.</p>
<span class="hljs-keyword">return</span> first.newInstance() <span class="hljs-keyword">if</span> first <span class="hljs-keyword">instanceof</span> Call <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> first.<span class="hljs-keyword">do</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> first.isNew
first = <span class="hljs-keyword">new</span> Parens first <span class="hljs-keyword">if</span> first <span class="hljs-keyword">instanceof</span> Code <span class="hljs-keyword">and</span> first.bound <span class="hljs-keyword">or</span> first.<span class="hljs-keyword">do</span>
<span class="hljs-keyword">super</span>()
@operator = CONVERSIONS[op] <span class="hljs-keyword">or</span> op
@first = first
@second = second
@ -5512,7 +5493,8 @@ parentheses, but no longer you can put in as many as you please.</p>
<span class="hljs-keyword">return</span> expr.compileToFragments o
fragments = expr.compileToFragments o, LEVEL_PAREN
bare = o.level &lt; LEVEL_OP <span class="hljs-keyword">and</span> (expr <span class="hljs-keyword">instanceof</span> Op <span class="hljs-keyword">or</span> expr <span class="hljs-keyword">instanceof</span> Call <span class="hljs-keyword">or</span>
(expr <span class="hljs-keyword">instanceof</span> For <span class="hljs-keyword">and</span> expr.returns))
(expr <span class="hljs-keyword">instanceof</span> For <span class="hljs-keyword">and</span> expr.returns)) <span class="hljs-keyword">and</span> (o.level &lt; LEVEL_COND <span class="hljs-keyword">or</span>
fragments.length &lt;= <span class="hljs-number">3</span>)
<span class="hljs-keyword">if</span> bare <span class="hljs-keyword">then</span> fragments <span class="hljs-keyword">else</span> @wrapInParentheses fragments</pre></div></div>
</li>
@ -5840,7 +5822,7 @@ some cannot.</p>
fragments = fragments.concat body, @makeCode(<span class="hljs-string">'\n'</span>) <span class="hljs-keyword">if</span> (body = block.compileToFragments o, LEVEL_TOP).length &gt; <span class="hljs-number">0</span>
<span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> i <span class="hljs-keyword">is</span> @cases.length - <span class="hljs-number">1</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> @otherwise
expr = @lastNonComment block.expressions
<span class="hljs-keyword">continue</span> <span class="hljs-keyword">if</span> expr <span class="hljs-keyword">instanceof</span> Return <span class="hljs-keyword">or</span> (expr <span class="hljs-keyword">instanceof</span> Literal <span class="hljs-keyword">and</span> expr.jumps() <span class="hljs-keyword">and</span> expr.value <span class="hljs-keyword">isnt</span> <span class="hljs-string">'debugger'</span>)
<span class="hljs-keyword">continue</span> <span class="hljs-keyword">if</span> expr <span class="hljs-keyword">instanceof</span> Return <span class="hljs-keyword">or</span> expr <span class="hljs-keyword">instanceof</span> Throw <span class="hljs-keyword">or</span> (expr <span class="hljs-keyword">instanceof</span> Literal <span class="hljs-keyword">and</span> expr.jumps() <span class="hljs-keyword">and</span> expr.value <span class="hljs-keyword">isnt</span> <span class="hljs-string">'debugger'</span>)
fragments.push cond.makeCode(idt2 + <span class="hljs-string">'break;\n'</span>)
<span class="hljs-keyword">if</span> @otherwise <span class="hljs-keyword">and</span> @otherwise.expressions.length
fragments.push @makeCode(idt1 + <span class="hljs-string">"default:\n"</span>), (@otherwise.compileToFragments o, LEVEL_TOP)..., @makeCode(<span class="hljs-string">"\n"</span>)
@ -6028,7 +6010,8 @@ force inner <em>else</em> bodies into statement form.</p>
</div>
<div class="content"><div class='highlight'><pre>
UTILITIES =</pre></div></div>
UTILITIES =
modulo: <span class="hljs-function">-&gt;</span> <span class="hljs-string">'function(a, b) { return (+a % (b = +b) + b) % b; }'</span></pre></div></div>
</li>
@ -6039,24 +6022,14 @@ UTILITIES =</pre></div></div>
<div class="pilwrap ">
<a class="pilcrow" href="#section-233">&#182;</a>
</div>
<p>Correctly set up a prototype chain for inheritance, including a reference
to the superclass for <code>super()</code> calls, and copies of any static properties.</p>
<p>Shortcuts to speed up the lookup time for native functions.</p>
</div>
<div class="content"><div class='highlight'><pre> extend: <span class="hljs-function"><span class="hljs-params">(o)</span> -&gt;</span> <span class="hljs-string">"
function(child, parent) {
for (var key in parent) {
if (<span class="hljs-subst">#{utility <span class="hljs-string">'hasProp'</span>, o}</span>.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor();
return child;
}
"</span></pre></div></div>
<div class="content"><div class='highlight'><pre> hasProp: <span class="hljs-function">-&gt;</span> <span class="hljs-string">'{}.hasOwnProperty'</span>
indexOf: <span class="hljs-function">-&gt;</span> <span class="hljs-string">'[].indexOf'</span>
slice : <span class="hljs-function">-&gt;</span> <span class="hljs-string">'[].slice'</span>
splice : <span class="hljs-function">-&gt;</span> <span class="hljs-string">'[].splice'</span></pre></div></div>
</li>
@ -6067,69 +6040,6 @@ to the superclass for <code>super()</code> calls, and copies of any static prope
<div class="pilwrap ">
<a class="pilcrow" href="#section-234">&#182;</a>
</div>
<p>Create a function bound to the current value of “this”.</p>
</div>
<div class="content"><div class='highlight'><pre> bind: <span class="hljs-function">-&gt;</span> <span class="hljs-string">'
function(fn, me){
return function(){
return fn.apply(me, arguments);
};
}
'</span></pre></div></div>
</li>
<li id="section-235">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-235">&#182;</a>
</div>
<p>Discover if an item is in an array.</p>
</div>
<div class="content"><div class='highlight'><pre> indexOf: <span class="hljs-function">-&gt;</span> <span class="hljs-string">"
[].indexOf || function(item) {
for (var i = 0, l = this.length; i &lt; l; i++) {
if (i in this &amp;&amp; this[i] === item) return i;
}
return -1;
}
"</span>
modulo: <span class="hljs-function">-&gt;</span> <span class="hljs-string">"""
function(a, b) { return (+a % (b = +b) + b) % b; }
"""</span></pre></div></div>
</li>
<li id="section-236">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-236">&#182;</a>
</div>
<p>Shortcuts to speed up the lookup time for native functions.</p>
</div>
<div class="content"><div class='highlight'><pre> hasProp: <span class="hljs-function">-&gt;</span> <span class="hljs-string">'{}.hasOwnProperty'</span>
slice : <span class="hljs-function">-&gt;</span> <span class="hljs-string">'[].slice'</span></pre></div></div>
</li>
<li id="section-237">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-237">&#182;</a>
</div>
<p>Levels indicate a nodes position in the AST. Useful for knowing if
parens are necessary or superfluous.</p>
@ -6145,11 +6055,11 @@ LEVEL_ACCESS = <span class="hljs-number">6</span> <span class="hljs-comment">#
</li>
<li id="section-238">
<li id="section-235">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-238">&#182;</a>
<a class="pilcrow" href="#section-235">&#182;</a>
</div>
<p>Tabs are two spaces for pretty printing.</p>
@ -6162,11 +6072,11 @@ SIMPLENUM = <span class="hljs-regexp">/^[+-]?\d+$/</span></pre></div></div>
</li>
<li id="section-239">
<li id="section-236">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-239">&#182;</a>
<a class="pilcrow" href="#section-236">&#182;</a>
</div>
<h2 id="helper-functions">Helper Functions</h2>
@ -6175,11 +6085,11 @@ SIMPLENUM = <span class="hljs-regexp">/^[+-]?\d+$/</span></pre></div></div>
</li>
<li id="section-240">
<li id="section-237">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-240">&#182;</a>
<a class="pilcrow" href="#section-237">&#182;</a>
</div>
</div>
@ -6187,11 +6097,11 @@ SIMPLENUM = <span class="hljs-regexp">/^[+-]?\d+$/</span></pre></div></div>
</li>
<li id="section-241">
<li id="section-238">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-241">&#182;</a>
<a class="pilcrow" href="#section-238">&#182;</a>
</div>
<p>Helper for ensuring that utility functions are assigned at the top level.</p>
@ -6221,11 +6131,11 @@ SIMPLENUM = <span class="hljs-regexp">/^[+-]?\d+$/</span></pre></div></div>
</li>
<li id="section-242">
<li id="section-239">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-242">&#182;</a>
<a class="pilcrow" href="#section-239">&#182;</a>
</div>
<p>Unfold a nodes child if soak, then tuck the node under created <code>If</code></p>

View File

@ -118,7 +118,7 @@
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./'</span>
child_process = <span class="hljs-built_in">require</span> <span class="hljs-string">'child_process'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span></pre></div></div>

View File

@ -122,12 +122,14 @@
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
nodeREPL = <span class="hljs-built_in">require</span> <span class="hljs-string">'repl'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./'</span>
{merge, updateSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
replDefaults =
prompt: <span class="hljs-string">'coffee&gt; '</span>,
historyFile: path.join process.env.HOME, <span class="hljs-string">'.coffee_history'</span> <span class="hljs-keyword">if</span> process.env.HOME
historyFile: <span class="hljs-keyword">do</span> -&gt;
historyPath = process.env.XDG_CACHE_HOME <span class="hljs-keyword">or</span> process.env.HOME
path.join historyPath, <span class="hljs-string">'.coffee_history'</span> <span class="hljs-keyword">if</span> historyPath
historyMaxInputSize: <span class="hljs-number">10240</span>
eval: <span class="hljs-function"><span class="hljs-params">(input, context, filename, cb)</span> -&gt;</span></pre></div></div>
@ -585,7 +587,7 @@ Unwrap that too.</p>
<span class="hljs-built_in">module</span>.exports =
start: <span class="hljs-function"><span class="hljs-params">(opts = {})</span> -&gt;</span>
[major, minor, build] = process.versions.node.split(<span class="hljs-string">'.'</span>).map (n) -&gt; parseInt(n)
[major, minor, build] = process.versions.node.split(<span class="hljs-string">'.'</span>).map (n) -&gt; parseInt(n, <span class="hljs-number">10</span>)
<span class="hljs-keyword">if</span> major &lt; <span class="hljs-number">6</span>
<span class="hljs-built_in">console</span>.warn <span class="hljs-string">"Node 6+ required for CoffeeScript REPL"</span>

View File

@ -157,7 +157,7 @@ its internal array of tokens.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">exports</span>.<span class="hljs-title">Rewriter</span></span></pre></div></div>
<div class="content"><div class='highlight'><pre>exports.Rewriter = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Rewriter</span></span></pre></div></div>
</li>
@ -168,11 +168,16 @@ its internal array of tokens.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Helpful snippet for debugging:</p>
<pre><code><span class="hljs-built_in">console</span>.log (t[<span class="hljs-number">0</span>] + <span class="hljs-string">'/'</span> + t[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> @tokens).join <span class="hljs-string">' '</span>
</code></pre>
<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 efficient switch, but its much nicer to work with
like this. The order of these passes matters indentation must be
corrected before implicit parentheses can be wrapped around blocks of code.</p>
</div>
<div class="content"><div class='highlight'><pre> rewrite: <span class="hljs-function"><span class="hljs-params">(@tokens)</span> -&gt;</span></pre></div></div>
</li>
@ -182,16 +187,12 @@ its internal array of tokens.</p>
<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 efficient switch, but its much nicer to work with
like this. The order of these passes matters indentation must be
corrected before implicit parentheses can be wrapped around blocks of code.</p>
<p>Helpful snippet for debugging:
console.log (t[0] + / + t[1] for t in @tokens).join </p>
</div>
<div class="content"><div class='highlight'><pre> rewrite: <span class="hljs-function"><span class="hljs-params">(@tokens)</span> -&gt;</span>
@removeLeadingNewlines()
<div class="content"><div class='highlight'><pre> @removeLeadingNewlines()
@closeOpenCalls()
@closeOpenIndexes()
@normalizeLines()
@ -449,9 +450,12 @@ and spliced, when returning for getting a new token.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">inImplicit</span> = -&gt;</span> stackTop()?[<span class="hljs-number">2</span>]?.ours
<span class="hljs-function"> <span class="hljs-title">inImplicitCall</span> = -&gt;</span> inImplicit() <span class="hljs-keyword">and</span> stackTop()?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'('</span>
<span class="hljs-function"> <span class="hljs-title">inImplicitObject</span> = -&gt;</span> inImplicit() <span class="hljs-keyword">and</span> stackTop()?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'{'</span></pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">isImplicit</span> = <span class="hljs-params">(stackItem)</span> -&gt;</span> stackItem?[<span class="hljs-number">2</span>]?.ours
<span class="hljs-function"> <span class="hljs-title">isImplicitObject</span> = <span class="hljs-params">(stackItem)</span> -&gt;</span> isImplicit(stackItem) <span class="hljs-keyword">and</span> stackItem?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'{'</span>
<span class="hljs-function"> <span class="hljs-title">isImplicitCall</span> = <span class="hljs-params">(stackItem)</span> -&gt;</span> isImplicit(stackItem) <span class="hljs-keyword">and</span> stackItem?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'('</span>
<span class="hljs-function"> <span class="hljs-title">inImplicit</span> = -&gt;</span> isImplicit stackTop()
<span class="hljs-function"> <span class="hljs-title">inImplicitCall</span> = -&gt;</span> isImplicitCall stackTop()
<span class="hljs-function"> <span class="hljs-title">inImplicitObject</span> = -&gt;</span> isImplicitObject stackTop()</pre></div></div>
</li>
@ -467,7 +471,7 @@ class declaration or if-conditionals)</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">inImplicitControl</span> = -&gt;</span> inImplicit <span class="hljs-keyword">and</span> stackTop()?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'CONTROL'</span>
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">inImplicitControl</span> = -&gt;</span> inImplicit() <span class="hljs-keyword">and</span> stackTop()?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'CONTROL'</span>
<span class="hljs-function">
<span class="hljs-title">startImplicitCall</span> = <span class="hljs-params">(j)</span> -&gt;</span>
idx = j ? i
@ -509,7 +513,7 @@ class declaration or if-conditionals)</p>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> inImplicitCall() <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">in</span> [<span class="hljs-string">'IF'</span>, <span class="hljs-string">'TRY'</span>, <span class="hljs-string">'FINALLY'</span>, <span class="hljs-string">'CATCH'</span>,
<span class="hljs-string">'CLASS'</span>, <span class="hljs-string">'SWITCH'</span>]
stack.push [<span class="hljs-string">'CONTROL'</span>, i, ours: <span class="hljs-literal">true</span>]
stack.push [<span class="hljs-string">'CONTROL'</span>, i, ours: <span class="hljs-literal">yes</span>]
<span class="hljs-keyword">return</span> forward(<span class="hljs-number">1</span>)
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'INDENT'</span> <span class="hljs-keyword">and</span> inImplicit()</pre></div></div>
@ -734,8 +738,22 @@ like e.g.:</p>
</code></pre>
</div>
<div class="content"><div class='highlight'><pre>
stackTop()[<span class="hljs-number">2</span>].sameLine = <span class="hljs-literal">no</span> <span class="hljs-keyword">if</span> inImplicitObject() <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">in</span> LINEBREAKS
</li>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>Mark all enclosing objects as not sameLine</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> LINEBREAKS
<span class="hljs-keyword">for</span> stackItem <span class="hljs-keyword">in</span> stack <span class="hljs-keyword">by</span> <span class="hljs-number">-1</span> <span class="hljs-keyword">when</span> isImplicitObject stackItem
stackItem[<span class="hljs-number">2</span>].sameLine = <span class="hljs-literal">no</span>
newLine = prevTag <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">or</span> prevToken.newLine
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> IMPLICIT_END <span class="hljs-keyword">or</span> tag <span class="hljs-keyword">in</span> CALL_CLOSERS <span class="hljs-keyword">and</span> newLine
@ -745,11 +763,11 @@ like e.g.:</p>
</li>
<li id="section-29">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Close implicit calls when reached end of argument list</p>
@ -761,11 +779,11 @@ like e.g.:</p>
</li>
<li id="section-30">
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<a class="pilcrow" href="#section-31">&#182;</a>
</div>
<p>Close implicit objects such as:
return a: 1, b: 2 unless true</p>
@ -779,11 +797,11 @@ return a: 1, b: 2 unless true</p>
</li>
<li id="section-31">
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<a class="pilcrow" href="#section-32">&#182;</a>
</div>
<p>Close implicit objects when at end of line, line didnt end with a comma
and the implicit object didnt start the line or the next line doesnt look like
@ -801,11 +819,11 @@ the continuation of an object.</p>
</li>
<li id="section-32">
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<a class="pilcrow" href="#section-33">&#182;</a>
</div>
<p>Close implicit object if comma is the last character
and what comes after doesnt look like it belongs.
@ -826,11 +844,11 @@ e = <span class="hljs-number">2</span>
</li>
<li id="section-33">
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<a class="pilcrow" href="#section-34">&#182;</a>
</div>
<p>When nextTag is OUTDENT the comma is insignificant and
should just be ignored so embed it in the implicit object.</p>
@ -848,11 +866,11 @@ array further up the stack, so give it a chance.</p>
</li>
<li id="section-34">
<li id="section-35">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<a class="pilcrow" href="#section-35">&#182;</a>
</div>
<p>Add location data to all tokens generated by the rewriter.</p>
@ -878,11 +896,11 @@ array further up the stack, so give it a chance.</p>
</li>
<li id="section-35">
<li id="section-36">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a>
<a class="pilcrow" href="#section-36">&#182;</a>
</div>
<p>OUTDENT tokens should always be positioned at the last character of the
previous token, so that AST nodes ending in an OUTDENT token end up with a
@ -906,11 +924,11 @@ location corresponding to the last “real” token under the node.</p>
</li>
<li id="section-36">
<li id="section-37">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a>
<a class="pilcrow" href="#section-37">&#182;</a>
</div>
<p>Because our grammar is LALR(1), it cant handle some single-line
expressions that lack ending delimiters. The <strong>Rewriter</strong> adds the implicit
@ -928,7 +946,8 @@ blocks are added.</p>
<span class="hljs-keyword">not</span> (token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span> <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> EXPRESSION_CLOSE) <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span> starter <span class="hljs-keyword">isnt</span> <span class="hljs-string">'THEN'</span>) <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'CATCH'</span>, <span class="hljs-string">'FINALLY'</span>] <span class="hljs-keyword">and</span> starter <span class="hljs-keyword">in</span> [<span class="hljs-string">'-&gt;'</span>, <span class="hljs-string">'=&gt;'</span>]) <span class="hljs-keyword">or</span>
token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> CALL_CLOSERS <span class="hljs-keyword">and</span> @tokens[i - <span class="hljs-number">1</span>].newLine
token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> CALL_CLOSERS <span class="hljs-keyword">and</span>
(@tokens[i - <span class="hljs-number">1</span>].newLine <span class="hljs-keyword">or</span> @tokens[i - <span class="hljs-number">1</span>][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span>)
<span class="hljs-function">
<span class="hljs-title">action</span> = <span class="hljs-params">(token, i)</span> -&gt;</span>
@tokens.splice (<span class="hljs-keyword">if</span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">','</span> <span class="hljs-keyword">then</span> i - <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> i), <span class="hljs-number">0</span>, outdent
@ -960,11 +979,11 @@ blocks are added.</p>
</li>
<li id="section-37">
<li id="section-38">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-37">&#182;</a>
<a class="pilcrow" href="#section-38">&#182;</a>
</div>
<p>Tag postfix conditionals as such, so that we can parse them with a
different precedence.</p>
@ -993,11 +1012,11 @@ different precedence.</p>
</li>
<li id="section-38">
<li id="section-39">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-38">&#182;</a>
<a class="pilcrow" href="#section-39">&#182;</a>
</div>
<p>Generate the indentation tokens, based on another token on the same line.</p>
@ -1018,11 +1037,11 @@ different precedence.</p>
</li>
<li id="section-39">
<li id="section-40">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-39">&#182;</a>
<a class="pilcrow" href="#section-40">&#182;</a>
</div>
<p>Look up a tag by token index.</p>
@ -1033,26 +1052,14 @@ different precedence.</p>
</li>
<li id="section-40">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-40">&#182;</a>
</div>
<h2 id="constants">Constants</h2>
</div>
</li>
<li id="section-41">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-41">&#182;</a>
</div>
<h2 id="constants">Constants</h2>
</div>
</li>
@ -1064,6 +1071,18 @@ different precedence.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-42">&#182;</a>
</div>
</div>
</li>
<li id="section-43">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-43">&#182;</a>
</div>
<p>List of the token pairs that must be balanced.</p>
</div>
@ -1083,11 +1102,11 @@ different precedence.</p>
</li>
<li id="section-43">
<li id="section-44">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-43">&#182;</a>
<a class="pilcrow" href="#section-44">&#182;</a>
</div>
<p>The inverse mappings of <code>BALANCED_PAIRS</code> were trying to fix up, so we can
look things up from either end.</p>
@ -1099,11 +1118,11 @@ look things up from either end.</p>
</li>
<li id="section-44">
<li id="section-45">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-44">&#182;</a>
<a class="pilcrow" href="#section-45">&#182;</a>
</div>
<p>The tokens that signal the start/end of a balanced pair.</p>
@ -1119,11 +1138,11 @@ EXPRESSION_END = []
</li>
<li id="section-45">
<li id="section-46">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-45">&#182;</a>
<a class="pilcrow" href="#section-46">&#182;</a>
</div>
<p>Tokens that indicate the close of a clause of an expression.</p>
@ -1134,11 +1153,11 @@ EXPRESSION_END = []
</li>
<li id="section-46">
<li id="section-47">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-46">&#182;</a>
<a class="pilcrow" href="#section-47">&#182;</a>
</div>
<p>Tokens that, if followed by an <code>IMPLICIT_CALL</code>, indicate a function invocation.</p>
@ -1149,11 +1168,11 @@ EXPRESSION_END = []
</li>
<li id="section-47">
<li id="section-48">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-47">&#182;</a>
<a class="pilcrow" href="#section-48">&#182;</a>
</div>
<p>If preceded by an <code>IMPLICIT_FUNC</code>, indicates a function invocation.</p>
@ -1173,11 +1192,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="hljs-string">'+'</span>, <span class="hlj
</li>
<li id="section-48">
<li id="section-49">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-48">&#182;</a>
<a class="pilcrow" href="#section-49">&#182;</a>
</div>
<p>Tokens that always mark the end of an implicit call for single-liners.</p>
@ -1189,11 +1208,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="hljs-string">'+'</span>, <span class="hlj
</li>
<li id="section-49">
<li id="section-50">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-49">&#182;</a>
<a class="pilcrow" href="#section-50">&#182;</a>
</div>
<p>Single-line flavors of block expressions that have unclosed endings.
The grammar cant disambiguate them, so we insert the implicit indentation.</p>
@ -1206,11 +1225,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
</li>
<li id="section-50">
<li id="section-51">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-50">&#182;</a>
<a class="pilcrow" href="#section-51">&#182;</a>
</div>
<p>Tokens that end a line.</p>
@ -1221,11 +1240,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
</li>
<li id="section-51">
<li id="section-52">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-51">&#182;</a>
<a class="pilcrow" href="#section-52">&#182;</a>
</div>
<p>Tokens that close open calls when they follow a newline.</p>

File diff suppressed because one or more lines are too long

View File

@ -730,7 +730,7 @@ textarea {
</ul>
</li>
<li class="nav-item">
<a href="#changelog" class="nav-link" data-action="sidebar-nav">Change Log</a>
<a href="#changelog" class="nav-link" data-action="sidebar-nav">Changelog</a>
</li>
</ul>
</nav>
@ -751,7 +751,7 @@ textarea {
<section id="overview">
<p><strong>CoffeeScript is a little language that compiles into JavaScript.</strong> Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.</p>
<p>The golden rule of CoffeeScript is: <em>“Its just JavaScript.”</em> The code 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, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.</p>
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.0.0-beta1">2.0.0-beta1</a></p>
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.0.0-beta2">2.0.0-beta2</a></p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install -g coffeescript@next
</code></pre>
</blockquote>
@ -863,10 +863,12 @@ cubes = (function() {
<p>To install, first make sure you have a working copy of the latest stable version of <a href="https://nodejs.org/">Node.js</a>. You can then install CoffeeScript globally with <a href="https://www.npmjs.com/">npm</a>:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install --global coffeescript@next
</code></pre>
</blockquote><p>When you need CoffeeScript as a dependency of a project, within that projects folder you can install it locally:</p>
</blockquote><p>This will make the <code>coffee</code> and <code>cake</code> commands available globally.</p>
<p>When you need CoffeeScript as a dependency of a project, within that projects folder you can install it locally:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install --save coffeescript@next
</code></pre>
</blockquote>
</blockquote><p>The <code>coffee</code> and <code>cake</code> commands will first look in the current folder to see if CoffeeScript is installed locally, and use that version if so. This allows different versions of CoffeeScript to be installed globally and locally.</p>
</section>
<section id="usage">
<h2>Usage</h2>
@ -3249,7 +3251,7 @@ The CoffeeScript logo is available in SVG for use in presentations.</li>
</section>
<section id="annotated-source">
<h2>Annotated Source</h2>
<p>You can browse the CoffeeScript 2.0.0-beta1 source in readable, annotated form <a href="http://coffeescript.org/v2/annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
<p>You can browse the CoffeeScript 2.0.0-beta2 source in readable, annotated form <a href="http://coffeescript.org/v2/annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
<ul>
<li><a href="http://coffeescript.org/v2/annotated-source/grammar.html">Grammar Rules — src/grammar</a></li>
<li><a href="http://coffeescript.org/v2/annotated-source/lexer.html">Lexing Tokens — src/lexer</a></li>
@ -3452,14 +3454,20 @@ f = function*() {
</code></pre>
</blockquote><p>Derived (extended) class <code>constructor</code>s cannot use <code>this</code> before calling <code>super</code>:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">B</span> <span class="keyword">extends</span> <span class="title">A</span></span>
constructor: <span class="function">-&gt;</span> <span class="keyword">this</span>
<span class="comment"># Throws a compiler error</span>
constructor: <span class="function">-&gt;</span> <span class="keyword">this</span> <span class="comment"># Throws a compiler error</span>
</code></pre>
</blockquote><p>Class methods cant be bound (i.e. you cant define a class method using a fat arrow) though you can define such methods in the constructor instead:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">B</span> <span class="keyword">extends</span> <span class="title">A</span></span>
method: <span class="function">=&gt;</span> <span class="comment"># Throws a compiler error</span>
constructor: <span class="function">-&gt;</span>
<span class="keyword">super</span>()
@method = <span class="function">=&gt;</span> <span class="comment"># This works</span>
</code></pre>
</blockquote><p>Class methods cant be used with <code>new</code> (uncommon):</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">Namespace</span></span>
@Klass = <span class="function">-&gt;</span>
<span class="keyword">new</span> Namespace.Klass
<span class="comment"># Throws a TypeError at runtime</span>
<span class="keyword">new</span> Namespace.Klass <span class="comment"># Throws a TypeError at runtime</span>
</code></pre>
</blockquote><p>Due to the hoisting required to compile to ES2015 classes, dynamic keys in class methods cant use values from the executable class body unless the methods are assigned in prototype style.</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">A</span></span>
@ -3621,7 +3629,36 @@ B = class B extends A {
</section>
</section>
<section id="changelog">
<h2>Change Log</h2>
<h2>Changelog</h2>
<div class="anchor" id="2.0.0-beta2"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/2.0.0-beta1...2.0.0-beta2">2.0.0-beta2</a>
<span class="timestamp"> &mdash; <time datetime="2017-05-16">May 16, 2017</time></span>
</h2><ul>
<li>This release includes <a href="#1.12.6">all the changes from 1.12.5 to 1.12.6</a>.</li>
<li>Bound (fat arrow) methods in classes must be declared in the class constructor, after <code>super()</code> if the class is extending a parent class. See <a href="#breaking-changes-classes">breaking changes for classes</a>.</li>
<li>All unnecessary utility helper functions have been removed, including the polyfills for <code>indexOf</code> and <code>bind</code>.</li>
<li>The <code>extends</code> keyword now only works in the context of classes; it cannot be used to extend a function prototype. See <a href="#breaking-changes-super-extends">breaking changes for <code>extends</code></a>.</li>
<li>Literate CoffeeScript is now parsed entirely based on indentation, similar to the 1.x implementation; there is no longer a dependency for parsing Markdown. See <a href="#breaking-changes-literate-coffeescript">breaking changes for Literate CoffeeScript parsing</a>.</li>
<li>JavaScript reserved words used as properties are no longer wrapped in quotes.</li>
<li><code>require('coffeescript')</code> should now work in non-Node environments such as the builds created by Webpack or Browserify. This provides a more convenient way to include the browser compiler in builds intending to run in a browser environment.</li>
<li>Unreachable <code>break</code> statements are no longer added after <code>switch</code> cases that <code>throw</code> exceptions.</li>
<li>The browser compiler is now compiled using Babili and transpiled down to Babels <code>env</code> preset (should be safe for use in all browsers in current use, not just evergreen versions).</li>
<li>Calling functions <code>@get</code> or <code>@set</code> no longer throws an error about required parentheses. (Bare <code>get</code> or <code>set</code>, not attached to an object or <code>@</code>, <a href="#unsupported-get-set">still intentionally throws a compiler error</a>.)</li>
<li>If <code>$XDG_CACHE_HOME</code> is set, the REPL <code>.coffee_history</code> file is saved there.</li>
</ul>
<div class="anchor" id="1.12.6"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/1.12.5...1.12.6">1.12.6</a>
<span class="timestamp"> &mdash; <time datetime="2017-05-15">May 15, 2017</time></span>
</h2><ul>
<li>The <code>return</code> and <code>export</code> keywords can now accept implicit objects (defined by indentation, without needing braces).</li>
<li>Support Unicode code point escapes (e.g. <code>\u{1F4A9}</code>).</li>
<li>The <code>coffee</code> command now first looks to see if CoffeeScript is installed under <code>node_modules</code> in the current folder, and executes the <code>coffee</code> binary there if so; or otherwise it runs the globally installed one. This allows you to have one version of CoffeeScript installed globally and a different one installed locally for a particular project. (Likewise for the <code>cake</code> command.)</li>
<li>Bugfixes for chained function calls not closing implicit objects or ternaries.</li>
<li>Bugfixes for incorrect code generated by the <code>?</code> operator within a termary <code>if</code> statement.</li>
<li>Fixed some tests, and failing tests now result in a nonzero exit code.</li>
</ul>
<div class="anchor" id="2.0.0-beta1"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/2.0.0-alpha1...2.0.0-beta1">2.0.0-beta1</a>

View File

@ -99,6 +99,10 @@ arrayEgal = (a, b) ->
@eq = (a, b, msg) -> ok egal(a, b), msg or "Expected #{a} to equal #{b}"
@arrayEq = (a, b, msg) -> ok arrayEgal(a,b), msg or "Expected #{a} to deep equal #{b}"
@toJS = (str) ->
CoffeeScript.compile str, bare: yes
.replace /^\s+|\s+$/g, '' # Trim leading/trailing whitespace
@doesNotThrow = (fn) ->
fn()
@ -2863,7 +2867,7 @@ test "block comments in functions", ->
ok fn1()
fn2 = ->
fn2 = ->
###
block comment
###
@ -2923,13 +2927,10 @@ test "#3132: Format single-line block comment nicely", ->
input = """
### Single-line block comment without additional space here => ###"""
result = """
output = """
/* Single-line block comment without additional space here => */
"""
eq CoffeeScript.compile(input, bare: on), result
eq toJS(input), output
test "#3132: Format multi-line block comment nicely", ->
input = """
@ -2939,17 +2940,14 @@ test "#3132: Format multi-line block comment nicely", ->
# comment
###"""
result = """
output = """
/*
* Multi-line
* block
* comment
*/
"""
eq CoffeeScript.compile(input, bare: on), result
eq toJS(input), output
test "#3132: Format simple block comment nicely", ->
input = """
@ -2958,17 +2956,14 @@ test "#3132: Format simple block comment nicely", ->
Preceding hash
###"""
result = """
output = """
/*
No
Preceding hash
*/
"""
eq CoffeeScript.compile(input, bare: on), result
eq toJS(input), output
test "#3132: Format indented block-comment nicely", ->
input = """
@ -2979,7 +2974,7 @@ test "#3132: Format indented block-comment nicely", ->
###
1"""
result = """
output = """
var fn;
fn = function() {
@ -2990,9 +2985,8 @@ test "#3132: Format indented block-comment nicely", ->
*/
return 1;
};
"""
eq CoffeeScript.compile(input, bare: on), result
eq toJS(input), output
# Although adequately working, block comment-placement is not yet perfect.
# (Considering a case where multiple variables have been declared …)
@ -3006,8 +3000,7 @@ test "#3132: Format jsdoc-style block-comment nicely", ->
fn = () -> 1
"""
result = """
output = """
/**
* Multiline for jsdoc-"@doctags"
*
@ -3017,10 +3010,8 @@ test "#3132: Format jsdoc-style block-comment nicely", ->
fn = function() {
return 1;
};
"""
eq CoffeeScript.compile(input, bare: on), result
};"""
eq toJS(input), output
# Although adequately working, block comment-placement is not yet perfect.
# (Considering a case where multiple variables have been declared …)
@ -3034,8 +3025,7 @@ test "#3132: Format hand-made (raw) jsdoc-style block-comment nicely", ->
fn = () -> 1
"""
result = """
output = """
/**
* Multiline for jsdoc-"@doctags"
*
@ -3045,10 +3035,8 @@ test "#3132: Format hand-made (raw) jsdoc-style block-comment nicely", ->
fn = function() {
return 1;
};
"""
eq CoffeeScript.compile(input, bare: on), result
};"""
eq toJS(input), output
# Although adequately working, block comment-placement is not yet perfect.
# (Considering a case where multiple variables have been declared …)
@ -3075,8 +3063,7 @@ test "#3132: Place block-comments nicely", ->
"""
result = """
output = """
/**
* A dummy class definition
*
@ -3106,10 +3093,8 @@ test "#3132: Place block-comments nicely", ->
return DummyClass;
})();
"""
eq CoffeeScript.compile(input, bare: on), result
})();"""
eq toJS(input), output
test "#3638: Demand a whitespace after # symbol", ->
input = """
@ -3118,17 +3103,13 @@ test "#3638: Demand a whitespace after # symbol", ->
#whitespace
###"""
result = """
output = """
/*
#No
#whitespace
*/
*/"""
"""
eq CoffeeScript.compile(input, bare: on), result
eq toJS(input), output
test "#3761: Multiline comment at end of an object", ->
anObject =
@ -6201,6 +6182,9 @@ test "indented heredoc", ->
# * single line arguments
# * inline function literal
# * inline object literal
#
# * chaining inside
# * implicit object literal
test "chaining after outdent", ->
id = (x) -> x
@ -6271,6 +6255,37 @@ test "#1495, method call chaining", ->
).join ', '
eq 'a, b, c', result
test "chaining should not wrap spilling ternary", ->
throws -> CoffeeScript.compile """
if 0 then 1 else g
a: 42
.h()
"""
test "chaining should wrap calls containing spilling ternary", ->
f = (x) -> h: x
id = (x) -> x
result = f if true then 42 else id
a: 2
.h
eq 42, result
test "chaining should work within spilling ternary", ->
f = (x) -> h: x
id = (x) -> x
result = f if false then 1 else id
a: 3
.a
eq 3, result.h
test "method call chaining inside objects", ->
f = (x) -> c: 42
result =
a: f 1
b: f a: 1
.c
eq 42, result.b
# Nested blocks caused by paren unwrapping
test "#1492: Nested blocks don't cause double semicolons", ->
js = CoffeeScript.compile '(0;0)'
@ -9224,12 +9239,6 @@ test "Verify all tokens get a location", ->
# CoffeeScript also supports optional commas within `{ … }`.
# Helper function
toJS = (str) ->
CoffeeScript.compile str, bare: yes
.replace /^\s+|\s+$/g, '' # Trim leading/trailing whitespace
# Import statements
test "backticked import statement", ->
@ -11501,12 +11510,6 @@ test "#1409: creating large ranges outside of a function body", ->
# * Regexen
# * Heregexen
# Helper function
toJS = (str) ->
CoffeeScript.compile str, bare: yes
.replace /^\s+|\s+$/g, '' # Trim leading/trailing whitespace
test "basic regular expression literals", ->
ok 'a'.match(/a/)
ok 'a'.match /a/
@ -12610,12 +12613,6 @@ test "`Future Reserved Word`s, `eval` and `arguments` restrictions", ->
# * Strings
# * Heredocs
# Helper function
toJS = (str) ->
CoffeeScript.compile str, bare: yes
.replace /^\s+|\s+$/g, '' # Trim leading/trailing whitespace
test "backslash escapes", ->
eq "\\/\\\\", /\/\\/.source

View File

@ -13,8 +13,18 @@ Derived (extended) class `constructor`s cannot use `this` before calling `super`
```coffee
class B extends A
constructor: -> this
# Throws a compiler error
constructor: -> this # Throws a compiler error
```
Class methods cant be bound (i.e. you cant define a class method using a fat arrow) though you can define such methods in the constructor instead:
```coffee
class B extends A
method: => # Throws a compiler error
constructor: ->
super()
@method = => # This works
```
Class methods cant be used with `new` (uncommon):
@ -22,8 +32,7 @@ Class methods cant be used with `new` (uncommon):
```coffee
class Namespace
@Klass = ->
new Namespace.Klass
# Throws a TypeError at runtime
new Namespace.Klass # Throws a TypeError at runtime
```
Due to the hoisting required to compile to ES2015 classes, dynamic keys in class methods cant use values from the executable class body unless the methods are assigned in prototype style.

View File

@ -1,4 +1,20 @@
## Change Log
## Changelog
```
releaseHeader('2017-05-16', '2.0.0-beta2', '2.0.0-beta1')
```
* This release includes [all the changes from 1.12.5 to 1.12.6](#1.12.6).
* Bound (fat arrow) methods in classes must be declared in the class constructor, after `super()` if the class is extending a parent class. See [breaking changes for classes](#breaking-changes-classes).
* All unnecessary utility helper functions have been removed, including the polyfills for `indexOf` and `bind`.
* The `extends` keyword now only works in the context of classes; it cannot be used to extend a function prototype. See [breaking changes for `extends`](#breaking-changes-super-extends).
* Literate CoffeeScript is now parsed entirely based on indentation, similar to the 1.x implementation; there is no longer a dependency for parsing Markdown. See [breaking changes for Literate CoffeeScript parsing](#breaking-changes-literate-coffeescript).
* JavaScript reserved words used as properties are no longer wrapped in quotes.
* `require('coffeescript')` should now work in non-Node environments such as the builds created by Webpack or Browserify. This provides a more convenient way to include the browser compiler in builds intending to run in a browser environment.
* Unreachable `break` statements are no longer added after `switch` cases that `throw` exceptions.
* The browser compiler is now compiled using Babili and transpiled down to Babels `env` preset (should be safe for use in all browsers in current use, not just evergreen versions).
* Calling functions `@get` or `@set` no longer throws an error about required parentheses. (Bare `get` or `set`, not attached to an object or `@`, [still intentionally throws a compiler error](#unsupported-get-set).)
* If `$XDG_CACHE_HOME` is set, the REPL `.coffee_history` file is saved there.
```
releaseHeader('2017-05-15', '1.12.6', '1.12.5')

View File

@ -35,7 +35,7 @@
<a href="#source-maps">Source Maps</a>
<a href="#scripts">"text/coffeescript" Script Tags</a>
<a href="#resources">Books, Screencasts, Examples and Resources</a>
<a href="#changelog">Change Log</a>
<a href="#changelog">Changelog</a>
</div>
</div>
<div class="navigation try">

View File

@ -165,7 +165,7 @@
</ul>
</li>
<li class="nav-item">
<a href="#changelog" class="nav-link" data-action="sidebar-nav">Change Log</a>
<a href="#changelog" class="nav-link" data-action="sidebar-nav">Changelog</a>
</li>
</ul>
</nav>

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var CoffeeScript, compile, runScripts,
indexOf = [].indexOf;

View File

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

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var Lexer, SourceMap, base64encode, compile, formatSourcePosition, getSourceMap, helpers, lexer, packageJson, parser, sourceMaps, sources, withPrettyErrors;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, makePrelude, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
indexOf = [].indexOf;

View File

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

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var CoffeeScript, compile, ext, fn, fs, helpers, i, len, path, ref, vm,
hasProp = {}.hasOwnProperty;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, HERE_JSTOKEN, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVERSES, JSTOKEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, REGEX_INVALID_ESCAPE, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_INVALID_ESCAPE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, UNICODE_CODE_POINT_ESCAPE, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, isForFrom, isUnassignable, key, locationDataToString, merge, repeat, starts, throwSyntaxError,
indexOf = [].indexOf;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var Access, Arr, Assign, AwaitReturn, Base, Block, BooleanLiteral, Call, Class, Code, CodeFragment, Comment, ExecutableClassBody, Existence, Expansion, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, ExportSpecifier, ExportSpecifierList, Extends, For, HoistTarget, IdentifierLiteral, If, ImportClause, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, ImportSpecifierList, In, Index, InfinityLiteral, JS_FORBIDDEN, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, ModuleDeclaration, ModuleSpecifier, ModuleSpecifierList, NEGATE, NO, NaNLiteral, NullLiteral, NumberLiteral, Obj, Op, Param, Parens, PassthroughLiteral, PropertyName, Range, RegexLiteral, RegexWithInterpolations, Return, SIMPLENUM, Scope, Slice, Splat, StatementLiteral, StringLiteral, StringWithInterpolations, Super, SuperCall, Switch, TAB, THIS, TaggedTemplateCall, ThisLiteral, Throw, Try, UTILITIES, UndefinedLiteral, Value, While, YES, YieldReturn, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, isLiteralArguments, isLiteralThis, isUnassignable, locationDataToString, merge, multident, shouldCacheOrIsAssignable, some, starts, throwSyntaxError, unfoldSoak, utility,
splice = [].splice,

View File

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

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, runInContext, updateSyntaxError, vm;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, Rewriter, SINGLE_CLOSERS, SINGLE_LINERS, generate, k, left, len, rite,
indexOf = [].indexOf;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var Scope,
indexOf = [].indexOf;

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.0.0-beta1
// Generated by CoffeeScript 2.0.0-beta2
(function() {
var LineMap, SourceMap;

View File

@ -8,7 +8,7 @@
"compiler"
],
"author": "Jeremy Ashkenas",
"version": "2.0.0-beta1",
"version": "2.0.0-beta2",
"license": "MIT",
"engines": {
"node": ">=7.6.0"