mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
2.0.0-beta3 (#4594)
* Don’t confuse the syntax highlighter * Comment Assign::compilePatternMatch a bit * Assignment expressions in conditionals are a bad practice * Rename `wrapInBraces` to `wrapInParentheses`, to set the stage for future `wrapInBraces` that uses `{` and `wrapInBrackets` that uses `[` * Correct comment * object destructuring * Allow custom position of the rest element. * Output simple array destructuring assignments to ES2015 * Output simple object destructured assignments to ES2015 * Compile shorthand object properties to ES2015 shorthand properties This dramatically improves the appearance of destructured imports. * Don’t confuse the syntax highlighter * Comment Assign::compilePatternMatch a bit * Assignment expressions in conditionals are a bad practice * Rename `wrapInBraces` to `wrapInParentheses`, to set the stage for future `wrapInBraces` that uses `{` and `wrapInBrackets` that uses `[` * object destructuring * Allow custom position of the rest element. * rest element in object destructuring * rest element in object destructuring * fix string interpolation * merging * fixing splats in object literal * Rest element in parameter destructuring * merging with CS2 * merged with CS2 * Add support for the object spread initializer. https://github.com/tc39/proposal-object-rest-spread/blob/master/Spread.md * Fix misspellings, trailing whitespace, other minor details * merging with beta2 * refactor object spread properties * small fix * - Fixed object spread function parameters. - Clean up "Assign" and moved all logic for object rest properties in single method (compileObjectDestruct). - Add helper function "objectWithoutKeys" to the "UTILITIES" for use with object rest properties, e.g. {a, b, r...} = obj => {a, b} = obj, r = objectWithoutKeys(...) - Clean up "Obj" and moved all logic for object spread properties in single method (compileSpread). - Clean up "Code". - Add method "hasSplat" to "Obj" and "Value" for checking if Obj contains the splat. - Enable placing spread syntax triple dots on either right or left, per #85 (https://github.com/coffeescript6/discuss/issues/85) * Fixed typos * Remove unused code * Removed dots (e.g. splat) on the left side from the grammar * Initial release for deep spread properties, e.g. obj2 = {obj.b..., a: 1} or {obj[b][c]..., d: 7} Tests need to be prepared! * 1. Object literal spread properties Object literals: - obj = { {b:{c:{d:1}}}..., a:1 } Parenthetical: - obj = { ( body ), a:1 } - obj = { ( body )..., a:1 } Invocation: - obj = { ( (args) -> ... )(params), a:1 } - obj = { ( (args) -> ... )(params)..., a:1 } - obj = { foo(), a:1 } - obj = { foo()..., a:1 } 2. Refactor, cleanup & other optimizations. * Merged with 2.0 * Cleanup * Some more cleanup. * Fixed error with freeVariable and object destructuring. * Fixed errors with object spread properties. * Improvements, fixed errors. * Minor improvement. * Minor improvements. * Typo. * Remove unnecessary whitespace. * Remove unnecessary whitespace. * Changed few "assertErrorFormat" tests since parentheses are now allowed in the Obj. * Whitespace cleanup * Comments cleanup * fix destructured obj param declarations * refine fix; add test * Refactor function args ({a, b...}) * Additional tests for object destructuring in function argument. * Minor improvement for object destructuring variable declaration. * refactor function args ({a, b...}) and ({a, b...} = {}); Obj And Param cleanup * fix comment * Fix object destructuring variable declaration. * more tests with default values * fix typo * Fixed default values in object destructuring. * small fix * Babel’s tests for object rest spread * Style: spaces after colons in object declarations * Cleanup comments * Simplify Babel tests * Fix comments * Fix destructuring with splats in multiple objects * Add test for default values in detsructuring assignment with splats * Handle default values when assigning to object splats * Rewrite traverseRest to fix handling of dynamic keys * Fix double parens around destructuring with splats * Update compileObjectDestruct comments * Improve formatting of top-level destructures with splats and tidy parens * Added a bigger destructuring-with-defaults test and fixed a bug * Refactor destructuring grammar to allow additional forms * Add a missing case to ObjSpreadExpr * These tests shouldn’t run in the browser * Fix test.html * Fix docs scroll position getting screwed up by CodeMirror initialization * Breaking change documentation about => (fixes #4593) * Spread/rest syntax documentation * Documentation about bound class methods * 2.0.0-beta3 changelog * Add note about ‘lib’ * Fix accidentally converting this to tabs * Bump version to 2.0.0-beta3 * Update annotated source and test.html
This commit is contained in:
parent
a7a6006533
commit
704924c3cd
39 changed files with 3537 additions and 1130 deletions
|
@ -6,4 +6,4 @@
|
|||
|
||||
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffeescript/tree/master/src). If you’re just getting started with CoffeeScript, there’s a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide).
|
||||
|
||||
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffeescript.js` file. We’ll do those things before cutting a new release.
|
||||
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffeescript.js` file. We’ll do those things before cutting a new release. You _should,_ however, commit the updated compiled JavaScript files in `lib`.
|
|
@ -238,7 +238,10 @@ sources = []
|
|||
sourceCode = []
|
||||
notSources = {}
|
||||
watchedDirs = {}
|
||||
optionParser = <span class="hljs-literal">null</span></pre></div></div>
|
||||
optionParser = <span class="hljs-literal">null</span>
|
||||
|
||||
exports.buildCSOptionParser = buildCSOptionParser = <span class="hljs-function">-></span>
|
||||
<span class="hljs-keyword">new</span> optparse.OptionParser SWITCHES, BANNER</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
@ -256,6 +259,7 @@ Many flags cause us to divert before compiling anything. Flags passed after
|
|||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function">-></span>
|
||||
optionParser = buildCSOptionParser()
|
||||
parseOptions()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
@ -771,7 +775,6 @@ same directory as the <code>.js</code> file.</p>
|
|||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">parseOptions</span> = -></span>
|
||||
optionParser = <span class="hljs-keyword">new</span> optparse.OptionParser SWITCHES, BANNER
|
||||
o = opts = optionParser.parse process.argv[<span class="hljs-number">2.</span>.]
|
||||
o.compile <span class="hljs-keyword">or</span>= !!o.output
|
||||
o.run = <span class="hljs-keyword">not</span> (o.compile <span class="hljs-keyword">or</span> o.<span class="hljs-built_in">print</span> <span class="hljs-keyword">or</span> o.map)
|
||||
|
@ -856,7 +859,7 @@ shown.</p>
|
|||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">usage</span> = -></span>
|
||||
printLine (<span class="hljs-keyword">new</span> optparse.OptionParser SWITCHES, BANNER).help()</pre></div></div>
|
||||
printLine optionParser.help()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
|
|
@ -446,6 +446,7 @@ token stream.</p>
|
|||
|
||||
Identifier: [
|
||||
o <span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> IdentifierLiteral $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'CSX_TAG'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> CSXTag $<span class="hljs-number">1</span>
|
||||
]
|
||||
|
||||
Property: [
|
||||
|
@ -541,6 +542,7 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
|
|||
|
||||
<div class="content"><div class='highlight'><pre> AssignObj: [
|
||||
o <span class="hljs-string">'ObjAssignable'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'ObjRestValue'</span>
|
||||
o <span class="hljs-string">'ObjAssignable : Expression'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">3</span>, <span class="hljs-string">'object'</span>,
|
||||
operatorToken: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'ObjAssignable :
|
||||
|
@ -574,6 +576,40 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
|
|||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Object literal spread properties.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> ObjRestValue: [
|
||||
o <span class="hljs-string">'SimpleObjAssignable ...'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> Splat <span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'ObjSpreadExpr ...'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> Splat $<span class="hljs-number">1</span>
|
||||
]
|
||||
|
||||
ObjSpreadExpr: [
|
||||
o <span class="hljs-string">'ObjSpreadIdentifier'</span>
|
||||
o <span class="hljs-string">'Object'</span>
|
||||
o <span class="hljs-string">'Parenthetical'</span>
|
||||
o <span class="hljs-string">'Super'</span>
|
||||
o <span class="hljs-string">'This'</span>
|
||||
o <span class="hljs-string">'SUPER Arguments'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> SuperCall LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Super), $<span class="hljs-number">2</span>
|
||||
o <span class="hljs-string">'SimpleObjAssignable Arguments'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> Call (<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">2</span>
|
||||
o <span class="hljs-string">'ObjSpreadExpr Arguments'</span>, <span class="hljs-function">-></span> <span class="hljs-keyword">new</span> Call $<span class="hljs-number">1</span>, $<span class="hljs-number">2</span>
|
||||
]
|
||||
|
||||
ObjSpreadIdentifier: [
|
||||
o <span class="hljs-string">'SimpleObjAssignable . Property'</span>, <span class="hljs-function">-></span> (<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>).add(<span class="hljs-keyword">new</span> Access $<span class="hljs-number">3</span>)
|
||||
o <span class="hljs-string">'SimpleObjAssignable INDEX_START IndexValue INDEX_END'</span>, <span class="hljs-function">-></span> (<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>).add($<span class="hljs-number">3</span>)
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>A return statement from a function body.</p>
|
||||
|
||||
</div>
|
||||
|
@ -596,11 +632,11 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>A block comment.</p>
|
||||
|
||||
|
@ -613,11 +649,11 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>The <strong>Code</strong> node is the function literal. It’s defined by an indented block
|
||||
of <strong>Block</strong> preceded by a function arrow, with an optional parameter list.</p>
|
||||
|
@ -632,11 +668,11 @@ of <strong>Block</strong> preceded by a function arrow, with an optional paramet
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>CoffeeScript has two different symbols for functions. <code>-></code> is for ordinary
|
||||
functions, and <code>=></code> is for functions bound to the current value of <em>this</em>.</p>
|
||||
|
@ -651,11 +687,11 @@ functions, and <code>=></code> is for functions bound to the current value of
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>An optional, trailing comma.</p>
|
||||
|
||||
|
@ -669,11 +705,11 @@ functions, and <code>=></code> is for functions bound to the current value of
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<p>The list of parameters that a function accepts can be of any length.</p>
|
||||
|
||||
|
@ -690,11 +726,11 @@ functions, and <code>=></code> is for functions bound to the current value of
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-28">
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
<p>A single parameter in a function definition can be ordinary, or a splat
|
||||
that hoovers up the remaining arguments.</p>
|
||||
|
@ -711,11 +747,11 @@ that hoovers up the remaining arguments.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-29">
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Function Parameters</p>
|
||||
|
||||
|
@ -731,11 +767,11 @@ that hoovers up the remaining arguments.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-30">
|
||||
<li id="section-31">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
</div>
|
||||
<p>A splat that occurs outside of a parameter list.</p>
|
||||
|
||||
|
@ -748,11 +784,11 @@ that hoovers up the remaining arguments.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-31">
|
||||
<li id="section-32">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
</div>
|
||||
<p>Variables and properties that can be assigned to.</p>
|
||||
|
||||
|
@ -768,11 +804,11 @@ that hoovers up the remaining arguments.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-32">
|
||||
<li id="section-33">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
<a class="pilcrow" href="#section-33">¶</a>
|
||||
</div>
|
||||
<p>Everything that can be assigned to.</p>
|
||||
|
||||
|
@ -787,11 +823,11 @@ that hoovers up the remaining arguments.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-33">
|
||||
<li id="section-34">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-33">¶</a>
|
||||
<a class="pilcrow" href="#section-34">¶</a>
|
||||
</div>
|
||||
<p>The types of things that can be treated as values – assigned to, invoked
|
||||
as functions, indexed into, named as a class, etc.</p>
|
||||
|
@ -810,11 +846,11 @@ as functions, indexed into, named as a class, etc.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-34">
|
||||
<li id="section-35">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-34">¶</a>
|
||||
<a class="pilcrow" href="#section-35">¶</a>
|
||||
</div>
|
||||
<p>A <code>super</code>-based expression that can be used as a value.</p>
|
||||
|
||||
|
@ -828,11 +864,11 @@ as functions, indexed into, named as a class, etc.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-35">
|
||||
<li id="section-36">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-35">¶</a>
|
||||
<a class="pilcrow" href="#section-36">¶</a>
|
||||
</div>
|
||||
<p>The general group of accessors into an object, by property, by prototype
|
||||
or by array index or slice.</p>
|
||||
|
@ -851,11 +887,11 @@ or by array index or slice.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-36">
|
||||
<li id="section-37">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-36">¶</a>
|
||||
<a class="pilcrow" href="#section-37">¶</a>
|
||||
</div>
|
||||
<p>Indexing into an object or array using bracket notation.</p>
|
||||
|
||||
|
@ -874,11 +910,11 @@ or by array index or slice.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-37">
|
||||
<li id="section-38">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-37">¶</a>
|
||||
<a class="pilcrow" href="#section-38">¶</a>
|
||||
</div>
|
||||
<p>In CoffeeScript, an object literal is simply a list of assignments.</p>
|
||||
|
||||
|
@ -891,11 +927,11 @@ or by array index or slice.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-38">
|
||||
<li id="section-39">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-38">¶</a>
|
||||
<a class="pilcrow" href="#section-39">¶</a>
|
||||
</div>
|
||||
<p>Assignment of properties within an object literal can be separated by
|
||||
comma, as in JavaScript, or simply by newline.</p>
|
||||
|
@ -913,11 +949,11 @@ comma, as in JavaScript, or simply by newline.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-39">
|
||||
<li id="section-40">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-39">¶</a>
|
||||
<a class="pilcrow" href="#section-40">¶</a>
|
||||
</div>
|
||||
<p>Class definitions have optional bodies of prototype property assignments,
|
||||
and optional references to the superclass.</p>
|
||||
|
@ -1002,11 +1038,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-40">
|
||||
<li id="section-41">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-40">¶</a>
|
||||
<a class="pilcrow" href="#section-41">¶</a>
|
||||
</div>
|
||||
<p>Ordinary function invocation, or a chained series of calls.</p>
|
||||
|
||||
|
@ -1022,11 +1058,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-41">
|
||||
<li id="section-42">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-41">¶</a>
|
||||
<a class="pilcrow" href="#section-42">¶</a>
|
||||
</div>
|
||||
<p>An optional existence check on a function.</p>
|
||||
|
||||
|
@ -1040,11 +1076,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-42">
|
||||
<li id="section-43">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-42">¶</a>
|
||||
<a class="pilcrow" href="#section-43">¶</a>
|
||||
</div>
|
||||
<p>The list of arguments to a function call.</p>
|
||||
|
||||
|
@ -1058,11 +1094,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-43">
|
||||
<li id="section-44">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-43">¶</a>
|
||||
<a class="pilcrow" href="#section-44">¶</a>
|
||||
</div>
|
||||
<p>A reference to the <em>this</em> current object.</p>
|
||||
|
||||
|
@ -1076,11 +1112,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-44">
|
||||
<li id="section-45">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-44">¶</a>
|
||||
<a class="pilcrow" href="#section-45">¶</a>
|
||||
</div>
|
||||
<p>A reference to a property on <em>this</em>.</p>
|
||||
|
||||
|
@ -1093,11 +1129,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-45">
|
||||
<li id="section-46">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-45">¶</a>
|
||||
<a class="pilcrow" href="#section-46">¶</a>
|
||||
</div>
|
||||
<p>The array literal.</p>
|
||||
|
||||
|
@ -1111,11 +1147,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-46">
|
||||
<li id="section-47">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-46">¶</a>
|
||||
<a class="pilcrow" href="#section-47">¶</a>
|
||||
</div>
|
||||
<p>Inclusive and exclusive range dots.</p>
|
||||
|
||||
|
@ -1129,11 +1165,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-47">
|
||||
<li id="section-48">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-47">¶</a>
|
||||
<a class="pilcrow" href="#section-48">¶</a>
|
||||
</div>
|
||||
<p>The CoffeeScript range literal.</p>
|
||||
|
||||
|
@ -1146,11 +1182,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-48">
|
||||
<li id="section-49">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-48">¶</a>
|
||||
<a class="pilcrow" href="#section-49">¶</a>
|
||||
</div>
|
||||
<p>Array slice literals.</p>
|
||||
|
||||
|
@ -1166,11 +1202,11 @@ and optional references to the superclass.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-49">
|
||||
<li id="section-50">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-49">¶</a>
|
||||
<a class="pilcrow" href="#section-50">¶</a>
|
||||
</div>
|
||||
<p>The <strong>ArgList</strong> is both the list of objects passed into a function call,
|
||||
as well as the contents of an array literal
|
||||
|
@ -1189,11 +1225,11 @@ as well as the contents of an array literal
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-50">
|
||||
<li id="section-51">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-50">¶</a>
|
||||
<a class="pilcrow" href="#section-51">¶</a>
|
||||
</div>
|
||||
<p>Valid arguments are Blocks or Splats.</p>
|
||||
|
||||
|
@ -1208,11 +1244,11 @@ as well as the contents of an array literal
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-51">
|
||||
<li id="section-52">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-51">¶</a>
|
||||
<a class="pilcrow" href="#section-52">¶</a>
|
||||
</div>
|
||||
<p>Just simple, comma-separated, required arguments (no fancy syntax). We need
|
||||
this to be separate from the <strong>ArgList</strong> for use in <strong>Switch</strong> blocks, where
|
||||
|
@ -1228,11 +1264,11 @@ having the newlines wouldn’t make sense.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-52">
|
||||
<li id="section-53">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-52">¶</a>
|
||||
<a class="pilcrow" href="#section-53">¶</a>
|
||||
</div>
|
||||
<p>The variants of <em>try/catch/finally</em> exception handling blocks.</p>
|
||||
|
||||
|
@ -1248,11 +1284,11 @@ having the newlines wouldn’t make sense.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-53">
|
||||
<li id="section-54">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-53">¶</a>
|
||||
<a class="pilcrow" href="#section-54">¶</a>
|
||||
</div>
|
||||
<p>A catch clause names its error and runs a block of code.</p>
|
||||
|
||||
|
@ -1267,11 +1303,11 @@ having the newlines wouldn’t make sense.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-54">
|
||||
<li id="section-55">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-54">¶</a>
|
||||
<a class="pilcrow" href="#section-55">¶</a>
|
||||
</div>
|
||||
<p>Throw an exception object.</p>
|
||||
|
||||
|
@ -1284,11 +1320,11 @@ having the newlines wouldn’t make sense.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-55">
|
||||
<li id="section-56">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-55">¶</a>
|
||||
<a class="pilcrow" href="#section-56">¶</a>
|
||||
</div>
|
||||
<p>Parenthetical expressions. Note that the <strong>Parenthetical</strong> is a <strong>Value</strong>,
|
||||
not an <strong>Expression</strong>, so if you need to use an expression in a place
|
||||
|
@ -1305,11 +1341,11 @@ the trick.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-56">
|
||||
<li id="section-57">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-56">¶</a>
|
||||
<a class="pilcrow" href="#section-57">¶</a>
|
||||
</div>
|
||||
<p>The condition portion of a while loop.</p>
|
||||
|
||||
|
@ -1325,11 +1361,11 @@ the trick.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-57">
|
||||
<li id="section-58">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-57">¶</a>
|
||||
<a class="pilcrow" href="#section-58">¶</a>
|
||||
</div>
|
||||
<p>The while loop can either be normal, with a block of expressions to execute,
|
||||
or postfix, with a single expression. There is no do..while.</p>
|
||||
|
@ -1351,11 +1387,11 @@ or postfix, with a single expression. There is no do..while.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-58">
|
||||
<li id="section-59">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-58">¶</a>
|
||||
<a class="pilcrow" href="#section-59">¶</a>
|
||||
</div>
|
||||
<p>Array, object, and range comprehensions, at the most generic level.
|
||||
Comprehensions can either be normal, with a block of expressions to execute,
|
||||
|
@ -1383,11 +1419,11 @@ or postfix, with a single expression.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-59">
|
||||
<li id="section-60">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-59">¶</a>
|
||||
<a class="pilcrow" href="#section-60">¶</a>
|
||||
</div>
|
||||
<p>An array of all accepted values for a variable inside the loop.
|
||||
This enables support for pattern matching.</p>
|
||||
|
@ -1404,11 +1440,11 @@ This enables support for pattern matching.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-60">
|
||||
<li id="section-61">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-60">¶</a>
|
||||
<a class="pilcrow" href="#section-61">¶</a>
|
||||
</div>
|
||||
<p>An array or range comprehension has variables for the current element
|
||||
and (optional) reference to the current index. Or, <em>key, value</em>, in the case
|
||||
|
@ -1424,11 +1460,11 @@ of object comprehensions.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-61">
|
||||
<li id="section-62">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-61">¶</a>
|
||||
<a class="pilcrow" href="#section-62">¶</a>
|
||||
</div>
|
||||
<p>The source of a comprehension is an array or object with an optional guard
|
||||
clause. If it’s an array comprehension, you can also choose to step through
|
||||
|
@ -1463,11 +1499,11 @@ in fixed-size increments.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-62">
|
||||
<li id="section-63">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-62">¶</a>
|
||||
<a class="pilcrow" href="#section-63">¶</a>
|
||||
</div>
|
||||
<p>An individual <strong>When</strong> clause, with action.</p>
|
||||
|
||||
|
@ -1481,11 +1517,11 @@ in fixed-size increments.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-63">
|
||||
<li id="section-64">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-63">¶</a>
|
||||
<a class="pilcrow" href="#section-64">¶</a>
|
||||
</div>
|
||||
<p>The most basic form of <em>if</em> is a condition and an action. The following
|
||||
if-related rules are broken up along these lines in order to avoid
|
||||
|
@ -1501,11 +1537,11 @@ ambiguity.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-64">
|
||||
<li id="section-65">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-64">¶</a>
|
||||
<a class="pilcrow" href="#section-65">¶</a>
|
||||
</div>
|
||||
<p>The full complement of <em>if</em> expressions, including postfix one-liner
|
||||
<em>if</em> and <em>unless</em>.</p>
|
||||
|
@ -1522,11 +1558,11 @@ ambiguity.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-65">
|
||||
<li id="section-66">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-65">¶</a>
|
||||
<a class="pilcrow" href="#section-66">¶</a>
|
||||
</div>
|
||||
<p>Arithmetic and logical operators, working on one or more operands.
|
||||
Here they are grouped by order of precedence. The actual precedence rules
|
||||
|
@ -1553,11 +1589,11 @@ rules are necessary.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-66">
|
||||
<li id="section-67">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-66">¶</a>
|
||||
<a class="pilcrow" href="#section-67">¶</a>
|
||||
</div>
|
||||
<p><a href="http://coffeescript.org/#existential-operator">The existential operator</a>.</p>
|
||||
|
||||
|
@ -1595,26 +1631,14 @@ rules are necessary.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-67">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-67">¶</a>
|
||||
</div>
|
||||
<h2 id="precedence">Precedence</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-68">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-68">¶</a>
|
||||
</div>
|
||||
|
||||
<h2 id="precedence">Precedence</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
@ -1626,6 +1650,18 @@ rules are necessary.</p>
|
|||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-69">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-70">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-70">¶</a>
|
||||
</div>
|
||||
<p>Operators at the top of this list have higher precedence than the ones lower
|
||||
down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:</p>
|
||||
<pre><code><span class="hljs-number">2</span> + (<span class="hljs-number">3</span> * <span class="hljs-number">4</span>)
|
||||
|
@ -1665,26 +1701,14 @@ down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-70">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-70">¶</a>
|
||||
</div>
|
||||
<h2 id="wrapping-up">Wrapping Up</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-71">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-71">¶</a>
|
||||
</div>
|
||||
|
||||
<h2 id="wrapping-up">Wrapping Up</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
@ -1696,6 +1720,18 @@ down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:</p>
|
|||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-72">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-73">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-73">¶</a>
|
||||
</div>
|
||||
<p>Finally, now that we have our <strong>grammar</strong> and our <strong>operators</strong>, we can create
|
||||
our <strong>Jison.Parser</strong>. We do this by processing all of our rules, recording all
|
||||
terminals (every symbol which does not appear as the name of a rule above)
|
||||
|
@ -1714,11 +1750,11 @@ as “tokens”.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-73">
|
||||
<li id="section-74">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-73">¶</a>
|
||||
<a class="pilcrow" href="#section-74">¶</a>
|
||||
</div>
|
||||
<p>Initialize the <strong>Parser</strong> with our list of terminal <strong>tokens</strong>, our <strong>grammar</strong>
|
||||
rules, and the name of the root. Reverse the operators because Jison orders
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -135,6 +135,8 @@ Use it like so:</p>
|
|||
options = parser.parse process.argv
|
||||
</code></pre><p>The first non-option is considered to be the start of the file (and file
|
||||
option) list, and all subsequent arguments are left unparsed.</p>
|
||||
<p>The <code>coffee</code> command uses an instance of <strong>OptionParser</strong> to parse its
|
||||
command-line arguments in <code>src/command.coffee</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ Unwrap that too.</p>
|
|||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> ast = <span class="hljs-keyword">new</span> Block [
|
||||
<span class="hljs-keyword">new</span> Assign (<span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> Literal <span class="hljs-string">'_'</span>), ast, <span class="hljs-string">'='</span>
|
||||
<span class="hljs-keyword">new</span> Assign (<span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> Literal <span class="hljs-string">'__'</span>), ast, <span class="hljs-string">'='</span>
|
||||
]
|
||||
js = ast.compile {bare: <span class="hljs-literal">yes</span>, locals: Object.keys(context), referencedVars}
|
||||
cb <span class="hljs-literal">null</span>, runInContext js, context, filename
|
||||
|
|
|
@ -124,6 +124,9 @@ parentheses, and generally clean things up.</p>
|
|||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
{throwSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
@ -199,6 +202,7 @@ corrected before implicit parentheses can be wrapped around blocks of code.</p>
|
|||
@tagPostfixConditionals()
|
||||
@addImplicitBracesAndParens()
|
||||
@addLocationDataToGeneratedTokens()
|
||||
@enforceValidCSXAttributes()
|
||||
@fixOutdentLocationData()
|
||||
@tokens</pre></div></div>
|
||||
|
||||
|
@ -225,16 +229,18 @@ our feet.</p>
|
|||
i += block.call <span class="hljs-keyword">this</span>, token, i, tokens <span class="hljs-keyword">while</span> token = tokens[i]
|
||||
<span class="hljs-literal">true</span>
|
||||
|
||||
detectEnd: <span class="hljs-function"><span class="hljs-params">(i, condition, action)</span> -></span>
|
||||
detectEnd: <span class="hljs-function"><span class="hljs-params">(i, condition, action, opts = {})</span> -></span>
|
||||
{tokens} = <span class="hljs-keyword">this</span>
|
||||
levels = <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">while</span> token = tokens[i]
|
||||
<span class="hljs-keyword">return</span> action.call <span class="hljs-keyword">this</span>, token, i <span class="hljs-keyword">if</span> levels <span class="hljs-keyword">is</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> condition.call <span class="hljs-keyword">this</span>, token, i
|
||||
<span class="hljs-keyword">return</span> action.call <span class="hljs-keyword">this</span>, token, i - <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> token <span class="hljs-keyword">or</span> levels < <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">return</span> action.call <span class="hljs-keyword">this</span>, token, i <span class="hljs-keyword">if</span> levels <span class="hljs-keyword">is</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> condition.call <span class="hljs-keyword">this</span>, token, i
|
||||
<span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> EXPRESSION_START
|
||||
levels += <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> EXPRESSION_END
|
||||
levels -= <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">if</span> levels < <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> opts.returnOnNegativeLevel
|
||||
<span class="hljs-keyword">return</span> action.call <span class="hljs-keyword">this</span>, token, i
|
||||
i += <span class="hljs-number">1</span>
|
||||
i - <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
|
@ -266,18 +272,16 @@ dispatch them here.</p>
|
|||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>The lexer has tagged the opening parenthesis of a method call. Match it with
|
||||
its paired close. We have the mis-nested outdent case included here for
|
||||
calls that close on the same line, just before their outdent.</p>
|
||||
its paired close.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> closeOpenCalls: <span class="hljs-function">-></span>
|
||||
<span class="hljs-function"> <span class="hljs-title">condition</span> = <span class="hljs-params">(token, i)</span> -></span>
|
||||
token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">')'</span>, <span class="hljs-string">'CALL_END'</span>] <span class="hljs-keyword">or</span>
|
||||
token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">and</span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">')'</span>
|
||||
token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">')'</span>, <span class="hljs-string">'CALL_END'</span>]
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">action</span> = <span class="hljs-params">(token, i)</span> -></span>
|
||||
@tokens[<span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</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>] = <span class="hljs-string">'CALL_END'</span>
|
||||
token[<span class="hljs-number">0</span>] = <span class="hljs-string">'CALL_END'</span>
|
||||
|
||||
@scanTokens (token, i) ->
|
||||
@detectEnd i + <span class="hljs-number">1</span>, condition, action <span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'CALL_START'</span>
|
||||
|
@ -292,7 +296,7 @@ calls that close on the same line, just before their outdent.</p>
|
|||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>The lexer has tagged the opening parenthesis of an indexing operation call.
|
||||
<p>The lexer has tagged the opening bracket of an indexing operation call.
|
||||
Match it with its paired close.</p>
|
||||
|
||||
</div>
|
||||
|
@ -417,7 +421,7 @@ add them.</p>
|
|||
@scanTokens (token, i, tokens) ->
|
||||
[tag] = token
|
||||
[prevTag] = prevToken = <span class="hljs-keyword">if</span> i > <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> tokens[i - <span class="hljs-number">1</span>] <span class="hljs-keyword">else</span> []
|
||||
[nextTag] = <span class="hljs-keyword">if</span> i < tokens.length - <span class="hljs-number">1</span> <span class="hljs-keyword">then</span> tokens[i + <span class="hljs-number">1</span>] <span class="hljs-keyword">else</span> []
|
||||
[nextTag] = nextToken = <span class="hljs-keyword">if</span> i < tokens.length - <span class="hljs-number">1</span> <span class="hljs-keyword">then</span> tokens[i + <span class="hljs-number">1</span>] <span class="hljs-keyword">else</span> []
|
||||
<span class="hljs-function"> <span class="hljs-title">stackTop</span> = -></span> stack[stack.length - <span class="hljs-number">1</span>]
|
||||
startIdx = i</pre></div></div>
|
||||
|
||||
|
@ -473,30 +477,35 @@ class declaration or if-conditionals)</p>
|
|||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">inImplicitControl</span> = -></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> -></span>
|
||||
idx = j ? i
|
||||
<span class="hljs-title">startImplicitCall</span> = <span class="hljs-params">(idx)</span> -></span>
|
||||
stack.push [<span class="hljs-string">'('</span>, idx, ours: <span class="hljs-literal">yes</span>]
|
||||
tokens.splice idx, <span class="hljs-number">0</span>, generate <span class="hljs-string">'CALL_START'</span>, <span class="hljs-string">'('</span>
|
||||
i += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> j?
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">endImplicitCall</span> = -></span>
|
||||
stack.pop()
|
||||
tokens.splice i, <span class="hljs-number">0</span>, generate <span class="hljs-string">'CALL_END'</span>, <span class="hljs-string">')'</span>, [<span class="hljs-string">''</span>, <span class="hljs-string">'end of input'</span>, token[<span class="hljs-number">2</span>]]
|
||||
i += <span class="hljs-number">1</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">startImplicitObject</span> = <span class="hljs-params">(j, startsLine = <span class="hljs-literal">yes</span>)</span> -></span>
|
||||
idx = j ? i
|
||||
<span class="hljs-title">startImplicitObject</span> = <span class="hljs-params">(idx, startsLine = <span class="hljs-literal">yes</span>)</span> -></span>
|
||||
stack.push [<span class="hljs-string">'{'</span>, idx, sameLine: <span class="hljs-literal">yes</span>, startsLine: startsLine, ours: <span class="hljs-literal">yes</span>]
|
||||
val = <span class="hljs-keyword">new</span> String <span class="hljs-string">'{'</span>
|
||||
val.generated = <span class="hljs-literal">yes</span>
|
||||
tokens.splice idx, <span class="hljs-number">0</span>, generate <span class="hljs-string">'{'</span>, val, token
|
||||
i += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> j?
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">endImplicitObject</span> = <span class="hljs-params">(j)</span> -></span>
|
||||
j = j ? i
|
||||
stack.pop()
|
||||
tokens.splice j, <span class="hljs-number">0</span>, generate <span class="hljs-string">'}'</span>, <span class="hljs-string">'}'</span>, token
|
||||
i += <span class="hljs-number">1</span></pre></div></div>
|
||||
i += <span class="hljs-number">1</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">implicitObjectContinues</span> = <span class="hljs-params">(j)</span> =></span>
|
||||
nextTerminatorIdx = <span class="hljs-literal">null</span>
|
||||
@detectEnd j,
|
||||
<span class="hljs-function"><span class="hljs-params">(token)</span> -></span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span>
|
||||
(token, i) -> nextTerminatorIdx = i
|
||||
returnOnNegativeLevel: <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> nextTerminatorIdx?
|
||||
@looksObjectish nextTerminatorIdx + <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
@ -507,12 +516,14 @@ class declaration or if-conditionals)</p>
|
|||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Don’t end an implicit call on next indent if any of these are in an argument</p>
|
||||
<p>Don’t end an implicit call/object on next indent if any of these are in an argument/value</p>
|
||||
|
||||
</div>
|
||||
|
||||
<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>]
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (
|
||||
(inImplicitCall() <span class="hljs-keyword">or</span> inImplicitObject()) <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">in</span> CONTROL_IN_IMPLICIT <span class="hljs-keyword">or</span>
|
||||
inImplicitObject() <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">is</span> <span class="hljs-string">':'</span> <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'FOR'</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>)
|
||||
|
||||
|
@ -535,8 +546,12 @@ class declaration or if-conditionals)</p>
|
|||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> prevTag <span class="hljs-keyword">not</span> <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">','</span>, <span class="hljs-string">'{'</span>, <span class="hljs-string">'TRY'</span>, <span class="hljs-string">'ELSE'</span>, <span class="hljs-string">'='</span>]
|
||||
endImplicitCall() <span class="hljs-keyword">while</span> inImplicitCall()
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> prevTag <span class="hljs-keyword">not</span> <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">','</span>, <span class="hljs-string">'{'</span>, <span class="hljs-string">'ELSE'</span>, <span class="hljs-string">'='</span>]
|
||||
<span class="hljs-keyword">while</span> inImplicitCall() <span class="hljs-keyword">or</span> inImplicitObject() <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">isnt</span> <span class="hljs-string">':'</span>
|
||||
<span class="hljs-keyword">if</span> inImplicitCall()
|
||||
endImplicitCall()
|
||||
<span class="hljs-keyword">else</span>
|
||||
endImplicitObject()
|
||||
stack.pop() <span class="hljs-keyword">if</span> inImplicitControl()
|
||||
stack.push [tag, i]
|
||||
<span class="hljs-keyword">return</span> forward(<span class="hljs-number">1</span>)</pre></div></div>
|
||||
|
@ -599,7 +614,7 @@ f a, f() b, f? c, h[0] d etc.</p>
|
|||
tag <span class="hljs-keyword">is</span> <span class="hljs-string">'?'</span> <span class="hljs-keyword">and</span> i > <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> tokens[i - <span class="hljs-number">1</span>].spaced) <span class="hljs-keyword">and</span>
|
||||
(nextTag <span class="hljs-keyword">in</span> IMPLICIT_CALL <span class="hljs-keyword">or</span>
|
||||
nextTag <span class="hljs-keyword">in</span> IMPLICIT_UNSPACED_CALL <span class="hljs-keyword">and</span>
|
||||
<span class="hljs-keyword">not</span> tokens[i + <span class="hljs-number">1</span>]?.spaced <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> tokens[i + <span class="hljs-number">1</span>]?.newLine)
|
||||
<span class="hljs-keyword">not</span> nextToken.spaced <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> nextToken.newLine)
|
||||
tag = token[<span class="hljs-number">0</span>] = <span class="hljs-string">'FUNC_EXIST'</span> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'?'</span>
|
||||
startImplicitCall i + <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">return</span> forward(<span class="hljs-number">2</span>)</pre></div></div>
|
||||
|
@ -617,11 +632,6 @@ f a, f() b, f? c, h[0] d etc.</p>
|
|||
<pre><code>f
|
||||
a: b
|
||||
c: d
|
||||
</code></pre><p>and</p>
|
||||
<pre><code>f
|
||||
<span class="hljs-number">1</span>
|
||||
a: b
|
||||
b: c
|
||||
</code></pre><p>Don’t accept implicit calls of this type, when on the same line
|
||||
as the control structures below as that may misinterpret constructs like:</p>
|
||||
<pre><code><span class="hljs-keyword">if</span> f
|
||||
|
@ -674,7 +684,9 @@ that creates grammatical ambiguities.</p>
|
|||
<span class="hljs-keyword">when</span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> EXPRESSION_END <span class="hljs-keyword">then</span> start[<span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">when</span> @tag(i - <span class="hljs-number">2</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'@'</span> <span class="hljs-keyword">then</span> i - <span class="hljs-number">2</span>
|
||||
<span class="hljs-keyword">else</span> i - <span class="hljs-number">1</span>
|
||||
s -= <span class="hljs-number">2</span> <span class="hljs-keyword">while</span> @tag(s - <span class="hljs-number">2</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'HERECOMMENT'</span></pre></div></div>
|
||||
s -= <span class="hljs-number">2</span> <span class="hljs-keyword">while</span> @tag(s - <span class="hljs-number">2</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'HERECOMMENT'</span>
|
||||
|
||||
startsLine = s <span class="hljs-keyword">is</span> <span class="hljs-number">0</span> <span class="hljs-keyword">or</span> @tag(s - <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> LINEBREAKS <span class="hljs-keyword">or</span> tokens[s - <span class="hljs-number">1</span>].newLine</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
@ -685,23 +697,6 @@ that creates grammatical ambiguities.</p>
|
|||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Mark if the value is a for loop</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> @insideForDeclaration = nextTag <span class="hljs-keyword">is</span> <span class="hljs-string">'FOR'</span>
|
||||
|
||||
startsLine = s <span class="hljs-keyword">is</span> <span class="hljs-number">0</span> <span class="hljs-keyword">or</span> @tag(s - <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> LINEBREAKS <span class="hljs-keyword">or</span> tokens[s - <span class="hljs-number">1</span>].newLine</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>Are we just continuing an already declared object?</p>
|
||||
|
||||
</div>
|
||||
|
@ -718,11 +713,11 @@ that creates grammatical ambiguities.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-28">
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>End implicit calls when chaining method calls
|
||||
like e.g.:</p>
|
||||
|
@ -741,11 +736,11 @@ like e.g.:</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-29">
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<p>Mark all enclosing objects as not sameLine</p>
|
||||
|
||||
|
@ -763,11 +758,11 @@ like e.g.:</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-30">
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
<p>Close implicit calls when reached end of argument list</p>
|
||||
|
||||
|
@ -779,29 +774,30 @@ like e.g.:</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-31">
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Close implicit objects such as:
|
||||
return a: 1, b: 2 unless true</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> inImplicitObject() <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> @insideForDeclaration <span class="hljs-keyword">and</span> sameLine <span class="hljs-keyword">and</span>
|
||||
tag <span class="hljs-keyword">isnt</span> <span class="hljs-string">'TERMINATOR'</span> <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">isnt</span> <span class="hljs-string">':'</span>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> inImplicitObject() <span class="hljs-keyword">and</span> sameLine <span class="hljs-keyword">and</span>
|
||||
tag <span class="hljs-keyword">isnt</span> <span class="hljs-string">'TERMINATOR'</span> <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">isnt</span> <span class="hljs-string">':'</span> <span class="hljs-keyword">and</span>
|
||||
<span class="hljs-keyword">not</span> (tag <span class="hljs-keyword">in</span> [<span class="hljs-string">'POST_IF'</span>, <span class="hljs-string">'FOR'</span>, <span class="hljs-string">'WHILE'</span>, <span class="hljs-string">'UNTIL'</span>] <span class="hljs-keyword">and</span> startsLine <span class="hljs-keyword">and</span> implicitObjectContinues(i + <span class="hljs-number">1</span>))
|
||||
endImplicitObject()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-32">
|
||||
<li id="section-31">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
</div>
|
||||
<p>Close implicit objects when at end of line, line didn’t end with a comma
|
||||
and the implicit object didn’t start the line or the next line doesn’t look like
|
||||
|
@ -819,11 +815,11 @@ the continuation of an object.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-33">
|
||||
<li id="section-32">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-33">¶</a>
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
</div>
|
||||
<p>Close implicit object if comma is the last character
|
||||
and what comes after doesn’t look like it belongs.
|
||||
|
@ -838,17 +834,16 @@ e = <span class="hljs-number">2</span>
|
|||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">','</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> @looksObjectish(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">and</span> inImplicitObject() <span class="hljs-keyword">and</span>
|
||||
<span class="hljs-keyword">not</span> @insideForDeclaration <span class="hljs-keyword">and</span>
|
||||
(nextTag <span class="hljs-keyword">isnt</span> <span class="hljs-string">'TERMINATOR'</span> <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> @looksObjectish(i + <span class="hljs-number">2</span>))</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-34">
|
||||
<li id="section-33">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-34">¶</a>
|
||||
<a class="pilcrow" href="#section-33">¶</a>
|
||||
</div>
|
||||
<p>When nextTag is OUTDENT the comma is insignificant and
|
||||
should just be ignored so embed it in the implicit object.</p>
|
||||
|
@ -866,6 +861,27 @@ array further up the stack, so give it a chance.</p>
|
|||
</li>
|
||||
|
||||
|
||||
<li id="section-34">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-34">¶</a>
|
||||
</div>
|
||||
<p>Make sure only strings and wrapped expressions are used in CSX attributes</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> enforceValidCSXAttributes: <span class="hljs-function">-></span>
|
||||
@scanTokens (token, i, tokens) ->
|
||||
<span class="hljs-keyword">if</span> token.csxColon
|
||||
next = tokens[i + <span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">if</span> next[<span class="hljs-number">0</span>] <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'('</span>]
|
||||
throwSyntaxError <span class="hljs-string">'expected wrapped or quoted CSX attribute'</span>, next[<span class="hljs-number">2</span>]
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-35">
|
||||
<div class="annotation">
|
||||
|
||||
|
@ -965,6 +981,10 @@ blocks are added.</p>
|
|||
<span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> [<span class="hljs-number">1.</span><span class="hljs-number">.2</span>] <span class="hljs-keyword">when</span> @tag(i + j) <span class="hljs-keyword">in</span> [<span class="hljs-string">'OUTDENT'</span>, <span class="hljs-string">'TERMINATOR'</span>, <span class="hljs-string">'FINALLY'</span>]
|
||||
tokens.splice i + j, <span class="hljs-number">0</span>, @indentation()...
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">2</span> + j
|
||||
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> [<span class="hljs-string">'->'</span>, <span class="hljs-string">'=>'</span>] <span class="hljs-keyword">and</span> (@tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">','</span> <span class="hljs-keyword">or</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'.'</span> <span class="hljs-keyword">and</span> token.newLine)
|
||||
[indent, outdent] = @indentation tokens[i]
|
||||
tokens.splice i + <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, indent, outdent
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> SINGLE_LINERS <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">isnt</span> <span class="hljs-string">'INDENT'</span> <span class="hljs-keyword">and</span>
|
||||
<span class="hljs-keyword">not</span> (tag <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'IF'</span>)
|
||||
starter = tag
|
||||
|
@ -1179,7 +1199,7 @@ EXPRESSION_END = []
|
|||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>IMPLICIT_CALL = [
|
||||
<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'PROPERTY'</span>, <span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'INFINITY'</span>, <span class="hljs-string">'NAN'</span>
|
||||
<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'CSX_TAG'</span>, <span class="hljs-string">'PROPERTY'</span>, <span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'INFINITY'</span>, <span class="hljs-string">'NAN'</span>
|
||||
<span class="hljs-string">'STRING'</span>, <span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">'REGEX_START'</span>, <span class="hljs-string">'JS'</span>
|
||||
<span class="hljs-string">'NEW'</span>, <span class="hljs-string">'PARAM_START'</span>, <span class="hljs-string">'CLASS'</span>, <span class="hljs-string">'IF'</span>, <span class="hljs-string">'TRY'</span>, <span class="hljs-string">'SWITCH'</span>, <span class="hljs-string">'THIS'</span>
|
||||
<span class="hljs-string">'UNDEFINED'</span>, <span class="hljs-string">'NULL'</span>, <span class="hljs-string">'BOOL'</span>
|
||||
|
@ -1254,6 +1274,21 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
|
|||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-53">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-53">¶</a>
|
||||
</div>
|
||||
<p>Tokens that prevent a subsequent indent from ending implicit calls/objects</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CONTROL_IN_IMPLICIT = [<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>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -597,7 +597,7 @@ textarea {
|
|||
<a href="#conditionals" class="nav-link" data-action="sidebar-nav">If, Else, Unless, and Conditional Assignment</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#splats" class="nav-link" data-action="sidebar-nav">Splats…</a>
|
||||
<a href="#splats" class="nav-link" data-action="sidebar-nav">Splats, or Rest Parameters/Spread Syntax</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#loops" class="nav-link" data-action="sidebar-nav">Loops and Comprehensions</a>
|
||||
|
@ -713,6 +713,9 @@ textarea {
|
|||
<li class="nav-item">
|
||||
<a href="#breaking-changes" class="nav-link" data-action="sidebar-nav">Breaking Changes From 1.x</a>
|
||||
<ul class="nav">
|
||||
<li class="nav-item">
|
||||
<a href="#breaking-change-fat-arrow" class="nav-link" data-action="sidebar-nav">Bound (Fat Arrow) Functions</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#breaking-changes-default-values" class="nav-link" data-action="sidebar-nav">Default Values</a>
|
||||
</li>
|
||||
|
@ -758,7 +761,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>“It’s 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-beta2">2.0.0-beta2</a></p>
|
||||
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.0.0-beta3">2.0.0-beta3</a></p>
|
||||
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install -g coffeescript@next
|
||||
</code></pre>
|
||||
</blockquote>
|
||||
|
@ -1385,8 +1388,8 @@ date = friday ? sue : jill;
|
|||
|
||||
</section>
|
||||
<section id="splats">
|
||||
<h2>Splats…</h2>
|
||||
<p>The JavaScript <code>arguments</code> object is a useful way to work with functions that accept variable numbers of arguments. CoffeeScript provides splats <code>...</code>, both for function definition as well as invocation, making variable numbers of arguments a little bit more palatable.</p>
|
||||
<h2>Splats, or Rest Parameters/Spread Syntax</h2>
|
||||
<p>The JavaScript <code>arguments</code> object is a useful way to work with functions that accept variable numbers of arguments. CoffeeScript provides splats <code>...</code>, both for function definition as well as invocation, making variable numbers of arguments a little bit more palatable. ES2015 adopted this feature as their <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters">rest parameters</a>.</p>
|
||||
<aside class="code-example container-fluid bg-ribbed-dark" data-example="splats">
|
||||
<div class="row">
|
||||
<div class="col-md-6 coffeescript-input-column">
|
||||
|
@ -1412,9 +1415,11 @@ contenders = [
|
|||
|
||||
awardMedals contenders...
|
||||
|
||||
alert "Gold: " + gold
|
||||
alert "Silver: " + silver
|
||||
alert "The Field: " + rest
|
||||
alert """
|
||||
Gold: #{gold}
|
||||
Silver: #{silver}
|
||||
The Field: #{rest.join ', '}
|
||||
"""
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="col-md-6 javascript-output-column">
|
||||
|
@ -1432,11 +1437,7 @@ contenders = ["Michael Phelps", "Liu Xiang", "Yao Ming", "Allyson Felix", "Shawn
|
|||
|
||||
awardMedals(...contenders);
|
||||
|
||||
alert("Gold: " + gold);
|
||||
|
||||
alert("Silver: " + silver);
|
||||
|
||||
alert("The Field: " + rest);
|
||||
alert(`Gold: ${gold}\nSilver: ${silver}\nThe Field: ${rest.join(', ')}`);
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1448,6 +1449,71 @@ alert("The Field: " + rest);
|
|||
</div>
|
||||
|
||||
</aside>
|
||||
<div id="array-spread" class="bookmark"></div>
|
||||
<p>Splats also let us elide array elements…</p>
|
||||
<aside class="code-example container-fluid bg-ribbed-dark" data-example="array_spread">
|
||||
<div class="row">
|
||||
<div class="col-md-6 coffeescript-input-column">
|
||||
<textarea class="coffeescript-input" id="array_spread-coffee">popular = ['pepperoni', 'sausage', 'cheese']
|
||||
unwanted = ['anchovies', 'olives']
|
||||
|
||||
all = [popular..., unwanted..., 'mushrooms']
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="col-md-6 javascript-output-column">
|
||||
<textarea class="javascript-output" id="array_spread-js">var all, popular, unwanted;
|
||||
|
||||
popular = ['pepperoni', 'sausage', 'cheese'];
|
||||
|
||||
unwanted = ['anchovies', 'olives'];
|
||||
|
||||
all = [...popular, ...unwanted, 'mushrooms'];
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 text-xs-right">
|
||||
<button type="button" class="btn btn-primary" data-action="run-code-example" data-example="array_spread" data-run="all"><small>▶</small> all</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</aside>
|
||||
<div id="object-spread" class="bookmark"></div>
|
||||
<p>…and object properties.</p>
|
||||
<aside class="code-example container-fluid bg-ribbed-dark" data-example="object_spread">
|
||||
<div class="row">
|
||||
<div class="col-md-6 coffeescript-input-column">
|
||||
<textarea class="coffeescript-input" id="object_spread-coffee">user =
|
||||
name: 'Werner Heisenberg'
|
||||
occupation: 'theoretical physicist'
|
||||
|
||||
currentUser = { user..., status: 'Uncertain' }
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="col-md-6 javascript-output-column">
|
||||
<textarea class="javascript-output" id="object_spread-js">var currentUser, user;
|
||||
|
||||
user = {
|
||||
name: 'Werner Heisenberg',
|
||||
occupation: 'theoretical physicist'
|
||||
};
|
||||
|
||||
currentUser = Object.assign({}, user, {
|
||||
status: 'Uncertain'
|
||||
});
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 text-xs-right">
|
||||
<button type="button" class="btn btn-primary" data-action="run-code-example" data-example="object_spread" data-run="JSON.stringify%28currentUser%29"><small>▶</small> JSON.stringify(currentUser)</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</aside>
|
||||
<p>In ECMAScript this is called <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator">spread syntax</a>, and has been supported for arrays since ES2015 but is <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Spread_in_object_literals">coming soon for objects</a>. Until object spread syntax is officially supported, the CoffeeScript compiler outputs the same polyfill as <a href="https://babeljs.io/docs/plugins/transform-object-rest-spread/">Babel’s rest spread transform</a>; but once it is supported, we will revise the compiler’s output. Note that there are <a href="https://developers.google.com/web/updates/2017/06/object-rest-spread">very subtle differences</a> between the polyfill and the current proposal.</p>
|
||||
|
||||
</section>
|
||||
<section id="loops">
|
||||
|
@ -3310,7 +3376,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-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>
|
||||
<p>You can browse the CoffeeScript 2.0.0-beta3 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>
|
||||
|
@ -3416,6 +3482,44 @@ Object.defineProperty(screen, 'height', {
|
|||
<h2>Breaking Changes From CoffeeScript 1.x to 2</h2>
|
||||
<p>CoffeeScript 2 aims to output as much idiomatic ES2015+ syntax as possible with as few breaking changes from CoffeeScript 1.x as possible. Some breaking changes, unfortunately, were unavoidable.</p>
|
||||
|
||||
<section id="breaking-change-fat-arrow">
|
||||
<h3>Bound (fat arrow) functions</h3>
|
||||
<p>In CoffeeScript 1.x, <code>=></code> compiled to a regular <code>function</code> but with references to <code>this</code>/<code>@</code> rewritten to use the outer scope’s <code>this</code>, or with the inner function bound to the outer scope via <code>.bind</code> (hence the name “bound function”). In CoffeeScript 2, <code>=></code> compiles to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">ES2015’s <code>=></code></a>, which behaves slightly differently. The largest difference is that in ES2015, <code>=></code> functions lack an <code>arguments</code> object:</p>
|
||||
<aside class="code-example container-fluid bg-ribbed-dark" data-example="breaking_change_fat_arrow">
|
||||
<div class="row">
|
||||
<div class="col-md-6 coffeescript-input-column">
|
||||
<textarea class="coffeescript-input" id="breaking_change_fat_arrow-coffee">outer = ->
|
||||
inner = => Array.from arguments
|
||||
inner()
|
||||
|
||||
outer(1, 2) # Returns '' in CoffeeScript 1.x, '1, 2' in CoffeeScript 2
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="col-md-6 javascript-output-column">
|
||||
<textarea class="javascript-output" id="breaking_change_fat_arrow-js">var outer;
|
||||
|
||||
outer = function() {
|
||||
var inner;
|
||||
inner = () => {
|
||||
return Array.from(arguments);
|
||||
};
|
||||
return inner();
|
||||
};
|
||||
|
||||
outer(1, 2);
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 text-xs-right">
|
||||
<button type="button" class="btn btn-primary" data-action="run-code-example" data-example="breaking_change_fat_arrow" data-run="outer%281%2C%202%29"><small>▶</small> outer(1, 2)</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</aside>
|
||||
|
||||
</section>
|
||||
<section id="breaking-changes-default-values">
|
||||
<h3>Default values for function parameters and destructured elements</h3>
|
||||
<p>Per the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters">ES2015 spec regarding function default parameters</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Default_values">destructuring default values</a>, default values are only applied when a value is missing or <code>undefined</code>. In CoffeeScript 1.x, the default value would be applied in those cases but also if the value was <code>null</code>.</p>
|
||||
|
@ -3515,13 +3619,16 @@ f = function*() {
|
|||
<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">-></span> <span class="keyword">this</span> <span class="comment"># Throws a compiler error</span>
|
||||
</code></pre>
|
||||
</blockquote><p>Class methods can’t be bound (i.e. you can’t 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">=></span> <span class="comment"># Throws a compiler error</span>
|
||||
|
||||
</blockquote><p>ES2015 classes don’t allow bound (fat arrow) methods. The CoffeeScript compiler goes through some contortions to preserve support for them, but one thing that can’t be accomodated is calling a bound method before it is bound:</p>
|
||||
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">Base</span></span>
|
||||
constructor: <span class="function">-></span>
|
||||
<span class="keyword">super</span>()
|
||||
@method = <span class="function">=></span> <span class="comment"># This works</span>
|
||||
@onClick() <span class="comment"># This works</span>
|
||||
clickHandler = @onClick
|
||||
clickHandler() <span class="comment"># This throws a runtime error</span>
|
||||
|
||||
<span class="class"><span class="keyword">class</span> <span class="title">Component</span> <span class="keyword">extends</span> <span class="title">Base</span></span>
|
||||
onClick: <span class="function">=></span>
|
||||
<span class="built_in">console</span>.log <span class="string">'Clicked!'</span>, @
|
||||
</code></pre>
|
||||
</blockquote><p>Class methods can’t 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>
|
||||
|
@ -3694,6 +3801,17 @@ B = class B extends A {
|
|||
</section>
|
||||
<section id="changelog">
|
||||
<h2>Changelog</h2>
|
||||
<div class="anchor" id="2.0.0-beta3"></div>
|
||||
<h2 class="header">
|
||||
<a href="https://github.com/jashkenas/coffeescript/compare/2.0.0-beta2...2.0.0-beta3">2.0.0-beta3</a>
|
||||
<span class="timestamp"> — <time datetime="2017-06-30">June 30, 2017</time></span>
|
||||
</h2><ul>
|
||||
<li><a href="#jsx">JSX</a> is now supported.</li>
|
||||
<li><a href="#object-spread">Object rest/spread properties</a> are now supported.</li>
|
||||
<li>Bound (fat arrow) methods are once again supported in classes; though an error will be thrown if you attempt to call the method before it is bound. See <a href="#breaking-changes-classes">breaking changes for classes</a>.</li>
|
||||
<li>The REPL no longer warns about assigning to <code>_</code>.</li>
|
||||
<li>Bugfixes for destructured nested default values and issues related to chaining or continuing expressions across multiple lines.</li>
|
||||
</ul>
|
||||
<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>
|
||||
|
@ -4445,6 +4563,8 @@ $(document).ready ->
|
|||
toggleTry()
|
||||
else
|
||||
initializeScrollspyFromHash window.location.hash
|
||||
# Initializing the code editors might’ve thrown off our vertical scroll position
|
||||
document.getElementById(window.location.hash.slice(1)).scrollIntoView()
|
||||
|
||||
</script>
|
||||
|
||||
|
|
2161
docs/v2/test.html
2161
docs/v2/test.html
File diff suppressed because it is too large
Load diff
4
documentation/examples/array_spread.coffee
Normal file
4
documentation/examples/array_spread.coffee
Normal file
|
@ -0,0 +1,4 @@
|
|||
popular = ['pepperoni', 'sausage', 'cheese']
|
||||
unwanted = ['anchovies', 'olives']
|
||||
|
||||
all = [popular..., unwanted..., 'mushrooms']
|
5
documentation/examples/breaking_change_fat_arrow.coffee
Normal file
5
documentation/examples/breaking_change_fat_arrow.coffee
Normal file
|
@ -0,0 +1,5 @@
|
|||
outer = ->
|
||||
inner = => Array.from arguments
|
||||
inner()
|
||||
|
||||
outer(1, 2) # Returns '' in CoffeeScript 1.x, '1, 2' in CoffeeScript 2
|
5
documentation/examples/object_spread.coffee
Normal file
5
documentation/examples/object_spread.coffee
Normal file
|
@ -0,0 +1,5 @@
|
|||
user =
|
||||
name: 'Werner Heisenberg'
|
||||
occupation: 'theoretical physicist'
|
||||
|
||||
currentUser = { user..., status: 'Uncertain' }
|
|
@ -20,6 +20,8 @@ contenders = [
|
|||
|
||||
awardMedals contenders...
|
||||
|
||||
alert "Gold: " + gold
|
||||
alert "Silver: " + silver
|
||||
alert "The Field: " + rest
|
||||
alert """
|
||||
Gold: #{gold}
|
||||
Silver: #{silver}
|
||||
The Field: #{rest.join ', '}
|
||||
"""
|
||||
|
|
7
documentation/sections/breaking_change_fat_arrow.md
Normal file
7
documentation/sections/breaking_change_fat_arrow.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
### Bound (fat arrow) functions
|
||||
|
||||
In CoffeeScript 1.x, `=>` compiled to a regular `function` but with references to `this`/`@` rewritten to use the outer scope’s `this`, or with the inner function bound to the outer scope via `.bind` (hence the name “bound function”). In CoffeeScript 2, `=>` compiles to [ES2015’s `=>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), which behaves slightly differently. The largest difference is that in ES2015, `=>` functions lack an `arguments` object:
|
||||
|
||||
```
|
||||
codeFor('breaking_change_fat_arrow', 'outer(1, 2)')
|
||||
```
|
|
@ -16,15 +16,18 @@ class B extends A
|
|||
constructor: -> this # Throws a compiler error
|
||||
```
|
||||
|
||||
Class methods can’t be bound (i.e. you can’t define a class method using a fat arrow) though you can define such methods in the constructor instead:
|
||||
ES2015 classes don’t allow bound (fat arrow) methods. The CoffeeScript compiler goes through some contortions to preserve support for them, but one thing that can’t be accomodated is calling a bound method before it is bound:
|
||||
|
||||
```coffee
|
||||
class B extends A
|
||||
method: => # Throws a compiler error
|
||||
|
||||
class Base
|
||||
constructor: ->
|
||||
super()
|
||||
@method = => # This works
|
||||
@onClick() # This works
|
||||
clickHandler = @onClick
|
||||
clickHandler() # This throws a runtime error
|
||||
|
||||
class Component extends Base
|
||||
onClick: =>
|
||||
console.log 'Clicked!', @
|
||||
```
|
||||
|
||||
Class methods can’t be used with `new` (uncommon):
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
## Changelog
|
||||
|
||||
```
|
||||
releaseHeader('2017-06-30', '2.0.0-beta3', '2.0.0-beta2')
|
||||
```
|
||||
|
||||
* [JSX](#jsx) is now supported.
|
||||
* [Object rest/spread properties](#object-spread) are now supported.
|
||||
* Bound (fat arrow) methods are once again supported in classes; though an error will be thrown if you attempt to call the method before it is bound. See [breaking changes for classes](#breaking-changes-classes).
|
||||
* The REPL no longer warns about assigning to `_`.
|
||||
* Bugfixes for destructured nested default values and issues related to chaining or continuing expressions across multiple lines.
|
||||
|
||||
|
||||
```
|
||||
releaseHeader('2017-05-16', '2.0.0-beta2', '2.0.0-beta1')
|
||||
```
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
## Splats…
|
||||
## Splats, or Rest Parameters/Spread Syntax
|
||||
|
||||
The JavaScript `arguments` object is a useful way to work with functions that accept variable numbers of arguments. CoffeeScript provides splats `...`, both for function definition as well as invocation, making variable numbers of arguments a little bit more palatable.
|
||||
The JavaScript `arguments` object is a useful way to work with functions that accept variable numbers of arguments. CoffeeScript provides splats `...`, both for function definition as well as invocation, making variable numbers of arguments a little bit more palatable. ES2015 adopted this feature as their [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
|
||||
|
||||
```
|
||||
codeFor('splats', true)
|
||||
```
|
||||
|
||||
<div id="array-spread" class="bookmark"></div>
|
||||
|
||||
Splats also let us elide array elements...
|
||||
|
||||
```
|
||||
codeFor('array_spread', 'all')
|
||||
```
|
||||
|
||||
<div id="object-spread" class="bookmark"></div>
|
||||
|
||||
...and object properties.
|
||||
|
||||
```
|
||||
codeFor('object_spread', 'JSON.stringify(currentUser)')
|
||||
```
|
||||
|
||||
In ECMAScript this is called [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator), and has been supported for arrays since ES2015 but is [coming soon for objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Spread_in_object_literals). Until object spread syntax is officially supported, the CoffeeScript compiler outputs the same polyfill as [Babel’s rest spread transform](https://babeljs.io/docs/plugins/transform-object-rest-spread/); but once it is supported, we will revise the compiler’s output. Note that there are [very subtle differences](https://developers.google.com/web/updates/2017/06/object-rest-spread) between the polyfill and the current proposal.
|
|
@ -157,6 +157,9 @@
|
|||
</section>
|
||||
<section id="breaking-changes">
|
||||
<%= htmlFor('breaking_changes') %>
|
||||
<section id="breaking-change-fat-arrow">
|
||||
<%= htmlFor('breaking_change_fat_arrow') %>
|
||||
</section>
|
||||
<section id="breaking-changes-default-values">
|
||||
<%= htmlFor('breaking_changes_default_values') %>
|
||||
</section>
|
||||
|
|
|
@ -124,3 +124,5 @@ $(document).ready ->
|
|||
toggleTry()
|
||||
else
|
||||
initializeScrollspyFromHash window.location.hash
|
||||
# Initializing the code editors might’ve thrown off our vertical scroll position
|
||||
document.getElementById(window.location.hash.slice(1)).scrollIntoView()
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<a href="#conditionals" class="nav-link" data-action="sidebar-nav">If, Else, Unless, and Conditional Assignment</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#splats" class="nav-link" data-action="sidebar-nav">Splats…</a>
|
||||
<a href="#splats" class="nav-link" data-action="sidebar-nav">Splats, or Rest Parameters/Spread Syntax</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#loops" class="nav-link" data-action="sidebar-nav">Loops and Comprehensions</a>
|
||||
|
@ -150,6 +150,9 @@
|
|||
<li class="nav-item">
|
||||
<a href="#breaking-changes" class="nav-link" data-action="sidebar-nav">Breaking Changes From 1.x</a>
|
||||
<ul class="nav">
|
||||
<li class="nav-item">
|
||||
<a href="#breaking-change-fat-arrow" class="nav-link" data-action="sidebar-nav">Bound (Fat Arrow) Functions</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#breaking-changes-default-values" class="nav-link" data-action="sidebar-nav">Default Values</a>
|
||||
</li>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var CoffeeScript, compile, runScripts,
|
||||
indexOf = [].indexOf;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var Lexer, SourceMap, base64encode, compile, formatSourcePosition, getSourceMap, helpers, lexer, packageJson, parser, sourceMaps, sources, withPrettyErrors;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, buildCSOptionParser, 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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var CoffeeScript, compile, ext, fn, fs, helpers, i, len, path, ref, vm,
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARABLE_LEFT_SIDE, COMPARE, COMPOUND_ASSIGN, CSX_ATTRIBUTE, CSX_IDENTIFIER, CSX_INTERPOLATION, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, HERE_JSTOKEN, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INSIDE_CSX, 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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var Access, Arr, Assign, AwaitReturn, Base, Block, BooleanLiteral, CSXTag, 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,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, runInContext, updateSyntaxError, vm;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var BALANCED_PAIRS, CALL_CLOSERS, CONTROL_IN_IMPLICIT, 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, throwSyntaxError,
|
||||
indexOf = [].indexOf;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var Scope,
|
||||
indexOf = [].indexOf;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 2.0.0-beta2
|
||||
// Generated by CoffeeScript 2.0.0-beta3
|
||||
(function() {
|
||||
var LineMap, SourceMap;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"compiler"
|
||||
],
|
||||
"author": "Jeremy Ashkenas",
|
||||
"version": "2.0.0-beta2",
|
||||
"version": "2.0.0-beta3",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=7.6.0"
|
||||
|
|
|
@ -360,16 +360,16 @@ test "#3906: handle further indentation inside indented chain", ->
|
|||
eq 1, CoffeeScript.eval '''
|
||||
z = -> b: -> e: ->
|
||||
|
||||
z()
|
||||
.b
|
||||
c: 'd'
|
||||
.e()
|
||||
z()
|
||||
.b
|
||||
c: 'd'
|
||||
.e()
|
||||
|
||||
f = [
|
||||
'g'
|
||||
]
|
||||
f = [
|
||||
'g'
|
||||
]
|
||||
|
||||
1
|
||||
1
|
||||
'''
|
||||
|
||||
eq 1, CoffeeScript.eval '''
|
||||
|
|
Loading…
Add table
Reference in a new issue