Compare commits

..

1192 Commits

Author SHA1 Message Date
Simon Lydell
fb0639fa38 Merge pull request #4381 from GeoffreyBooth/1.12
[WIP] 1.12.0
2016-12-04 20:32:45 +01:00
Geoffrey Booth
b7dbee2402 Update broken links 2016-12-03 23:49:44 -08:00
Geoffrey Booth
2ca0f44cc8 Update 1.12.0 release date 2016-12-03 23:14:08 -08:00
Geoffrey Booth
c5121c8c4e Rebuild 2016-12-03 22:06:07 -08:00
Geoffrey Booth
2f72d0394f Improve comments formatting for better output in annotated source 2016-12-03 21:53:43 -08:00
Geoffrey Booth
026d9d6ccd Merge branch 'master' of github.com:jashkenas/coffeescript into 1.12 2016-12-03 20:24:28 -08:00
Simon Lydell
c9de5be966 Merge pull request #4383 from GeoffreyBooth/escape-template-literals
Escape backticks and `${` within template literals; fixes #4380
2016-12-03 20:41:25 +01:00
Geoffrey Booth
d45d780869 Improve tests and comments 2016-12-03 10:16:41 -08:00
Geoffrey Booth
d8abfae457 Handle tagged template literals (and future CS2 interpolated strings) with “invalidly escaped” backticks or ${—one backslash instead of two 2016-12-02 16:54:31 -08:00
Geoffrey Booth
98bf335777 Regenerate docs 2016-12-01 21:42:17 -08:00
Geoffrey Booth
1a69493f87 Remove change log updates related to documentation and the compiler build system 2016-12-01 21:40:18 -08:00
Geoffrey Booth
abe746bf53 Wrap HTML in comments in backticks, so as not to fool docco when generating the annotated source 2016-12-01 21:36:15 -08:00
Geoffrey Booth
075e48df95 Add Trix to list of examples; closes #4227 2016-12-01 21:28:42 -08:00
Geoffrey Booth
47c0a5cbef Escape backticks and ${ within template literals; fixes #4380 2016-12-01 13:10:03 -08:00
Geoffrey Booth
c48f5ce30f Add link to browser tests 2016-11-30 22:51:25 -08:00
Geoffrey Booth
4efd27ed28 Update annotated source for 1.12.0 2016-11-30 22:38:14 -08:00
Geoffrey Booth
e6b1218ae1 Updated output docs for 1.12.0, including new browser compiler 2016-11-30 22:33:20 -08:00
Geoffrey Booth
68938cda30 Updated lib for 1.12.0 2016-11-30 22:27:32 -08:00
Geoffrey Booth
7d6a3b5fa4 Docs examples with quotation marks were broken. Properly escape the quotes. http://stackoverflow.com/a/1082558/223225 2016-11-30 22:23:51 -08:00
Geoffrey Booth
f187440bb8 Update size of browser compiler 2016-11-30 22:06:22 -08:00
Geoffrey Booth
d0d2ef9f77 Convert eligible HTML entities to unicode characters (a recommended practice: http://stackoverflow.com/a/436637/223225) and convert straight quotes to curly quotes 2016-11-30 21:55:24 -08:00
Geoffrey Booth
a15bf3d336 1.11.1 to 1.12.0 change log 2016-11-30 20:48:58 -08:00
Geoffrey Booth
6d507b46d3 Bump version to 1.12.0; pass through as a variable to index.html 2016-11-30 20:48:06 -08:00
Jeremy Ashkenas
5588658641 Merge pull request #4378 from GeoffreyBooth/fix-browser-tests
Fix browser tests
2016-11-30 10:22:42 -05:00
Geoffrey Booth
d99ae0e7ef Refactor the way test.html runs tests to be similar to how Cakefile runs them; most importantly, tests fail when the test function throws an exception, not when ok does (which happens intentionally a few times in the classes tests); this also produces a more accurate count of tests run 2016-11-30 00:34:07 -08:00
Geoffrey Booth
cf3a27259a Exclude error messages from browser-based tests; watch test files 2016-11-30 00:31:18 -08:00
Geoffrey Booth
1ea753d19f Polyfill missing helper functions from Node’s assert, one with CDN-hosted Underscore; handle .litcoffee correctly 2016-11-30 00:02:45 -08:00
Geoffrey Booth
831d3c9341 test.html: better test failure output; add inexplicably missing testingBrowser 2016-11-29 21:37:54 -08:00
Geoffrey Booth
729fec2947 Abstract the eq and arrayEq functions, shared by Cakefile and test.html, into one file that can be included into both 2016-11-29 21:19:11 -08:00
Geoffrey Booth
faab9330e9 Run literate 2016-11-29 18:33:18 -08:00
Geoffrey Booth
8c8ebf874a Add test description to error message 2016-11-29 18:27:34 -08:00
Geoffrey Booth
06b3180223 Refactor test.html to be part of the docs output, with the tests embedded inside it; update test.html styles; move UTF-8 comment test out of test.html and into test/comments.coffee where it belongs 2016-11-29 18:13:12 -08:00
Geoffrey Booth
6d29086519 Standardize on .html file extension; move test.html into its new home 2016-11-29 08:45:46 -08:00
Geoffrey Booth
a401f587c3 Organize Cakefile: move helper functions that are only used by doc:site into the doc:site task 2016-11-29 08:39:00 -08:00
Geoffrey Booth
ac26360fdc Replace Uglify.js with Google Closure Compiler, JS version; let NPM finally reformat package.json the way it likes (#4376) 2016-11-28 23:10:17 -08:00
Geoffrey Booth
ac20f6634a Browser compiler should convert the string to load to UTF-8, in case it is UTF-16 like the contents of a <script> block generally are (#4375) 2016-11-27 23:05:49 -08:00
Geoffrey Booth
5c765f4cc7 Add for…from to list of ES2015 exceptions in the introduction (#4373) 2016-11-27 23:05:05 -08:00
Geoffrey Booth
02c5641b32 Fix path to browser compiler (#4374) 2016-11-27 20:47:54 -08:00
Gregory Huczynski
555e47dbb9 Docs for tagged template literals (#4372)
* Correct tagged template literal test.

Should use Coffeescript form of interpolated
strings, not Javascript!

* First pass at docs for tagged template literals.

* Correct alerted variable.

* Add note re checking runtime for tagged template literals

* Fixed broken example.

* Consistent style

* Clarify that CoffeeScript isn’t handling the tagged template literal, the runtime is; fix CoffeeScript spelling

* Collapse notes about generator functions and tagged template literals into the same sentence

* Make tagged template literals example into a function

* Make text less clunky.

* More clarity on what CoffeeScript is doing versus what the runtime is doing, and emphasize runtimes vs Babel/Traceur
2016-11-26 19:28:43 -08:00
Geoffrey Booth
992eb49e92 Docs for triple-backticks and escaping backticks (#4369)
* Documentation for triple backticks and escaping backticks

* Better explanation of escaped backticks within triple-backticks block
2016-11-22 22:09:35 -08:00
Geoffrey Booth
8ea67ff3e9 Update Bower.json per latest spec (#4371)
* Remove moot `version` property from bower.json

Per bower/bower.json-spec@a325da3

* No need for bower to know about dev dependencies, and this is one less thing to keep in sync
2016-11-22 22:00:51 -08:00
Geoffrey Booth
56482a3166 Docs for for…from (#4368)
* Documentation of `for...from` for iterating over generator functions

* Add note that the CoffeeScript compiler does not, in fact, generate JavaScript that runs in every JavaScript runtime 😢
2016-11-22 09:30:39 -08:00
Daniel Bayley
6c759d49bd Docs shorthand object notation (#4356)
* Docs shorthand object notation

A simple but slightly more imaginative example of shorthand object notation.

Closes #1808.

Signed-off-by: Daniel Bayley <daniel.bayley@me.com>

* Update for new documentation folder structure

* Fix typo
2016-11-20 23:04:49 -08:00
Geoffrey Booth
cc3be717a0 Docs improvements (#4367)
* The generated JavaScript for the examples in the docs ends up within index.html, so we don’t need the intermediate generated .js files committed in the repo; also, even while .gitignored they should be under `docs`, with the rest of the generated files, not under `documentation`, where the source files are.

* Add “Existential Operator” to the table of contents. Closes #4361

* Updated output due to newer version of highlight.js

* Generated the JavaScript for the docs examples should be synchronous, so that index.html isn’t generated before the JavaScript is

* In “Try CoffeeScript,” if you press the tab key it should type a tab character. Closes #3342.

* Rename doc example folders from `js` and `coffee` to just `examples`

* Add missing `yield` to the list of keywords to highlight until highlight.js catches up; update the class used to match highlight.js’ `keyword`

* `cake doc:site` should watch the example files too, not just index.html.js

* Remove examples folder, including underscore.coffee; remove link to annotated underscore.coffee
2016-11-20 17:05:19 -08:00
Geoffrey Booth
073e14746e Triple backticks to allow creation of JavaScript blocks (#4357)
* Support JavaScript code blocks set apart by triple backticks (``` ... ```)

* Add test for escaped backticks

* Remove TODOs for things we’re never going to support

* Convert escaped backticks to backticks; update tests

* Block inline JavaScript can end with an escaped backtick character

* Updated JavaScript token regexes per @lydell

* In JavaScript blocks, escape backslashes when they immediately precede backticks; additional tests

* Test that we don’t break backslash escaping in JavaScript literals
2016-11-19 11:13:30 -08:00
Gregory Huczynski
78e1f43b24 CS1 tagged template literals (and CS2 interpolated strings as template literals) (#4352)
* Add initial support for template literals with no
interpolation

* Change ‘unexpected string’ error message tests to
use number not identifier prefix.

Identifer prefixes are now valid as tagged
template literals

* Test tagged template literals for non-interpolated
strings and tag function.

* Tagged template literals work for pure Strings.

Pull tagged template definition up to Invocation
level in grammar, enabling chained invocation calls.

We can view a tagged template is a special form
of function call.

* Readying for StringWithInterpolations work.

* Tweaks.

* Fix style

* Pass StringWithInterpolations parameter straight
into Call constructor.

StringWithInterpolations will be output as
template literal, so already in correct form for
outputting tagged template literal.

* Strip down compileNode for StringWithInterpolations

* Done StringLiteral case for interpolated Strings

* Remove need for TemplateLiteral

* Simplify code.

* Small code tidy

* Interpolated strings now outputting as template literals.

Still needs comprehensive testing.

* Move error message tests into error_messages.coffee; remove test that is testing for a Node runtime error

* Split up tests that were testing multiple things per test, so that each test tests only one thing

* Edge cases: tagged template literals containing interpolated strings or even internal tagged template literals

* Make more concise, more idiomatic style

* Pull back extreme indentation

* Restore and fix commented-out tests

* Edge case: tagged template literal with empty string

* Only use new ES2015 interpolated string syntax if we’re inside a tagged template literal; this keeps this PR safe to merge into CoffeeScript 1.x. Remove the code from this commit to make all interpolated strings use ES2015 syntax, for CoffeeScript 2.

* Compiler now _doesn’t_ use template literals.

* Expand tagged template literal tests

* Move ‘Unexpected string’ error message tests into
tagged template literal section.

‘Unexpected string’ is not reported in these test
scenarios anymore. Instead, we error that the
prefixing literal is not a function.

* Don’t unwrap StringWithInterpolations.

Saw bug with program consisting of “#{2}” not
compiling with template literals. Root cause was
that Block.compileNode was unwrapping interpolated
string and so didn’t use compileNode logic at
StringWithInterpolations level.

* No need to bracket interpolated strings any more.

When interpolated string looks like `hello ${2}`,
no extract brackets are needed, as the `s mark the
beginning and end.

* Show html templating with tagged template literals

* Multiline should match multiline

* Comment out unnecessary `unwrap`, which is only needed for CoffeeScript 2 all-ES2015 syntax output
2016-11-18 10:25:03 -08:00
Geoffrey Booth
a49c5c5150 Revert to http://coffeescript.org until GitHub pages supports HTTPS for custom domains (#4363) 2016-11-17 09:57:03 -08:00
Jeremy Ashkenas
24033eb11a move CNAME 2016-11-17 12:02:30 -05:00
Jeremy Ashkenas
f32740c032 Merge pull request #4360 from GeoffreyBooth/branch-docs
Reorganize docs for v1/v2 split
2016-11-17 11:59:37 -05:00
Geoffrey Booth
bebc5812e5 Revert unintended changes to generated index.html 2016-11-15 22:08:27 -08:00
Geoffrey Booth
4ab6fbca72 Fix missing hunk 2016-11-15 21:55:19 -08:00
Geoffrey Booth
7bc5b73db1 Fix links to annotated source 2016-11-15 21:37:41 -08:00
Geoffrey Booth
a95d986055 coffeescript.org goes HTTPS! 2016-11-15 21:31:53 -08:00
Geoffrey Booth
846c0e4c51 Even 1.x doesn’t need to limit generators tests to --harmony mode anymore; minor cleanup 2016-11-15 21:28:35 -08:00
Geoffrey Booth
3736b0fed1 Update cake build:browser to reflect new path to coffee-script.js 2016-11-15 21:19:43 -08:00
Geoffrey Booth
eb46975d87 Update cake doc:source to output to new docs/v{1|2}/annotated-source; collapse doc:underscore into it and generate missing underscore.html (closes #4295) 2016-11-15 21:16:13 -08:00
Geoffrey Booth
3739954de6 Move v1 documentation under docs/v1, with docs/index.html symlinking to docs/v1/index.html (with .nojekyll file to hopefully make the symlink work) 2016-11-15 20:54:30 -08:00
Geoffrey Booth
3b0b002f29 Use Google-hosted jQuery 2016-11-15 20:37:11 -08:00
Geoffrey Booth
6f09d36ec8 Update dev dependencies; update template rendering to use new Underscore syntax 2016-11-14 21:39:25 -08:00
Geoffrey Booth
b3896d08e8 Add a for .. from .. loop for generators, see #4306, #3832 (#4355)
* Added support for for-from loop, see #3832

* for-from: remove extra newline and add support for ranges

* for-from: tidy up the lexer

* for-from: add support for patterns

* for-from: fix bad alignment

* for-from: add two more tests

* for-from: fix test "for-from loops over generators"

See explanation here: https://github.com/jashkenas/coffeescript/pull/4306#issuecomment-257066877

* for-from: delete leftover console.log

* Refactor the big `if` block in the lexer to be as minimal a change from `master` as we can get away with

* Cleanup to make more idiomatic, remove trailing whitespace, minor performance improvements

* for-from: move code from one file to another

* for-from: clean up whitespace

* for-from: lexer bikeshedding

* Move "own is not supported in for-from loops" test into error_messages.coffee; improve error message so that "own" is underlined

* Revert unnecessary changes, to minimize the lines of code modified by this PR
2016-11-07 23:40:01 -08:00
Simon Lydell
aca72f9b91 Merge pull request #4350 from alangpierce/upstream-fix-generated-close-curly-location
Include generated } tokens when fixing closing token positions
2016-10-31 07:54:24 +01:00
Alan Pierce
c5afb4e2fd Include generated } tokens when fixing closing token positions
This is an upstream port of https://github.com/decaffeinate/coffeescript/pull/10
See that PR for links to the issues that this fixes.

Just like OUTDENT and CALL_END tokens, close-curly-brace tokens can be generated
without having a real location, and if that position overlaps with a later
token, it can cause the AST to have bad location data. Just like the other two
token types, we now give `}` tokens the position of the previous real token,
which makes all AST nodes have reasonable locations.
2016-10-30 21:39:54 -07:00
Geoffrey Booth
0d132318ce Resolve conflicts with 2 branch 2016-10-26 09:05:35 -07:00
geebo
26ad6d4670 Selectively ignore CS-only keywords in ES imports and exports (#4347) 2016-10-26 14:37:19 +02:00
Geoffrey Booth
887052de07 Merge branch 'master' of github.com:jashkenas/coffeescript 2016-10-23 17:06:13 -07:00
Alan Pierce
6087c2c8fc Properly set location for string tokens ending in a newline (#4344)
This is an upstream port of https://github.com/decaffeinate/coffeescript/pull/9

The existing logic for computing the end location of a string was to take the
end of the string contents, then add the delimiter length to last_column. For
example, `"""abc"""` would have an end position three characters after the `c`.
However, if a string ended in a newline, then the end location for the string
contents would be one line above the end location for the string, so the proper
fix is to move the end location to the next line, not just to shift it to the
right.

This avoids a bug where the location data would sometimes reference a
non-existent location (one past the end of its line). It fixes the AST location
data, although as far as I know, it never has caused correctness issues in the
CoffeeScript output.
2016-10-23 09:41:46 +02:00
Geoffrey Booth
0521c3582c Fix typo 2016-10-22 23:11:04 -07:00
Simon Lydell
3c42b400a1 Merge pull request #4340 from GeoffreyBooth/node-deprecations
Call synchronous `fs` methods using the `Sync` variants
2016-10-19 08:05:20 +02:00
Geoffrey Booth
be44ebd2cd Node 7-nightly throws deprecation warnings when calling fs non-Sync functions without callbacks; but we always want the synchronous versions, so we should just call those in the first place 2016-10-18 21:49:15 -07:00
Simon Lydell
4d3d7352f1 Merge pull request #4339 from GeoffreyBooth/fix-export-anonymous-class
Disallow exporting anonymous classes
2016-10-16 10:23:37 +02:00
Geoffrey Booth
48e00d81a9 The CoffeeScript compiler should error on trying to export anonymous classes (previously we were outputting invalid JavaScript that the runtime was erroring on) 2016-10-15 21:32:06 -07:00
Simon Lydell
0853b412c6 Merge pull request #4296 from alangpierce/move-outdents-to-previous-token
Change OUTDENT tokens to be positioned at the end of the previous token
2016-10-10 19:08:35 +02:00
Simon Lydell
a75fe280f2 Merge pull request #4335 from alangpierce/fix-operator-precedence
Define proper operator precedence for bitwise/logical operators
2016-10-10 16:09:09 +02:00
Alan Pierce
e14946b3e6 Define proper operator precedence for bitwise/logical operators
This is an upstream port for the patch https://github.com/decaffeinate/coffeescript/pull/8

See https://github.com/decaffeinate/decaffeinate/issues/291 for the bug that this fixed.

For the most part, CoffeeScript and JavaScript have the same precedence rules,
but in some cases, the intermediate AST format didn't represent the actual
evaluation order. For example, in the expression `a or b and c`, the `and` is
evaluated first, but the parser treated the two operators with equal precedence.
This was still correct end-to-end because CoffeeScript simply emitted the result
without parens, but any intermediate tools using the CoffeeScript parser could
become confused.

Here are the JS operator precedence rules:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

For the most part, CoffeeScript already follows these. `COMPARE` operators
already behave differently due to chained comparisons, so I think we don't need
to worry about following JS precedence for those. So I think the only case where
it was behaving differently in an important way was for the binary/bitwise
operators that are being changed here.

As part of this change, I also introduced a new token tag, `BIN?`, for the
binary form of the `?` operator.
2016-10-09 14:45:25 -07:00
Alan Pierce
88693e420d Fix location data for implicit CALL_END tokens
Fixes https://github.com/decaffeinate/decaffeinate/issues/446

In addition to OUTDENT tokens, CALL_END tokens can also be virtual tokens
without a real location, and sometimes they end up with a location that's
incorrect.
2016-10-06 19:46:41 -07:00
Alan Pierce
ce971b766f Change OUTDENT tokens to be positioned at the end of the previous token
This commit adds another post-processing step after normal lexing that sets the
locationData on all OUTDENT tokens to be at the last character of the previous
token. This does feel like a little bit of a hack. Ideally the location data
would be set correctly in the first place and not in a post-processing step, but
I tried that and some temporary intermediate tokens were causing problems, so I
decided to set the location data once those intermediate tokens were removed.
Also, having this as a separate processing step makes it more robust and
isolated.

This fixes the problem in https://github.com/decaffeinate/decaffeinate/issues/371 .
In that issue, the CoffeeScript tokens had three OUTDENT tokens in a row, and
the last two overlapped with the `]`. Since at least one of those OUTDENT tokens
was considered part of the function body, the function expression had an ending
position just after the end of the `]`.

OUTDENT tokens are sort of a weird case in the lexer anyway, since they often
don't correspond to an actual location in the source code. It seems like the
code in `lexer.coffee` makes an attempt at finding a good place for them, but in
some cases, it has a bad result. This seems hard to avoid in the general case.
For example, in this code:
```coffee
[->
  a]
```
There must be an OUTDENT between the `a` and the `]`, but CoffeeScript tokens
have an inclusive start and end, so they must always be at least one character
wide (I think). In this case, the lexer was choosing the `]` as the location,
and the parser ended up generating correct location data, I believe because
it ignores the outermost INDENT and OUTDENT tokens. However, with multiple
OUTDENT tokens in a row, the parser ends up producing location data that is
wrong.

It seems to me like there isn't a solid answer to "what location do OUTDENT
tokens have", since it hasn't mattered much, but for this commit, I'm defining
it: they always have the location of the last character of the previous token.
This should hopefully be fairly safe because tokens are still in the same order
relative to each other. Also, it's worth noting that this makes the start
location for OUTDENT tokens awkward. However, OUTDENT tokens are always used to
mark the end of something, so their `last_line` and `last_column` values are
always what matter when determining AST node bounds, so it is most important for
those to be correct.
2016-10-06 19:39:31 -07:00
Simon Lydell
11561dddcf Merge pull request #4329 from shreeve/strip-cr-if-present
strip \r (if present) before final \n
2016-10-04 07:39:52 +02:00
Steve Shreeve
7c7bc8ee2f strip \r (if present) before final \n 2016-10-02 15:17:54 -04:00
Simon Lydell
7b9fbf2c76 Merge pull request #4327 from lydell/1.11.1
1.11.1
2016-10-02 18:21:28 +02:00
Simon Lydell
8623792bcd CoffeeScript 1.11.1 2016-10-01 20:58:53 +02:00
Simon Lydell
809634ba39 Add changelog for version 1.11.1 2016-10-01 20:55:23 +02:00
Simon Lydell
46841d916d Fix shorthands after interpolated key in objects
Fixes #4324.
2016-09-29 19:02:00 +02:00
Simon Lydell
0b2d852f67 Merge pull request #4322 from fliptheweb/patch-1
Fix minor typo in changelog for 1.11.0
2016-09-26 20:04:33 +02:00
Artur Kornakov
964a588e29 Fix minor typo in changelog for 1.11.0 2016-09-26 20:37:37 +03:00
Simon Lydell
568a0c7b4e Fix indentation-stripping in """ strings
`"""` (and `"`) strings are lexed into an array of tokens, consisting of
strings and interpolations. Previously, the minimum indententation
inside `"""` strings was stripped from the beginning of _all_ of those
string tokens. Usually, the indentation is longer than any other
sequence of spaces in a `"""` string, so the problem didn't occur in
most cases. This commit makes sure to only strip indentation after
newlines.

Fixes #4314.
2016-09-26 17:14:31 +02:00
Simon Lydell
57f5297714 Handle very large hexadecimal number literals correctly
Very large decimal number literals, binary number literals and octal
literals are lexed into an INFINITY token (instead of a NUMBER token)
and compiled into `2e308`. That is is supposed to be the case for very
large hexdecimal dumber literals as well, but previously wasn't.

Before:

    $ node -p 'require("./").tokens(`0x${Array(256 + 1).join("f")}`)[0][0]'
    NUMBER

After:

    $ node -p 'require("./").tokens(`0x${Array(256 + 1).join("f")}`)[0][0]'
    INFINITY

This commit also cleans up `numberToken` in lexer.coffee a bit.
2016-09-26 16:33:57 +02:00
Simon Lydell
32041806ae Fix isLiteralArguments
`isLiteralArguments` mistakenly looked at `Literal`s instead of
`IdentifierLiteral`s.

This also gets rid of the ugly `.asKey` hack in nodes.coffee.

Fixes #4320.
2016-09-26 15:33:44 +02:00
Simon Lydell
b0d8fca245 Update the changelog for 1.11.0
Fixes #4321.
2016-09-26 15:09:53 +02:00
Simon Lydell
c3f5b8db86 Replace .npmignore with "files": [...] in package.json 2016-09-24 14:26:46 +02:00
Simon Lydell
2923e88207 Merge pull request #4315 from lydell/1.11.0 2016-09-24 14:18:33 +02:00
Simon Lydell
66b5203689 CoffeeScript 1.11.0 2016-09-24 14:16:00 +02:00
Simon Lydell
e908fd4a91 Styling fixes for the documentation 2016-09-24 14:15:54 +02:00
Simon Lydell
ab97e2224e Add changelog for version 1.11.0 2016-09-24 14:15:54 +02:00
Simon Lydell
f6bc4b4c32 Update CLI flags documentation 2016-09-24 14:01:41 +02:00
Geoffrey Booth
a8b77fb4e7 Add modules documentation (#4309) 2016-09-18 20:54:44 +02:00
Simon Lydell
7667cb2370 Merge pull request #4308 from GeoffreyBooth/import-export
Be much more careful about parsing `*` in import and export statements
2016-09-15 17:20:07 +02:00
Geoffrey Booth
51f24e0641 Be much more careful about parsing * in import and export statements; handle export expressions that use * on the same line as export 2016-09-14 23:30:58 -07:00
Simon Lydell
9ae377b481 Fix source maps for errors thrown from .coffee.md files
Before:

```
$ cat tmp.coffee.md
test

    a
$ ./bin/coffee tmp.coffee.md
ReferenceError: a is not defined
  at Object.<anonymous> (/src/coffee-script/tmp.coffee.md:2:3)
  ...
```

Note how the line and column numbers (2 and 3, respectively) are not
correct.

After:

```
$ ./bin/coffee tmp.coffee.md
ReferenceError: a is not defined
  at Object.<anonymous> (/home/lydell/forks/coffee-script/tmp.coffee.md:3:5)
  ...
```

Line 3, column 5 is the actual position of the `a` in tmp.coffee.md.

Supersedes and fixes #4204.
2016-09-14 21:45:06 +02:00
Simon Lydell
0e0e8f87e1 Fix CLI crash when null is thrown
Before:

```
$ ./bin/coffee -e 'throw null'
/src/coffee-script/lib/coffee-script/command.js:251
      message = err.stack || ("" + err);
                   ^

TypeError: Cannot read property 'stack' of null
  at compileScript ...
```

After:

```
$ ./bin/coffee -e 'throw null'
null
```

Supersedes and closes #4135.
2016-09-14 21:33:36 +02:00
Simon Lydell
ec9c4d8594 Merge pull request #4291 from alangpierce/fix-outdent-location-data
Fix incorrect location data in OUTDENT nodes
2016-09-14 21:21:25 +02:00
Geoffrey Booth
66ac8af678 Support import and export of ES2015 modules (#4300)
This pull request adds support for ES2015 modules, by recognizing `import` and `export` statements. The following syntaxes are supported, based on the MDN [import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) and [export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) pages:

```js
import "module-name"
import defaultMember from "module-name"
import * as name from "module-name"
import { } from "module-name"
import { member } from "module-name"
import { member as alias } from "module-name"
import { member1, member2 as alias2, … } from "module-name"
import defaultMember, * as name from "module-name"
import defaultMember, { … } from "module-name"

export default expression
export class name
export { }
export { name }
export { name as exportedName }
export { name as default }
export { name1, name2 as exportedName2, name3 as default, … }

export * from "module-name"
export { … } from "module-name"
```

As a subsitute for ECMAScript’s `export var name = …` and `export function name {}`, CoffeeScript also supports:
```js
export name = …
```

CoffeeScript also supports optional commas within `{ … }`.

This PR converts the supported `import` and `export` statements into ES2015 `import` and `export` statements; it **does not resolve the modules**. So any CoffeeScript with `import` or `export` statements will be output as ES2015, and will need to be transpiled by another tool such as Babel before it can be used in a browser. We will need to add a warning to the documentation explaining this.

This should be fully backwards-compatible, as `import` and `export` were previously reserved keywords. No flags are used.

There are extensive tests included, though because no current JavaScript runtime supports `import` or `export`, the tests compare strings of what the compiled CoffeeScript output is against what the expected ES2015 should be. I also conducted two more elaborate tests:

* I forked the [ember-piqu](https://github.com/pauc/piqu-ember) project, which was an Ember CLI app that used ember-cli-coffeescript and [ember-cli-coffees6](https://github.com/alexspeller/ember-cli-coffees6) (which adds “support” for `import`/`export` by wrapping such statements in backticks before passing the result to the CoffeeScript compiler). I removed `ember-cli-coffees6` and replaced the CoffeeScript compiler used in the build chain with this code, and the app built without errors. [Demo here.](https://github.com/GeoffreyBooth/coffeescript-modules-test-piqu)
* I also forked the [CoffeeScript version of Meteor’s Todos example app](https://github.com/meteor/todos/tree/coffeescript), and replaced all of its `require` statements with the `import` and `export` statements from the original ES2015 version of the app on its `master` branch. I then updated the `coffeescript` Meteor package in the app to use this new code, and again the app builds without errors. [Demo here.](https://github.com/GeoffreyBooth/coffeescript-modules-test-meteor-todos)

The discussion history for this work started [here](https://github.com/jashkenas/coffeescript/pull/4160) and continued [here](https://github.com/GeoffreyBooth/coffeescript/pull/2). @lydell provided guidance, and @JimPanic and @rattrayalex contributed essential code.
2016-09-14 20:46:05 +02:00
Alan Pierce
feb42e5128 Add a test that tokens have locations that are in order 2016-08-01 20:28:56 -07:00
Alan Pierce
bd0024a9c2 Fix incorrect location data in OUTDENT nodes
In f609036bee, a line was changed from
`if length > 0 then (length - 1) else 0` to `Math.max 0, length - 1`. However,
in some cases, the `length` variable can be `undefined`. The previous code would
correctly compute `lastCharacter` as 0, but the new code would compute it as
`NaN`. This would cause trouble later on: the end location would just be the end
of the current chunk, which would be incorrect.

Here's a specific case where the parser was behaving incorrectly:
```
a {
  b: ->
    return c d,
      if e
        f
}
g
```

The OUTDENT tokens after the `f` had an undefined length, so the `NaN` made it
so the end location was at the end of the file. That meant that various nodes in
the AST, like the `return` node, would incorrectly have an end location at the
end of the file.

To fix, I just reverted the change to that particular line.
2016-07-29 20:42:08 -07:00
Simon Lydell
133fadd36a Merge pull request #4289 from GeoffreyBooth/fix-typos
Fix misspellings
2016-07-25 09:42:19 +02:00
Geoffrey Booth
a5980247dc Fix misspellings 2016-07-24 20:37:37 -07:00
Simon Lydell
ec333a061b Merge pull request #4274 from lydell/for-variables
Improve naming of generated 'i-variables'
2016-06-19 12:00:33 +02:00
Simon Lydell
0247b135f8 Improve naming of generated 'i-variables'
In for example `for` loops, a variable called `i` is generated (for the
loop index). If that name is unavailable, `j` is used instead, then `k`,
`l`, etc. all the way to `z`. Then, `aa`, `ab`, `ac` etc. are used.

This meant that, eventually, `do` would be used, but that's not a valid
variable name since `do` is a JavaScript keyword.

This logic was also inefficiently implemented. For example, going from
`aa` to `ab` or from `az` to `ba` required lots of loop iterations.

This commit changes the variable naming convention. Now, `i`, `j`, `k`,
etc. to `z` are used like before. Then comes `i1`, `j1`, `k1`, etc. Then
`i2`, `j2`, `k2` and so on. This is simpler, efficient and easier to
understand. `i1` is more obvious to be a loop index than `aa`.

Fixes #4267.
2016-06-10 08:58:18 +02:00
Simon Lydell
d7e752bc5d Fix failing source map tests
This should have been done in commit 841b3cd2, but I forgot to. Since
that commit, `SourceMap::generate` returns an object instead of
`JSON.stringify()` of that object, but the tests still compared strings.

Fixes #4269.

Note: `SourceMap::generate` is only used internally, so its change in
return type is not a breaking change. The "public API" is unchanged.
2016-06-02 09:04:58 +02:00
Ben Buckman
7c2f348a63 Fix 'Error: EBADF: bad file descriptor, write' on .exit in REPL
Fixes issue #4252.
2016-04-14 09:24:21 -07:00
Michael Ficarra
88192c197a Merge pull request #4226 from eventualbuddha/patch-1
Fix typo.
2016-03-09 09:39:56 -08:00
Brian Donovan
d7385ece46 Fix typo. 2016-03-09 09:30:20 -08:00
Michael Ficarra
e318469cb0 Merge pull request #4219 from lydell/infinity-nan
Treat Infinity and NaN as reserved words
2016-03-07 09:04:51 -08:00
Michael Ficarra
6291b53492 Merge pull request #4223 from lydell/inline-maps
Improve inline source maps generation
2016-03-06 07:33:10 -08:00
Simon Lydell
841b3cd2ad Improve inline source maps generation
- Inline source maps are now shorter by not using pretty-printed JSON.
- `.register()`ed files are now given more information in their inline source
  maps: The name and contents of the source file.
- Some code cleanup.

If you decode the inline source map generated (when using `.register()`) for a
file test.coffee with the contents `console.log "it works!"`, here is the
output:

Before:

    {
      "version": 3,
      "file": "",
      "sourceRoot": "",
      "sources": [
        ""
      ],
      "names": [],
      "mappings": "AAAA;EAAA,OAAO,CAAC,GAAR,CAAY,eAAZ;AAAA"
    }

After:

    {"version":3,"file":"","sourceRoot":"","sources":["test.coffee"],"names":[],"mappings":"AAAA;EAAA,OAAO,CAAC,GAAR,CAAY,WAAZ;AAAA","sourcesContent":["console.log \"it works!\"\n"]}

Related: #4214.
2016-03-06 14:41:26 +01:00
Simon Lydell
9a0babf5b1 Treat Infinity and NaN as reserved words
Fixes #4218.
2016-03-06 11:41:48 +01:00
Simon Lydell
cbc72a29bf Merge pull request #4220 from lydell/propertyliteral
Split out properties from identifiers
2016-03-06 10:57:31 +01:00
Simon Lydell
e42fc47747 Split out properties from identifiers
- Split out a PROPERTY token from the IDENTIFIER token.
- Split out Property from the Identifier in the grammar.
- Split out PropertyLiteral from IdentifierLiteral.
2016-03-06 10:53:01 +01:00
Michael Ficarra
5b7ac32905 Merge pull request #4221 from lydell/assignment-errors
Unify, simplify and fixup assignment errors
2016-03-06 01:41:51 -08:00
Simon Lydell
4d8cd03298 Unify, simplify and fixup assignment errors
- Show the same type of error message for compound assignment as for `=`
  assignment when the LHS is invalid.
- Show the same type of error message when trying to assign to a CoffeeScript
  keyword as when trying to assign to a JavaScript keyword.
- Now longer treat `&& =` as `&&=`. The same goes for `and=`, `||=` and `or=`.
- Unify the error message to: `<optional type> '<value>' can't be assigned`.
2016-03-06 10:33:30 +01:00
Michael Ficarra
585932cf5b compile InfinityLiterals to 2e308 2016-03-05 08:35:26 -08:00
Michael Ficarra
8afb7cc95b Merge pull request #4198 from lydell/node-types
Refactor `Literal` into several subtypes
2016-03-05 08:20:19 -08:00
Simon Lydell
021d2e4376 Refactor Literal into several subtypes
Previously, the parser created `Literal` nodes for many things. This resulted in
information loss. Instead of being able to check the node type, we had to use
regexes to tell the different types of `Literal`s apart. That was a bit like
parsing literals twice: Once in the lexer, and once (or more) in the compiler.
It also caused problems, such as `` `this` `` and `this` being indistinguishable
(fixes #2009).

Instead returning `new Literal` in the grammar, subtypes of it are now returned
instead, such as `NumberLiteral`, `StringLiteral` and `IdentifierLiteral`. `new
Literal` by itself is only used to represent code chunks that fit no category.
(While mentioning `NumberLiteral`, there's also `InfinityLiteral` now, which is
a subtype of `NumberLiteral`.)

`StringWithInterpolations` has been added as a subtype of `Parens`, and
`RegexWithInterpolations` as a subtype of `Call`. This makes it easier for other
programs to make use of CoffeeScript's "AST" (nodes). For example, it is now
possible to distinguish between `"a #{b} c"` and `"a " + b + " c"`. Fixes #4192.

`SuperCall` has been added as a subtype of `Call`.

Note, though, that some information is still lost, especially in the lexer. For
example, there is no way to distinguish a heredoc from a regular string, or a
heregex without interpolations from a regular regex. Binary and octal number
literals are indistinguishable from hexadecimal literals.

After the new subtypes were added, they were taken advantage of, removing most
regexes in nodes.coffee. `SIMPLENUM` (which matches non-hex integers) had to be
kept, though, because such numbers need special handling in JavaScript (for
example in `1..toString()`).

An especially nice hack to get rid of was using `new String()` for the token
value for reserved identifiers (to be able to set a property on them which could
survive through the parser). Now it's a good old regular string.

In range literals, slices, splices and for loop steps when number literals
are involved, CoffeeScript can do some optimizations, such as precomputing the
value of, say, `5 - 3` (outputting `2` instead of `5 - 3` literally). As a side
bonus, this now also works with hexadecimal number literals, such as `0x02`.

Finally, this also improves the output of `coffee --nodes`:

    # Before:
    $ bin/coffee -ne 'while true
      "#{a}"
      break'
    Block
      While
        Value
          Bool
        Block
          Value
            Parens
              Block
                Op +
                  Value """"
                  Value
                    Parens
                      Block
                        Value "a" "break"

    # After:
    $ bin/coffee -ne 'while true
      "#{a}"
      break'
    Block
      While
        Value BooleanLiteral: true
        Block
          Value
            StringWithInterpolations
              Block
                Op +
                  Value StringLiteral: ""
                  Value
                    Parens
                      Block
                        Value IdentifierLiteral: a
          StatementLiteral: break
2016-03-05 17:08:11 +01:00
Michael Ficarra
87216ea5b6 Merge pull request #4212 from nvignola/issue4042
Change a bad link in documentation issue#4042
2016-03-01 06:57:54 -08:00
nvignola
f80a8a5120 Change a bad link in documentation 2016-02-29 23:00:27 +00:00
Michael Ficarra
9590ad7622 Merge pull request #4199 from pra85/patch-1
Fix minor typo
2016-02-02 21:51:03 -08:00
Prayag Verma
402133a50e Fix minor typo
Remove extra `the`
2016-02-03 10:52:15 +05:30
Simon Lydell
34b4311544 Fix broken CoffeeScript.register() and commit build
Commit 347a6255 is a bit problematic:

- It doesn't include the built .js files.
- It breaks `CoffeeScript.register()`. This can be seen by running the tests;
  four of them fails. The error is that `CoffeeScript.register()` calls
  `CoffeeScript._compileFile()` with the `sourceMap` option enabled, which
  returns an object while the code expected a string.

This commit fixes the broken `CoffeeScript.register()`, by setting the
`sourceMap` option to `false` (but still keeping the `inlineMap` option enabled,
which was the intention of commit 347a6255). It also commits the built .js
files. The tests now pass.
2016-01-31 19:48:40 +01:00
Michael Ficarra
65c35e05a1 Merge pull request #4193 from DylanPiercey/master
Allow for external and inline sourcemap generation separately
2016-01-30 20:13:47 -08:00
Dylan Piercey
f7277c9de5 Allow for external and inline sourcemap generation separately 2016-01-30 21:09:19 -07:00
Jeremy Ashkenas
08129d0f1f Merge pull request #4111 from DylanPiercey/master
Add inline sourcemap support
2016-01-30 23:00:06 -03:00
Dylan Piercey
347a625525 Add inline sourcemap support 2016-01-23 12:58:22 -07:00
Michael Ficarra
2df011f378 Merge pull request #4180 from zhanzhenzhen/master
Fix #4178: an issue of processing Unicode characters in stdin
2016-01-12 08:54:45 -08:00
Zhenzhen Zhan
97882b8e49 Build for #4178 2016-01-13 00:49:45 +08:00
Zhenzhen Zhan
67b0f95d4d Fix #4178: an issue of processing Unicode characters in stdin 2016-01-12 19:16:19 +08:00
Simon Lydell
ce84924101 Fix invalid JS in one of the docs examples
Fixes #4175.
2016-01-07 08:22:59 +01:00
Simon Lydell
ae72dbb379 Fix scoping error in coffee-script.coffee
Closes #4167.
2016-01-07 07:53:53 +01:00
Michael Ficarra
b8403bfa97 Merge pull request #4146 from mvj3/minor-document-typos
Fixed minor document typos
2015-11-17 16:04:59 -08:00
David Chen
f179b20e6e Fixed minor document typos 2015-11-18 08:00:58 +08:00
Michael Ficarra
0995ba361c Merge pull request #4140 from lydell/issue-4137
Fix #4137: Caught errors named `undefined`
2015-11-01 23:18:47 -08:00
Simon Lydell
89921c0667 Fix #4137: Caught errors named undefined
Previously, `catch`-less `try`s named the caught error `undefined`, instead of
`error` like usual.
2015-11-02 08:05:35 +01:00
Michael Ficarra
87a854afb4 Merge pull request #4131 from lydell/issue-4130
Fix #4130: Unassignable param destructuring crash
2015-10-22 10:14:39 -07:00
Simon Lydell
1dd5795960 Fix #4130: Unassignable param destructuring crash 2015-10-22 19:11:23 +02:00
Michael Ficarra
968f94f782 Merge pull request #4112 from lydell/renamed-destrucured-params-with-defaults
Fix compiler crash with renamed destrucured params with defaults
2015-10-03 15:33:14 -07:00
Simon Lydell
4b4675de30 Fix compiler crash with renamed destrucured params with defaults
`({a = 1}) ->` and `({a: b}) ->` worked, but not the combination of the two:
`({a: b = 1}) ->`. That destrucuring worked for normal assignments, though:
`{a: b = 1} = c`. This commit fixes the param case.
2015-09-27 15:54:44 +02:00
Jeremy Ashkenas
36e80d7f5c Merge pull request #4099 from lydell/yield-return
Only allow `yield return` as a statement
2015-09-17 12:41:17 -04:00
ven
2536bfd75c Merge pull request #4102 from casidiablo/patch-1
Fixed link to Groovy doc link
2015-09-17 17:43:31 +02:00
Cristian
4acafad07b Fixed link to Groovy doc link 2015-09-17 08:22:56 -07:00
Michael Ficarra
73b05a55b6 Merge pull request #4101 from mjhassanpur/fix-doc-typos
Fix documentation typos
2015-09-16 23:27:32 -07:00
mjhassanpur
de2db48474 Fix documentation typos 2015-09-16 21:24:53 -07:00
Simon Lydell
4ceb6a6818 Only allow yield return as a statement
Fixes #4097. Also happens to fix #4096. I also took the liberty to simplify the
error message for invalid use of `yield`.
2015-09-16 17:39:59 +02:00
Jeremy Ashkenas
d6ff91a454 Merge pull request #4095 from alubbe/standaloneyieldd
Add support for standalone yield
2015-09-14 10:55:39 -04:00
Jeremy Ashkenas
da23a2f702 Merge pull request #4093 from alubbe/betteryieldcompilation
Remove unnecessary brackets and empty spaces around yield
2015-09-14 10:54:35 -04:00
Jeremy Ashkenas
d1c6db476b Merge pull request #4094 from alubbe/removeuncaughterrorvars
Remove uncaught error vars
2015-09-14 10:54:07 -04:00
Andreas Lubbe
b1ef5a9996 Remove unnecessary brackets and empty spaces around yield
This removes unnecessary brackets and empty spaces around yield when not needed. We still need brackets for if(a === (yield)).
2015-09-13 13:11:10 +02:00
Andreas Lubbe
c1a9cfa044 Add support for standalone yield
This breaks compatibility with
->
  yield for i in [1..3]
    i * 2
and
->
  yield
    i * 2

yield's behaviour now mirrors that of return in that it can be used stand alone as well as with expressions. Thus, it currently also inherits the above limitations.
2015-09-13 12:30:59 +02:00
Andreas Lubbe
d3cff9082f Remove uncaught error vars 2015-09-13 12:27:07 +02:00
Jeremy Ashkenas
1739c9d720 Merge pull request #4089 from lydell/issue-4088
Fix #4088: Don't declare caught variables
2015-09-10 13:16:53 -04:00
Simon Lydell
75a4c01e17 Fix #4088: Don't declare caught variables 2015-09-10 18:59:01 +02:00
Michael Ficarra
8711da03a2 Merge pull request #4080 from lydell/single-newline-at-eof
Ensure that all source files end with a single `\n`
2015-09-03 20:57:39 -07:00
Jeremy Ashkenas
eb6baf2d9b Merge pull request #4083 from lydell/remove-unnecessary-files
Remove unnecessary .js files
2015-09-03 16:51:00 -04:00
Jeremy Ashkenas
d742a7dd1f Merge pull request #4082 from lydell/changelog-fix
Update date and fix formatting error in 1.10.0 changelog
2015-09-03 16:50:27 -04:00
Simon Lydell
ae65875c8b Remove unnecessary .js files
The example code in documentation/coffee/*.coffee accidentally had duplicate
compiled .js versions committed: Both as documentation/js/*.js and as
documentation/coffee/*.js.

The former is generated when running `cake doc:site`, while the latter has no
cake task to be generated. Removing the former and then re-compiling index.html
results in all the code examples being missing in the resulting HTML, while
removing the latter makes no difference.

In conclusion, documentation/coffee/*.js must be the unnecessary duplicates.
They are removed by this commit.
2015-09-03 22:15:45 +02:00
Simon Lydell
fcf5924dae Update date and fix formatting error in 1.10.0 changelog 2015-09-03 22:08:34 +02:00
Jeremy Ashkenas
f26d33d418 Merge pull request #4079 from lydell/v1.10.0
CoffeeScript 1.10.0
2015-09-03 15:45:13 -04:00
Simon Lydell
cea773ec81 CoffeeScript 1.10.0 2015-09-03 20:10:18 +02:00
Simon Lydell
6c6c8d48bf Ensure that all source files end with a single \n
This was done by first checking all files in the repository root by hand, and
then by doing the following:

    $ npm i get-stdin@4
    $ cat clean.coffee
    fs = require 'fs'
    stdin = require 'get-stdin'

    stdin (text) ->
      for file in text.trim().split('\n')
        contents = fs.readFileSync file
          .toString().replace /\s*$/, '\n'
        fs.writeFileSync file, contents
      return
    $ ls !(node_modules)/**/*.coffee | coffee clean.coffee
2015-09-03 19:20:12 +02:00
Jeremy Ashkenas
98dd1bf8e8 Merge pull request #4073 from lydell/issue-3926
Fix #3926: Disallow implicit objects as parameter destructuring
2015-09-01 15:03:29 -04:00
Jeremy Ashkenas
56d75baac7 Merge pull request #4075 from lydell/documentation-improvements
Documentation improvements
2015-09-01 13:16:55 -04:00
Simon Lydell
0872c3d13d Git rid of the deprecated <tt> tag in the docs
Replaced with `<code>` tags.
2015-08-30 12:41:47 +02:00
Simon Lydell
5095e02b62 Remove unnecessary blank lines at EOF in examples
On less wide screens, where the CoffeeScript is above the JavaScript, those
lines resulted in an unnecessarily high box of CoffeeScript code.
2015-08-30 12:41:47 +02:00
Simon Lydell
874628b1d0 Improve the documentation site on smaller screens
"Smaller screens" means screens smaller than 820px wide. That's the smallest
width that the current design looks good at.

I tried to not change the current design in any way and to make as few changes
as possible.

This is what happens on smaller screens:

- The navigation bar is no longer fixed to the viewport, but always at the top
  of the page.
- The navigation bar is vertical rather than horizontal.
- CoffeeScript code is above the compiled JavaScript rather than having them
  side by side.

This allows for a larger text size, which is more compfortable to read, and no
horizontal scrolling, which many find difficult to use.
2015-08-30 12:41:36 +02:00
Michael Ficarra
ff9d5117f9 Merge pull request #4074 from lydell/destructuring-defaults-docs
Document destructuring defaults
2015-08-29 10:33:44 -07:00
Simon Lydell
10aca2a38e Document destructuring defaults 2015-08-29 19:18:44 +02:00
Simon Lydell
2c4d437e98 Fix #3926: Disallow implicit objects as parameter destructuring 2015-08-28 23:11:47 +02:00
Jeremy Ashkenas
c0c13c1977 Merge pull request #4069 from lydell/destructuring-defaults
Implement ES2015-like destructuring defaults
2015-08-27 17:50:33 -04:00
Simon Lydell
6d9553a016 Implement ES2015-like destructuring defaults
This let's you do things like:

    fullName = ({first = 'John', last = 'Doe'}) -> "#{first} #{last}"

Note: CoffeeScrits treats `undefined` and `null` the same, and that's true in
the case of destructuring defaults as well, as opposed to ES2015 which only uses
the default value if the target is `undefined`. A similar ES2015 difference
already exists for function parameter defaults. It is important for CoffeeScript
to be consistent with itself.

    fullName2 = (first = 'John', last = 'Doe') -> "#{first} #{last}"
    assert fullName('Bob', null) is fullName2(first: 'Bob', last: null)

Fixes #1558, #3288 and #4005.
2015-08-27 22:16:13 +02:00
Jeremy Ashkenas
66716cd730 Merge pull request #4071 from lydell/lone-expansion
Fix #4070: Improve error message for lone expansion
2015-08-27 13:09:54 -04:00
Simon Lydell
f588ecb288 Fix #4070: Improve error message for lone expansion 2015-08-26 22:30:55 +02:00
Michael Ficarra
dc3e177811 Merge pull request #4068 from lydell/issue-1192
Fix #1192: Assignment starting with object literals
2015-08-22 07:24:23 -07:00
Simon Lydell
2eef667916 Fix #1192: Assignment starting with object literals 2015-08-22 16:21:35 +02:00
Jeremy Ashkenas
617a932e89 Merge pull request #4059 from BrunoBernardino/hotfix/4036-try-variable-improvement
Closes #4036: "Try catch" optimisation
2015-08-19 14:33:11 -04:00
Bruno Bernardino
beac56d4d5 Updated compile 2015-08-16 21:34:22 +01:00
Bruno Bernardino
cc98e99070 Removing unnecessary assignment 2015-08-16 21:33:58 +01:00
Bruno Bernardino
93e4eeafed Removing the unnecessary underscore now :) 2015-08-16 21:32:16 +01:00
Bruno Bernardino
efdc67241a Improved the tests and removed the hardcoded variable, according to suggestions. 2015-08-16 21:27:28 +01:00
Bruno Bernardino
24e8f1c98f Closes #4036: "Try catch" optimisation
Let me know if there's something I should be doing differently as this is my first contribution to coffeescript.
I fixed the reported issue where a generated variable could clash with a user-defined one in a try/catch block.
I added a test for a few scenarios with different variable names for a try/catch, to confirm the fix and avoid regressions.
2015-08-16 20:47:04 +01:00
Michael Ficarra
2d1a6fa6ec Merge pull request #4029 from yjerem/reset-seenfor
Reset @seenFor in lexer before tokenizing
2015-07-07 21:31:23 -07:00
Jeremy Ruten
3d7d68a766 Reset @seenFor in lexer before tokenizing 2015-07-07 22:23:26 -06:00
Michael Ficarra
342b395b0a Merge pull request #4019 from rvagg/master
Don't copy arguments or caller from require
2015-06-22 06:33:07 -07:00
Rod Vagg
75ae45e2bb don't copy arguments or caller from require
causes an error in io.js where strict-mode is set on internal modules

Fixes: https://github.com/jashkenas/coffeescript/issues/3810
2015-06-22 22:51:39 +10:00
Michael Ficarra
1f197fcc1b Merge pull request #3985 from ide/array-check
Replace "instanceof Array" in transformer with "[object Array]" comparison
2015-06-05 09:40:02 -07:00
Jeremy Ashkenas
e339f5f2da correct release date 2015-05-27 13:04:12 -04:00
Jeremy Ashkenas
c37f284771 redoc 2015-05-27 11:57:31 -04:00
Jeremy Ashkenas
585298dc17 Merge pull request #3980 from lydell/v1.9.3
CoffeeScript 1.9.3
2015-05-27 11:51:32 -04:00
James Ide
2087923163 Replace "instanceof Array" in transformer with "[object Array]" comparison
Testing with `'[object Array]' is Object::toString.call element` allows arrays from another JS context to be properly handled. The specific use case here is to support jest, which sets up JS contexts using Node/io.js's "vm" module. This approach works in ES3 environments in contrast with ES5's `Array.isArray`.
2015-05-20 21:06:36 -07:00
Simon Lydell
b58772e8a7 CoffeeScript 1.9.3 2015-05-14 11:24:39 +02:00
Michael Ficarra
769f02ec05 Merge pull request #3979 from lydell/herecomments-formatting
Fix formatting of `#`-only lines in herecomments
2015-05-13 09:02:34 -07:00
Simon Lydell
52b1749d57 Fix formatting of #-only lines in herecomments
Before:

    $ ./bin/coffee -bpe '###
    > # paragraph 1
    > #
    > # paragraph 2
    > ###'
    /*
     * paragraph 1
    #
     * paragraph 2
     */

After:

    $ ./bin/coffee -bpe '###
    # paragraph 1
    #
    # paragraph 2
    ###'
    /*
     * paragraph 1
     *
     * paragraph 2
     */

This does not re-break #3638:

    $ ./bin/coffee -bpe '###
    > #/
    > ###'
    /*
    #/
     */
2015-05-13 17:50:09 +02:00
Simon Lydell
ba85a38cb0 Commit compiled code that should have been in commit 378a04e4 2015-05-13 17:50:02 +02:00
Michael Ficarra
c0d44b1abd Merge pull request #3966 from davidbau/simplesourcemaps
Fix #3965, sourcemaps for bare programs.
2015-05-08 07:52:58 -07:00
Michael Ficarra
0262322400 Merge pull request #3974 from carlsmith/issue3958
Improved try/catch/finally to explain the options better.
2015-05-02 09:06:49 -07:00
Carl Smith
8e8f6d13bd Improved try/catch/finally to explain the options better. 2015-05-01 22:38:25 +01:00
Michael Ficarra
b6667f0735 Merge pull request #3970 from lydell/docs
Document a few undocumented things
2015-05-01 08:12:53 -07:00
Simon Lydell
99ea1c7a39 Document a for [b..c] 2015-05-01 17:01:05 +02:00
Simon Lydell
27fd65390a Document yield from and yield return
Fixes #3825.
2015-05-01 17:01:05 +02:00
Simon Lydell
79a6d89849 Document interpolation in object keys
Fixes #3962.
2015-05-01 17:01:05 +02:00
Simon Lydell
6fb5833843 Improve modulo documentation
Fixes #3959.
2015-05-01 17:00:58 +02:00
Simon Lydell
5494ac13ee Document extra try/catch features
Fixes #3958.
2015-05-01 16:59:34 +02:00
Michael Ficarra
300faf401c Merge pull request #3968 from lydell/nodes-tokens-errors
Fix `CoffeeScript.nodes(tokens)`; fix the repl
2015-05-01 07:51:17 -07:00
Michael Ficarra
f2c6066103 Merge pull request #3967 from lydell/implicit-call-implicit-obj
Fix #3935: Implicit calls + obj key interpolation
2015-05-01 07:48:59 -07:00
Michael Ficarra
2a5320fd2b Merge pull request #3969 from lydell/alias-origin
Save alias names in the origin of tokens
2015-05-01 07:41:14 -07:00
Simon Lydell
36695540fc Save alias names in the origin of tokens
... and use it for "reserved word can't be assigned" errors. Fixes #2306.
2015-05-01 14:33:11 +02:00
Simon Lydell
fc0c4fdd5f Fix CoffeeScript.nodes(tokens); fix the repl
If you passed an array of tokens (as opposed to a string of code) to
`CoffeeScript.nodes`, its attempts to prettify error messages would break. Now
it does not attempt to prettify error messages in that case anymore (because it
is not possible to prettify the errors without a string of code).

The repl was affected by the above bug.

Fixes #3887.
2015-05-01 13:43:04 +02:00
Simon Lydell
ebc172d1ee Fix #3935: Implicit calls + obj key interpolation
Allow implicit calls when the first key of an implicit object has interpolation.
2015-05-01 12:02:03 +02:00
Simon Lydell
4e6b6678f7 Add tests for implicit calls with implicit object 2015-05-01 11:53:37 +02:00
David Bau
378a04e48c Fix #3965, sourcemaps for bare programs.
Instead of mapping all generated spaces and semicolons and newlines
to the source position (0,0), we avoid generating sourcemap information
for generated space-or-semicolon-only fragments.

(In addition to shortening sourcemaps, this fixes a correctness issue
where an empty fragment at the beginning of each line maps from (0,0),
but in a bare program, that position at the begining of the line
should map from the actual source line.  When this conflict occurred,
(0,0) would win, resulting in an incorrect sourcemap, where each
top-level function call mapped to (0,0).)
2015-04-30 22:08:26 -04:00
Michael Ficarra
1e62781759 Merge pull request #3953 from sixmen/fix_repl_fd_leak
fix history file descriptor leak
2015-04-23 06:46:50 -07:00
Michael Ficarra
234adef20c Merge pull request #3952 from sixmen/fix_write_after_fin
fix write after FIN error when using repl via socket
2015-04-23 06:45:04 -07:00
Sangmin Yoon
8b463cd3ad fix history file descriptor leak 2015-04-22 15:26:44 +09:00
Sangmin Yoon
ce10a463f3 fix write after FIN error when using repl via socket
if repl.outputStream is a socket, it is closed when 'exit' event
occurred, so write throws an exception
2015-04-22 15:11:56 +09:00
Jeremy Ashkenas
140a73dca7 adding new packt book at their request 2015-04-15 12:03:22 -04:00
Jeremy Ashkenas
46d16b5c49 #3942 -- revising changelog 2015-04-15 11:49:14 -04:00
Jeremy Ashkenas
d16cf19c15 Merge pull request #3942 from alubbe/master
1.9.2
2015-04-15 11:44:48 -04:00
Andreas Lubbe
edbb9a77e7 build & docs for 1.9.2 2015-04-15 17:26:30 +02:00
Andreas Lubbe
cc4c3b2606 added 1.9.2 changelog 2015-04-15 17:26:06 +02:00
Andreas Lubbe
3a2888f97a bumped version to 1.9.2 2015-04-15 17:25:49 +02:00
Jeremy Ashkenas
bd17cc9b3c Merge pull request #3892 from matthieubulte/master
Added checking on process.stdout to be compatible with browserify
2015-03-09 09:42:27 -04:00
Jeremy Ashkenas
0a3e3639dc Merge pull request #3706 from imcotton/script-data-src
Optionally to read data-src out from <script>
2015-03-09 09:41:32 -04:00
Cotton Hou
008bacf5d5 add compiled lib/browser.js 2015-03-09 15:59:10 +08:00
Cotton Hou
cc1b056b03 optionally to read data-src out from <script> 2015-03-09 15:37:09 +08:00
Matthieu Bulté
3548b4883e Added checking on process.stdout to be compatible with browserify 2015-03-09 08:30:01 +01:00
Michael Ficarra
37a376497c Merge pull request #3893 from josh/escape-literal-bracket-regexp
Escape literal ] in regexp
2015-03-08 22:18:16 -07:00
Joshua Peek
83744917b0 Escape literal ] in REGEX
] is not allowed in the PatternCharacter set
2015-03-08 21:59:09 -07:00
Jeremy Ashkenas
a548b70e8c Merge pull request #3661 from dtaniwaki/fix-deprecated-option
Use stdio option instead of customFds
2015-03-06 09:58:33 -05:00
Jeremy Ashkenas
c8147c046a Reverts #3758, Fixes #3863 -- kills the broken warning 2015-03-03 14:30:52 -05:00
Jeremy Ashkenas
4a7497b451 Merge pull request #3886 from jashkenas/revert-3885-escape-literal-bracket-regexp
Revert "Escape literal [ in regexp"
2015-02-26 16:05:25 -05:00
Jeremy Ashkenas
06aa329596 Revert "Escape literal [ in regexp" 2015-02-26 16:05:12 -05:00
Jeremy Ashkenas
9becb0e937 Merge pull request #3885 from josh/escape-literal-bracket-regexp
Escape literal [ in regexp
2015-02-26 14:49:24 -05:00
Joshua Peek
7f7765546f Escape literal [ in regexp
Improves compatibility with strict ES5 regexp syntax
2015-02-26 12:37:27 -06:00
Jeremy Ashkenas
c7a365b6f1 Merge pull request #3883 from alubbe/master
yield now behaves as expected around 'this'
2015-02-26 11:41:42 -05:00
Andreas Lubbe
84c125a71b yield now behaves as expected around 'this' - fixes https://github.com/jashkenas/coffeescript/issues/3882 2015-02-26 13:01:12 +01:00
Jeremy Ashkenas
06b74591e7 Merge pull request #3877 from gilesbowkett/ocd-test-description-details
added descriptions to tests which only had Issue numbers
2015-02-23 23:18:22 -05:00
Giles Bowkett
6645fbb895 added descriptions to tests which only had Issue numbers 2015-02-23 16:39:05 -07:00
Jeremy Ashkenas
c2758da9eb Merge pull request #3873 from Taritsyn/master
Fix getting of character at index
2015-02-23 10:36:47 -05:00
Jeremy Ashkenas
7a1c8fef0a Merge pull request #3872 from banyan/add-link-of-changelog
Update README.md and remove README
2015-02-23 10:36:01 -05:00
Andrey Taritsyn
71c59dddcc Fix getting of character at index 2015-02-22 19:08:15 +03:00
Kohei Hasegawa
ef6f90753a Delete README 2015-02-21 14:12:19 -05:00
Kohei Hasegawa
50fff63252 Add link of changelog 2015-02-21 13:59:35 -05:00
Jeremy Ashkenas
8f5c77c3ce Merge pull request #3871 from jcrben/doc_tweak
Replace references to jQuery's 'bind' with 'on'
2015-02-20 17:16:32 -05:00
Ben Creasy
88529bc339 Replace references to jQuery's 'bind' with 'on' 2015-02-20 14:02:47 -08:00
Jeremy Ashkenas
f37f9d1eda Merge pull request #3867 from sgentle/require-option
add -r/--require command line option
2015-02-19 14:06:51 -05:00
Sam Gentle
836175baab add -r/--require command line option 2015-02-20 02:58:10 +11:00
Jeremy Ashkenas
7395ac1d4f variable names 2015-02-18 15:48:45 -05:00
Jeremy Ashkenas
61988fe361 #3862 changelog 2015-02-18 15:46:14 -05:00
Jeremy Ashkenas
533ad8afe9 CoffeeScript 1.9.1 2015-02-18 15:43:33 -05:00
Jeremy Ashkenas
1961f06e08 Merge pull request #3861 from lydell/heredoc-undefined
Fix single-line heredocs starting with "undefined"
2015-02-18 14:06:09 -05:00
Simon Lydell
4503e2716e Fix single-line heredocs starting with "undefined" 2015-02-18 17:40:40 +01:00
Jeremy Ashkenas
e4d81005be Merge pull request #3854 from alubbe/fixyieldreturn
fixed yield return producing incorrect output when used outside of the last line
2015-02-17 15:47:24 -05:00
Andreas Lubbe
b6012c4617 improved yield return test 2015-02-17 19:11:06 +01:00
Andreas Lubbe
feee6954a6 fixed yield return producing incorrect output when used outside of the last line 2015-02-17 19:11:06 +01:00
Jeremy Ashkenas
fea058c53a Merge pull request #3858 from alubbe/master
fixed overly fragile repl test to work with 0.12
2015-02-17 10:49:43 -05:00
Andreas Lubbe
25d97aa136 fixed overly fragile repl test to work with 0.12, see https://github.com/jashkenas/coffeescript/issues/3855 2015-02-17 11:36:24 +01:00
Michael Ficarra
7c8849cc21 Merge pull request #3852 from alubbe/moretests
added a lot of ES6 generator tests
2015-02-15 11:46:10 -08:00
Andreas Lubbe
b362bd672c added a lot of ES6 generator tests 2015-02-15 20:35:22 +01:00
Michael Ficarra
a4f510501c Merge pull request #3853 from alubbe/fixyieldthrow
fixed being unable to use 'yield throw'
2015-02-15 10:55:17 -08:00
Andreas Lubbe
e3f6e19950 fixed being unable to use 'yield throw' 2015-02-15 19:01:00 +01:00
Jeremy Ashkenas
b49b41320e Merge pull request #3758 from DiThi/master
Prevent writing the same file several times (fixes #3753)
2015-02-12 14:27:06 -05:00
Alberto Torres Ruiz
6bc3157793 Prevent writing the same file several times (fixes #3753) 2015-02-12 20:20:35 +01:00
Jeremy Ashkenas
dc8a2b17d0 Merge pull request #3849 from lydell/regex-end-invalid-escape
Fix error message for invalid escape at end of regex
2015-02-12 13:55:10 -05:00
Jeremy Ashkenas
c3ae2328af Merge pull request #3850 from lydell/implicit-object-start-token
Fix #3846: Fix odd start token of implicit objects
2015-02-12 13:54:38 -05:00
Simon Lydell
57846ea5c0 Fix #3846: Fix odd start token of implicit objects
Now the same hack as for reserved identifier tokens in the lexer is used
instead.
2015-02-12 19:41:12 +01:00
Simon Lydell
3da88b9b3f Fix error message for invalid escape at end of regex 2015-02-12 19:26:41 +01:00
Jeremy Ashkenas
8130e63e43 Merge pull request #3802 from mapmeld/multiline_comment_fix
Allow multiline comment at end of an object definition [Fixes #3761]
2015-02-10 23:56:01 -05:00
Nick Doiron
dc44ebbdaa allow multiline comment inside of an object definition [Fixes #3761]
use more CoffeeScript syntax
2015-02-10 23:35:39 -05:00
Jeremy Ashkenas
88ad059d54 Merge pull request #3840 from lydell/dynakeys
Fix #3597: Allow interpolations in object keys
2015-02-10 10:43:26 -05:00
Simon Lydell
76c076db55 Fix #3597: Allow interpolations in object keys
The following is now allowed:

    o =
      a: 1
      b: 2
      "#{'c'}": 3
      "#{'d'}": 4
      e: 5
      "#{'f'}": 6
      g: 7

It compiles to:

    o = (
      obj = {
        a: 1,
        b: 2
      },
      obj["" + 'c'] = 3,
      obj["" + 'd'] = 4,
      obj.e = 5,
      obj["" + 'f'] = 6,
      obj.g = 7,
      obj
    );

- Closes #3039. Empty interpolations in object keys are now _supposed_ to be
  allowed.
- Closes #1131. No need to improve error messages for attempted key
  interpolation anymore.
- Implementing this required fixing the following bug: `("" + a): 1` used to
  error out on the colon, saying "unexpected colon". But really, it is the
  attempted object key that is unexpected. Now the error is on the opening
  parenthesis instead.
- However, the above fix broke some error message tests for regexes. The easiest
  way to fix this was to make a seemingly unrelated change: The error messages
  for unexpected identifiers, numbers, strings and regexes now say for example
  'unexpected string' instead of 'unexpected """some #{really long} string"""'.
  In other words, the tag _name_ is used instead of the tag _value_.
  This was way easier to implement, and is more helpful to the user. Using the
  tag value is good for operators, reserved words and the like, but not for
  tokens which can contain any text. For example, 'unexpected identifier' is
  better than 'unexpected expected' (if a variable called 'expected' was used
  erraneously).
- While writing tests for the above point I found a few minor bugs with string
  locations which have been fixed.
2015-02-09 17:32:37 +01:00
Michael Ficarra
5698e6c72a Merge pull request #3842 from arianf/master
Fixed copyright range to be updated to 2015
2015-02-08 13:56:05 -08:00
Arian Faurtosh
e0e4967ad8 Fixed copyright range to be updated to 2015 2015-02-08 11:28:51 -08:00
Michael Ficarra
53c7891599 Merge pull request #3841 from lydell/last
Replace `last array` helper with `[..., last] = array`
2015-02-08 10:22:09 -08:00
Simon Lydell
94a17cb74a Replace last array helper with [..., last] = array 2015-02-07 21:50:41 +01:00
Jeremy Ashkenas
5d139596f8 Merge pull request #3834 from lydell/better-lexer-errors
Improve lexer error messages
2015-02-06 12:17:26 -05:00
Simon Lydell
213225418a Improve lexer error messages
- Erraneous tokens are now fully underlined with ^:s.
- The error messages are now a bit more consistent.
2015-02-06 10:52:02 +01:00
Jeremy Ashkenas
3b3e52097a Merge pull request #3833 from lydell/escapes
Fix #3795: Never generate invalid strings and regexes
2015-02-05 11:32:00 -05:00
Simon Lydell
72ceec5680 Fix #3795: Never generate invalid strings and regexes
- Invalid `\x` and `\u` escapes now throw errors.
- U+2028 and U+2029 (which JavaScript treats as newline characters) are now
  escaped to `\u2028` and `\u2029`, respectively.
- Octal escapes are now forbidden not only in strings, but in regexes as well.
- `\0` escapes are now escaped if needed (so that they do not form an octal
  literal by mistake). Note that `\01` is an octal escape in a regex, while `\1`
  is a backreference. (Added a test for backreferences while at it.)
- Fixed a bug where newlines in strings weren't removed if preceded by an
  escaped character.
2015-02-05 17:23:03 +01:00
Michael Ficarra
5a220d4e13 Merge pull request #3830 from swang/fix_incorrect_token
Fix incorrect token representation
2015-02-04 21:40:45 -08:00
Shuan Wang
92e5ab2857 Fix incorrect token representation
The third element in a token should just be an object containing line
number and column info. This PR fixes the problem with one of the tokens
being set incorrectly.
2015-02-04 21:02:44 -08:00
Jeremy Ashkenas
64632e3332 Merge pull request #3827 from lydell/unexpected-regex
Improve error messages for unexpected regexes
2015-02-03 15:10:29 -05:00
Jeremy Ashkenas
c0e1f23f23 Merge pull request #3785 from lydell/super
Allow super in methods with dynamic names
2015-02-03 15:09:31 -05:00
Simon Lydell
ee8f889cbd Allow super in methods with dynamic names
As discussed in https://github.com/jashkenas/coffeescript/issues/3039#issuecomment-68916918.
This is the first step to implement dynamic object literal keys (see #3597).

This also fixes #1392.

In short, `super` is now allowed:

    # in class definitions:
    class A
      instanceMethod: -> super
      @staticMethod: -> super
      @staticMethod2 = -> super

    # in assignment where the next to last access is 'prototype':
    A::m = -> super
    A.prototype.m = -> super
    a.b()[5]::m = -> super
    A::[x()] = -> super
    class B
      @::m = -> super
2015-02-03 20:46:37 +01:00
Simon Lydell
ffa25aae77 Improve error messages for unexpected regexes 2015-02-03 20:42:50 +01:00
Jeremy Ashkenas
04b30a6cc4 Merge pull request #3786 from lydell/loop-safety
Fix #3778: Make for loops more consistent
2015-02-03 13:08:33 -05:00
Simon Lydell
996a171a4e Fix #3778: Make for loops more consistent
The following two lines might seem equivalent:

    for n in [1, 2, 3] by  a then a = 4; n
    for n in [1, 2, 3] by +a then a = 4; n

But they used not to be, because `+a` was cached into a `ref`, while the plain
`a` wasn’t. Now even simple identifiers are cached, making the two lines
equivalent as expected.
2015-02-03 19:05:07 +01:00
Jeremy Ashkenas
17a271af06 Merge pull request #3826 from lydell/string-locations
Fix #3822: Include delimiters in string/regex locations
2015-02-03 12:58:46 -05:00
Simon Lydell
f8c366c479 Fix #3822: Include delimiters in string/regex locations 2015-02-03 18:55:38 +01:00
Jeremy Ashkenas
934bd2acc7 Merge branch 'master' of github.com:jashkenas/coffeescript 2015-02-03 11:31:44 -05:00
Jeremy Ashkenas
dd0ec84ebe redoc 2015-02-03 11:31:43 -05:00
Jeremy Ashkenas
e9a372dff5 Merge pull request #3821 from lydell/no-underscore
Name generated variables without leading underscore
2015-01-30 14:56:22 -05:00
Simon Lydell
4d7a0d2470 Name generated variables without leading underscore
For example, `ref` not `_ref`. It's cleaner.

This also fixes #3816.
2015-01-30 20:33:03 +01:00
Jeremy Ashkenas
c2abe253a1 Revert "move changelog"
This reverts commit 3ddd3115eb.
2015-01-30 13:44:42 -05:00
Jeremy Ashkenas
3ddd3115eb move changelog 2015-01-30 11:43:05 -05:00
Jeremy Ashkenas
a3096eab91 #3819 changelog docs 2015-01-30 11:14:03 -05:00
Jeremy Ashkenas
3fd004b852 Fixes #3816 -- prettier internal variable names. 2015-01-29 16:24:30 -05:00
Jeremy Ashkenas
0a9c7a3257 docs 2015-01-29 14:58:49 -05:00
Jeremy Ashkenas
f7692c92ce more text tweaks 2015-01-29 12:25:25 -05:00
Jeremy Ashkenas
cdf69eb5bc Merge branch 'gh-pages' 2015-01-29 12:22:26 -05:00
Jeremy Ashkenas
9aeecf582b text tweak 2015-01-29 12:22:16 -05:00
Jeremy Ashkenas
e0ec8a51e4 CoffeeScript 1.9.0 2015-01-29 12:20:46 -05:00
Jeremy Ashkenas
a62e49311e removing the mkdirp test 2015-01-29 11:39:18 -05:00
Jeremy Ashkenas
9a38486d08 Merge pull request #3800 from ysmood/decouple_mkdirp
Decouple "mkdirp".
2015-01-29 11:38:27 -05:00
Jeremy Ashkenas
06e8be5d94 rebuilt browser just for testing 2015-01-29 11:16:01 -05:00
Yad Smood
90a1cbac49 Optimize the mkdirp test 2015-01-29 03:49:40 +08:00
Yad Smood
3d58b4cda1 Add test for mkdirp 2015-01-29 00:44:28 +08:00
Michael Ficarra
2f0724f0ad Merge pull request #3812 from xfq/patch-1
Update index.html.js
2015-01-27 20:39:47 -08:00
Xue Fuqiao
f288d20409 Update index.html.js
Node comes with npm installed and "npm" is not an abbreviation for "Node Package Manager".
2015-01-28 08:52:08 +08:00
Michael Ficarra
dca915af60 Merge pull request #3808 from lydell/api-break-fix
Fix broken CoffeeScript APIs
2015-01-26 09:43:04 -08:00
Simon Lydell
54a4560340 Fix broken CoffeeScript APIs
As evidenced in #3804, commit 8ab15d7 broke the CoffeeScript API. The REPL uses
those APIs, but wasn't updated in that commit. Still, that shouldn't have
_broken_ the REPL. The reason it broke is because the added _option_
'referencedVars' wasn't actually _optional;_ if it was omitted code that relies
on it being set broke. This commit defaults that option to an empty array, which
makes things behave exactly like before when the 'referencedVars' option is
omitted.
2015-01-26 18:21:02 +01:00
Michael Ficarra
518d7c16b7 Merge pull request #3807 from lydell/repl-fix
Fix #3804: Provide list of referenced vars to REPL
2015-01-26 08:35:38 -08:00
Simon Lydell
8ed691e266 Fix #3804: Provide list of referenced vars to REPL
Supersedes #3805. Here is a comparison of master, #3805 and this commit:

    # master
    $ bin/coffee
    coffee> 1 %% 2
    TypeError: Array.prototype.indexOf called on null or undefined

    # #3805
    $ bin/coffee
    coffee> 1 %% 2
    1
    coffee> (_results = null; i) for i in [1, 2, 3]
    TypeError: Cannot call method 'push' of null

    # this commit
    $ bin/coffee
    coffee> 1 %% 2
    1
    coffee> (_results = null; i) for i in [1, 2, 3]
    [ 1, 2, 3 ]
2015-01-26 17:18:35 +01:00
Yad Smood
74fc7128ab Decouple "mkdirp"
Make coffee completely independent.
2015-01-22 04:20:34 +08:00
Michael Ficarra
68c0e2dc0f Merge pull request #3798 from ogennadi/patch-1
Fixed broken link
2015-01-20 18:21:55 -08:00
Oge Nnadi
42dde38842 Fixed broken link 2015-01-20 12:45:27 -08:00
Michael Ficarra
7d6f6174d5 Merge pull request #3787 from lydell/single-token-interpolation
Fix #1316: Interpolate interpolations safely
2015-01-16 08:43:05 -08:00
Simon Lydell
05b3707506 Fix #1316: Interpolate interpolations safely
Instead of compiling to `"" + + (+"-");`, `"#{+}-"'` now gives an appropriate
error message:

    [stdin]:1:5: error: unexpected end of interpolation
    "#{+}-"
        ^

This is done by _always_ (instead of just sometimes) wrapping the interpolations
in parentheses in the lexer. Unnecessary parentheses won't be output anyway.

I got tired of updating the tests in test/location.coffee (which I had enough of
in #3770), which relies on implementation details (the exact amount of tokens
generated for a given string of code) to do their testing, so I refactored them
to be less fragile.
2015-01-16 17:19:42 +01:00
Michael Ficarra
5d1d1b7999 Merge pull request #3792 from lydell/issue-3194
Fix #3194: Make strings always uncallable
2015-01-15 22:34:57 -08:00
Simon Lydell
3db029f2c1 Make regexes always uncallable
No matter if they have interpolations or not.
2015-01-15 19:44:14 +01:00
Michael Ficarra
67aaa8b57f Merge pull request #3794 from lydell/jison-update
Make CoffeeScript work with jison 0.4.14+
2015-01-15 09:03:27 -08:00
Simon Lydell
28c07d30cb Make CoffeeScript work with jison 0.4.14+
Since zaach/jison commit 3548861b, `parser.lexer` is never modified anymore (a
copy of it is made, and that copy is modified instead). CoffeeScript itself
modifies `parser.lexer` and then accesses those modifications in the custom
`parser.yy.parseError` function, but that of course does not work anymore. This
commit puts the data that `parser.yy.parseError` needs directly on the `parser`
so that it is not lost.

Supersedes #3603. Fixes #3608 and zaach/jison#243.
2015-01-15 17:47:07 +01:00
Simon Lydell
fce502ac98 Fix #3194: Make strings always uncallable
No matter if they have interpolations or not.
2015-01-14 21:27:24 +01:00
Michael Ficarra
669e7fed10 Merge pull request #3791 from lydell/issue-3502
Fix #3502: Define param variables when expansion
2015-01-13 20:00:32 -08:00
Michael Ficarra
4bf45ff894 Merge pull request #3790 from lydell/scope-root
Get rid of `Scope.root` hack
2015-01-13 12:53:03 -08:00
Simon Lydell
4c2c472e07 Fix #3502: Define param variables when expansion 2015-01-13 21:26:11 +01:00
Simon Lydell
22f19522ff Get rid of Scope.root hack
Using the static property `Scope.root` for the top-level scope of a file is a
hack, which makes it impossible to have several independent `Scope` instances
at the same time (should we ever need that).

This commit makes every instance have a reference to its root instead.
2015-01-13 20:21:45 +01:00
Michael Ficarra
9fa77af576 Merge pull request #3784 from lydell/unique-generated-vars
Unique generated vars
2015-01-12 21:14:44 -08:00
Michael Ficarra
efd7ebb066 Merge pull request #3788 from lydell/unexpected-call-end
Better error message for unexpected CALL_END
2015-01-12 20:55:25 -08:00
Simon Lydell
62712060c0 Better error message for unexpected CALL_END 2015-01-12 20:40:59 +01:00
Simon Lydell
a46978640b Allow variables named like helper functions 2015-01-11 12:12:40 +01:00
Simon Lydell
8ab15d7372 Fix #1500, #1574, #3318: Name generated vars uniquely
Any variables generated by CoffeeScript are now made sure to be named to
something not present in the source code being compiled. This way you can no
longer interfere with them, either on purpose or by mistake. (#1500, #1574)

For example, `({a}, _arg) ->` now compiles correctly. (#1574)

As opposed to the somewhat complex implementations discussed in #1500, this
commit takes a very simple approach by saving all used variables names using a
single pass over the token stream. Any generated variables are then made sure
not to exist in that list.

`(@a) -> a` used to be equivalent to `(@a) -> @a`, but now throws a runtime
`ReferenceError` instead (unless `a` exists in an upper scope of course). (#3318)

`(@a) ->` used to compile to `(function(a) { this.a = a; })`. Now it compiles to
`(function(_at_a) { this.a = _at_a; })`. (But you cannot access `_at_a` either,
of course.)

Because of the above, `(@a, a) ->` is now valid; `@a` and `a` are not duplicate
parameters.

Duplicate this-parameters with a reserved word, such as `(@case, @case) ->`,
used to compile but now throws, just like regular duplicate parameters.
2015-01-10 23:25:01 +01:00
Joshua Peek
23a691ae87 Add test for reserved keywords as parameters 2015-01-10 23:23:26 +01:00
Michael Ficarra
bec8f27e8a Merge pull request #3782 from lydell/regex
Fix #3410, #3182: Allow regex to start with space or =
2015-01-10 07:52:02 -08:00
Michael Ficarra
ac2e540e1b Merge pull request #3777 from lydell/unary-plus-minus-refs
Fix #3598: Make unary + and - generate _refs
2015-01-09 18:12:52 -08:00
Michael Ficarra
e0ad0d795d Merge pull request #3783 from lydell/issue-3671
Fix #3671: Allow step in optimized range comprehensions
2015-01-09 17:54:55 -08:00
Simon Lydell
a63009fccb Fix #3671: Allow step in optimized range comprehensions
Allow the `by c` part in `for [a..b] by c then`.

Continue disallowing a `when d` part, since it makes no sense having a guard
that isn't given access to anything that changes on every iteration.
2015-01-10 02:31:56 +01:00
Simon Lydell
8fd6258a46 Fix #3410, #3182: Allow regex to start with space or =
A regex may not follow a specific set of tokens. These were already known before
in the `NOT_REGEX` and `NOT_SPACED_REGEX` arrays. (However, I've refactored them
to be more correct and to add a few missing tokens). In all other cases (except
after a spaced callable) a slash is the start of a regex, and may now start with
a space or an equals sign. It’s really that simple!

A slash after a spaced callable is the only ambigous case. We cannot know if
that's division or function application with a regex as the argument. The
spacing determines which is which:

Space on both sides:
- `a / b/i`  -> `a / b / i`
- `a /= b/i` -> `a /= b / i`

No spaces:
- `a/b/i`    -> `a / b / i`
- `a/=b/i`   -> `a /= b / i`

Space on the right side:
- `a/ b/i`   -> `a / b / i`
- `a/= b/i`  -> `a /= b / i`

Space on the left side:
- `a /b/i`   -> `a(/b/i)`
- `a /=b/i`  -> `a(/=b/i)`

The last case used to compile to `a /= b / i`, but that has been changed to be
consistent with the `/` operator. The last case really looks like a regex, so it
should be parsed as one.

Moreover, you may now also space the `/` and `/=` operators with other
whitespace characters than a space (such as tabs and non-breaking spaces) for
consistency.

Lastly, unclosed regexes are now reported as such, instead of generating some
other confusing error message.

It should perhaps also be noted that apart from escaping (such as `a /\ b/`) you
may now also use parentheses to disambiguate division and regex: `a (/ b/)`. See
https://github.com/jashkenas/coffeescript/issues/3182#issuecomment-26688427.
2015-01-10 01:48:00 +01:00
Simon Lydell
24398774fc Fix #3598: Make unary + and - generate _refs
Before commit c056c93e `Op::isComplex()` used to return true always. As far as I
understand, that commit attempts to exclude code such as `+1` and `-2` from
being marked as complex (and thus getting cached into `_ref` variables
sometimes). CoffeeScript is supposed to generate readable output so that choice
is understandable. However, it also excludes code such as `+a` (by mistake I
believe), which can cause `a` to be coerced multiple times. This commit fixes
this by only excluding unary + and - ops followed by a number.
2015-01-09 18:12:10 +01:00
Jeremy Ashkenas
e769423d52 Merge pull request #3774 from lydell/unicode-spaces
Fix #2516, #3560: Unicode space handling
2015-01-06 16:10:59 -05:00
Simon Lydell
9ec427ba80 Fix #2516, #3560: Unicode space handling
It is possible to match only valid JavaScript identifiers with a really long
regex (like coco and CoffeeScriptRedux does), but CoffeeScript uses a much
simpler one, which allows a bit too much.

Quoting jashkenas/coffeescript#1718 #issuecomment-2152464 @jashkenas:

> But it still seems very much across the "worth it" line. You'll get the
> SyntaxError as soon as it hits JS, and performance aside -- even the increase
> in filesize for our browser coffee-script.js lib seems too much, considering
> this is something no one ever does, apart from experimentation.

In short, CoffeeScript treats any non-ASCII character as part of an identifier.
However, unicode spaces should be excluded since having blank characters as part
of a _word_ is very confusing. This commit does so, while still keeping the
regex really simple.
2015-01-06 21:32:14 +01:00
Jeremy Ashkenas
c478f283f4 Merge pull request #3771 from mbrio/master
Fix issue #3498
2015-01-05 15:51:26 -05:00
Michael Diolosa
8e299b09cc Fix issue #3498 2015-01-05 15:40:04 -05:00
Michael Ficarra
b70f6571bd Merge pull request #3770 from lydell/interpolations
Refactor interpolation (and string and regex) handling in lexer
2015-01-04 12:12:56 -08:00
Simon Lydell
ae6df88c5c Point "missing )/}/]" errors to the unclosed (/{/[
Previously such errors pointed at the end of the input, which wasn't very
helpful. This is also consistent with unclosed strings, where the errors point
at the opening quote.

Note that this includes unclosed #{ (interpolations).
2015-01-04 07:51:53 +01:00
Simon Lydell
0dcff507fb Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
  used to pass through the lexer, causing a parsing error later, while
  double-quoted strings caused an error already in the lexing phase. Now both
  single and double-quoted unclosed strings error out in the lexer (which is the
  more logical option) with consistent error messages. This also fixes the last
  comment by @satyr in #3301.

- Similar to the above, unclosed heregexes also used to pass through the lexer
  and not error until in the parsing phase, which resulted in confusing error
  messages. This has been fixed, too.

- Fix #3348, by adding passing tests.

- Fix #3529: If a string starts with an interpolation, an empty string is no
  longer emitted before the interpolation (unless it is needed to coerce the
  interpolation into a string).

- Block comments cannot contain `*/`. Now the error message also shows exactly
  where the offending `*/`. This improvement might seem unrelated, but I had to
  touch that code anyway to refactor string and regex related code, and the
  change was very trivial. Moreover, it's consistent with the next two points.

- Regexes cannot start with `*`. Now the error message also shows exactly where
  the offending `*` is. (It might actually not be exatly at the start in
  heregexes.) It is a very minor improvement, but it was trivial to add.

- Octal escapes in strings are forbidden in CoffeeScript (just like in
  JavaScript strict mode). However, this used to be the case only for regular
  strings. Now they are also forbidden in heredocs. Moreover, the errors now
  point at the offending octal escape.

- Invalid regex flags are no longer allowed. This includes repeated modifiers
  and unknown ones. Moreover, invalid modifiers do not stop a heregex from
  being matched, which results in better error messages.

- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
  `RegExp("a#{1}")`. Still, those two code snippets used to generate different
  tokens, which is a bit weird, but more importantly causes problems for
  coffeelint (see clutchski/coffeelint#340). This required lots of tests in
  test/location.coffee to be updated. Note that some updates to those tests are
  unrelated to this point; some have been updated to be more consistent (I
  discovered this because the refactored code happened to be seemingly more
  correct).

- Regular regex literals used to erraneously allow newlines to be escaped,
  causing invalid JavaScript output. This has been fixed.

- Heregexes may now be completely empty (`//////`), instead of erroring out with
  a confusing message.

- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
  you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
  heregex inside a heregex.

- Fix #2321: If you used division inside interpolation and then a slash later in
  the string containing that interpolation, the division slash and the latter
  slash was erraneously matched as a regex. This has been fixed.

- Indentation inside interpolations in heredocs no longer affect how much
  indentation is removed from each line of the heredoc (which is more
  intuitive).

- Whitespace is now correctly trimmed from the start and end of strings in a few
  edge cases.

- Last but not least, the lexing of interpolated strings now seems to be more
  efficient. For a regular double-quoted string, we used to use a custom
  function to find the end of it (taking interpolations and interpolations
  within interpolations etc. into account). Then we used to re-find the
  interpolations and recursively lex their contents. In effect, the same string
  was processed twice, or even more in the case of deeper nesting of
  interpolations. Now the same string is processed just once.

- Code duplication between regular strings, heredocs, regular regexes and
  heregexes has been reduced.

- The above two points should result in more easily read code, too.
2015-01-04 07:47:09 +01:00
Jeremy Ashkenas
8e4fb1b937 Merge pull request #3748 from sscotth/master
Include logo .svg files
2014-12-03 10:20:32 -05:00
Scott
931b74e449 include logo .svg files 2014-12-02 18:33:07 -06:00
Jeremy Ashkenas
4199f4f325 Merge pull request #3734 from alubbe/master
fixed yield keyword not working in switch & for loop expressions
2014-11-21 18:38:11 -05:00
alubbe
5950d6328d added tests for yield in switch & for loop expressions 2014-11-21 23:14:53 +01:00
alubbe
a9fbf14adf fixed yield keyword not working in switch & for loop expressions 2014-11-21 22:52:09 +01:00
Jeremy Ashkenas
485aa8efcf add Die Alternative to books section 2014-11-17 13:43:41 -05:00
Jeremy Ashkenas
a563e8f8fe Merge pull request #3703 from bigtunacan/master
Add bower.json configuration
2014-10-29 17:05:25 -04:00
Joiey Seeley
4035e7caab Removed "mkdirp": "~0.3.5" from bower.json 2014-10-29 15:10:57 -05:00
Joiey Seeley
2c6e6ca870 Added an initial bower.json configuration file 2014-10-29 14:23:31 -05:00
Jeremy Ashkenas
f2a3f7507e Merge pull request #3521 from gscottolson/master
Retina favicon.ico
2014-10-27 17:18:33 -04:00
Jeremy Ashkenas
4f82e5912e Merge pull request #3677 from alubbe/master
implemented proper precedence for 'yield'
2014-10-13 11:41:36 -04:00
alubbe
dd5da7f5f2 implemented proper precedence for 'yield' 2014-10-13 03:32:02 +02:00
Anatoly Ressin
ec44aba71a Improved test readability + fixed integer divison 2014-10-12 22:32:02 +03:00
Anatoly Ressin
e8a4e93a72 Added failing test case for the yield precedence 2014-10-12 20:08:28 +03:00
dtaniwaki
1301390087 Use stdio option instead of customFds 2014-10-04 12:54:07 +09:00
Jeremy Ashkenas
158ca0d869 Merge pull request #3638 from lbeschastny/issue3638
Invalid block comments compilation
2014-09-23 14:52:03 -04:00
Jeremy Ashkenas
a78cbe78a1 Merge pull request #3240 from alubbe/master
using 'yield' automatically turns functions into generators
2014-09-19 16:38:41 -04:00
Leonid Beschastny
77d5b95260 Added test for jashkenas/coffee-script#3638 2014-09-17 15:02:18 +04:00
Leonid Beschastny
55e3b6b3c3 Fixed jashkenas/coffeescript#3638 - invalid block comments compilation 2014-09-17 15:02:10 +04:00
Andreas Lubbe
efca2861a6 added tests for yield, yield from, yield return and yield in if statements 2014-09-06 17:25:44 +02:00
Andreas Lubbe
781ea22d57 always wrap 'yield' in () to allow composability with all other operators 2014-09-06 17:12:25 +02:00
Andreas Lubbe
437b9ed65c added 'yield return' 2014-09-06 15:40:53 +02:00
Andreas Lubbe
c72556619f added 'yield from' 2014-09-06 13:53:21 +02:00
Andreas Lubbe
565d78f00b removed support for '->*" and '=>*' 2014-09-06 13:38:04 +02:00
Andreas Lubbe
75900660fd Merge remote-tracking branch 'A/master' 2014-09-06 11:32:25 +02:00
Michael Ficarra
b407a59baf Merge pull request #3618 from josh/update-site-example-projects
Refresh site Examples section
2014-08-28 00:40:35 -04:00
Joshua Peek
9dfd71b0e4 Add Atom to Examples 2014-08-27 21:24:42 -07:00
Joshua Peek
872092f6de Remove josh/nack from Examples 2014-08-27 21:21:25 -07:00
Michael Ficarra
8b066f125d Merge pull request #3616 from epmatsw/spelling
Quick spelling fixes
2014-08-26 19:46:34 -07:00
Will Stamper
94c467b520 Quick spelling fixes 2014-08-26 20:41:32 -05:00
Jeremy Ashkenas
53aa50f785 merged 2014-08-26 12:28:39 -04:00
Jeremy Ashkenas
81047d45ee CoffeeScript 1.8.0 2014-08-26 12:24:29 -04:00
Jeremy Ashkenas
9177676979 Merge pull request #3611 from lydell/release-1.8.0
Release 1.8.0
2014-08-26 12:20:18 -04:00
Simon Lydell
7cfba37f7c Update changelog for 1.8.0 2014-08-25 19:39:27 +02:00
Simon Lydell
ee8d105194 Rebuild docs 2014-08-23 16:08:39 +02:00
Michael Ficarra
6929441cb7 Merge pull request #3592 from mmotorny/master
Exit with an error code 1 if could not write a compiled JavaScript file ...
2014-08-17 22:07:07 -07:00
Maksym Motornyy
b5734028d9 Exit with an error code 1 if could not write a compiled JavaScript file or a source map
Currently CoffeeScript reports a success even if it failed to write a
compiled file to disk. This behavior confuses automated tools such as
test runners which may return false positives if a test failed to
compile because of a file lock.
2014-08-17 20:42:30 -07:00
Michael Ficarra
ab6f69c741 Merge pull request #3561 from yjo/js-map-file-ext
Use '.js.map' as file extension for created map files
2014-07-29 10:52:59 -07:00
Joe Lee-Moyet
2ec6e7e944 Use '.js.map' as file extension for created map files
Addresses jashkenas/coffeescript#3297
2014-07-29 17:28:08 +01:00
Nami-Doc
e8c96de269 Fix the "Examples" link on coffeescript.org
It now points to the "Trending repositories" of the month.
2014-07-23 22:21:14 +02:00
Nami-Doc
fbbda3f85f Fix the "Examples" link on coffeescript.org
It now points to the "Trending repositories" of the month.
2014-07-23 22:17:00 +02:00
Michael Ficarra
f96ab11feb Merge pull request #3545 from jordanbtucker/patch-1
`bin/cake` will be in `coffeescript`
2014-07-17 16:23:47 -07:00
jordanbtucker
5c1daf966a bin/cake will be in coffeescript
Since the name change, `bin/cake` will be in `coffeescript`, not `coffee-script`.
2014-07-17 15:04:40 -07:00
Michael Ficarra
df8529fbfb Merge pull request #3543 from ysmood/err_info_issue
Fixed an error formatting issue
2014-07-16 07:36:48 -07:00
Yad Smood
3465e7554d Fixed an error formatting issue f7b36054fc
When using tab for code indent, the error marker
will be wrongly positioned.
2014-07-16 17:56:07 +08:00
Yad Smood
f7b36054fc Add a test case for compiler error formatting.
Error formatting with mixed tab and space.
2014-07-16 17:50:15 +08:00
Michael Ficarra
3ec10df4a1 Merge pull request #3539 from minodisk/fix-heregex-interpolation
Fix wrong location issue in heregex interpolation
2014-07-13 21:10:03 -07:00
minodisk
deead4bfad Fix wrong location issue in heregex interpolation 2014-07-13 16:39:41 +09:00
Michael Ficarra
302aa6a457 Merge pull request #3533 from minodisk/fix-string-interpolation
Fix wrong location issue in "string" interpolation
2014-07-02 21:49:24 -07:00
minodisk
5920939e23 Fix wrong location issue in "string" interpolation 2014-07-03 13:11:20 +09:00
Michael Ficarra
2bab1b6aa1 Merge pull request #3524 from minodisk/master
Fix location data bug for string interpolations
2014-07-01 07:35:57 -07:00
minodisk
2b539ebea8 Fix wrong location issue in string interpolation starting with line break 2014-07-01 11:28:21 +09:00
dabbler0
159d562230 Fix off-by-one issue with string interpolation in lexer 2014-07-01 10:55:17 +09:00
Nami-Doc
eb030a2c73 Update link to "CoffeeScript Ristretto", fixes #3489 2014-06-26 17:10:11 +02:00
Nami-Doc
1157b32413 Update link to "CoffeeScript Ristretto", fixes #3489 2014-06-26 17:08:31 +02:00
G. Scott Olson
ba4157b5e2 Retina favicon.ico 2014-06-23 11:11:54 -04:00
Michael Ficarra
5a54d8ba6d Merge pull request #3509 from aviflax/patch-1
Remove sudo from install command in introduction
2014-06-09 08:21:27 -07:00
Avi Flax
f619416492 Remove typo
No idea how that got in there.
2014-06-06 13:46:41 -04:00
Avi Flax
2dd1ec3314 Remove sudo from install command in introduction
1. It just seems like a bad practice to encourage people to run npm with `sudo`
2. The doc wasn’t consistent with itself — down below in the full “Installation” section the same command did *not* include `sudo`
2014-06-06 09:26:18 -04:00
Michael Ficarra
4ad625a265 Merge pull request #3508 from bwin/patch-1
remove docco as dependency (still a devDependency)
2014-06-05 21:51:26 -07:00
Benjamin Winkler
df2b79fa56 remove docco as dependency (still a devDependency)
also changed version requirement notation for from `n.n.x` to `~n.n.n` like the others
2014-06-06 04:33:19 +02:00
Michael Ficarra
c4f9c3abf5 Merge pull request #3503 from datenreisender/handle-dotless-commands
Handle dotless commands in the REPL.
2014-06-03 23:22:15 -07:00
Marko Schulz
9410216b02 Make getCommandId() more readable. 2014-06-03 22:50:25 +02:00
Marko Schulz
233055a7ab Implement changes recommended in the pull request. 2014-06-03 11:29:03 +02:00
Marko Schulz
edf3c12fcc Handle dotless commands in the REPL.
Node 0.11 switched to storing the REPL commands dotless internally.
This fixes the problem brought up in #3450.
2014-06-02 13:24:57 +02:00
Michael Ficarra
1bb3c843e1 Merge pull request #3450 from ehuss/node11repl
Fix repl for Node 0.11.12.
2014-05-28 07:56:15 -07:00
Nami-Doc
48f2c2d0d2 Merge pull request #3494 from ELLIOTTCABLE/patch-1
Fix “list of open-source CoffeeScript on GitHub”
2014-05-24 10:57:17 +02:00
ELLIOTTCABLE
7e01672479 Fix “list of open-source CoffeeScript on GitHub”
Link's been broken with the recent GitHub re-arrangement. This is the closest thing I could find to what that link used to lead to.
2014-05-24 01:22:27 -05:00
Michael Ficarra
ddc023b28b Merge pull request #3492 from forty/master
Do not rely on properties order in scope tests
2014-05-21 07:49:39 -07:00
Quentin Barbe
c65f584112 Do not rely on properties order in scope tests 2014-05-21 16:40:44 +02:00
Jeremy Ashkenas
70a9a341ac Merge pull request #3491 from forty/master
Add tests to check that the FOR variable is defined after the loop
2014-05-20 17:48:26 -04:00
forty
c608901d5a Add tests to check that the FOR variable is defined after the loop 2014-05-20 23:37:33 +02:00
Jeremy Ashkenas
a5a1ea9157 Merge pull request #3477 from davidchambers/deprecate-join
command: deprecate --join
2014-05-12 10:59:17 -04:00
David Chambers
1cd48a9f5d command: deprecate --join 2014-05-11 22:41:39 -07:00
Jeremy Ashkenas
d8b7a55eb9 Merge pull request #3448 from leedm777/export-repl
Export the CoffeeScript REPL.
2014-05-08 16:08:45 -04:00
Jeremy Ashkenas
6ae21ae461 merged 2014-05-08 15:09:40 -04:00
Jeremy Ashkenas
f0764096e9 now that github supports renames, coffeescript, not coffee-script 2014-05-08 15:07:42 -04:00
Michael Ficarra
ade9620351 Merge pull request #3460 from datenreisender/correct-repl-help
Fix help for .load
2014-05-01 07:48:58 -07:00
Marko Schulz
3fdc3a4758 Fix help for .load 2014-05-01 14:54:43 +02:00
Eric Huss
03705c674f Fix repl for Node 0.11.12.
Node changed their repl so that it inherits from readline.Interface.
This means that `prompt` is now the rli function and not the original
prompt string.  This may be a little hacky, but I figure it would give
someone a start if they want to do a better fix.

The commit that changed this in Node is joyent/node@3ae0b17c76

This bug was mentioned in Issue #3395.
2014-04-19 01:18:21 -07:00
David M. Lee
576fe44ef8 Export the CoffeeScript REPL.
This is done by adding a root level wrapper script for
lib/coffee-script/repl, similar to how the register script is wrapped.
This allows user programs to embed a CoffeeScript REPL without digging
into CoffeeScript's internals.
2014-04-18 08:26:51 -05:00
Michael Ficarra
e02c8abb1a Merge pull request #3425 from charlierudolph/compile_errors
Display compile errors - rebase from @jeremybanks
2014-03-18 08:11:29 -05:00
Michael Ficarra
2723f1afe9 Merge pull request #3424 from charlierudolph/fix_index
Fix errors on index
2014-03-17 21:57:38 -05:00
Jeremy Banks
6114751d21 Display compile errors - rebase from @jeremybanks 2014-03-17 17:09:05 -07:00
charlierudolph
15b64addbf Fix errors on index
Extra quotations resulted in subtracting two strings and then a
javascript syntax error
2014-03-17 16:15:31 -07:00
Nami-Doc
4547612e50 Merge pull request #3418 from fcolas6013/patch-2
fix spell mistake on index.html.js
2014-03-15 22:24:54 +01:00
Fabrice Colas
9c15b13a96 fix spell mistake on index.html.js 2014-03-15 14:23:46 -07:00
Jeremy Ashkenas
63acf6a5ff Merge pull request #3355 from aroben/kill-isUndefined
Remove reference to never-defined .isUndefined property
2014-03-15 16:37:59 -04:00
Jeremy Ashkenas
3339c2f228 Merge pull request #3415 from matt-hickford/patch-1
Package with preferGlobal as appropriate for command-line application
2014-03-14 23:36:28 -04:00
Matt Hickford
c2db81d892 Package with preferGlobal as appropriate for command-line application
Per https://www.npmjs.org/doc/json.html#preferGlobal

> If your package is primarily a command-line application that should be installed globally, then set this value to true to provide a warning if it is installed locally.
>
> It doesn't actually prevent users from installing it locally, but it does help prevent some confusion if it doesn't work as expected.
2014-03-15 00:44:38 +00:00
Nami-Doc
8b15d8218d Merge pull request #3401 from sailxjx/master
fix a spell mistake in cakefile
2014-03-11 09:09:00 +01:00
sailxjx
bfc9d4d594 fix a spell mistake in cakefile 2014-03-11 15:11:02 +08:00
Michael Ficarra
ab5728c030 fix cake install; related: #3395, #3393 2014-03-03 13:24:20 -06:00
Michael Ficarra
dcf1556ffc Update README.md 2014-02-28 13:18:54 -06:00
Jeremy Ashkenas
53c53bd3e6 Update README.md 2014-02-28 07:59:24 -05:00
Jeremy Ashkenas
c2e1ab589c Delete README 2014-02-28 07:58:14 -05:00
Jeremy Ashkenas
75207a08ad Merge pull request #3393 from christianbundy/markdown-readme
Convert README to Markdown
2014-02-28 07:57:41 -05:00
Christian Bundy
a2dbfdc2f4 Convert README to Markdown 2014-02-27 22:19:04 -08:00
Michael Ficarra
0a82ac7d69 remove editorialisation 2014-02-22 23:20:06 -06:00
Michael Ficarra
a489006afb typo: mult-dot => multi-dot 2014-02-22 23:20:06 -06:00
Michael Ficarra
af08cfd37f add newlines to end of files 2014-02-22 23:20:06 -06:00
Michael Ficarra
9dc3a3df13 Merge pull request #3386 from blmarket/deprecate_warning
Fixes issue #3349, prints deprecation warning
2014-02-22 22:33:25 -06:00
Jeong, Heon
a82aecc008 Improved coding convention and messages. 2014-02-23 13:03:42 +09:00
Jeong, Heon
36a3e03048 Fixes issue #3349, prints deprecation warning
This patch fixes issue #3349, by prints deprecation warning for
users who depends on old(<1.7.0) implicit module registration.
2014-02-23 11:48:16 +09:00
Jeremy Ashkenas
fc8e9fd92a Merge pull request #3382 from davidchambers/time-elements
changelog: use time elements for release dates
2014-02-18 12:18:45 -05:00
David Chambers
c9e87f3044 changelog: use time elements for release dates 2014-02-18 08:49:46 -08:00
Michael Ficarra
bb319e2add Merge pull request #3381 from davidchambers/inline-css
changelog: replace inline CSS
2014-02-18 08:08:03 -06:00
David Chambers
81e2253a55 changelog: replace inline CSS 2014-02-17 21:45:49 -08:00
Michael Ficarra
c41a14f447 Merge pull request #3380 from madprgmr/master
Rudimentary fix for jashkenas/coffee-script#3379.
2014-02-17 17:56:36 -06:00
Sean Hussey
a323160d14 Rudimentary fix for jashkenas/coffee-script#3379. 2014-02-17 18:37:10 -05:00
Jeremy Ashkenas
a216f93b54 Merge pull request #3376 from davidchambers/anchors
change log improvements
2014-02-17 14:14:13 -05:00
David Chambers
551cf56ceb changelog: add missing compare view URLs 2014-02-16 18:09:17 -08:00
David Chambers
09446ad515 changelog: add anchor to each section
Add releaseHeader helper to avoid repetition.
2014-02-16 18:08:35 -08:00
Michael Ficarra
b31951980e Merge pull request #3368 from ricardobeat/cake-register-by-default
Cakefile: register .coffee extension by default
2014-02-09 22:19:41 -06:00
Ricardo Tomasi
e7ba29514d Register .coffee extension by default on Cakefile 2014-02-10 01:16:14 -02:00
Michael Ficarra
a2c0106b3f fixes #3363: modulo operator evaluation order 2014-02-08 20:56:34 -06:00
Michael Ficarra
4dfc75dede Merge pull request #3362 from epidemian/fix-modulo-coercion
Fix #3361, make %% coerce right operand only once
2014-02-08 10:38:58 -06:00
Demian Ferreiro
0ad30e9b3f Fix #3361, make %% coerce right operand only once
Force coercion of right operand once before doing arithmetic with it in the `__modulo` utility function.
2014-02-08 13:24:39 -03:00
Jeremy Ashkenas
46f55d1bb4 Merge pull request #3360 from lydell/install-docs
Improve installation documentation
2014-02-07 10:53:51 -05:00
Simon Lydell
27f1976159 Improve installation documentation
- Simplify the command to install latest master.

- Promote using `--save` when installing locally, since it automatically
  locks the minor version, protecting users from accidentally installing
  breaking updates.
2014-02-07 16:30:52 +01:00
Michael Ficarra
816241d9a1 Merge pull request #3359 from lydell/v8-consistent-stacktraces
Make patched stack traces’ prelude consistent with V8
2014-02-07 09:00:45 -06:00
Simon Lydell
4bbd63c883 Make patched stack traces’ prelude consistent with V8
In V8, the `stack` property of errors contains a prelude and then the
stack trace. The contents of the prelude depends on whether the error
has a message or not.

If the error has _not_ got a message, the prelude contains the name of the
error and a newline.

If the error _has_ got a message, the prelude contains the name of the
error, a colon, a space, the message and a newline.

In other words, the prelude consists of `error.toString() + "\n"`

Before, coffee-script’s patched stack traces worked exactly like that,
except that it _always_ added a colon and a space after the name of the
error.

This fix is important because it allows for easy and consistent
consumption of the stack trace only:

`stack = error.stack[error.toString().length..]`
2014-02-07 13:01:01 +01:00
Adam Roben
e9a0512663 Remove reference to never-defined .isUndefined property
This was added in f4a7cca075 to fix #1038
for CoffeeScript 1.0.1. `.isUndefined` was removed in
caf3da2f66 but this code was never
updated. That actually caused the behavior of this code to change
(trailing `undefined` and `return undefined` statements no longer got
optimized away) when CoffeeScript 1.3.2 was released, but the new
behavior was deemed correct in
https://github.com/jashkenas/coffee-script/issues/1038#issuecomment-14427560.
2014-02-06 09:23:16 -05:00
Adam Roben
8980647f32 Add tests for the optimization of trailing return statements
This documents current behavior. When #1038 was fixed, we also optimized
away trailing "undefined" and "return undefined", but that is no longer
the case.
2014-02-06 09:21:35 -05:00
Michael Ficarra
eda4f0c55b Merge remote-tracking branch 'origin/gh-pages' 2014-02-01 21:07:10 -06:00
Michael Ficarra
ed928928f6 use npm-installed docco rather than relying on globally installed docco 2014-02-01 21:06:21 -06:00
Michael Ficarra
5f28319cb1 update "latest version" documentation link to 1.7.1 2014-01-29 23:24:06 -06:00
Michael Ficarra
6b0ee127da recompile documentation with 1.7.1 2014-01-29 23:21:44 -06:00
Michael Ficarra
5e31672793 Merge branch 'master' into gh-pages 2014-01-29 23:21:00 -06:00
Michael Ficarra
4ab8503e5a CoffeeScript 1.7.1 2014-01-29 23:19:36 -06:00
Michael Ficarra
cc4cc8e652 update changelog for 1.7.1 2014-01-29 23:07:27 -06:00
Michael Ficarra
52b89d5b03 rebuild annotated source documentation 2014-01-29 22:54:00 -06:00
Michael Ficarra
094a0cbe95 add docco as npm dependency so it doesn't have to be installed globally 2014-01-29 22:52:49 -06:00
Michael Ficarra
f8eca2e822 Merge branch 'master' into gh-pages 2014-01-29 22:51:23 -06:00
Jeremy Ashkenas
114eccb459 Merge pull request #3340 from benbria/master
Fix a typo causing module.paths to be always set as the cwd.
2014-01-29 10:29:55 -08:00
Geoffry Song
38bd879a9a Fix a typo causing module.paths to be always set as the cwd.
`options.fileName` was used instead of `options.filename`.
2014-01-29 13:23:19 -05:00
Jeremy Ashkenas
a73a6e24a6 Merge pull request #3337 from roryokane/fix-operator-docs-commas
In docs, move commas out of code
2014-01-28 18:45:17 -08:00
Rory O’Kane
b4d35f13a4 In docs, move commas, part 2
I had missed that the next line had comma-separated operators, too.
2014-01-28 21:09:08 -05:00
Rory O’Kane
3fcaebb007 In docs, move commas out of code
The commas separating these three keywords are not code themselves – not what the user would write – so they should be outside of the `<tt>` tags.

Edits the table in the section [Operators and Aliases](http://coffeescript.org/#operators).
2014-01-28 21:01:22 -05:00
Jeremy Ashkenas
3357b6cf2c index.html 2014-01-28 20:49:26 -05:00
Rory O’Kane
6df8d92499 Fix markup in math operator documentation
In the documentation, surround the new operators with `<tt>` tags instead of Markdown-style backticks, since this is HTML.
2014-01-28 20:49:20 -05:00
Jeremy Ashkenas
e543eb5101 index.html 2014-01-28 20:49:09 -05:00
Jeremy Ashkenas
7c4f842501 Merge pull request #3336 from roryokane/fix-math-operator-docs-markup
Fix markup in math operator documentation
2014-01-28 17:47:32 -08:00
Rory O’Kane
a5fef52751 Fix markup in math operator documentation
In the documentation, surround the new operators with `<tt>` tags instead of Markdown-style backticks, since this is HTML.
2014-01-28 18:56:43 -05:00
dannguyen
ef7b3a75e0 Just a small typo in 1.7.0 changelog 2014-01-28 16:47:42 -05:00
Jeremy Ashkenas
734fcedc06 Merge pull request #3334 from dannguyen/patch-1
Just a small typo in 1.7.0 changelog
2014-01-28 13:46:39 -08:00
dannguyen
e4c8bcf8f6 Just a small typo in 1.7.0 changelog 2014-01-28 16:36:04 -05:00
Jeremy Ashkenas
a3ae0c5c75 CoffeeScript 1.7.0 2014-01-28 14:05:38 -05:00
Jeremy Ashkenas
46895419b3 Merge pull request #3333 from xixixao/release1.7.0
Implement #3332
2014-01-28 10:59:22 -08:00
xixixao
4f6a4bab30 Removed idle styles 2014-01-28 18:57:37 +00:00
xixixao
9e5ffaea69 Use actual _.template instead of custom one 2014-01-28 18:56:43 +00:00
xixixao
928d2d7f4a Extras compiled with 1.7.0 2014-01-28 03:35:09 +00:00
xixixao
10293df1f9 Recompile source with 1.7.0 version 2014-01-28 03:34:00 +00:00
xixixao
41c4c822ba Recompile documentation js files with 1.7.0 version 2014-01-28 03:33:03 +00:00
xixixao
6030ac3a23 Fixes in documentation 2014-01-28 03:30:06 +00:00
xixixao
f42329ca0a Use Node instead of Ruby for documentation 2014-01-28 03:17:12 +00:00
Jeremy Ashkenas
570529f526 Fixing tests for browser. 2014-01-27 11:55:20 -05:00
Jeremy Ashkenas
8b8436d794 Merge pull request #3326 from xixixao/release1.7.0
Prepare 1.7.0 release
2014-01-27 08:42:58 -08:00
Jeremy Ashkenas
b0594aad3e Merge pull request #3331 from xixixao/inlineobjectchain
Fixes chaining after inline implicit objects
2014-01-26 14:15:09 -08:00
xixixao
04b0b94a8c Fixes chaining after inline implicit objects 2014-01-26 22:11:10 +00:00
xixixao
e1f46cfb9b Prepare 1.7.0 release 2014-01-26 18:32:12 +00:00
Michael Ficarra
cc1b74f11b Merge pull request #3329 from xixixao/issue3325
Fixes #3325: implicit indendation error messages
2014-01-25 22:00:24 -08:00
xixixao
104b4666fe Fix indendation error messages 2014-01-26 05:25:13 +00:00
Michael Ficarra
835fc84330 Merge pull request #3328 from xixixao/issue3216
Fixes #3216 for declarations in object literals
2014-01-25 21:05:34 -08:00
Michael Ficarra
a5d6285cfd forgotten compilation from parent commit 2014-01-25 22:54:25 -06:00
xixixao
c2727d964c Fix for declarations in object literals 2014-01-26 04:41:30 +00:00
Andreas Lubbe
f375394381 Merge https://github.com/jashkenas/coffee-script
Conflicts:
	lib/coffee-script/lexer.js
	lib/coffee-script/parser.js
	lib/coffee-script/rewriter.js
	src/lexer.coffee
	src/rewriter.coffee
2014-01-25 19:37:35 -08:00
Michael Ficarra
d687d52f9e Merge pull request #2887 from epidemian/more-math-operators
Add new mathematical operators
2014-01-24 13:18:29 -08:00
Demian Ferreiro
6a43de789f Simplify modulo tests 2014-01-24 17:55:50 -03:00
Demian Ferreiro
1288786fdc Make modulo operator convert arguments to numbers 2014-01-24 16:08:39 -03:00
Demian Ferreiro
2b4421fca1 Merge branch 'master' into more-math-operators
Conflicts:
	lib/coffee-script/grammar.js
	lib/coffee-script/lexer.js
	lib/coffee-script/nodes.js
	lib/coffee-script/parser.js
	test/regexps.coffee
2014-01-24 15:40:28 -03:00
Jeremy Ashkenas
6bdd52733e Merge pull request #3327 from xixixao/forexpansion
Fix expansion in destructuring inside comprehensions
2014-01-24 10:24:51 -08:00
xixixao
bd6b4142fe Fix expansion in destructuring inside comprehensions 2014-01-24 18:20:45 +00:00
Jeremy Ashkenas
daa6ad5470 Merge pull request #3268 from xixixao/issue156
Implement #156, Added expansion to destructuring
2014-01-24 08:33:42 -08:00
xixixao
369e0545c0 Added expansion to destructuring 2014-01-24 16:00:34 +00:00
Michael Ficarra
5f31a3d60e Merge pull request #3324 from xixixao/issue1871
Fixes #1871, close implicit objects in implicit returns
2014-01-23 15:24:10 -08:00
xixixao
8b976acac1 Fixes #1871, close implicit objects in implicit returns 2014-01-23 23:12:12 +00:00
Jeremy Ashkenas
b00962db1a Merge pull request #3322 from xixixao/issue1099
Fix #1099, remove in empty array optimization
2014-01-23 07:16:00 -08:00
xixixao
26dcf025f4 Remove in empty array optimization 2014-01-23 15:09:25 +00:00
Jeremy Ashkenas
d2f90d2236 Merge pull request #3320 from xixixao/issue1275
Fix #1275
2014-01-22 10:54:18 -08:00
xixixao
c3391e1dd8 Fix 1275 2014-01-22 18:33:44 +00:00
Jeremy Ashkenas
b3463a1378 Merge pull request #3319 from xixixao/issue1096
Fix 1096, 1131, 1828: Improve error messages for generated tokens
2014-01-22 05:29:03 -08:00
xixixao
f0463e9981 Improve error messages for generated tokens 2014-01-22 02:54:09 +00:00
Jeremy Ashkenas
1cc583b382 Merge pull request #3317 from xixixao/chainafteroutdent
Chaining semantics after arguments with outdent
2014-01-21 14:27:32 -08:00
xixixao
39cb8815f7 Fixed chaining semantics after outdent 2014-01-21 22:00:57 +00:00
Michael Ficarra
21db08a23d add missing implicit object literal test
ref michaelficarra/CoffeeScriptRedux#266 and 670a1f5f78 (diff-2)
2014-01-12 11:16:27 -06:00
Michael Ficarra
1f301d8c07 Merge pull request #3292 from marchaefner/CLI
`coffee DIR` executes `DIR/index.coffee`
2013-12-29 14:24:02 -08:00
Andreas Lubbe
1e377ed59b 'yield*' now works as expected 2013-12-27 22:12:04 -08:00
Andreas Lubbe
64e78a2bec updated lexer to allow 'yield*' 2013-12-26 01:16:02 -08:00
Jeremy Ashkenas
35f185440f Merge pull request #3293 from marchaefner/master
Fix `child_process.fork` patch
2013-12-23 22:19:55 -08:00
Michael Ficarra
5ce0c84907 Merge pull request #3284 from xixixao/issue3056
Fix multiple postfix conditionals
2013-12-23 22:08:34 -08:00
Andreas Lubbe
25b1eee293 first attempt at including 'yield*' 2013-12-23 19:32:25 -08:00
Marc Häfner
a6891e4feb Fix child_process.fork patch
* Preserve `options` when called without `args`
  * Don't use `coffee` script as `execPath` (Fixes #2919)
2013-12-24 02:05:53 +01:00
Marc Häfner
8a3ebb9181 CLI: Run index.coffee when called on a directory 2013-12-24 01:53:27 +01:00
Andreas Lubbe
dab4ae9416 '->*' and '=>*' now produce generators 2013-12-19 18:08:25 -08:00
Andreas Lubbe
56b04a58dc first attempt at using '->*" and '=>*' for generators 2013-12-19 14:21:14 -08:00
Michael Ficarra
308299fe04 Merge pull request #3285 from xixixao/formatutils
Format utilities using single quoted literals
2013-12-16 20:08:05 -08:00
xixixao
1cc8463b9c Formatted utilities using single quoted literals 2013-12-17 03:36:49 +01:00
xixixao
d7862647d9 Fix multiple postfix conditionals 2013-12-17 03:31:19 +01:00
Nami-Doc
6c786f0fb7 Merge pull request #3283 from Fritz-Lium/patch-1
the page lists only top 100 contributors
2013-12-14 03:31:43 -08:00
Fritz-Lium
cc345def46 the page list only top 100 contributors 2013-12-14 19:31:04 +08:00
Michael Ficarra
818983b6a4 Merge pull request #3280 from xixixao/issue3271
Examples: Back to non-naked constructor, @, preincrement, comprehension bracketing...
2013-12-09 14:31:23 -08:00
xixixao
b859d92d2c Back to non-naked constructor, @, preincrement, comprehension bracketing, idioms: calls, comprehensions, interpolations 2013-12-09 22:28:34 +00:00
Jeremy Ashkenas
8cd9ba168d Merge pull request #3279 from michaelficarra/fix-require.extensions-registration
fix require.extensions registration
2013-12-08 13:26:15 -08:00
Michael Ficarra
08a57898a7 add CoffeeScript.register method for require.extensions registration 2013-12-08 14:21:18 -06:00
Michael Ficarra
ba4743cc83 fix auto and manual require.extensions registration; ref #3141
You can now `require('coffee-script/register')` to manually register,
and the compiler auto-registers when directly running a coffee file.
2013-12-08 14:19:10 -06:00
Jeremy Ashkenas
94e22ab819 Merge pull request #3275 from marchaefner/CLI
Fix --watch handling of deleted sources
2013-12-07 22:28:19 -08:00
Michael Ficarra
c1b46f777f Merge pull request #3277 from boundvariable/master
Add CoffeeScript in Action book link
2013-12-06 08:04:46 -08:00
Patrick Lee
81cf9ca00f Add CoffeeScript in Action book link 2013-12-07 00:58:43 +11:00
Nami-Doc
96f087ca6b Merge pull request #3276 from xixixao/issue1495fixup
Fixup #3263: Prevent loop collection in endAllImplicitCalls
2013-12-05 13:55:38 -08:00
xixixao
bc975e556e Prevent loop collection in endAllImplicitCalls 2013-12-05 21:53:42 +00:00
Andreas Lubbe
e1000205fd Merge github.com:jashkenas/coffee-script 2013-12-05 11:56:34 -08:00
Andreas Lubbe
c02a403f2e fixed misspelling in Cakefile 2013-12-04 21:49:17 -08:00
Marc Häfner
6804c1065b Fix: EPERM when deleting watched dirs in Windows
* Suppress `EPERM` from watchers
  * Suppress `EPERM` from `fs.unlink`
2013-12-04 17:12:24 +01:00
Marc Häfner
74cf54a84f Prettify watch 2013-12-04 14:50:36 +01:00
Andreas Lubbe
f4b850d59c further improved readability of cakefile generator check 2013-12-02 23:33:16 -08:00
Marc Häfner
73af30b5d8 Fixes #3267 -- Remove source maps of deleted source files 2013-12-01 12:03:22 +01:00
Marc Häfner
54633aee3f Remove unnecessary parameter 2013-12-01 11:35:03 +01:00
Andreas Lubbe
85c7fffd1a improved readability of cakefile generator check 2013-11-30 20:51:53 -08:00
Andreas Lubbe
9d29a830df entire generator test file is now ignored if generators are not available 2013-11-30 12:26:32 -08:00
Andreas Lubbe
74a92db173 improved readability of generator test 2013-11-30 11:45:19 -08:00
Andreas Lubbe
d712a6c0f4 npm run-script test-harmony executes generator tests 2013-11-29 20:59:22 -08:00
Andreas Lubbe
7906a2b6c1 removed yield from the reserved words 2013-11-29 20:58:43 -08:00
Andreas Lubbe
f11ca9888f added a test for generators 2013-11-29 20:58:26 -08:00
Marc Häfner
26200f4640 Improve HEREDOC regexp
* Exclude trailing blank line from the match group
  * Fix backslash handling
2013-11-28 16:46:00 +01:00
Marc Häfner
13f205404c Merge pull request #3261 from xixixao/issue1273
Fix #1273, Handle backslashes at the end of heredocs
2013-11-28 07:32:20 -08:00
Jeremy Ashkenas
563f14b178 Merge pull request #3263 from xixixao/issue1495
Implement #1495,  Method call chaining
2013-11-27 22:58:46 -08:00
xixixao
5e4cca90a3 Fix #3264, missing leading whitespace before interpolation in heredoc 2013-11-27 20:53:20 +00:00
xixixao
a61b6ee925 Fixed leading whitespace before interpolation in simple strings 2013-11-27 20:29:45 +00:00
xixixao
b11d956d53 Added compilation regression test 2013-11-27 12:58:14 +00:00
xixixao
ee9febe399 Handle nested calls and function oneliners when chaining 2013-11-27 04:57:44 +00:00
xixixao
15a70f863c Implemented method call chaining 2013-11-27 03:41:52 +00:00
Michael Ficarra
4eee9c318e Merge pull request #3262 from xixixao/issue1766
Fix #1766, Add negative slice end index into docs
2013-11-26 19:10:46 -08:00
xixixao
ac6a76ee10 Add negative slice end index into docs 2013-11-27 01:01:32 +00:00
xixixao
42aa8d256c Handle backslashes at the end of heredocs 2013-11-26 19:29:13 +00:00
Marc Häfner
873ed071d4 Fixes #3259 -- Use placeholders when adding params to scope
Don't register nested variables of complex parameters as parameters of the compiled function. Use the computed placeholder name instead.
2013-11-26 14:23:20 +01:00
Jeremy Ashkenas
210376f7a9 Merge pull request #3256 from xixixao/issue3249
Implements #3249, #1994 Escape newlines in heredocs with backslashes
2013-11-24 10:54:53 -08:00
xixixao
35d327a304 Escape newlines in heredocs with backslashes 2013-11-24 18:37:11 +00:00
Jeremy Ashkenas
e3e8b1c501 Merge pull request #3255 from marchaefner/CLI
CLI fixes and refactoring
2013-11-23 18:31:27 -08:00
Marc Häfner
52a54a7681 Fix and simplify management of sources in CLI
* Move all source path filtering to `compilePath`
  * Restrict modification of `sources` to
    * `compilePath` for adding
    * `removeSource` for removing
  * Don't add unfiltered paths to `sources` (and remove them later on)
2013-11-23 07:54:35 +01:00
Marc Häfner
1fe28c1fc9 Simplify and rename unwatchDir (to removeSourceDir) 2013-11-23 06:55:57 +01:00
Marc Häfner
89efd05a3f Make timeout callback in watchDir synchronous 2013-11-23 06:49:41 +01:00
Marc Häfner
caafafcf4d Simplify removeSource and make it synchronous 2013-11-23 06:49:13 +01:00
Marc Häfner
81d8224b9a Remove path.exists* as fallback for fs.exists* 2013-11-23 06:42:39 +01:00
Marc Häfner
22c85e216f Use absolute paths in CLI
* Use absolute paths for source files and target paths
  * Memorize and explicitly check for watched directories
  * Make path comparison and construction more precise and clear
  * Remove now unnecessary check for special relative paths
2013-11-23 06:41:08 +01:00
Michael Ficarra
f047ba52b2 Merge pull request #3250 from xixixao/issue3229
Fix multiple escaped backslashes in literal strings
2013-11-19 20:32:41 -08:00
xixixao
130899a39f Fix multiple escaped backslashes in literal strings 2013-11-19 23:44:39 +00:00
Jeremy Ashkenas
6847400ccb Merge pull request #3246 from xixixao/issue3229
Implements #3229 - Changed multiline string literals
2013-11-18 16:42:10 -08:00
xixixao
1102567b0c Handle escaped backslashes 2013-11-19 00:04:17 +00:00
xixixao
8c6647849b Don't rely on multiline in other tests 2013-11-18 16:26:48 +00:00
xixixao
de42ad0e1c More test cases 2013-11-18 15:25:11 +00:00
xixixao
073d025fac Better method name and fixed regexps for IE 2013-11-18 15:13:40 +00:00
xixixao
efe8c68c75 Changed multiline string literals 2013-11-18 04:32:15 +00:00
Andreas Lubbe
9941050120 using 'yield' automatically turns functions into generators 2013-11-15 22:19:31 +01:00
Andreas Lubbe
dafc7bdea5 added 'yield' to the unary keywords 2013-11-15 22:16:28 +01:00
Andreas Lubbe
f51cbd7117 removed 'yield' from the reserved keywords 2013-11-15 22:15:31 +01:00
Jeremy Ashkenas
45d97b3dfe Remove old Node pre-0.6 warning. 2013-11-15 14:26:47 -05:00
Jeremy Ashkenas
fcc88ca472 Revert "add: Stat polling support while fs.watch doesn't work."
This reverts commit 2853e718f2.
2013-11-15 14:26:16 -05:00
Jeremy Ashkenas
187ebd0374 Revert "mov: Change the option name --polling to --watch-polling, and only leaves the long option name."
This reverts commit 08f6c65c3b.
2013-11-15 14:26:05 -05:00
Jeremy Ashkenas
c4999efda7 Revert "fix: opts.polling changed to opts[watch-polling]"
This reverts commit 52789f5b19.
2013-11-15 14:25:55 -05:00
Jeremy Ashkenas
b6231e50c3 Merge pull request #3212 from ysmood/issue3210
add: Stat polling support while `fs.watch` doesn't work.
2013-11-15 11:09:50 -08:00
Marc Häfner
592aa33577 Fixes #2367 -- super in for-loop 2013-11-15 06:35:04 +01:00
Marc Häfner
544c99a9ad Fix error location for illegal pure statements 2013-11-15 05:37:34 +01:00
Jeremy Ashkenas
de0e3baf1f Merge pull request #3237 from marchaefner/fixSuper
Fix super-related tagging of `Code` nodes
2013-11-14 19:25:50 -08:00
Marc Häfner
aea0f2533b Fixes #3232 -- Tag all class properties static
(and remove duplicate `context` assigment)
2013-11-15 03:44:26 +01:00
Marc Häfner
138c25fe5f Cleanup and extend METHOD_DEF
* Fixes #2949: Detect reserved names (not only for instance methods)
  * Don't assign names which might result in incorrect `super` calls
2013-11-12 16:53:09 +01:00
Jeremy Ashkenas
e0195756dc Merge pull request #3234 from marchaefner/issue3087
Fixes #3087 -- Use `fs.*Sync` for CLI compilation
2013-11-10 04:19:49 -08:00
Marc Häfner
96ae98fade Fixes #3087 -- Use fs.*Sync for CLI compilation
* Make `compilePath` synchronous
 * Remove unused variable
2013-11-10 08:36:29 +01:00
Nami-Doc
efb9809d3b Merge pull request #3233 from xixixao/issue2953cleanup
Clean up `Method calls on splice endpoints`
2013-11-09 16:20:13 -08:00
xixixao
0dada3dd27 Remove unnecessary type conversions to Number 2013-11-10 00:13:52 +00:00
xixixao
849c8e8ef4 Remove unnecessary existential check 2013-11-10 00:13:14 +00:00
Jeremy Ashkenas
9e9c83f788 Merge pull request #3228 from marchaefner/fixClassCompilation
Avoid unnecessary wrapping of some bound functions
2013-11-05 18:47:01 -08:00
Marc Häfner
d41d87a874 Avoid unnecessary wrapping of some bound functions 2013-11-03 03:14:13 +01:00
Jeremy Ashkenas
ab40571ffc Merge pull request #3227 from marchaefner/fixClassCompilation
Fix scope of external constructor reference / Refactor `Closure`
2013-11-01 13:08:27 -07:00
Marc Häfner
5d13d14de9 Closes #3008 -- Fix scope of constructor reference
* Make scope of `Code` nodes accessible (prior to `compileNode`)
* Use correct scope for reference of external constructor.
* Remove unreachable code.
2013-11-01 01:13:10 +01:00
Marc Häfner
1df8abf1cb Refactor closure compilation
* Break up `Closure` and merge `Closure.wrap` into `Base.compileClosure`
* Construct class closure directly in `Class.compileNode`
* Reuse `isLiteralArguments` in `Range.compileArray`
* Move all helpers to bottom of file
* Add test for #3063
2013-10-31 23:25:11 +01:00
Jeremy Ashkenas
45b60c9a52 Merge pull request #3224 from marchaefner/fixClassCompilation
Minor fixes for class compilation
2013-10-28 17:51:23 -07:00
Marc Häfner
091bc56a96 Code cleanup in Class
* Don't insert unnecessary `_ref` (in the wrong scope)
* Improve code prettiness. (Reverts most of 903e9c99)
2013-10-29 00:01:20 +01:00
Yad Smood
52789f5b19 fix: opts.polling changed to opts[watch-polling] 2013-10-27 01:04:03 +08:00
Marc Häfner
9ba1d41ec8 Fix: __extends helper above directive prologue 2013-10-26 06:54:54 +02:00
Jeremy Ashkenas
5456bd5f89 Merge pull request #3218 from marchaefner/issue3059
Escapable linebreaks in heregexes
2013-10-23 16:03:32 -07:00
Marc Häfner
0d662c3ad2 Missing parentheses 2013-10-24 00:43:29 +02:00
Marc Häfner
fa76e2dd21 Escapable linebreaks in heregexes 2013-10-24 00:36:46 +02:00
Yad Smood
08f6c65c3b mov: Change the option name --polling to --watch-polling, and only leaves the long option name.
opt: Optimize the comment of the `--watch-polling` option.
2013-10-23 00:52:40 +08:00
Jeremy Ashkenas
54840c0cbf Merge pull request #3214 from marchaefner/issue3059
Escaped whitespace and slashes in Heregexes
2013-10-22 09:35:00 -07:00
Marc Häfner
91ac3fa031 Escaped whitespace and slashes in Heregexes
* Resolves #3059: Don't remove escaped whitespace.
* Fixes #2238: Prevent escaping slashes that are already escaped.
* Fix detection of end of heregex with escaped slashes.
2013-10-22 18:08:17 +02:00
Yad Smood
2853e718f2 add: Stat polling support while fs.watch doesn't work.
Add a new cli option: -g --polling [SPAN]

    If state polling mode is enabled, use it.
    Else use the native api.

    This is useful while watching remote directory.
    Such as the `fs.watch` won't catch the SMB server's file change event.
2013-10-21 15:26:20 +08:00
Jeremy Ashkenas
c22707cd53 Fixes #2941 -- don't destroy extensionless filenames for --join 2013-10-20 19:09:55 -03:00
Jeremy Ashkenas
351c875576 merged in stricter noncallables 2013-10-20 18:49:30 -03:00
Jeremy Ashkenas
35b64d7f18 Merge pull request #3211 from marchaefner/issue2181
Fix compilation for conditional assignment
2013-10-20 14:16:38 -07:00
Jeremy Ashkenas
db87d817e8 Merge pull request #3012 from imcotton/parallel-loading
Script loading parallelized in browser
2013-10-20 14:10:40 -07:00
Jeremy Ashkenas
f3c5cc6774 Fixes #3019 - Documentation tweak to default argument meaning. 2013-10-20 18:08:28 -03:00
Marc Häfner
4cc2c305a4 Fixes #2181 -- conditional assignment as subexpression
* Parenthesize compilation of `||=` and `&&=` (when needed).
* Fix variable caching for `?=`
2013-10-20 22:59:01 +02:00
Jeremy Ashkenas
a5513c45d0 Fixes #3047 -- Fixes module.paths when running directly with no explicit passed-in files. 2013-10-20 17:50:13 -03:00
Jeremy Ashkenas
c820e0241e Fixes #3053 - error for mismatched own/for-in without an index. 2013-10-20 17:40:50 -03:00
Jeremy Ashkenas
eb2ac2c64d Fixes #3063 -- wait a moment so that an error can be raised. 2013-10-20 17:04:52 -03:00
Jeremy Ashkenas
59cf19fd1c Fixes #3072 -- tweak process.argv to match when running REPL 2013-10-20 16:53:08 -03:00
Jeremy Ashkenas
d5a25d138d Fixes #3089 -- don't mutate options passed in to compile() 2013-10-20 16:21:06 -03:00
Jeremy Ashkenas
a7ecd80c92 Merge pull request #3096 from marchaefner/issue2994
Disallow single-line `IF expr ELSE` without `THEN`
2013-10-20 12:13:39 -07:00
Jeremy Ashkenas
465cffc675 Merge pull request #3113 from mklement0/make-repl-use-global-context
Make the REPL *CLI* use the global context to be consistent with the node REPL *CLI*.
2013-10-20 09:17:07 -07:00
Jeremy Ashkenas
302a46d093 Merge pull request #3132 from caitp/issue-3132
Format block-comments better
2013-10-20 09:08:40 -07:00
Jeremy Ashkenas
392767a04e Fixes #3143 -- Potential memory leaks caused by use of fat arrow next to other (non-fat-arrow-using) long-lived closures. 2013-10-20 12:53:18 -03:00
Jeremy Ashkenas
928f949761 Fixes #3160 -- a missing bit of locationData 2013-10-20 12:15:15 -03:00
Jeremy Ashkenas
8bb833d858 Merge pull request #3165 from grschafer/master
Fix constructor_destructuring docs example to alert a defined value
2013-10-20 08:04:44 -07:00
Jeremy Ashkenas
2b03fa9077 Fixes #3166 -- add a (simpler) flag to suppress the generated header. 2013-10-20 12:03:37 -03:00
Jeremy Ashkenas
cfdb774da9 CoffeeScript REPL should be able to require coffeescript files. 2013-10-20 11:22:23 -03:00
Jeremy Ashkenas
b173a377a6 Fixes #3208. You now have to require 'coffee-script/extensions' in order to be able to auto-require CoffeeScript files. 2013-10-20 11:08:13 -03:00
Jeremy Ashkenas
581af4540a Merge pull request #3193 from celwell/master
fixed ascii art inconsistencies in coffee's water vapor
2013-10-04 04:04:10 -07:00
Christopher Elwell
18e5b6b199 fixed ascii art inconsistencies in coffee's water vapor 2013-10-03 19:02:28 -07:00
Michael Ficarra
6da2306fe2 Merge pull request #3189 from mal/issue3186
Fixes #3186
2013-09-29 07:42:36 -07:00
Mal Graty
a8e4b78803 Fixes #3186 2013-09-29 15:28:58 +01:00
Nami-Doc
a3be1f6e48 Merge pull request #3174 from a3gis/master
Accept all format of numbers in ranges
2013-09-24 11:20:57 -07:00
a3gis
89ef3d4117 accept all format of numbers in ranges 2013-09-24 19:15:31 +01:00
Jeremy Ashkenas
4cf75ec027 Forgot to update the .erb as well. 2013-09-24 09:52:00 -03:00
Jeremy Ashkenas
830c294aea Add new Packt book. 2013-09-22 14:56:33 -03:00
a3gis
bb86e54ece accept all format of numbers in ranges 2013-09-21 00:51:12 +01:00
Caitlin Potter
359e17277f Merge pull request #1 from sjorek/issue-3132
Enhancement: Add more block-comment related tests
2013-09-17 10:12:31 -07:00
Stephan Jorek
89f5f9d59d added more block-comment related tests for single-line block-comments and jsdoc-like @doctags-comments. 2013-09-17 18:09:15 +02:00
Greg Schafer
26c0f7ca2d Fix constructor_destructuring example to alert a defined value 2013-09-14 14:34:53 -05:00
Michael Ficarra
40c1086efa Merge pull request #3151 from kchmck/master
Fix some inconsistent indentation
2013-09-03 16:33:27 -07:00
Mick Koch
999a3db499 Fix some inconsistent indentation
Some places used 4 spaces instead of 2
2013-09-03 19:02:18 -04:00
Michael Klement
50e13f62f2 Merge branch 'make-repl-use-global-context' of https://github.com/mklement0/coffee-script into make-repl-use-global-context 2013-09-03 18:35:21 -04:00
Michael Klement
fceff1729c Make the REPL *CLI* use the global context so as to be consistent with the node REPL CLI.
Make the REPL *CLI* use the global context so as to (a) be consistent
with the `node` REPL CLI and, therefore, (b) make packages that modify
native prototypes (such as 'colors' and 'sugar') work as expected.

Note that, by contrast, programmatic use (`require 'repl'`) will
continue to default to a NON-global context - again, consistent with
node's behavior.
2013-09-03 18:19:43 -04:00
Michael Ficarra
1765a7ae0c Merge pull request #3150 from mklement0/fix-repl-module-global-context-support
Fix: support for consumers of the REPL *module* being able to opt into using the global context ...
2013-09-03 14:47:22 -07:00
Michael Klement
ae79ff9fa3 Merge branch 'make-repl-use-global-context' of https://github.com/mklement0/coffee-script into make-repl-use-global-context 2013-09-03 17:28:03 -04:00
Michael Klement
3e9d01d6c6 Make the REPL *CLI* use the global context so as to be consistent with the node REPL CLI.
Make the REPL *CLI* use the global context so as to (a) be consistent
with the `node` REPL CLI and, therefore, (b) make packages that modify
native prototypes (such as 'colors' and 'sugar') work as expected.

Note that, by contrast, programmatic use (`require 'repl'`) will
continue to default to a NON-global context - again, consistent with
node's behavior.
2013-09-03 17:27:13 -04:00
Michael Klement
ae4535d639 Fix: support for consumers of the REPL *module* being able to opt into using the global context via option .useGlobal.
Note that, at least for now, CoffeeScript's own REPL *CLI* still uses a
non-global context, rendering modules such as `color`, which attempt to
modify the prototypes of JavaScript primitives, ineffective. By
contrast, node's own CLI does use the global context.
2013-09-03 16:41:27 -04:00
a3gis
c5120c7980 fix exit code when using --nodejs option 2013-09-02 16:11:22 -05:00
Jeremy Ashkenas
92e83489fc Merge pull request #3146 from phillipalexander/fix-underscore-docs
Fix broken formatting in underscore.coffee docs
2013-09-02 13:33:26 -07:00
Caitlin Potter
1b7491d63d Fixes #3132 - Improve rendering of block-comments 2013-08-23 20:53:18 -04:00
Phillip Alexander
ce14ad764a Fix formatting issues in underscore.coffee documentation (generated html)
Use docco to regenerate documentation for underscore.coffee.
2013-08-20 09:57:52 -07:00
Jeremy Ashkenas
96e807c677 Improve license part of package.json ;) 2013-08-19 16:10:25 +02:00
Michael Klement
70994d4b50 Refactored inline-if into more readable multi-line statement. 2013-08-07 11:40:11 -04:00
Michael Klement
675095efbe Amended - Make the REPL *CLI* use the global context so as to be consistent with the node REPL CLI.
(My apologies: In the previous commit I accidentally made `useGlobal:
yes` the default for _programmatic_ use also, but the intent was to
only do it for the stand-alone *CLI*.)

Make the REPL *CLI* use the global context so as to (a) be consistent
with the `node` REPL CLI and, therefore, (b) make packages that modify
native prototypes (such as 'colors' and 'sugar') work as expected.

Note that, by contrast, programmatic use (`require 'repl'`) will
continue to default to a NON-global context - again, consistent with
node's behavior.
2013-08-07 08:59:27 -04:00
Michael Klement
0235d12927 Make the REPL use the global context to be consistent with the node REPL.
This will make packages that modify prototypes - e.g. 'colors', 'sugar'
- work as expected.

To verify that the `node` REPL uses the global context, execute `global
=== module.exports.repl.context`.

Note: Tests pass, except `cluster.coffee`, which, however, failed even
before these modifications.
2013-08-06 21:28:34 -04:00
Michael Ficarra
9d24a3420d Merge pull request #3111 from benbria/master
Issue #3092: Fix column numbers in sourcemaps to not be essentially random.
2013-08-06 13:52:52 -07:00
Jason Walton
3ad332d5d4 Issue #3092: Fix column numbers in sourcemaps to not be essentially random. 2013-08-06 16:25:23 -04:00
Michael Ficarra
15517df417 Merge pull request #3107 from mal/issue2957
Fork with binary of coffee-script in use, rather than global
2013-08-02 15:44:55 -07:00
Mal Graty
3c2f0d174e Use coffee binary of coffee that overrode fork
This solves two potential problems when it comes to forking:

    1) Forking will now work correctly even when `coffee` is not installed
       globally.
    2) Forking when using a locally installed version of `coffee` will fork
       using that version, and not fallback to a globally installed version.

Fixes #2957
2013-08-02 23:10:45 +01:00
Jeremy Ashkenas
8cf6f62ea4 Merge pull request #3100 from epidemian/issue3023
Fix #3023, Change how error messages are shown
2013-08-02 13:05:37 -07:00
Demian Ferreiro
9e716b310d Avoid using a getter for the compiler error's "stack" property
Instead, set the "stack" property manually when the error gets updated on re-throws.
2013-08-02 01:52:36 -03:00
Michael Ficarra
e44bf9ae81 Merge pull request #3104 from davidchambers/recompile
recompile
2013-08-01 14:17:14 -07:00
David Chambers
f5f99b3022 recompile 2013-08-01 14:14:12 -07:00
Jeremy Ashkenas
dc3d70e696 cleaning up mkdirp bit. 2013-08-01 11:12:41 -04:00
Jeremy Ashkenas
77fded3c5e Merge pull request #3101 from FredyC/master
Fixed deep directory creation for command line utility
2013-08-01 08:11:07 -07:00
FredyC
e644f7244d Using original existence check with mkdirp call on failure 2013-08-01 17:03:32 +02:00
FredyC
457cdfde26 Fixed deep directory creation for command line utility 2013-08-01 11:17:27 +02:00
Marc Häfner
910e38749c Merge removeMidExpressionNewlines into addImplicitIndentation
and rename it to `normalizeLines`
2013-07-31 22:12:44 +02:00
Demian Ferreiro
2b4a37296f Override the SyntaxError's "stack" property instead of deleting it
This makes the "stack" property more useful when it's shown on other Node.js applications that compile CoffeeScript (e.g. testing libraries) and should fix #3023. A minimal example:

    $ node -e 'require("coffee-script").compile("class class")'

    /usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:41
            throw err;
                  ^
    [stdin]:1:7: error: unexpected CLASS
    class class
          ^^^^^
2013-07-31 09:24:43 -03:00
Demian Ferreiro
3f9cdcf1fa Change how error messages are shown
Instead of throwing the syntax errors with their source file location and needing to then catch them and call a `prettyErrorMessage` function in order to get the formatted error message, now syntax errors know how to pretty-print themselves (their `toString` method gets overridden).

An intermediate `catch` & re-`throw` is needed at the level of `CoffeeScript.compile` and friends. But the benefit of this approach is that now libraries that use the `CoffeeScript` object directly don't need to bother catching the possible compilation errors and calling a special function in order to get the nice error messages; they can just print the error itself (or let it bubble up) and the error will know how to pretty-print itself.
2013-07-31 08:27:49 -03:00
Marc Häfner
4342bedd2f Fix multi-line if-else in single-line expression.
* When searching for the closing token of a single-line expression, ignore TERMINATORS that will subsequently be removed.
* Add a test.
2013-07-31 12:18:50 +02:00
Marc Häfner
fdd5796f5e Disallow single-line IF expr ELSE without THEN
* Supplement missing block before `ELSE` token only for multi-line `if`.
* Don't prematurely remove `TERMINATOR` before `ELSE` (so we can  differentiate single- and multi-line forms).
* Cleanup: Remove `WHEN` from `EXPRESSION_CLOSE`. (Only `LEADING_WHEN` tokens are preceded by a `TERMINATOR`.)
* Cleanup: Remove really old, inapplicable text from comment.
2013-07-30 19:31:46 +02:00
Jeremy Ashkenas
f48aa44386 Merge pull request #3094 from epidemian/compile-js
Update compiled JS
2013-07-29 23:17:38 -07:00
Demian Ferreiro
51c625205b Update compiled JS 2013-07-30 01:06:41 -03:00
Michael Ficarra
e581f7d2f0 Merge pull request #3051 from CaseyLeask/source-map-syntax-update
Updated the Source Maps syntax
2013-07-04 07:03:00 -07:00
Cotton Hou
3aa646e425 rebuild for PR #3012 2013-06-28 09:40:22 +08:00
Cotton Hou
92208fec44 simplify logic and changing less from before 2013-06-28 09:28:20 +08:00
Cotton Hou
cdc603c794 remove logic redundancy 2013-06-28 09:28:20 +08:00
Cotton Hou
46d8902004 parallelized script loading in browser, yet order remain 2013-06-28 09:28:20 +08:00
Casey Leask
34c1704286 Removed multi-line comment wrapping 2013-06-26 13:11:13 +00:00
Casey Leask
19767a0f10 Updated the Source Maps syntax 2013-06-26 12:34:21 +00:00
Nami-Doc
0c9f0fd099 Merge pull request #3049 from dpatti/extensions-scope
Avoid variable scope collision with extensions
2013-06-24 15:14:01 -07:00
Doug Patti
7f1088054c Avoid variable scope collision with extensions
In #3031, an extensions variable was introduced with file-level scope
that defined the filetypes that CoffeeScript can compile. However, the
Module::load patching calls findExtension() which uses a local variable
called "extensions", which was overriding the outer level one and
causing getSourceMap() to fail.
2013-06-24 18:13:04 -04:00
Nami-Doc
ef5f58e30e Merge pull request #3045 from marchaefner/master
Fix path separator issues in tests.
2013-06-22 06:04:46 -07:00
Marc Häfner
13024e6911 Fix path separator issues in tests. 2013-06-22 14:57:23 +02:00
Nami-Doc
32e8e562ea Merge pull request #3043 from imcotton/reference-check
check existence of "path" for browser execution
2013-06-21 10:08:49 -07:00
Cotton Hou
7fdac5c3b9 check existence of "path" for browser execution 2013-06-22 00:58:30 +08:00
Jeremy Ashkenas
b68fd9d76e Merge pull request #3042 from marchaefner/issue2844
Avoid excessive AST traversal in `updateLocationDataIfMissing`.
2013-06-20 22:33:50 -07:00
Marc Häfner
25c6001a6c Speed up updateLocationDataIfMissing.
* Avoid excessive search for missing `locationData`
  * Fix `locationData` for `ELSE IF`.
2013-06-21 02:47:29 +02:00
Jeremy Ashkenas
7250fdd576 Merge pull request #3031 from alexgorbatchev/stack-trace-patch-optimizations-2
Stack trace patch optimizations
2013-06-16 02:37:33 -07:00
Jeremy Ashkenas
b7f8443052 Merge pull request #3034 from marchaefner/baseIndent
Better handling of initial indent at file start.
2013-06-16 02:35:06 -07:00
Marc Häfner
4fd5e9a3ab Better handling of initial indent at file start.
* Detect initial indentation before the first token and enforce it.
  * Don't add `INDENT` token (or the matching `OUTDENT, TERMINATOR`).
2013-06-14 00:28:45 +02:00
Alex Gorbatchev
3785996c44 Made stack patch test less brittle. 2013-06-13 13:50:05 -07:00
Alex Gorbatchev
eb0a222eea Using more standard convention for patched stack line numbers. 2013-06-13 12:58:04 -07:00
Alex Gorbatchev
3d761e73e3 Removed unnecessary source map generation during require() and made stack line number patching on by default. 2013-06-13 12:54:20 -07:00
Alex Gorbatchev
cc3b4e8080 Removed not used variable. 2013-06-13 12:23:06 -07:00
Michael Ficarra
ba7cb3ab69 fix #3029 2013-06-13 13:38:13 -05:00
Michael Ficarra
054443c46e rebuild #3029 2013-06-13 13:35:40 -05:00
Jeremy Ashkenas
c8dae22cb0 Merge pull request #3029 from wangxian/master
fix block comment format "\n"
2013-06-13 10:55:52 -07:00
木頭
183ec48308 fix block comment 2013-06-13 07:44:17 +08:00
Jeremy Ashkenas
13187b0199 Merge pull request #2856 from epidemian/issue2849
Fixes #2849: use correct filename and code in require()d sources
2013-06-09 00:40:18 -07:00
Demian Ferreiro
3c880bf601 Move a try/catch from compile to loadFile
This try/catch should only be necessary for dynamically loaded files. Also added a lengthier explanation of why this try/catch is needed.
2013-06-09 02:54:34 -03:00
Demian Ferreiro
8e90aaefc1 Merge branch 'master' into issue2849
Conflicts:
	lib/coffee-script/coffee-script.js
	src/coffee-script.coffee
2013-06-09 02:40:53 -03:00
Michael Ficarra
426ae97e49 Merge pull request #3014 from mset/master
base path for compilation can be './' as well as '.'
2013-06-03 06:27:38 -07:00
Marek Setnicka
f277a43645 Bug fix. When coffee is invoked with the -c parameter and './' value, first two characters of the directory into which the compiled files are stored get chopped off.
Example: if compilation invoked like this: 'coffee -o ../lib/ -cw ./', then
Source file: ./OutputFolder/file.coffee, compiled output: ./../lib/tputFolder/
The code only expected '.' to mark the local folder. However, './' is equally valid.
2013-06-03 13:51:26 +01:00
Jeremy Ashkenas
2e408648aa renaming import test files to avoid risking the disfavor of .gitignore 2013-06-02 10:57:18 +04:00
Jeremy Ashkenas
f2f10e85a8 Revert "remove cake build:ultraviolet"
This reverts commit 2e6a781014.
2013-06-02 09:45:11 +04:00
Jeremy Ashkenas
84b8b5ccee CoffeeScript 1.6.3 2013-06-02 09:37:45 +04:00
Jeremy Ashkenas
7b14a6aad2 Fixing browser build boilerplate. 2013-06-02 09:21:36 +04:00
Jeremy Ashkenas
342306587c Removing out of date testing cruft 2013-06-02 09:13:16 +04:00
Jeremy Ashkenas
3298c9caad merge 2013-06-02 09:10:16 +04:00
Jeremy Ashkenas
7089b02a74 Merging in a monkey-patching of Module::load, unfortunately. 2013-06-02 09:03:54 +04:00
Jeremy Ashkenas
bd451800bf Merge pull request #3000 from sgentle/require-extensions
Patch module.prototype.load to enable multiple extensions like .coffee.md
2013-06-01 21:44:02 -07:00
Jeremy Ashkenas
5e06f7e859 Removing Ultraviolet workaround 2013-06-02 07:50:03 +04:00
Michael Ficarra
0f5ae54014 Merge pull request #2930 from marchaefner/Issue1057
Fixes #1057: Allow catch/finally in single line functions.
2013-05-31 14:56:04 -07:00
Michael Ficarra
5496a189bc fixes #2934 2013-05-31 16:51:30 -05:00
Michael Ficarra
2e6a781014 remove cake build:ultraviolet 2013-05-31 15:49:48 -05:00
Michael Ficarra
b85cf5355f Merge pull request #2085 from stepheneb/ruby-1-9-generate-coffeescript-syntax
rake task creates/installs coffeescript.syntax
2013-05-31 13:48:22 -07:00
Jeremy Ashkenas
f038d0514a Merge pull request #2984 from xixixao/literatetest
Fixes tabbed code test in literate
2013-05-26 04:08:01 -07:00
Jeremy Ashkenas
7c4128ee3b Merge pull request #3002 from Nami-Doc/issue3001
Disallowed `for own in`
2013-05-26 03:43:22 -07:00
Sam Gentle
012e3c019c fix style problems part 3 2013-05-26 15:59:49 +10:00
Nami-Doc
b3ffd25339 Disallowed for own in 2013-05-26 00:29:26 +02:00
Sam Gentle
46a0dc6dce Didn't mean to commit testsymlink 2013-05-26 02:33:11 +10:00
Sam Gentle
30b2af820a Early exit + refactor findExtension 2013-05-26 02:17:34 +10:00
Sam Gentle
e7d01b903f New tests for module importing 2013-05-26 02:09:52 +10:00
Sam Gentle
e4407dd73c fix style problems part 2 2013-05-26 00:50:18 +10:00
Sam Gentle
2fd956d8d4 fix style problems 2013-05-26 00:10:07 +10:00
Sam Gentle
c0aac8e598 use helpers.isCoffee in test runner 2013-05-26 00:04:18 +10:00
Sam Gentle
d46a44ac48 Patch node module loader to handle multiple extensions - fixes #2928 & #2855 2013-05-25 23:22:27 +10:00
Sam Gentle
9b1bdd4b36 Add test for .coffee.md loading 2013-05-25 23:06:44 +10:00
Michal Srb
fd47920c63 Fixes tabbed code test in literate 2013-05-15 10:30:20 +01:00
Michael Ficarra
088b8b3ec5 Merge pull request #2978 from pushrax/master
Fix 'propeties' typo in docs
2013-05-08 17:44:53 -07:00
Justin Li
afd9b44dea Fix 'propeties' typo in docs 2013-05-08 15:57:46 -04:00
In-Ho Yi
b54db2ea07 keep track of source map information for require()d coffee files 2013-04-29 17:06:22 +10:00
Michael Ficarra
3650d6eb4e Merge pull request #2933 from marchaefner/master
Fix implicit calls with preceding herecomment
2013-04-28 21:07:52 -07:00
Marc Häfner
05b74f3743 Merge remote-tracking branch 'refs/remotes/upstream/master' 2013-04-29 05:27:13 +02:00
Michael Ficarra
174cd7eaa0 rebuild for some unneccessary parentheses changes
rebuild of 3921e3db34
2013-04-28 22:09:46 -05:00
Nami-Doc
3921e3db34 Merge pull request #2965 from Nami-Doc/style-cleanup1
Style cleanup
2013-04-28 16:20:53 -07:00
Nami-Doc
63bc7fe354 final style edits 2013-04-29 01:19:24 +02:00
Nami-Doc
ba01e36cc2 partly revert 7be996c 2013-04-28 22:34:56 +02:00
Marc Häfner
40d2761bd8 Fixes #2916 -- implicit calls with preceding herecomment 2013-04-28 10:30:03 +02:00
Nami-Doc
4ff7fef3bb remove jsl config file and the doc line about it 2013-04-28 00:58:34 +02:00
Nami-Doc
7be996c010 code cleanup 2013-04-28 00:56:44 +02:00
Michael Ficarra
f4332475b5 Merge pull request #2963 from Nami-Doc/lint-flag-removal
Lint flag removal
2013-04-27 15:13:38 -07:00
Nami-Doc
4da00e8296 Fix docs : modify source file instead of built file 2013-04-27 20:55:37 +02:00
Nami-Doc
e8fae286be remove --lint. #2894 : rebuild and fix docs 2013-04-27 19:35:32 +02:00
Nami-Doc
f451bb5f61 Merge pull request #2894 from billymoon/master
Literate flag
2013-04-27 10:29:03 -07:00
Billy Moon
d8d7495767 give the -l flag to literate
remove `-l` from lint, allowing it to be used for literate
2013-04-27 10:42:10 +03:00
Michal Srb
e7ebdce60f Fix #2953. Method calls on splice endpoints 2013-04-23 05:42:37 +02:00
Michal Srb
fd61476106 Fix #1069. Non-callable literals shouldn't compile 2013-04-23 04:28:45 +02:00
Michael Ficarra
4b4f6ac222 Merge pull request #2951 from xixixao/issue1437
Fix #1437. Unneeded ref in existential assignment.
2013-04-22 13:04:32 -07:00
Michal Srb
7b9699c5fa Fix #1437. Unneeded ref in existential assignment. 2013-04-22 21:58:49 +02:00
Jeremy Ashkenas
8a59558e2d Merge pull request #2946 from Nami-Doc/issue2944
Fix #2944
2013-04-21 08:15:15 -07:00
Nami-Doc
5162472f16 Fix REPL when env.HOME isn't available - #2945 2013-04-21 16:03:30 +02:00
Nami-Doc
1917bb69ed Fix #2944 2013-04-21 12:33:00 +02:00
Michael Ficarra
3b38153759 Merge pull request #2940 from jiangmiao/issue2908
Fixes #2908, add "\n" between pure literal header and function body.
2013-04-20 12:03:25 -07:00
Michael Ficarra
e06a17d929 Merge pull request #2943 from bobbydavid/master
fix warning in REPL tests about memory leak.
2013-04-20 12:00:37 -07:00
Robert Martin
71aea4b862 Fix bug in REPL where history file was closed late.
The history file was set to close on process exit, when it
should close on REPL exit. Listening to the process exit
event causes a warning when more than 10 CoffeeScript REPL
instances are opened in the same program, which happens in
the test.
2013-04-20 14:49:54 -04:00
Nami-Doc
4b4818d819 Fix missing ` `` - #2926 2013-04-20 00:11:29 +02:00
Michael Ficarra
c785e00a15 Merge pull request #2929 from lucasb-eyer/master
Keep a single-line herecomment as a single-line js comment.
2013-04-15 13:12:43 -07:00
Michael Ficarra
c6398e16b1 Merge pull request #2925 from marchaefner/master
Fix error reporting for invalid object key.
2013-04-15 13:07:16 -07:00
lucasb-eyer
ccc7c4404d Keep the js comment on a single line if the herecomment is on a single line. 2013-04-15 21:45:55 +02:00
Marc Häfner
69d66a1d4d Fixes #1057: Allow catch/finally in single line functions.
* Don't end single-line functions at `catch` or `finally`.
* Remove unused `IMPLICIT_BLOCK` and superfluous test for `IF`.
2013-04-15 20:20:52 +02:00
Marc Häfner
af81f6de70 Fix error reporting for invalid object key. 2013-04-12 18:10:26 +02:00
Jeremy Ashkenas
f21dc7a96e Merge pull request #2924 from marchaefner/master
Parameter-less catch clause.
2013-04-12 08:57:01 -07:00
Marc Häfner
cf07fcb4b1 #2900 -- parameter-less catch clause.
Plus some minor cleanup after f8c6b494aa
2013-04-12 17:50:45 +02:00
Jeremy Ashkenas
740a7bcb45 Merge pull request #2914 from danielgtaylor/repl-history
repl history implementation improvements
2013-04-07 21:47:16 -07:00
Daniel G. Taylor
0e2d2ea637 Move lastLine setter into conditional block to prevent .commands and blank lines from setting lastLine 2013-04-07 11:28:59 -07:00
Daniel G. Taylor
feaea49eac Replace large comprehension with much simpler code; fix comment to reference maxSize instead of previous 10KB limit; only pop a history entry if the file size is actually bigger than maxSize; only add items to the history if they are different from the last item by storing the last line and loading it on startup. 2013-04-06 22:10:08 -07:00
Jeremy Ashkenas
170f311101 Merge branch 'master' of https://github.com/jashkenas/coffee-script 2013-04-06 09:31:30 +08:00
Jeremy Ashkenas
0cadcdc097 Fix regression with executable class bodies and prototypal attachment. 2013-04-06 09:31:24 +08:00
Miao Jiang
337ebd3ce9 Fixes #2908, add "\n" between pure literal header and function body. 2013-04-05 13:20:59 +08:00
Billy Moon
5d5920c5d0 Literate flag
Add `-L` or `--literate` command line flags (lowercase `l` is already taken) to allow literate coffee script to be read in from `stdio`
2013-03-28 10:28:12 +03:00
Jeremy Ashkenas
8be65dee93 Merge pull request #2886 from danielgtaylor/repl-history
Add history to the coffee interactive interpreter that persists between ...
2013-03-27 15:55:15 -07:00
Daniel G. Taylor
4dbd9dc264 Pop off partial line if input history file was truncated; make maximum input history file size configurable via repl start options 2013-03-25 20:50:56 -07:00
Daniel G. Taylor
2d0e45c46d Use string interpolation for .history command; rename out variable to history an store the history in it as an array in the proper order so that printing it is just a join operation 2013-03-25 20:34:04 -07:00
Demian Ferreiro
d57b1aab10 Add power operator to the list of tokens that force a line continuation if they appear at the end of a line 2013-03-25 20:41:14 -03:00
Michael Ficarra
cc84d6ea67 Merge pull request #2890 from Nami-Doc/issue2846
fix #2846
2013-03-25 11:14:07 -07:00
Nami-Doc
53a5f26430 fix #2846 2013-03-25 18:56:24 +01:00
Daniel G. Taylor
a1ff4ae7b8 Use separate variable for fd used to read history file; use string interpolation to print code lines; do not use unit test to remove temporary file and instead use a process exit event handler 2013-03-25 09:49:59 -07:00
Daniel G. Taylor
3251efa9c6 Add unit test to read and run a line from the interpreter history file and remove the dummy history file after tests have completed. 2013-03-25 08:47:34 -07:00
Daniel G. Taylor
17a1cdb2cf Make history file optional and configurable via the opts passed to repl.start 2013-03-25 08:46:40 -07:00
Daniel G. Taylor
1643f7df7a Remove explicit catch that did nothing 2013-03-25 07:49:25 -07:00
Daniel G. Taylor
3c0344b954 Rebuild to remove debugging log statement 2013-03-25 07:28:55 -07:00
Demian Ferreiro
22e8856b4d Add floor division // and modulo %% operators, and compound forms of the new operators
Also kill the empty regex :(
2013-03-25 03:19:05 -03:00
Daniel G. Taylor
9bfafb88cb Add history to the coffee interactive interpreter that persists between sessions using a ~/.coffee_history file in a similar way to bash. Code based on repl.history and Node pull request 3178 with modifications. 2013-03-24 22:44:35 -07:00
Demian Ferreiro
08b59aef8a Make power operator have higher precedence than unary operators: +, -, ~, ! 2013-03-25 00:05:04 -03:00
Demian Ferreiro
fbc019171c Make power operator compilation use proper AST nodes 2013-03-25 00:02:21 -03:00
Demian Ferreiro
e237abff84 Merge branch 'power-operator' of git://github.com/charliesome/coffee-script into more-math-operators
Conflicts:
	src/nodes.coffee
	test/operators.coffee
2013-03-24 22:47:46 -03:00
Michael Ficarra
718224f99a Merge pull request #2867 from hden/2853
encode unicode src, test added
2013-03-24 12:17:10 -07:00
Demian Ferreiro
c0d1f22487 Add test for compiler errors on require()d files 2013-03-21 03:11:31 -03:00
Hao-kang Den
b2d6997eff encode unicode src, test added 2013-03-21 09:04:23 +08:00
Michael Ficarra
e26f982c24 Merge pull request #2869 from marchaefner/master
Fix Windows path separator issue in `baseFileName`.
2013-03-20 17:25:54 -07:00
Marc Häfner
1b2fe69a18 Fix Windows path separator issue in baseFileName.
Windows accepts forward and backward slashes as path separator.
2013-03-20 22:38:29 +01:00
Jeremy Ashkenas
c159a64b58 Merge pull request #2865 from hden/inline
quick-fix
2013-03-20 00:46:32 -07:00
Hao-kang Den
e091c9d6b4 quick-fix with a different approach 2013-03-20 15:23:33 +08:00
Demian Ferreiro
67fd84fc1d Fixes #2849: now the compilation errors thrown by CoffeeScript.compile will include the correct filename and source code information 2013-03-19 04:27:34 -03:00
Jeremy Ashkenas
57d3cfd67f Merge pull request #2851 from toots/master
More explicit window context.
2013-03-18 18:52:31 -07:00
Romain Beauxis
6dd61626d2 Rebuild. 2013-03-18 14:16:05 -05:00
Romain Beauxis
1e99f887e7 More explicit window context in src/browser.coffee. 2013-03-18 11:16:26 -05:00
Jeremy Ashkenas
78d10f30a0 removing sourceColumn reset 2013-03-18 21:50:40 +08:00
Jeremy Ashkenas
7f0610d0bd better docs for source maps 2013-03-18 19:46:43 +08:00
Jeremy Ashkenas
4bef435e0e better docs for source maps 2013-03-18 19:46:30 +08:00
Jeremy Ashkenas
194baa0bd7 better docs for source maps 2013-03-18 19:46:19 +08:00
Jeremy Ashkenas
c8b8beb500 slimming SourceMap slightly further 2013-03-18 19:36:34 +08:00
Jeremy Ashkenas
6786bab2ba Big refactor of SourceMap class. Literate CoffeeScript. Purdy. 2013-03-18 19:23:05 +08:00
Jeremy Ashkenas
566a7dabb2 Fixing erroneous whitespace fix in generated JS 2013-03-18 17:47:55 +08:00
Jeremy Ashkenas
a3e8de338a CoffeeScript 1.6.2 2013-03-18 13:06:33 +08:00
Jeremy Ashkenas
4f815ea978 Fixes #2737, fix fork() for both .js and .coffee, revised. 2013-03-18 11:46:54 +08:00
Michael Ficarra
417008a030 be a little more descriptive, as per @epidemian's suggestion 2013-03-17 21:53:46 -05:00
Michael Ficarra
84c44c0099 small stylistic change and optimisation to code from #2847 2013-03-17 21:50:20 -05:00
Jeremy Ashkenas
2d6a856d61 Merge pull request #2847 from hden/browser-source-map
Browser source map
2013-03-17 19:39:36 -07:00
Hao-kang Den
011d7dc245 better naming by @michaelficarra 2013-03-18 10:23:33 +08:00
Hao-kang Den
b2aa1798b1 safer browser check 2013-03-18 09:31:12 +08:00
Hao-kang Den
5fb047930e fixed lineno 2013-03-18 09:31:12 +08:00
Hao-kang Den
c24e957f17 use btoa as base64 encoder, inspired by @ashtuchkin 2013-03-18 09:31:12 +08:00
Jeremy Ashkenas
fd0b1ffc4d Fixes #2478 -- mention js2coffee in docs 2013-03-17 19:34:00 +08:00
Jeremy Ashkenas
0bfe6394a4 whitespace 2013-03-17 19:31:06 +08:00
Jeremy Ashkenas
9d025df9e3 Merge pull request #2827 from hden/lineno
Lineno
2013-03-17 04:29:44 -07:00
Jeremy Ashkenas
2f5b11b295 Fixes #2555 2013-03-17 19:27:16 +08:00
Jeremy Ashkenas
c44826acc7 Merge pull request #2838 from marchaefner/master
Improve literal mode.
2013-03-17 03:49:06 -07:00
Jeremy Ashkenas
4386f2abc7 Merge pull request #2840 from MattKunze/windows_paths
fix path handling on Windows
2013-03-17 03:09:28 -07:00
Matt Kunze
f217a10721 fix path handling on Windows 2013-03-15 16:13:04 -06:00
Marc Häfner
b8d695a4e1 Compiled JavaScript files for improved literal mode. 2013-03-15 03:26:12 +01:00
Marc Häfner
44c2b4aa7f Test case for literal mode: Code blocks must be preceded by blank line. 2013-03-15 03:23:09 +01:00
Marc Häfner
52ca531b7c Improve literate mode.
* Expect a blank line as delimiter between text and code (#2821).
* Don't change indentation of code. It is not necessary and leads to
  erroneous locationData. (#2835)
* Don't modify blank lines and reverse the change in the lexer.
* Don't ignore indentation with mixed whitespace.
2013-03-15 00:17:10 +01:00
Hao-kang Den
d4254a40a9 Apply modifications by @jwalton 2013-03-14 08:36:07 +08:00
Hao-kang Den
052e3cc8eb found a linear shift of lineno, dirty patch for now
It seems that js -> coffee line mapping has a linear shifting.
Dirty patch by applying linear correction.
Dumb, but maybe a hint.
2013-03-14 08:36:07 +08:00
Jeremy Ashkenas
56413ba3b4 Merge pull request #2817 from epidemian/keep-repl-running
Keep REPL running on runtime errors
2013-03-13 01:56:33 -07:00
Jeremy Ashkenas
71bb6108fb Merge pull request #2819 from hden/fix-path
Quick fix for node v0.10 path
2013-03-13 01:03:57 -07:00
Hao-kang Den
7d08dbb86c build 2013-03-13 16:00:57 +08:00
Hao-kang Den
a8b65565dd roll back to options.filename 2013-03-13 15:58:39 +08:00
Jeremy Ashkenas
54258e441d Merge pull request #2826 from epidemian/bump-engines-node
Bump engines.node version on package.json to 0.8
2013-03-13 00:40:56 -07:00
Michael Ficarra
4ac223b684 minor cleanup of parent commit 2013-03-12 21:11:48 -05:00
Michael Ficarra
707655daef Merge pull request #2824 from iamwilhelm/master
added warning that repl needs node.js >= 0.8
2013-03-12 18:46:19 -07:00
Wil Chung
70e83030a7 added warning that we need node 0.8+ to run repl
remove unnecessary parens and else statement in repl

we do this by convention of the main coffee source

fix: exit should be process.exit

compiled and build full
2013-03-12 18:28:48 -07:00
Demian Ferreiro
9787ce543d Bump engines.node version on package.json to 0.8 2013-03-12 21:46:48 -03:00
Hao-kang Den
22595424a8 manually add the newline at EOF 2013-03-12 21:28:48 +08:00
Hao-kang Den
601189ea2d Merge branch 'fix-path' of https://github.com/hden/coffee-script into fix-path 2013-03-12 20:54:12 +08:00
Hao-kang Den
d3263dc35b fix node v0.10 path 2013-03-12 20:53:13 +08:00
Jeremy Ashkenas
e1c6b083f8 Merge pull request #2820 from hden/source-maps-in-node
Source maps in node
2013-03-12 05:35:39 -07:00
Michael Ficarra
f56f5f234e @epidemian typo 2013-03-12 15:32:52 +08:00
Demian Ferreiro
4ca6da4a95 Add REPL scoping tests 2013-03-12 15:32:52 +08:00
Demian Ferreiro
b0cbd90e64 Fixes #1829. Preserve variable scope in the REPL 2013-03-12 15:32:52 +08:00
Hao-kang Den
9b6772a390 accept override 2013-03-12 15:29:13 +08:00
Hao-kang Den
b7f0653a0e port patchStackTrace from Redux 2013-03-12 15:29:13 +08:00
Demian Ferreiro
45bcd9fa2f Keep REPL running on runtime errors 2013-03-11 23:58:00 -03:00
Michael Ficarra
20d98c7106 @epidemian typo 2013-03-11 21:48:21 -05:00
Michael Ficarra
5ec658c55d Merge remote-tracking branch 'epidemian/issue1829' 2013-03-11 21:47:19 -05:00
Hao-kang Den
64301d0d08 fix node v0.10 path 2013-03-12 09:09:07 +08:00
Demian Ferreiro
119ec16e5e Add REPL scoping tests 2013-03-11 20:16:48 -03:00
Jeremy Ashkenas
decc0f18fc Merge pull request #2814 from epidemian/issue1829
Fixes #1829. Preserve variable scope in the REPL
2013-03-11 16:15:34 -07:00
Demian Ferreiro
5a004425ca Fixes #1829. Preserve variable scope in the REPL 2013-03-11 19:52:18 -03:00
Jeremy Ashkenas
69f6500ba9 rebuilt source code documentation with new version of Docco. 2013-03-11 11:37:22 +08:00
Jeremy Ashkenas
97980ffc7f Merge pull request #2723 from epidemian/improved-error-messages
Improved error messages
2013-03-10 16:46:25 -07:00
Demian Ferreiro
f0fcf4aee0 Merge branch 'master' of git://github.com/jashkenas/coffee-script into improved-error-messages
Conflicts:
	lib/coffee-script/coffee-script.js
	lib/coffee-script/command.js
	lib/coffee-script/helpers.js
	lib/coffee-script/lexer.js
	lib/coffee-script/nodes.js
	lib/coffee-script/repl.js
	src/coffee-script.coffee
	src/command.coffee
	src/helpers.coffee
	src/lexer.coffee
	src/nodes.coffee
	test/helpers.coffee
2013-03-10 20:29:36 -03:00
Michael Ficarra
838e5e1163 Merge pull request #2810 from SonicHedgehog/master
Fix typo in documentation
2013-03-10 11:58:01 -07:00
Jakob Krigovsky
af0bdae675 Fix typo in documentation 2013-03-10 19:09:03 +01:00
Jeremy Ashkenas
0d45287057 Fixes #2808. Remove --require flag. 2013-03-10 17:17:04 +08:00
Demian Ferreiro
09f8df9640 Add check for end of input on parseError handler 2013-03-10 00:30:27 -03:00
Jeremy Ashkenas
dbb99f31a7 Reverting #2490 2013-03-10 07:21:00 +08:00
Jeremy Ashkenas
c7da623d4b #2490. A bit more of the style. 2013-03-10 06:55:52 +08:00
Jeremy Ashkenas
b44435ab8a #2490 -- implementing a conditional in terms of the guard style. 2013-03-10 06:44:45 +08:00
Jeremy Ashkenas
c53df12ec1 disallow multiple else blocks in if/guard syntax 2013-03-09 15:44:45 +08:00
Jeremy Ashkenas
13fae12f69 Fixes #2490 -- adding guard-style if blocks 2013-03-09 10:40:37 +08:00
Jeremy Ashkenas
0120db0efc Merge pull request #2803 from benbria/master
Rework source map files and paths
2013-03-08 07:19:48 -08:00
Jason Walton
c4f50b52d7 Merge remote-tracking branch 'upstream/master'
Conflicts:
	lib/coffee-script/helpers.js
	test/helpers.coffee
2013-03-08 10:17:47 -05:00
Jason Walton
242f397bfa Remove dead variables. 2013-03-07 21:30:04 -05:00
Jason Walton
f85d19b459 Rework API for sourcemap filenames and paths. 2013-03-07 21:26:09 -05:00
Jeremy Ashkenas
8f7f3627e0 Fixes #2796, by adding a test for it. 2013-03-07 23:13:22 +13:00
Jeremy Ashkenas
8b134cf348 Add an additonal test, courtesy @matehat 2013-03-07 23:10:39 +13:00
Jeremy Ashkenas
67de35ff29 Fixes #2781, fixes #2782. Reverting to old method of instance method binding. 2013-03-07 23:09:32 +13:00
Jeremy Ashkenas
774ee6a554 merge 2013-03-07 22:59:23 +13:00
Jeremy Ashkenas
4be4ea3623 Merge pull request #2795 from fahad19/master
Fix: compiling `coffee.coffee` produces `.js` file.
2013-03-07 01:30:07 -08:00
Fahad Ibnay Heylaal
18fec7e202 tests for baseFileName helper for files with only coffee-script extensions as the file name. 2013-03-07 10:23:36 +06:00
Fahad Ibnay Heylaal
072df5ecc9 more test coverage for baseFileName helper. 2013-03-07 10:15:01 +06:00
Fahad Ibnay Heylaal
4d7151aa5d fix: compiling coffee.coffee produces .js file. 2013-03-07 03:41:34 +06:00
Jason Walton
185b2ce632 Code inspect fixes from the inimitable Nami-Doc 2013-03-06 16:26:34 -05:00
Jason Walton
ce6772f2be Better fix for sourceRoot and relative path for .coffee files in source maps. 2013-03-06 15:45:47 -05:00
Jason Walton
d6e1a979e4 Fix sourceRoot and relative path for .coffee files in generated source maps. 2013-03-06 11:05:57 -05:00
Jeremy Ashkenas
de8ec2beb0 Fixes #1066 -- interpolated strings are not implicit funcs 2013-03-05 21:28:29 +13:00
Demian Ferreiro
342a796cc0 Remove column number from online editor error box 2013-03-05 05:16:29 -03:00
Jeremy Ashkenas
355754ed20 Fixes #1055 -- disallow invalid keys in object literals ... but allow them where the implicit object is being used as a class defn' or a destructuring 2013-03-05 21:10:56 +13:00
Jeremy Ashkenas
fbe07f1fce Removing debugging source location output from --nodes. It shouldn't have snuck in there. 2013-03-05 20:50:03 +13:00
Jeremy Ashkenas
304432c197 Merge pull request #2417 from gabehollombe/doc_for_switch_with_no_control_expression
Documentation for switch statements with no control expression
2013-03-04 22:27:38 -08:00
Demian Ferreiro
5da7f6a488 Get rid of CompilationError and instead have a couple of functions on helpers.coffee 2013-03-05 01:13:46 -03:00
Jeremy Ashkenas
f8c6b494aa Fixes #2422 -- Catch clause scoping plus old IE 2013-03-05 16:13:22 +13:00
Jeremy Ashkenas
1b573412d3 cleaning up the previous merge -- moving it out to helpers.invertLiterate 2013-03-05 15:45:57 +13:00
Demian Ferreiro
b400047045 Merge branch 'master' of git://github.com/jashkenas/coffee-script into improved-error-messages
Conflicts:
	Cakefile
	lib/coffee-script/coffee-script.js
	lib/coffee-script/command.js
	lib/coffee-script/nodes.js
	lib/coffee-script/repl.js
	src/coffee-script.coffee
	src/helpers.coffee
	src/nodes.coffee
	src/repl.coffee
2013-03-04 23:42:47 -03:00
Jeremy Ashkenas
51b1affbc5 Merge pull request #2776 from mintplant/fix-2768
Fix #2768: support --join'ing mixed literate and non-literate CoffeeScript source files
2013-03-04 18:39:30 -08:00
Jeremy Ashkenas
903e9c994c Fixes #2773 -- tricky dependency ordering when overriding bound functions. 2013-03-05 15:35:02 +13:00
Michael Smith
fca68717ff Fix #2768: rewrite literate code before the join 2013-03-04 18:30:24 -08:00
Michael Ficarra
22d6a4b255 Merge pull request #2770 from benbria/master
Move sourceMappingURL to bottom of generated JavaScript file.
2013-03-04 17:45:16 -08:00
Jeremy Ashkenas
26102a0970 Merge pull request #2772 from marchaefner/master
Minor improvements for locationData of tokens and some clean up.
2013-03-04 17:43:09 -08:00
Jason Walton
add84bfddc Add multiline horrible kludge for IE 2013-03-04 19:08:33 -05:00
Marc Häfner
dcd74d3e59 Clean up unused parameter. 2013-03-05 01:02:16 +01:00
Jason Walton
2684737b66 Move sourceMappingURL line to bottom of file 2013-03-04 18:43:49 -05:00
Marc Häfner
74181c0ec0 Improve locationData of implicit object braces.
Set location of generated left brace to start of content, so the corresponding AST nodes don't span preceding spaces, blank lines or comments.
2013-03-05 00:12:51 +01:00
Marc Häfner
ebff9fbc31 Exclude preceding newlines from INDENT tokens.
Produces more meanignful locationData.
2013-03-05 00:03:08 +01:00
Marc Häfner
97a41adf0c Fix location of tokens with no length
by actually using the computed offset.
2013-03-05 00:01:17 +01:00
Jeremy Ashkenas
eef83a9fcb CoffeeScript 1.6.1 2013-03-05 11:07:16 +13:00
Jeremy Ashkenas
b62a90d54c Fixes #2765 -- incorrect line number in mappings 2013-03-05 10:49:47 +13:00
Jeremy Ashkenas
b2ef77d92e refactoring to a baseFileName that can work in the browser, for later 2013-03-05 10:40:39 +13:00
Jeremy Ashkenas
b2b801a78b Fixes #2766 -- incompatible line number API 2013-03-05 10:19:21 +13:00
Jeremy Ashkenas
b4c12f6746 Fixing lingering brain fart. Inexcusable. 2013-03-05 09:23:50 +13:00
Jeremy Ashkenas
a4cc15c95c Merge pull request #2763 from matthewwithanm/source-map-fix
Fix Source Map Generation for 1.6.0
2013-03-04 12:09:26 -08:00
Matthew Tretter
3c42a8e01c Update compiled version 2013-03-04 15:07:20 -05:00
Matthew Tretter
4a94a9fbd1 Fix source map generation
Small typo fix (:
2013-03-04 14:57:56 -05:00
Jeremy Ashkenas
9f614fedec CoffeeScript 1.6.0 2013-03-05 08:19:08 +13:00
Demian Ferreiro
9ea4268b92 Make duplicate param name errors mark the actual duplicate parameter
Before:

    coffee> foo = (bar, baz, bar, qux) ->
    repl:1:7: error: multiple parameters named 'bar'
    foo = (bar, baz, bar, qux) ->
          ^^^^^^^^^^^^^^^^^^^^^^^

Now:

    coffee> foo = (bar, baz, bar, qux) ->
    repl:1:18: error: multiple parameters named 'bar'
    foo = (bar, baz, bar, qux) ->
                     ^^^

Also works with destructuring parameters and what have you.
2013-03-04 15:39:03 -03:00
Jeremy Ashkenas
e417a0ca6f Reverts 56fe211b79 2013-03-05 07:38:41 +13:00
Jeremy Ashkenas
75769503ff Renaming --maps option to --map for consistency. 2013-03-05 07:29:46 +13:00
Demian Ferreiro
589d67d8b7 Remove a couple of TODOs (WONTDOs really) 2013-03-04 13:11:34 -03:00
Demian Ferreiro
3127e76f4b Integrate error messages on the site editor
Nothing really fancy here; mostly preserves the old format. Maybe if we had a more full-fledged test editor we could show the errors in-line =D

  Also, i couldn't get the `rake doc` task running properly, so i mostly test this editing the index.html directly (ups!).
2013-03-04 13:00:25 -03:00
Jason Walton
979e110a84 Minor API changes. 2013-03-04 09:45:25 -05:00
Jason Walton
96785872cd Merge remote-tracking branch 'upstream/master' into sourcemaps
Conflicts:
	lib/coffee-script/coffee-script.js
	lib/coffee-script/command.js
	lib/coffee-script/nodes.js
	src/coffee-script.coffee
	src/command.coffee
	src/nodes.coffee
2013-03-04 09:25:55 -05:00
Jason Walton
ee71b9143f Remove PARANOID flag. 2013-03-04 09:11:34 -05:00
Troels Nielsen
37a6ea63b1 #2757, Allow non-significant commas at end of nested implicit objects 2013-03-04 12:55:15 +01:00
Jeremy Ashkenas
56fe211b79 Fixes #2455 -- condition should know what variables the body has declared. 2013-03-04 23:33:50 +13:00
Jeremy Ashkenas
cf11a570e9 Fixes #2489, fixes #1819, fixes #1821 -- remove the __bind helper. 2013-03-04 23:11:38 +13:00
Jeremy Ashkenas
9fe0e711d6 Fixes #2502 -- improper compilation with parenthesized inner value of instance properties in a class body. 2013-03-04 22:26:55 +13:00
Jeremy Ashkenas
b3452c1276 Fixes #2508 -- existential access of the prototype. 2013-03-04 22:07:47 +13:00
Jeremy Ashkenas
47f0ea69b8 Fixes #2749. Restricting to instance methods in class bodies, where it actually has a chance in hell of calling the correct thing. 2013-03-04 21:26:01 +13:00
Jeremy Ashkenas
667b96b495 Fixes #2750 -- clarify error message 2013-03-04 21:17:26 +13:00
Jeremy Ashkenas
3b25aea168 When printing out --tokens, hide the location data. 2013-03-04 20:54:45 +13:00
Demian Ferreiro
0affb4f936 Integrate error messages on the REPL 2013-03-03 22:08:41 -03:00
Michael Ficarra
8435df29c6 Merge pull request #2752 from marchaefner/master
Fix line number mismatch when first line is indented.
2013-03-03 16:21:49 -08:00
Demian Ferreiro
55c99dfaec Show colorized error messages 2013-03-01 22:42:26 -03:00
Michael Smith
c98fae59fc Patch child_process.fork to run .coffee files 2013-03-01 16:19:05 -08:00
Marc Häfner
3c38a34ab2 Fix line numbers when first line is indented.
* Offset @chunkLine for inserted line break.
* Avoid line break insertion for blank lines.
2013-03-01 21:30:07 +01:00
Jason Walton
ad7dcbc797 Change some more "!"s to "not"s. Make spacing consistent after periods in commnets. 2013-03-01 11:36:48 -05:00
Jason Walton
ad0306b00c Change compileWithSourceMap() so it returns an object instead of an Array, and return the SourceMap object. 2013-03-01 11:34:39 -05:00
Jason Walton
d626e70287 Fix from code inspect: Use "not" instead of "!". 2013-03-01 11:19:22 -05:00
Demian Ferreiro
3182475207 Make error messages show only first line on multi-line errors 2013-03-01 13:10:04 -03:00
Jason Walton
ea86e3e7b1 Optionally allow replacement of existing mappings in SourceMap#addMapping(). 2013-03-01 10:18:37 -05:00
Jason Walton
844549954a Minor API clean up, and make it so sourcemaps are pretty-printed to the .map file. 2013-03-01 10:12:10 -05:00
Jason Walton
51fe417d58 Fix generated file name in v3 source map 2013-03-01 08:56:17 -05:00
Jason Walton
0e718f0968 Merge branch 'sourcemaps' of https://github.com/surjikal/coffee-script into sourcemaps 2013-03-01 08:47:42 -05:00
Jason Walton
0d6d479d77 Merge branch 'master' into sourcemaps
Conflicts:
	lib/coffee-script/coffee-script.js
	lib/coffee-script/nodes.js
	src/nodes.coffee
2013-03-01 08:47:16 -05:00
Nicolas Porter
88e02322e5 Fixed key name in source map, added coffee file to map sources
These are the modifications I had to do in order to get source maps working
in 27.0.1425.2 (Official Build 185250) canary. I haven't tested other
browsers.

I first looked at the V3 spec and a few examples, and I saw that the
`source` key of the source map should be called `sources`.

After doing the `source` to `sources` change, the coffee source and for
some odd reason the javascript file would not show up in the browser
dev tools (it was being fetched but not evaluated).

To fix this, I had to add the coffee source to the `sources` list in the
source map file.
2013-03-01 05:58:26 -05:00
Jeremy Ashkenas
5dea70b82e Fixes #2721 -- show error message for naked super 2013-03-01 13:25:49 +13:00
Jeremy Ashkenas
6b79af2b7c Fixes #2721, super outside of classes with extends for instance methods. 2013-03-01 13:17:07 +13:00
Jeremy Ashkenas
68718b6938 Moving path dependency back into 'command' 2013-03-01 12:50:42 +13:00
Jeremy Ashkenas
d70d71f574 Merging in .coffee.md support alongside .litcoffee ... I think we'll keep .litcoffee as the canonical, however. 2013-03-01 12:46:40 +13:00
Jeremy Ashkenas
f33517368e Removing duplicate 'CATCH' 2013-03-01 12:38:41 +13:00
Jeremy Ashkenas
a48ca260bd Merge pull request #2746 from troels/implicit-calls-with-overhang-on-first-argument-only-on-implicit-object
Disallow implicit calls in cases like:
2013-02-28 14:55:45 -08:00
Troels Nielsen
71e04d9839 Disallow implicit calls in cases like:
f
  a

and only allow cases like:

f
  a: 1
2013-02-28 23:20:42 +01:00
Jeremy Ashkenas
2970d59395 Merge pull request #2743 from epidemian/revert-2599
Revert #2599
2013-02-28 13:53:34 -08:00
Jason Walton
7073d18f23 Add source map support 2013-02-28 15:51:29 -05:00
Jeremy Ashkenas
23d8cd6c2a Merge branch 'master' of https://github.com/jashkenas/coffee-script 2013-03-01 07:46:04 +13:00
Jeremy Ashkenas
e70dd156b0 Fixing heredocs in literate coffeescript 2013-03-01 07:42:12 +13:00
Demian Ferreiro
4469d062e1 Add a couple of tests to document the behaviour of other typed constructors 2013-02-28 10:37:47 -03:00
Demian Ferreiro
bf70b4660e Revert #2599 2013-02-28 10:37:30 -03:00
Jeremy Ashkenas
c0e07013e8 Merge pull request #2741 from troels/implicit-call-try-catch-finally
Fix implicit calls with try/catch/finally as arguments
2013-02-28 03:00:49 -08:00
Jeremy Ashkenas
c6f30935a8 (Aside: For historical reasons we do make the filename extension optional, which is a deeply regrettable accident of history that I would not repeat, given the chance.) 2013-02-28 23:54:19 +13:00
Troels Nielsen
cb187fd900 Fix implicit calls with try/catch/finally as arguments 2013-02-28 11:53:04 +01:00
Jeremy Ashkenas
3f23be2854 Merge pull request #2718 from sbp/sbp-literate
Add support for text/literate-coffeescript in the browser
2013-02-28 02:47:43 -08:00
Sean B. Palmer
881ae5528d Add support for text/literate-coffeescript in the browser 2013-02-28 10:15:20 +00:00
Michael Smith
1a8354482a Modify extension handling to allow for .coffee.md
Move filename processing to a `parseFileName` function in
helpers.coffee.

Map `.coffee.md` as a Literate CoffeeScript extension.

Also, make .litcoffee and .coffee.md files executable without their file
extension - eg. `coffee test` would work for a file called
`test.litcoffee`.
2013-02-27 22:49:24 -08:00
Jeremy Ashkenas
32eb1bf58f Merge pull request #2740 from mintplant/hoist-build
Hoist build function to top level of Cakefile
2013-02-27 22:27:01 -08:00
Michael Smith
b2e17c3045 Hoist build function to top level of Cakefile 2013-02-27 22:21:10 -08:00
Jeremy Ashkenas
ac2c5f0201 Merge pull request #2712 from troels/implicit-object-implicit-call-stuff
Implicit object/implicit call interaction handling
2013-02-27 17:32:31 -08:00
Troels Nielsen
1666716c31 Improve the handling of implicit object and implicit call combinations
by handling them together.
2013-02-27 08:15:38 +01:00
Demian Ferreiro
5115fcb162 Add CompilationError.fromLocationData 2013-02-26 23:03:33 -03:00
Jason Walton
541ab8334d Compile to an array of CodeFragments instead of to a giant string. 2013-02-26 13:34:27 -05:00
Demian Ferreiro
1db89d1589 Optimized repeat and its tests 2013-02-26 14:41:01 -03:00
Michael Ficarra
965237e0da Merge pull request #2725 from mintplant/repl-fix
Fix REPL crashing on execution error
2013-02-26 08:20:36 -08:00
Michael Smith
5698e425fd Use blank line regex from Redux 2013-02-26 08:08:47 -08:00
Demian Ferreiro
fbc8417263 Fix failing parser error message test 2013-02-26 05:55:09 -03:00
Michael Smith
ff1ddd0284 Fix repl handling of blank line
Since the move to the nodeREPL package, input lines to be evaluated are
now wrapped in parentheses; that is:

    'foo'

would become:

    ('foo'
    )

The old way of detecting empty lines was to see if the input string was
either totally empty, or whitespace-only. The addition of these
parentheses breaks that.

In order to fix this, we simply tweak the regex a little to ignore these
added parentheses if they're present. As an added bonus, the regex
should match empty inputs even if they aren't.

This also makes the "empty command evaluates to undefined" test pass,
for the right reasons (i.e. not because of the broken error behavior
from before).
2013-02-25 22:09:50 -08:00
Michael Smith
deaa31dca5 Prevent repl from crashing on error [Fixes #2716]
Move execution of the compiled code inside the try/catch block:

    try
      js = CoffeeScript.compile "_=(#{input}\n)", {filename, bare: yes}
    catch err
      cb err
>   cb null, vm.runInContext(js, context, filename)

    try
      js = CoffeeScript.compile "_=(#{input}\n)", {filename, bare: yes}
>     cb null, vm.runInContext(js, context, filename)
    catch err
      cb err
2013-02-25 22:08:01 -08:00
Demian Ferreiro
44e3a76881 Add some error formatting tests
Thanks to them i discovered that the parser errors where indicating the wrong token ¬¬
2013-02-26 01:30:23 -03:00
Demian Ferreiro
f2efada0d4 Improved compiler error messages 2013-02-25 23:37:30 -03:00
Demian Ferreiro
5f00d6478a Remove redundant filename in error message 2013-02-25 19:20:37 -03:00
Michael Ficarra
8b0dd9d224 Merge pull request #2719 from epidemian/minor-embellishments
Minor embellishments
2013-02-25 10:35:25 -08:00
Demian Ferreiro
7e5f1b14a3 Pass 0-based indexes to CompilerError 2013-02-25 15:12:25 -03:00
Demian Ferreiro
caacd892cc Improved parser error messages 2013-02-25 15:09:42 -03:00
Demian Ferreiro
25091fb2a0 Improved lexer error messages 2013-02-25 14:41:34 -03:00
Demian Ferreiro
dcdfe9bc34 Fix indentation on test 2013-02-25 14:15:24 -03:00
Demian Ferreiro
f609036bee Remove unnecessary returns and use default parameters 2013-02-25 10:44:56 -03:00
Jeremy Ashkenas
c39723c053 expanding literate explanation 2013-02-25 22:29:42 +13:00
Jeremy Ashkenas
d2f400944d Adding a negative array loop example to the docs 2013-02-25 22:27:06 +13:00
Jeremy Ashkenas
673125e64a Merge branch 'master' into gh-pages 2013-02-25 21:23:24 +13:00
Jeremy Ashkenas
e1592890cb Retina-ifying the CoffeeScript logo 2013-02-25 21:23:08 +13:00
Jeremy Ashkenas
f1b5f81eaf merged 2013-02-25 21:13:39 +13:00
Jeremy Ashkenas
af53c230a1 CoffeeScript 1.5.0 2013-02-25 21:12:22 +13:00
Jeremy Ashkenas
ac9d0e17e4 Merging in location data in the AST. Yee-hah. 2013-02-25 17:51:05 +13:00
Jeremy Ashkenas
5e498ca395 merged 2013-02-25 17:41:27 +13:00
Jeremy Ashkenas
5c3acfefeb Removing Riak JS 2013-02-25 17:36:56 +13:00
Jeremy Ashkenas
9b63e806dd #2702 -- remove more dead code 2013-02-25 17:34:14 +13:00
Jeremy Ashkenas
bd842241a6 #2702 -- remove dead code 2013-02-25 17:33:27 +13:00
Jeremy Ashkenas
3815f0a132 #2702 -- remove old code 2013-02-25 17:32:51 +13:00
Jeremy Ashkenas
d43b50b1ca Merge branch 'master' of https://github.com/jashkenas/coffee-script 2013-02-25 17:17:07 +13:00
Jeremy Ashkenas
14c2a16833 Reverted b31cc70 -- putting Generated comment back up top. Why? Why not? 2013-02-25 17:17:01 +13:00
Michael Ficarra
5ae9c5d947 compile a320e1e535 2013-02-24 21:12:57 -06:00
Michael Ficarra
2402f9774a Revert "Moving the 'generated by coffeescript version X' comment to the bottom, to get it out of the way"
This reverts commit b31cc70235.
2013-02-24 21:11:43 -06:00
Michael Ficarra
3d3fe0df34 Merge pull request #2711 from troels/fix-1435
Fix #1435 by amending away sign reversal.
2013-02-24 11:58:41 -08:00
Troels Nielsen
a320e1e535 Fix #1435 by amending away sign reversal. 2013-02-24 20:33:58 +01:00
Michael Ficarra
8f0a7774f9 Merge pull request #2710 from troels/fix-full-build-tests
Build:full sometimes uses old code when running tests.
2013-02-24 11:33:54 -08:00
Troels Nielsen
7f8b56eadd Use the newly compiled code when running tests under build:full 2013-02-24 18:08:54 +01:00
Michael Ficarra
385d93e332 Merge pull request #2709 from epidemian/minor-embellishments
Minor embellishments
2013-02-23 03:39:34 -08:00
Demian Ferreiro
9ed804d9b1 Simplify Value::unfoldSoak momoization code (only a bit...) 2013-02-23 08:26:10 -03:00
Demian Ferreiro
03cfe23493 Remove unnecessary if statement 2013-02-23 08:24:04 -03:00
Demian Ferreiro
a97c23a4bd Make it more explicit that 'this' is the only possible value for tag in Value's constructor. 2013-02-23 06:34:11 -03:00
Jason Walton
e1a2e11de4 Fix merge problem, and rebuild parser.js 2013-02-21 20:17:06 -05:00
Jason Walton
5e49df8ed4 Merge remote-tracking branch 'upstream/master'
Conflicts:
	lib/coffee-script/grammar.js
	src/grammar.coffee
2013-02-14 14:21:46 -05:00
Jeremy Ashkenas
fa1ffa66d3 Fixes #2359 -- tweak grammar to use new name 2013-02-14 16:34:32 +13:00
Jeremy Ashkenas
1aa57bf24f moving book link to the proper place to be rebuilt 2013-02-13 10:35:21 +13:00
Jeremy Ashkenas
31dd0b75af Merge pull request #2480 from jamierumbelow/patch-1
Adding Testing with CoffeeScript to books list
2013-02-12 13:33:55 -08:00
Reg Braithwaite
46ecfd3c1a CLoses #2700
Signed-off-by: Reg Braithwaite <reg@braythwayt.com>
2013-02-13 10:33:11 +13:00
Jason Walton
c31bc6deb7 Update js files. 2013-02-06 10:40:48 -05:00
Jason Walton
fe45f1bf35 Merge remote-tracking branch 'upstream/master'
Conflicts:
	lib/coffee-script/grammar.js
	lib/coffee-script/rewriter.js
	src/grammar.coffee
	src/rewriter.coffee
2013-02-06 10:29:19 -05:00
Jeremy Ashkenas
fc7f4ed904 Fixes #2523 -- remove resetting of process.execPath 2013-02-02 12:40:50 +11:00
Jeremy Ashkenas
33553839e2 Fixes #2690 -- tweak cake bench to handle literate coffeescript 2013-02-02 12:36:05 +11:00
Jeremy Ashkenas
1818e74f42 Fixes #2525, #1187, #1208, #1758, and many more -- allow looping over an array downwards 2013-02-02 12:23:14 +11:00
Jeremy Ashkenas
d72daca7bd simpler implementation of the previous commit 2013-02-02 11:19:29 +11:00
Jeremy Ashkenas
c37202ecb9 Removing variable indirection for simple steps 2013-02-02 11:16:17 +11:00
Jeremy Ashkenas
1f5b19b81c slightly better conditions for range steps 2013-02-02 11:02:40 +11:00
Jeremy Ashkenas
8a98cb380e Fixes #2531. Allow colors where Node says that colors are available. 2013-02-02 10:50:32 +11:00
Jeremy Ashkenas
de5e2c60ae require a file name before checking for a fallback 2013-02-02 10:46:17 +11:00
Jeremy Ashkenas
b31cc70235 Moving the 'generated by coffeescript version X' comment to the bottom, to get it out of the way 2013-02-02 10:42:46 +11:00
Jeremy Ashkenas
78891a0ccc Merging in @epedemian's fix for #2359 -- disallow other-typed constructors 2013-02-01 22:30:22 +11:00
Jeremy Ashkenas
0b1d4d374a Adding a test for #2613 2013-02-01 22:07:19 +11:00
Jeremy Ashkenas
ac398998a2 Fixes #2613 -- bug with over-optimization of parentheses on LHS of destructuring 2013-02-01 22:05:55 +11:00
Jeremy Ashkenas
21d69e3e6e Fixes #2617 -- implicit object call getting out of control. 2013-02-01 21:59:48 +11:00
Jeremy Ashkenas
33140259b8 Fixes #2681 -- removes old --require hook. 2013-02-01 21:25:57 +11:00
Jeremy Ashkenas
723907464a Merge pull request #2685 from jordimassaguerpla/master
add license information to the gemspec
2013-01-29 04:24:47 -08:00
Jordi Massaguer Pla
bf4d91dd38 fix spacing in Rakefile
previous commit was not following the right indentation when adding the
license field.
2013-01-29 12:11:45 +01:00
Jordi Massaguer Pla
64fe56a9e1 add license information to gemspec
this way you can get this info from the rubygems.org API
2013-01-28 13:53:29 +01:00
Jeremy Ashkenas
39a05b7e4f Merge branch 'master' into gh-pages 2013-01-28 20:06:25 +10:00
Jeremy Ashkenas
e7f72c9555 Adding new coffeescript book per request 2013-01-28 20:06:07 +10:00
Jeremy Ashkenas
a106fb451b Merge pull request #2682 from jashkenas/repl-rewrite
REPL rewrite
2013-01-26 02:26:52 -08:00
Michael Ficarra
b1300bdd79 fix typo; thanks @Nami-Doc 2013-01-26 02:29:16 -06:00
Michael Ficarra
be9707f8d2 final tweaks to REPL rewrite
We can still use some more extensive tests, but it's already much better
tested than the current REPL.
2013-01-26 02:07:56 -06:00
Alon Salant
702071553f Remove testing TODO 2013-01-25 21:53:35 -08:00
Alon Salant
47bd05e9a0 REPL tests based on direct interaction with input and output stream. Includes multiline tests. 2013-01-21 21:56:34 -08:00
Michael Ficarra
537c5f4b70 fix some issues pointed out in 041033a51a 2013-01-21 10:27:52 -06:00
Michael Ficarra
041033a51a finish multiline support for REPL rewrite 2013-01-21 00:43:08 -06:00
Michael Ficarra
2e191dc0e7 Merge branch 'node_repl_multiline' of https://github.com/asalant/coffee-script into repl-rewrite 2013-01-18 21:16:39 -06:00
Alon Salant
4a52814a79 Multiline WIP 2013-01-18 11:33:04 -08:00
Alon Salant
69d80e2ded Single quotes 2013-01-16 11:48:50 -08:00
Alon Salant
d84cd9466e empty command evaluates to undefined 2013-01-15 22:40:41 -08:00
Alon Salant
627b921bca Initial commit of REPL based on node's REPLServer 2013-01-15 22:40:40 -08:00
Jeremy Ashkenas
955afe0c9f Merge branch 'master' of github.com:jashkenas/coffee-script 2013-01-16 17:34:04 +11:00
Jeremy Ashkenas
316d5e5e77 fixing missing file finding logic for litcoffee 2013-01-16 17:33:54 +11:00
Alon Salant
1f051e6e14 Merge branch 'repl-tests' of https://github.com/lihanli/coffee-script into node_repl 2013-01-14 20:50:06 -08:00
Jason Walton
f67da27d2f Add unit tests, fix last_column reporting. 2013-01-14 17:11:07 -05:00
Jason Walton
923739ebb4 Remove files committed by accident. 2013-01-14 17:10:49 -05:00
Jason Walton
97bc9f4730 Add quick unit test for location data. 2013-01-14 15:20:47 -05:00
Jason Walton
bbbf612f29 Put location data in token[2] instead of in token.locationData 2013-01-14 15:20:35 -05:00
Jeremy Ashkenas
d11fa573e6 do not try to compile traces of coffee within node_modules 2013-01-14 11:45:02 -08:00
Jeremy Ashkenas
6becd8fb13 Reverting the unthrow of the error. 2013-01-14 11:44:15 -08:00
Jason Walton
a1ba0a89f8 Merge remote-tracking branch 'origin/master'
Conflicts:
	lib/coffee-script/coffee-script.js
	lib/coffee-script/lexer.js
	lib/coffee-script/parser.js
	src/lexer.coffee
2013-01-14 14:26:06 -05:00
Jason Walton
a9aa52dc6a Use .explicit when deciding whether or not to add location data. 2013-01-14 13:38:31 -05:00
satyr
9595b30d6f fix tabbed literate code 2013-01-10 06:24:12 +09:00
Michael Ficarra
f672e0cdb5 fix 'litcoffee' extension support
As pointed out by @satyr in 27551b23f3
2013-01-07 22:35:20 -06:00
Michael Ficarra
66bbef4ce0 revert broken parts of cdde576182
Thanks @alagopus.
2013-01-07 22:32:39 -06:00
Michael Ficarra
dfe91d1766 rebuilding after cdde576182 2013-01-07 22:27:02 -06:00
Jeremy Ashkenas
cdde576182 Syntax errors no longer report full stack traces ... just the error, please 2013-01-06 19:12:23 -10:00
Jeremy Ashkenas
82aeb70380 Fixes #2630 -- Class bodies shouldn't be able to reference arguments. 2013-01-06 19:08:32 -10:00
Jeremy Ashkenas
69ef1abdf6 Fixes #2389 -- strip the BOM for once and for all 2013-01-06 18:56:58 -10:00
Jeremy Ashkenas
cc6f0451e7 Fixes #2621 -- buggy function parameter name detection with complex destructuring in param list. 2013-01-05 18:32:57 -10:00
Jeremy Ashkenas
2c20ac6aa9 Fixes #2622 -- better document how --nodejs flag works 2013-01-05 18:18:08 -10:00
Jeremy Ashkenas
f8c751b3a4 adding one more compound operator test for #2627 2013-01-05 18:14:05 -10:00
Jeremy Ashkenas
547a271cee Merge pull request #2627 from int3/master
Parse compound assignment operator followed by a terminator. Closes #2532.
2013-01-05 20:10:32 -08:00
Jeremy Ashkenas
cd2444e546 Fixes #2645 -- block comments should always be closed 2013-01-05 18:04:16 -10:00
Jeremy Ashkenas
6f1fb0352c doing the Scope in literate coffee ... just for kicks. 2013-01-05 12:05:09 -10:00
Jeremy Ashkenas
4bf2c6b2e9 Merge branch 'master' of github.com:jashkenas/coffee-script into literate 2013-01-05 11:34:48 -10:00
Jeremy Ashkenas
025b0be31b Correct line numbers in literate coffeescript syntax errors 2013-01-04 17:23:18 -10:00
Jeremy Ashkenas
27551b23f3 add litcoffee to supported file formats 2013-01-04 10:03:49 -10:00
Jeremy Ashkenas
ba08a21d21 bumping version to 1.5.0-pre 2013-01-04 09:35:20 -10:00
Jeremy Ashkenas
48d625816c Merge branch 'master' into literate 2013-01-04 09:07:09 -10:00
Jason Walton
cee4f4ab6e Location test. 2012-12-24 08:34:16 -05:00
Jeremy Ashkenas
de29613d91 Merge pull request #2632 from caseywebdev/update-uglify
gh-2631 Update to uglifyjs's new API
2012-11-29 10:08:42 -08:00
Casey Foster
9e3d43193d gh-2631 Update to uglifyjs's new API 2012-11-29 09:45:31 -08:00
Jez Ng
847ab4d18e Parse compound assignment followed by a terminator.
Closes #2532.
2012-11-27 20:11:01 -05:00
Jason Walton
183e124077 Fix broken case for generated explicit indentation. 2012-11-22 14:22:38 -05:00
Jason Walton
3142b237f5 Hook up new token location data to parser. 2012-11-21 16:57:30 -05:00
Jason Walton
969e45a599 Fix TODO in interpolateString. 2012-11-20 12:05:59 -05:00
Jason Walton
df6c497ab0 Clean up TODOs 2012-11-19 17:37:46 -05:00
Jason Walton
12625cc00c Add location data to tokens generated by the rewriter. 2012-11-19 11:34:09 -05:00
Jason Walton
bb94e02fad Lexer now adds location data, including first/last line/column to all generated tokens. 2012-11-16 19:09:56 -05:00
Jason Walton
25126e2f99 Add location data to nodes without passing it in constructors. 2012-11-15 15:35:01 -05:00
Jason Walton
d5d772d55e Remove debug logging from Cakefile. 2012-11-15 15:18:52 -05:00
Jason Walton
bdcd77d8e6 Use 1-based line numbers instead of 0-based line numbers in nodes toString(). 2012-11-14 16:32:35 -05:00
Jason Walton
b9ebcbf555 Add more descriptive line numbers to node toString() 2012-11-14 16:20:25 -05:00
Jason Walton
c407a0bf19 Fix reporting of errors in 'cake test' 2012-11-14 16:19:17 -05:00
Jason Walton
7c77a5d3c8 Fix line numbers for TERMINATOR tokens. 2012-11-14 14:38:02 -05:00
Jason Walton
ce2bf36aae Parser passes location data to each node in tree 2012-11-14 11:50:43 -05:00
lihan
3284f6af18 tests for the repl: ignoring comments, output in inspect mode, variable saving 2012-10-31 00:09:59 -04:00
Demian Ferreiro
52b0f76eb2 Prevent constructors from returning values 2012-10-28 08:55:48 -03:00
Demian Ferreiro
e46b129c4f Remove return statement on auto-generated constructors 2012-10-28 08:55:02 -03:00
Jeremy Ashkenas
35787ef79b Fixes #2567 -- optimize generated code with an existential is directly negated. 2012-10-23 18:17:53 -04:00
Jeremy Ashkenas
f029695db8 Fixing wonky spacing at top level. 2012-10-23 18:08:29 -04:00
Jeremy Ashkenas
0ba628159f Fixes #2580 -- Try/Catch is allowed to destructure the error object. 2012-10-23 17:57:22 -04:00
Jeremy Ashkenas
be65807370 Merge branch 'master' into gh-pages 2012-10-23 16:45:50 -04:00
Jeremy Ashkenas
158d37215a CoffeeScript 1.4.0 2012-10-23 16:45:31 -04:00
Jeremy Ashkenas
7ad25c90fa rebuilding nodes 2012-10-23 15:51:13 -04:00
Jeremy Ashkenas
b06a326c7d Merge pull request #2587 from sstur/pullreq
Simplify Call.prototype.compileSplat based on how Traceur does it
2012-10-16 10:03:49 -07:00
Simon Sturmer
25bdde85a9 Simplify Call.prototype.compileSplat based on how Traceur does it 2012-10-16 21:05:31 +07:00
Gabe Hollombe
334dcbd162 Updated example using @epidemian's suggestion 2012-10-16 16:41:14 +11:00
Jeremy Ashkenas
caed958455 Fixes #2577 -- better instructions for installing master 2012-10-08 10:08:33 -04:00
Jeremy Ashkenas
d8905e2f87 Fixes #2577 -- better instructions for installing master 2012-10-08 10:08:23 -04:00
Jeremy Ashkenas
b4e13b294d pretty decent initial test. 2012-09-25 19:37:54 -05:00
Jeremy Ashkenas
4fb3a312b0 fixing block comment indentation 2012-09-25 19:35:02 -05:00
Jeremy Ashkenas
82fadea1ed first working version of literate coffeescript 2012-09-25 19:15:40 -05:00
Jeremy Ashkenas
bb194dc6c6 start with comments... 2012-09-25 18:10:43 -05:00
Jeremy Ashkenas
9167b3aca1 removing export of RESERVED ... more progress. 2012-09-25 18:01:16 -05:00
Jeremy Ashkenas
76a25dc797 ignore litcoffee files 2012-09-25 17:50:04 -05:00
Jeremy Ashkenas
97de09c8f1 rebuilding 2012-09-25 17:16:10 -05:00
Jeremy Ashkenas
7595cb689a Adding a CONTRIBUTING to CoffeeScript. 2012-09-17 13:16:41 -04:00
Jeremy Ashkenas
2b86470665 Merge pull request #2535 from philikon/issue2534
Fix #2534: Don't pass a string argument to the XMLHttpRequest constructor
2012-09-07 13:41:45 -07:00
Philipp von Weitershausen
78423e9a14 Fix #2534: Address @jashkenas review comment. 2012-09-07 12:53:37 -07:00
Philipp von Weitershausen
ec59a626f2 Fix #2534: Don't pass a string argument to the XMLHttpRequest constructor. 2012-09-05 00:09:18 -07:00
Michael Ficarra
1b14c035e7 fixes #2521: line numbers in errors affected by newlines in backticks 2012-08-29 12:54:50 -05:00
Michael Ficarra
ba34f8d389 updated compiled output 2012-08-29 12:54:16 -05:00
Jeremy Ashkenas
b74e73058c Merge pull request #2484 from paulyoung/remove-register-extension
Fixes #2441: Remove (deprecated) registerExtension support.
2012-08-10 07:24:55 -07:00
Paul Young
c29597b3bc Fixes #2441: Remove (deprecated) registerExtension support. 2012-08-08 20:01:07 -04:00
Jamie Rumbelow
7c53d8c120 Adding Testing with CoffeeScript to books list 2012-08-07 15:22:06 +03:00
Michael Ficarra
5d7a83468a fixed broken compilation due to pull #2430
cc @jashkenas, @domenic, @yyfearth
2012-07-11 10:24:58 -05:00
Michael Ficarra
a396837fa4 building #2430 2012-07-10 23:08:14 -05:00
Jeremy Ashkenas
1fa3da68ba Merge pull request #2430 from domenic/bom
Strip UTF-8 BOM when require'ing .coffee modules.
2012-07-09 08:25:48 -07:00
Jeremy Ashkenas
219726a9c5 Merge pull request #2431 from domenic/npm-test
Add test script to package.json.
2012-07-09 08:24:49 -07:00
Domenic Denicola
81c0964e48 Add test script to package.json.
Allows one to run the tests using `npm test`.
2012-07-08 22:55:43 -04:00
Domenic Denicola
c9388ce767 Strip UTF-8 BOM when require'ing .coffee modules.
Allows people to author their .coffee files with UTF-8 BOMs at the start, because sometimes that happens. Fixes #798.
2012-07-08 22:52:13 -04:00
Gabe Hollombe
7065538224 add documentation for using switch without a control expression 2012-07-04 11:57:20 +07:00
Michael Smith
2a56f0cdf7 Correct incorrect line in blocks.coffee 2012-07-02 08:36:00 -07:00
Michael Smith
ace4837365 Migrate from path.exists to fs.exists
Compatibility is kept for path.exists. Versions of node that have
made the change will use fs.exists, while older versions will fall
back to path.exists. The same goes for path.existsSync.
2012-07-02 00:20:13 -07:00
Michael Ficarra
6417cf4d1b removed duplicate "let" in RESERVED list
thanks @phleet for finding it:
161e9a6559 (commitcomment-1448952)
2012-06-12 15:16:50 -05:00
Gabe Hollombe
7fdd21b26d Add example of destructuring assignment in class constructors for options 2012-06-10 11:19:54 +07:00
Michael Ficarra
1731f7d321 rebuild after merging #2371 2012-06-06 19:39:17 -05:00
Michael Ficarra
8d39c1cc79 Merge pull request #2371 from takkaw/del_unused
dead code removal
2012-06-06 17:38:22 -07:00
takkaw
bc7e0cf09a delete unused sentence 2012-06-06 23:05:10 +09:00
Michael Ficarra
7c29ea4d38 removing code that restricts duplicate key names and associated tests 2012-05-21 13:49:00 -04:00
Michael Ficarra
6c6c8bd454 typo in test case for #2333 2012-05-21 13:28:18 -04:00
Michael Ficarra
81f780f1fb finally put #2333 to rest by resorting to using indirect eval
related: #1772, #1776; we're relying on the underlying engine having the
string escaping behaviour we want instead of implementing it manually.
2012-05-21 13:26:29 -04:00
Jeremy Ashkenas
6838bae36e Merge pull request #2347 from heyLu/fix-repl
fix repl completion and navigation
2012-05-21 06:22:04 -07:00
Michael Ficarra
972a5299d5 correct spacing around operators in slice output 2012-05-20 16:32:10 -04:00
Michael Ficarra
b8149812cd fixes #2349: inclusive slicing to numeric strings 2012-05-20 16:22:25 -04:00
Lucas Stadler
01d4e87f57 fix repl completion and navigation
The readline interface of node has changed in [aad12d0][] and because of
that the autocompletion and key movement didn't work anymore. This
commit fixes this by checking whether stdin is in raw mode (i.e. invoked
as a script) or not (as a repl).

[aad12d0]: https://github.com/joyent/node/commit/aad12d0
2012-05-20 11:38:50 +02:00
Michael Ficarra
f938a213fe trying to commit built files again; here goes nothing 2012-05-16 15:50:34 -04:00
Michael Ficarra
df54c63b1b yet another small cleanup and obscure bugfix related to #2333 2012-05-16 15:29:00 -04:00
Michael Ficarra
1810d9f318 object key dupe checking again: support newlines and \a in strings 2012-05-16 12:53:28 -04:00
Michael Ficarra
29b9c3bb29 correcting broken fix for #2333 regarding string escape sequences
Sorry for all the commits! It should really be done this time.
2012-05-16 10:36:00 -04:00
Michael Ficarra
da2298988a Merge pull request #2334 from michaelficarra/issue2333
fixes #2333: fix prohibition of duplicate object properties
2012-05-16 05:55:28 -07:00
Michael Ficarra
f31ff7774a fix escaping in test for #2333 2012-05-16 08:19:06 -04:00
Michael Ficarra
c6fafa1bc9 renaming any helper to some, reflecting Array::some 2012-05-16 07:58:14 -04:00
Michael Ficarra
e8a8209a2b Finally rid eval from fix for #2333. I feel comfortable with it now. 2012-05-16 07:41:00 -04:00
Michael Ficarra
fa82859814 another refactoring for #2333 2012-05-16 07:02:16 -04:00
Michael Ficarra
55e1386503 issue #2333: removed gratuitous test, refactored 2012-05-16 02:07:35 -04:00
Michael Ficarra
dc9565f54a fix to #2333 greatly improved, but still depends on eval :( 2012-05-16 02:03:02 -04:00
Michael Ficarra
c264bf04cc fixes #2333: fix prohibition of duplicate object properties 2012-05-16 01:07:10 -04:00
Michael Ficarra
5c66e552d7 corrected some SIGINT/EOT logic in REPL 2012-05-15 13:15:23 -04:00
Michael Ficarra
c4ebe352a4 more changes to REPL autocompletion as suggested in 8dcbe54e55 2012-05-15 12:48:02 -04:00
Jeremy Ashkenas
1cba2e2339 Merge branch 'master' into gh-pages 2012-05-15 12:36:12 -04:00
Jeremy Ashkenas
b4af24b7e2 Merge branch 'master' into gh-pages 2012-05-14 14:45:35 -04:00
Jeremy Ashkenas
3fc0e6be90 adding a rel=canonical 2012-05-10 17:42:40 -04:00
Jeremy Ashkenas
9d4dc094a1 adding a link to the high-rez logo 2012-04-24 12:12:32 -04:00
Stephen Bannasch
deae3e53f5 rake task creates/installs coffeescript.syntax
The ultraviolet gem doesn't work with Ruby 1.9, instead
we need to use the updated 'spox' versions of ultraviolet
and plist:

  spox-ultraviolet, spox-plist

This new rake task: install_coffeescript_syntax loads
either the original gems if running Ruby < 1.9 or the
'spox' versions if running on Ruby >= 1.9.

Load CoffeeScript.tmLanguage directly from the github repo
for the TextMate bundle.

Parse and write the yaml-format syntax file directly
into the correct location in the ultraviolet gem.
2012-01-31 17:15:46 -05:00
charliesome
3bd4dea305 fix the precedence test so it's actually meaningful 2012-01-11 21:37:06 +11:00
charliesome
a4249fd573 power operator + tests 2012-01-11 17:14:23 +11:00
278 changed files with 49343 additions and 25440 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
raw
presentation
test.coffee
test.litcoffee
parser.output
test/fixtures/underscore
test/*.js

0
.nojekyll Normal file
View File

View File

@@ -1,11 +0,0 @@
*.coffee
*.html
.DS_Store
.git*
Cakefile
documentation/
examples/
extras/coffee-script.js
raw/
src/
test/

1
CNAME
View File

@@ -1 +0,0 @@
coffeescript.org

9
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,9 @@
## How to contribute to CoffeeScript
* Before you open a ticket or send a pull request, [search](https://github.com/jashkenas/coffeescript/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
* Before sending a pull request for a feature, be sure to have [tests](https://github.com/jashkenas/coffeescript/tree/master/test).
* 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 `coffee-script.js` file. We'll do those things before cutting a new release.

271
Cakefile
View File

@@ -1,16 +1,13 @@
fs = require 'fs'
path = require 'path'
{extend} = require './lib/coffee-script/helpers'
CoffeeScript = require './lib/coffee-script'
{spawn, exec} = require 'child_process'
fs = require 'fs'
path = require 'path'
_ = require 'underscore'
{ spawn, exec, execSync } = require 'child_process'
CoffeeScript = require './lib/coffee-script'
helpers = require './lib/coffee-script/helpers'
# ANSI Terminal Colors.
enableColors = no
unless process.platform is 'win32'
enableColors = not process.env.NODE_DISABLE_COLORS
bold = red = green = reset = ''
if enableColors
unless process.env.NODE_DISABLE_COLORS
bold = '\x1B[0;1m'
red = '\x1B[0;31m'
green = '\x1B[0;32m'
@@ -27,17 +24,21 @@ header = """
*/
"""
sources = [
'coffee-script', 'grammar', 'helpers'
'lexer', 'nodes', 'rewriter', 'scope'
].map (filename) -> "src/#{filename}.coffee"
# Used in folder names like docs/v1
majorVersion = CoffeeScript.VERSION.split('.')[0]
# Build the CoffeeScript language from source.
build = (cb) ->
files = fs.readdirSync 'src'
files = ('src/' + file for file in files when file.match(/\.(lit)?coffee$/))
run ['-c', '-o', 'lib/coffee-script'].concat(files), cb
# Run a CoffeeScript through our node/coffee interpreter.
run = (args, cb) ->
proc = spawn 'node', ['bin/coffee'].concat(args)
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
proc.on 'exit', (status) ->
process.exit(1) if status != 0
process.exit(1) if status isnt 0
cb() if typeof cb is 'function'
# Log a message with a color.
@@ -51,12 +52,12 @@ task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options)
lib = "#{base}/lib/coffee-script"
bin = "#{base}/bin"
node = "~/.node_libraries/coffee-script"
console.log "Installing CoffeeScript to #{lib}"
console.log "Linking to #{node}"
console.log "Linking 'coffee' to #{bin}/coffee"
console.log "Installing CoffeeScript to #{lib}"
console.log "Linking to #{node}"
console.log "Linking 'coffee' to #{bin}/coffee"
exec([
"mkdir -p #{lib} #{bin}"
"cp -rf bin lib LICENSE README package.json src #{lib}"
"cp -rf bin lib LICENSE README.md package.json src #{lib}"
"ln -sfn #{lib}/bin/coffee #{bin}/coffee"
"ln -sfn #{lib}/bin/cake #{bin}/cake"
"mkdir -p ~/.node_libraries"
@@ -66,42 +67,37 @@ task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options)
)
task 'build', 'build the CoffeeScript language from source', build = (cb) ->
files = fs.readdirSync 'src'
files = ('src/' + file for file in files when file.match(/\.coffee$/))
run ['-c', '-o', 'lib/coffee-script'].concat(files), cb
task 'build', 'build the CoffeeScript language from source', build
task 'build:full', 'rebuild the source twice, and run the tests', ->
build ->
build ->
csPath = './lib/coffee-script'
delete require.cache[require.resolve csPath]
csDir = path.dirname require.resolve csPath
for mod of require.cache when csDir is mod[0 ... csDir.length]
delete require.cache[mod]
unless runTests require csPath
process.exit 1
task 'build:parser', 'rebuild the Jison parser (run build first)', ->
extend global, require('util')
helpers.extend global, require 'util'
require 'jison'
parser = require('./lib/coffee-script/grammar').parser
fs.writeFile 'lib/coffee-script/parser.js', parser.generate()
task 'build:ultraviolet', 'build and install the Ultraviolet syntax highlighter', ->
exec 'plist2syntax ../coffee-script-tmbundle/Syntaxes/CoffeeScript.tmLanguage', (err) ->
throw err if err
exec 'sudo mv coffeescript.yaml /usr/local/lib/ruby/gems/1.8/gems/ultraviolet-0.10.2/syntax/coffeescript.syntax'
fs.writeFileSync 'lib/coffee-script/parser.js', parser.generate()
task 'build:browser', 'rebuild the merged script for inclusion in the browser', ->
code = ''
for name in ['helpers', 'rewriter', 'lexer', 'parser', 'scope', 'nodes', 'coffee-script', 'browser']
for name in ['helpers', 'rewriter', 'lexer', 'parser', 'scope', 'nodes', 'sourcemap', 'coffee-script', 'browser']
code += """
require['./#{name}'] = new function() {
var exports = this;
require['./#{name}'] = (function() {
var exports = {}, module = {exports: exports};
#{fs.readFileSync "lib/coffee-script/#{name}.js"}
};
return module.exports;
})();
"""
code = """
(function(root) {
@@ -113,57 +109,170 @@ task 'build:browser', 'rebuild the merged script for inclusion in the browser',
if (typeof define === 'function' && define.amd) {
define(function() { return CoffeeScript; });
} else {
root.CoffeeScript = CoffeeScript;
} else {
root.CoffeeScript = CoffeeScript;
}
}(this));
"""
unless process.env.MINIFY is 'false'
{parser, uglify} = require 'uglify-js'
code = uglify.gen_code uglify.ast_squeeze uglify.ast_mangle parser.parse code
fs.writeFileSync 'extras/coffee-script.js', header + '\n' + code
{compiledCode} = require('google-closure-compiler-js').compile
jsCode: [
src: code
languageOut: if majorVersion is 1 then 'ES5' else 'ES6'
]
outputFolder = "docs/v#{majorVersion}/browser-compiler"
fs.mkdirSync outputFolder unless fs.existsSync outputFolder
fs.writeFileSync "#{outputFolder}/coffee-script.js", header + '\n' + compiledCode
console.log "built ... running browser tests:"
invoke 'test:browser'
task 'doc:site', 'watch and continually rebuild the documentation for the website', ->
exec 'rake doc', (err) ->
throw err if err
# Helpers
codeFor = ->
counter = 0
hljs = require 'highlight.js'
hljs.configure classPrefix: ''
(file, executable = false, showLoad = true) ->
counter++
return unless fs.existsSync "docs/v#{majorVersion}/examples/#{file}.js"
cs = fs.readFileSync "documentation/examples/#{file}.coffee", 'utf-8'
js = fs.readFileSync "docs/v#{majorVersion}/examples/#{file}.js", 'utf-8'
js = js.replace /^\/\/ generated.*?\n/i, ''
cshtml = "<pre><code>#{hljs.highlight('coffeescript', cs).value}</code></pre>"
# Temporary fix until highlight.js adds support for newer CoffeeScript keywords
# Added in https://github.com/isagalaev/highlight.js/pull/1357, awaiting release
if file in ['generator_iteration', 'generators', 'modules']
cshtml = cshtml.replace /(yield|import|export|from|as|default) /g, '<span class="keyword">$1</span> '
jshtml = "<pre><code>#{hljs.highlight('javascript', js).value}</code></pre>"
append = if executable is yes then '' else "alert(#{executable});".replace /"/g, '&quot;'
if executable and executable isnt yes
cs.replace /(\S)\s*\Z/m, "$1\n\nalert #{executable}"
run = if executable is true then 'run' else "run: #{executable}"
name = "example#{counter}"
script = "<script>window.#{name} = #{JSON.stringify cs}</script>"
load = if showLoad then "<div class='minibutton load' onclick='javascript: loadConsole(#{name});'>load</div>" else ''
button = if executable then """<div class="minibutton ok" onclick="javascript: #{js.replace /"/g, '&quot;'};#{append}">#{run}</div>""" else ''
"<div class='code'>#{cshtml}#{jshtml}#{script}#{load}#{button}<br class='clear' /></div>"
monthNames = [
'January'
'February'
'March'
'April'
'May'
'June'
'July'
'August'
'September'
'October'
'November'
'December'
]
formatDate = (date) ->
date.replace /^(\d\d\d\d)-(\d\d)-(\d\d)$/, (match, $1, $2, $3) ->
"#{monthNames[$2 - 1]} #{+$3}, #{$1}"
releaseHeader = (date, version, prevVersion) -> """
<div class="anchor" id="#{version}"></div>
<b class="header">
#{prevVersion and "<a href=\"https://github.com/jashkenas/coffeescript/compare/#{prevVersion}...#{version}\">#{version}</a>" or version}
<span class="timestamp"> &mdash; <time datetime="#{date}">#{formatDate date}</time></span>
</b>
"""
testHelpers = fs.readFileSync('test/support/helpers.coffee', 'utf-8').replace /exports\./g, '@'
testsInScriptBlocks = ->
output = ''
excludedTestFiles = ['error_messages.coffee']
for filename in fs.readdirSync 'test'
continue if filename in excludedTestFiles
if filename.indexOf('.coffee') isnt -1
type = 'coffeescript'
else if filename.indexOf('.litcoffee') isnt -1
type = 'literate-coffeescript'
else
continue
# Set the type to text/x-coffeescript or text/x-literate-coffeescript
# to prevent the browser compiler from automatically running the script
output += """
<script type="text/x-#{type}" class="test" id="#{filename.split('.')[0]}">
#{fs.readFileSync "test/#{filename}", 'utf-8'}
</script>\n
"""
output
# Task
examplesSourceFolder = 'documentation/examples'
examplesOutputFolder = "docs/v#{majorVersion}/examples"
fs.mkdirSync examplesOutputFolder unless fs.existsSync examplesOutputFolder
do renderExamples = ->
execSync "bin/coffee -bc -o #{examplesOutputFolder} #{examplesSourceFolder}/*.coffee"
indexFile = 'documentation/index.html'
do renderIndex = ->
render = _.template fs.readFileSync(indexFile, 'utf-8')
output = render
codeFor: codeFor()
releaseHeader: releaseHeader
majorVersion: majorVersion
fullVersion: CoffeeScript.VERSION
fs.writeFileSync "docs/v#{majorVersion}/index.html", output
log 'compiled', green, "#{indexFile} → docs/v#{majorVersion}/index.html"
testFile = 'documentation/test.html'
do renderTest = ->
render = _.template fs.readFileSync(testFile, 'utf-8')
output = render
testHelpers: testHelpers
tests: testsInScriptBlocks()
majorVersion: majorVersion
fs.writeFileSync "docs/v#{majorVersion}/test.html", output
log 'compiled', green, "#{testFile} → docs/v#{majorVersion}/test.html"
fs.watch examplesSourceFolder, interval: 200, ->
renderExamples()
renderIndex()
fs.watch indexFile, interval: 200, renderIndex
fs.watch testFile, interval: 200, renderTest
fs.watch 'test', interval: 200, renderTest
log 'watching...' , green
task 'doc:source', 'rebuild the internal documentation', ->
exec 'docco src/*.coffee && cp -rf docs documentation && rm -r docs', (err) ->
throw err if err
task 'doc:source', 'rebuild the annotated source documentation', ->
exec "node_modules/docco/bin/docco src/*.*coffee --output docs/v#{majorVersion}/annotated-source", (err) -> throw err if err
task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
exec 'docco examples/underscore.coffee && cp -rf docs documentation && rm -r docs', (err) ->
throw err if err
task 'bench', 'quick benchmark of compilation time', ->
{Rewriter} = require './lib/coffee-script/rewriter'
co = sources.map((name) -> fs.readFileSync name).join '\n'
sources = ['coffee-script', 'grammar', 'helpers', 'lexer', 'nodes', 'rewriter']
coffee = sources.map((name) -> fs.readFileSync "src/#{name}.coffee").join '\n'
litcoffee = fs.readFileSync("src/scope.litcoffee").toString()
fmt = (ms) -> " #{bold}#{ " #{ms}".slice -4 }#{reset} ms"
total = 0
now = Date.now()
time = -> total += ms = -(now - now = Date.now()); fmt ms
tokens = CoffeeScript.tokens co, rewrite: false
tokens = CoffeeScript.tokens coffee, rewrite: no
littokens = CoffeeScript.tokens litcoffee, rewrite: no, literate: yes
tokens = tokens.concat(littokens)
console.log "Lex #{time()} (#{tokens.length} tokens)"
tokens = new Rewriter().rewrite tokens
console.log "Rewrite#{time()} (#{tokens.length} tokens)"
nodes = CoffeeScript.nodes tokens
console.log "Parse #{time()}"
js = nodes.compile bare: true
js = nodes.compile bare: yes
console.log "Compile#{time()} (#{js.length} chars)"
console.log "total #{ fmt total }"
task 'loc', 'count the lines of source code in the CoffeeScript compiler', ->
exec "cat #{ sources.join(' ') } | grep -v '^\\( *#\\|\\s*$\\)' | wc -l | tr -s ' '", (err, stdout) ->
console.log stdout.trim()
# Run the CoffeeScript test suite.
runTests = (CoffeeScript) ->
CoffeeScript.register()
startTime = Date.now()
currentFile = null
passedTests = 0
@@ -173,6 +282,7 @@ runTests = (CoffeeScript) ->
# Convenience aliases.
global.CoffeeScript = CoffeeScript
global.Repl = require './lib/coffee-script/repl'
# Our test helper function for delimiting different test cases.
global.test = (description, fn) ->
@@ -181,27 +291,13 @@ runTests = (CoffeeScript) ->
fn.call(fn)
++passedTests
catch e
e.description = description if description?
e.source = fn.toString() if fn.toString?
failures.push filename: currentFile, error: e
failures.push
filename: currentFile
error: e
description: description if description?
source: fn.toString() if fn.toString?
# See http://wiki.ecmascript.org/doku.php?id=harmony:egal
egal = (a, b) ->
if a is b
a isnt 0 or 1/a is 1/b
else
a isnt a and b isnt b
# A recursive functional equivalence helper; uses egal for testing equivalence.
arrayEgal = (a, b) ->
if egal a, b then yes
else if a instanceof Array and b instanceof Array
return no unless a.length is b.length
return no for el, idx in a when not arrayEgal el, b[idx]
yes
global.eq = (a, b, msg) -> ok egal(a, b), msg
global.arrayEq = (a, b, msg) -> ok arrayEgal(a,b), msg
helpers.extend global, require './test/support/helpers'
# When all the tests have run, collect and print errors.
# If a stacktrace is available, output the compiled function source.
@@ -211,25 +307,22 @@ runTests = (CoffeeScript) ->
return log(message, green) unless failures.length
log "failed #{failures.length} and #{message}", red
for fail in failures
{error, filename} = fail
jsFilename = filename.replace(/\.coffee$/,'.js')
match = error.stack?.match(new RegExp(fail.file+":(\\d+):(\\d+)"))
match = error.stack?.match(/on line (\d+):/) unless match
[match, line, col] = match if match
{error, filename, description, source} = fail
console.log ''
log " #{error.description}", red if error.description
log " #{description}", red if description
log " #{error.stack}", red
log " #{jsFilename}: line #{line ? 'unknown'}, column #{col ? 'unknown'}", red
console.log " #{error.source}" if error.source
console.log " #{source}" if source
return
# Run every test in the `test` folder, recording failures.
files = fs.readdirSync 'test'
for file in files when file.match /\.coffee$/i
for file in files when helpers.isCoffee file
literate = helpers.isLiterate file
currentFile = filename = path.join 'test', file
code = fs.readFileSync filename
try
CoffeeScript.run code.toString(), {filename}
CoffeeScript.run code.toString(), {filename, literate}
catch error
failures.push {filename, error}
return !failures.length
@@ -240,7 +333,7 @@ task 'test', 'run the CoffeeScript language test suite', ->
task 'test:browser', 'run the test suite against the merged browser script', ->
source = fs.readFileSync 'extras/coffee-script.js', 'utf-8'
source = fs.readFileSync "docs/v#{majorVersion}/browser-compiler/coffee-script.js", 'utf-8'
result = {}
global.testingBrowser = yes
(-> eval source).call result

View File

@@ -1,4 +1,4 @@
Copyright (c) 2009-2012 Jeremy Ashkenas
Copyright (c) 2009-2015 Jeremy Ashkenas
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
OTHER DEALINGS IN THE SOFTWARE.

51
README
View File

@@ -1,51 +0,0 @@
{
} } {
{ { } }
} }{ {
{ }{ } } _____ __ __
( }{ }{ { ) / ____| / _|/ _|
.- { { } { }} -. | | ___ | |_| |_ ___ ___
( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|`-..________ ..-'| | |___| (_) | | | || __/ __/
| | \_____\___/|_| |_| \___|\___|
| ;--.
| (__ \ _____ _ _
| | ) ) / ____| (_) | |
| |/ / | (___ ___ _ __ _ _ __ | |_
| ( / \___ \ / __| '__| | '_ \| __|
| |/ ____) | (__| | | | |_) | |_
| | |_____/ \___|_| |_| .__/ \__|
`-.._________..-' | |
|_|
CoffeeScript is a little language that compiles into JavaScript.
Install Node.js, and then the CoffeeScript compiler:
sudo bin/cake install
Or, if you have the Node Package Manager installed:
npm install -g coffee-script
(Leave off the -g if you don't wish to install globally.)
Execute a script:
coffee /path/to/script.coffee
Compile a script:
coffee -c /path/to/script.coffee
For documentation, usage, and examples, see:
http://coffeescript.org/
To suggest a feature, report a bug, or general discussion:
http://github.com/jashkenas/coffee-script/issues/
If you'd like to chat, drop by #coffeescript on Freenode IRC,
or on webchat.freenode.net.
The source repository:
git://github.com/jashkenas/coffee-script.git
All contributors are listed here:
http://github.com/jashkenas/coffee-script/contributors

62
README.md Normal file
View File

@@ -0,0 +1,62 @@
{
} } {
{ { } }
} }{ {
{ }{ } } _____ __ __
{ }{ }{ { } / ____| / _|/ _|
.- { { } { }} -. | | ___ | |_| |_ ___ ___
( { } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|`-..________ ..-'| | |___| (_) | | | || __/ __/
| | \_____\___/|_| |_| \___|\___|
| ;--.
| (__ \ _____ _ _
| | ) ) / ____| (_) | |
| |/ / | (___ ___ _ __ _ _ __ | |_
| ( / \___ \ / __| '__| | '_ \| __|
| |/ ____) | (__| | | | |_) | |_
| | |_____/ \___|_| |_| .__/ \__|
`-.._________..-' | |
|_|
CoffeeScript is a little language that compiles into JavaScript.
## Installation
If you have the node package manager, npm, installed:
```shell
npm install -g coffee-script
```
Leave off the `-g` if you don't wish to install globally. If you don't wish to use npm:
```shell
git clone https://github.com/jashkenas/coffeescript.git
sudo coffeescript/bin/cake install
```
## Getting Started
Execute a script:
```shell
coffee /path/to/script.coffee
```
Compile a script:
```shell
coffee -c /path/to/script.coffee
```
For documentation, usage, and examples, see: http://coffeescript.org/
To suggest a feature or report a bug: http://github.com/jashkenas/coffeescript/issues
If you'd like to chat, drop by #coffeescript on Freenode IRC.
The source repository: https://github.com/jashkenas/coffeescript.git
Changelog: http://coffeescript.org/#changelog
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors

View File

@@ -1,78 +0,0 @@
require 'rubygems'
require 'erb'
require 'fileutils'
require 'rake/testtask'
require 'json'
desc "Build the documentation page"
task :doc do
source = 'documentation/index.html.erb'
child = fork { exec "bin/coffee -bcw -o documentation/js documentation/coffee/*.coffee" }
at_exit { Process.kill("INT", child) }
Signal.trap("INT") { exit }
loop do
mtime = File.stat(source).mtime
if !@mtime || mtime > @mtime
rendered = ERB.new(File.read(source)).result(binding)
File.open('index.html', 'w+') {|f| f.write(rendered) }
end
@mtime = mtime
sleep 1
end
end
desc "Build coffee-script-source gem"
task :gem do
require 'rubygems'
require 'rubygems/package'
gemspec = Gem::Specification.new do |s|
s.name = 'coffee-script-source'
s.version = JSON.parse(File.read('package.json'))["version"]
s.date = Time.now.strftime("%Y-%m-%d")
s.homepage = "http://jashkenas.github.com/coffee-script/"
s.summary = "The CoffeeScript Compiler"
s.description = <<-EOS
CoffeeScript is a little language that compiles into JavaScript.
Underneath all of those embarrassing braces and semicolons,
JavaScript has always had a gorgeous object model at its heart.
CoffeeScript is an attempt to expose the good parts of JavaScript
in a simple way.
EOS
s.files = [
'lib/coffee_script/coffee-script.js',
'lib/coffee_script/source.rb'
]
s.authors = ['Jeremy Ashkenas']
s.email = 'jashkenas@gmail.com'
s.rubyforge_project = 'coffee-script-source'
end
file = File.open("coffee-script-source.gem", "w")
Gem::Package.open(file, 'w') do |pkg|
pkg.metadata = gemspec.to_yaml
path = "lib/coffee_script/source.rb"
contents = <<-ERUBY
module CoffeeScript
module Source
def self.bundled_path
File.expand_path("../coffee-script.js", __FILE__)
end
end
end
ERUBY
pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
tar_io.write(contents)
end
contents = File.read("extras/coffee-script.js")
path = "lib/coffee_script/coffee-script.js"
pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
tar_io.write(contents)
end
end
end

19
bower.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "coffee-script",
"main": [
"lib/coffee-script/coffee-script.js"
],
"description": "Unfancy JavaScript",
"keywords": [
"javascript",
"language",
"coffeescript",
"compiler"
],
"author": {
"name": "Jeremy Ashkenas"
},
"ignore": [
"test"
]
}

1
docs/CNAME Normal file
View File

@@ -0,0 +1 @@
coffeescript.org

1
docs/index.html Symbolic link
View File

@@ -0,0 +1 @@
v1/index.html

1
docs/v1/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
examples/

View File

@@ -0,0 +1,299 @@
<!DOCTYPE html>
<html>
<head>
<title>browser.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>browser.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>This <strong>Browser</strong> compatibility layer extends core CoffeeScript functions
to make things work smoothly when compiling code directly in the browser.
We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
<code>text/coffeescript</code> script tags, source maps via data-URLs, and so on.</p>
</div>
<div class="content"><div class='highlight'><pre>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
CoffeeScript.<span class="hljs-built_in">require</span> = <span class="hljs-built_in">require</span>
compile = CoffeeScript.compile</pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Use standard JavaScript <code>eval</code> to eval code.</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
options.bare ?= <span class="hljs-literal">on</span>
eval compile code, options</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Running code does not provide access to this scope.</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.run = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
options.bare = <span class="hljs-literal">on</span>
options.shiftLine = <span class="hljs-literal">on</span>
Function(compile code, options)()</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>If were not in a browser environment, were finished with the public API.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> <span class="hljs-built_in">window</span>?</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Include source maps where possible. If weve got a base64 encoder, a
JSON serializer, and tools for escaping unicode characters, were good to go.
Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">https://developer.mozilla.org/en-US/docs/DOM/window.btoa</a></p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> btoa? <span class="hljs-keyword">and</span> JSON?
<span class="hljs-function"> <span class="hljs-title">compile</span> = <span class="hljs-params">(code, options = {})</span> -&gt;</span>
options.inlineMap = <span class="hljs-literal">true</span>
CoffeeScript.compile code, options</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Load a remote script from the current domain via XHR.</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.load = <span class="hljs-function"><span class="hljs-params">(url, callback, options = {}, hold = <span class="hljs-literal">false</span>)</span> -&gt;</span>
options.sourceFiles = [url]
xhr = <span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.ActiveXObject
<span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.ActiveXObject(<span class="hljs-string">'Microsoft.XMLHTTP'</span>)
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.XMLHttpRequest()
xhr.open <span class="hljs-string">'GET'</span>, url, <span class="hljs-literal">true</span>
xhr.overrideMimeType <span class="hljs-string">'text/plain'</span> <span class="hljs-keyword">if</span> <span class="hljs-string">'overrideMimeType'</span> <span class="hljs-keyword">of</span> xhr
xhr.onreadystatechange = <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">if</span> xhr.readyState <span class="hljs-keyword">is</span> <span class="hljs-number">4</span>
<span class="hljs-keyword">if</span> xhr.status <span class="hljs-keyword">in</span> [<span class="hljs-number">0</span>, <span class="hljs-number">200</span>]
param = [xhr.responseText, options]
CoffeeScript.run param... <span class="hljs-keyword">unless</span> hold
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Could not load <span class="hljs-subst">#{url}</span>"</span>
callback param <span class="hljs-keyword">if</span> callback
xhr.send <span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Activate CoffeeScript in the browser by having it compile and evaluate
all script tags with a content-type of <code>text/coffeescript</code>.
This happens on page load.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">runScripts</span> = -&gt;</span>
scripts = <span class="hljs-built_in">window</span>.<span class="hljs-built_in">document</span>.getElementsByTagName <span class="hljs-string">'script'</span>
coffeetypes = [<span class="hljs-string">'text/coffeescript'</span>, <span class="hljs-string">'text/literate-coffeescript'</span>]
coffees = (s <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> scripts <span class="hljs-keyword">when</span> s.type <span class="hljs-keyword">in</span> coffeetypes)
index = <span class="hljs-number">0</span>
<span class="hljs-function">
<span class="hljs-title">execute</span> = -&gt;</span>
param = coffees[index]
<span class="hljs-keyword">if</span> param <span class="hljs-keyword">instanceof</span> Array
CoffeeScript.run param...
index++
execute()
<span class="hljs-keyword">for</span> script, i <span class="hljs-keyword">in</span> coffees
<span class="hljs-keyword">do</span> (script, i) -&gt;
options = literate: script.type <span class="hljs-keyword">is</span> coffeetypes[<span class="hljs-number">1</span>]
source = script.src <span class="hljs-keyword">or</span> script.getAttribute(<span class="hljs-string">'data-src'</span>)
<span class="hljs-keyword">if</span> source
CoffeeScript.load source,
<span class="hljs-function"><span class="hljs-params">(param)</span> -&gt;</span>
coffees[i] = param
execute()
options
<span class="hljs-literal">true</span>
<span class="hljs-keyword">else</span>
options.sourceFiles = [<span class="hljs-string">'embedded'</span>]
coffees[i] = [script.innerHTML, options]
execute()</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Listen for window load, both in decent browsers and in IE.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.addEventListener
<span class="hljs-built_in">window</span>.addEventListener <span class="hljs-string">'DOMContentLoaded'</span>, runScripts, <span class="hljs-literal">no</span>
<span class="hljs-keyword">else</span>
<span class="hljs-built_in">window</span>.attachEvent <span class="hljs-string">'onload'</span>, runScripts</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,345 @@
<!DOCTYPE html>
<html>
<head>
<title>cake.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>cake.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p><code>cake</code> is a simplified version of <a href="http://www.gnu.org/software/make/">Make</a>
(<a href="http://rake.rubyforge.org/">Rake</a>, <a href="http://github.com/280north/jake">Jake</a>)
for CoffeeScript. You define tasks with names and descriptions in a Cakefile,
and can call them from the command line, or invoke them from other tasks.</p>
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the
current directorys Cakefile.</p>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>External dependencies.</p>
</div>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">'./optparse'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span></pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Register .coffee extension</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.register()</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Keep track of the list of defined tasks, the accepted options, and so on.</p>
</div>
<div class="content"><div class='highlight'><pre>tasks = {}
options = {}
switches = []
oparse = <span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Mixin the top-level Cake functions for Cakefiles to use directly.</p>
</div>
<div class="content"><div class='highlight'><pre>helpers.extend <span class="hljs-built_in">global</span>,</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Define a Cake task with a short name, an optional sentence description,
and the function to run as the action itself.</p>
</div>
<div class="content"><div class='highlight'><pre> task: <span class="hljs-function"><span class="hljs-params">(name, description, action)</span> -&gt;</span>
[action, description] = [description, action] <span class="hljs-keyword">unless</span> action
tasks[name] = {name, description, action}</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Define an option that the Cakefile accepts. The parsed options hash,
containing all of the command-line options passed, will be made available
as the first argument to the action.</p>
</div>
<div class="content"><div class='highlight'><pre> option: <span class="hljs-function"><span class="hljs-params">(letter, flag, description)</span> -&gt;</span>
switches.push [letter, flag, description]</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Invoke another task in the current Cakefile.</p>
</div>
<div class="content"><div class='highlight'><pre> invoke: <span class="hljs-function"><span class="hljs-params">(name)</span> -&gt;</span>
missingTask name <span class="hljs-keyword">unless</span> tasks[name]
tasks[name].action options</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Nodes
asynchrony may cause tasks to execute in a different order than youd expect.
If no tasks are passed, print the help screen. Keep a reference to the
original directory name, when running Cake tasks from subdirectories.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function">-&gt;</span>
<span class="hljs-built_in">global</span>.__originalDirname = fs.realpathSync <span class="hljs-string">'.'</span>
process.chdir cakefileDirectory __originalDirname
args = process.argv[<span class="hljs-number">2.</span>.]
CoffeeScript.run fs.readFileSync(<span class="hljs-string">'Cakefile'</span>).toString(), filename: <span class="hljs-string">'Cakefile'</span>
oparse = <span class="hljs-keyword">new</span> optparse.OptionParser switches
<span class="hljs-keyword">return</span> printTasks() <span class="hljs-keyword">unless</span> args.length
<span class="hljs-keyword">try</span>
options = oparse.parse(args)
<span class="hljs-keyword">catch</span> e
<span class="hljs-keyword">return</span> fatalError <span class="hljs-string">"<span class="hljs-subst">#{e}</span>"</span>
invoke arg <span class="hljs-keyword">for</span> arg <span class="hljs-keyword">in</span> options.arguments</pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Display the list of Cake tasks in a format similar to <code>rake -T</code></p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">printTasks</span> = -&gt;</span>
relative = path.relative <span class="hljs-keyword">or</span> path.resolve
cakefilePath = path.join relative(__originalDirname, process.cwd()), <span class="hljs-string">'Cakefile'</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"<span class="hljs-subst">#{cakefilePath}</span> defines the following tasks:\n"</span>
<span class="hljs-keyword">for</span> name, task <span class="hljs-keyword">of</span> tasks
spaces = <span class="hljs-number">20</span> - name.length
spaces = <span class="hljs-keyword">if</span> spaces &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> Array(spaces + <span class="hljs-number">1</span>).join(<span class="hljs-string">' '</span>) <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
desc = <span class="hljs-keyword">if</span> task.description <span class="hljs-keyword">then</span> <span class="hljs-string">"# <span class="hljs-subst">#{task.description}</span>"</span> <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"cake <span class="hljs-subst">#{name}</span><span class="hljs-subst">#{spaces}</span> <span class="hljs-subst">#{desc}</span>"</span>
<span class="hljs-built_in">console</span>.log oparse.help() <span class="hljs-keyword">if</span> switches.length</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Print an error and exit when attempting to use an invalid task/option.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">fatalError</span> = <span class="hljs-params">(message)</span> -&gt;</span>
<span class="hljs-built_in">console</span>.error message + <span class="hljs-string">'\n'</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">'To see a list of all tasks/options, run "cake"'</span>
process.exit <span class="hljs-number">1</span>
<span class="hljs-function">
<span class="hljs-title">missingTask</span> = <span class="hljs-params">(task)</span> -&gt;</span> fatalError <span class="hljs-string">"No such task: <span class="hljs-subst">#{task}</span>"</span></pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>When <code>cake</code> is invoked, search in the current and all parent directories
to find the relevant Cakefile.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">cakefileDirectory</span> = <span class="hljs-params">(dir)</span> -&gt;</span>
<span class="hljs-keyword">return</span> dir <span class="hljs-keyword">if</span> fs.existsSync path.join dir, <span class="hljs-string">'Cakefile'</span>
parent = path.normalize path.join dir, <span class="hljs-string">'..'</span>
<span class="hljs-keyword">return</span> cakefileDirectory parent <span class="hljs-keyword">unless</span> parent <span class="hljs-keyword">is</span> dir
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Cakefile not found in <span class="hljs-subst">#{process.cwd()}</span>"</span></pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,903 @@
<!DOCTYPE html>
<html>
<head>
<title>coffee-script.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>coffee-script.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>CoffeeScript can be used both on the server, as a command-line compiler based
on Node.js/V8, or to run CoffeeScript directly in the browser. This module
contains the main entry functions for tokenizing, parsing, and compiling
source CoffeeScript into JavaScript.</p>
</div>
<div class="content"><div class='highlight'><pre>
fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
{Lexer} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./lexer'</span>
{parser} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./parser'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
SourceMap = <span class="hljs-built_in">require</span> <span class="hljs-string">'./sourcemap'</span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>The current CoffeeScript version number.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.VERSION = <span class="hljs-string">'1.12.0'</span>
exports.FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'</span>, <span class="hljs-string">'.litcoffee'</span>, <span class="hljs-string">'.coffee.md'</span>]</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Expose helpers for testing.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.helpers = helpers</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Function that allows for btoa in both nodejs and the browser.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">base64encode</span> = <span class="hljs-params">(src)</span> -&gt;</span> <span class="hljs-keyword">switch</span>
<span class="hljs-keyword">when</span> <span class="hljs-keyword">typeof</span> Buffer <span class="hljs-keyword">is</span> <span class="hljs-string">'function'</span>
<span class="hljs-keyword">new</span> Buffer(src).toString(<span class="hljs-string">'base64'</span>)
<span class="hljs-keyword">when</span> <span class="hljs-keyword">typeof</span> btoa <span class="hljs-keyword">is</span> <span class="hljs-string">'function'</span></pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>The contents of a <code>&lt;script&gt;</code> block are encoded via UTF-16, so if any extended
characters are used in the block, btoa will fail as it maxes out at UTF-8.
See <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem">https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem</a>
for the gory details, and for the solution implemented here.</p>
</div>
<div class="content"><div class='highlight'><pre> btoa encodeURIComponent(src).replace <span class="hljs-regexp">/%([0-9A-F]{2})/g</span>, <span class="hljs-function"><span class="hljs-params">(match, p1)</span> -&gt;</span>
String.fromCharCode <span class="hljs-string">'0x'</span> + p1
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error(<span class="hljs-string">'Unable to base64 encode inline sourcemap.'</span>)</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Function wrapper to add source file information to SyntaxErrors thrown by the
lexer/parser/compiler.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">withPrettyErrors</span> = <span class="hljs-params">(fn)</span> -&gt;</span>
(code, options = {}) -&gt;
<span class="hljs-keyword">try</span>
fn.call @, code, options
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'string'</span> <span class="hljs-comment"># Support `CoffeeScript.nodes(tokens)`.</span>
<span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, code, options.filename</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.</p>
<p>If <code>options.sourceMap</code> is specified, then <code>options.filename</code> must also be specified. All
options that can be passed to <code>SourceMap#generate</code> may also be passed here.</p>
<p>This returns a javascript string, unless <code>options.sourceMap</code> is passed,
in which case this returns a <code>{js, v3SourceMap, sourceMap}</code>
object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic
lookups.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.compile = compile = withPrettyErrors (code, options) -&gt;
{merge, extend} = helpers
options = extend {}, options
generateSourceMap = options.sourceMap <span class="hljs-keyword">or</span> options.inlineMap
<span class="hljs-keyword">if</span> generateSourceMap
map = <span class="hljs-keyword">new</span> SourceMap
tokens = lexer.tokenize code, options</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Pass a list of referenced variables, so that generated variables wont get
the same name.</p>
</div>
<div class="content"><div class='highlight'><pre> options.referencedVars = (
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'IDENTIFIER'</span>
)</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Check for import or export; if found, force bare mode</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> options.bare? <span class="hljs-keyword">and</span> options.bare <span class="hljs-keyword">is</span> <span class="hljs-literal">yes</span>
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens
<span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'IMPORT'</span>, <span class="hljs-string">'EXPORT'</span>]
options.bare = <span class="hljs-literal">yes</span>
<span class="hljs-keyword">break</span>
fragments = parser.parse(tokens).compileToFragments options
currentLine = <span class="hljs-number">0</span>
currentLine += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> options.header
currentLine += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> options.shiftLine
currentColumn = <span class="hljs-number">0</span>
js = <span class="hljs-string">""</span>
<span class="hljs-keyword">for</span> fragment <span class="hljs-keyword">in</span> fragments</pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Update the sourcemap with data from each fragment</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> generateSourceMap</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Do not include empty, whitespace, or semicolon-only fragments.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> fragment.locationData <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> <span class="hljs-regexp">/^[;\s]*$/</span>.test fragment.code
map.add(
[fragment.locationData.first_line, fragment.locationData.first_column]
[currentLine, currentColumn]
{noReplace: <span class="hljs-literal">true</span>})
newLines = helpers.count fragment.code, <span class="hljs-string">"\n"</span>
currentLine += newLines
<span class="hljs-keyword">if</span> newLines
currentColumn = fragment.code.length - (fragment.code.lastIndexOf(<span class="hljs-string">"\n"</span>) + <span class="hljs-number">1</span>)
<span class="hljs-keyword">else</span>
currentColumn += fragment.code.length</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Copy the code from each fragment into the final JavaScript.</p>
</div>
<div class="content"><div class='highlight'><pre> js += fragment.code
<span class="hljs-keyword">if</span> options.header
header = <span class="hljs-string">"Generated by CoffeeScript <span class="hljs-subst">#{@VERSION}</span>"</span>
js = <span class="hljs-string">"// <span class="hljs-subst">#{header}</span>\n<span class="hljs-subst">#{js}</span>"</span>
<span class="hljs-keyword">if</span> generateSourceMap
v3SourceMap = map.generate(options, code)
<span class="hljs-keyword">if</span> options.inlineMap
encoded = base64encode JSON.stringify v3SourceMap
sourceMapDataURI = <span class="hljs-string">"//# sourceMappingURL=data:application/json;base64,<span class="hljs-subst">#{encoded}</span>"</span>
sourceURL = <span class="hljs-string">"//# sourceURL=<span class="hljs-subst">#{options.filename ? <span class="hljs-string">'coffeescript'</span>}</span>"</span>
js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n<span class="hljs-subst">#{sourceMapDataURI}</span>\n<span class="hljs-subst">#{sourceURL}</span>"</span>
<span class="hljs-keyword">if</span> options.sourceMap
{
js
sourceMap: map
v3SourceMap: JSON.stringify v3SourceMap, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>
}
<span class="hljs-keyword">else</span>
js</pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.tokens = withPrettyErrors (code, options) -&gt;
lexer.tokenize code, options</pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.nodes = withPrettyErrors (source, options) -&gt;
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> source <span class="hljs-keyword">is</span> <span class="hljs-string">'string'</span>
parser.parse lexer.tokenize source, options
<span class="hljs-keyword">else</span>
parser.parse source</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Compile and execute a string of CoffeeScript (on the server), correctly
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
mainModule = <span class="hljs-built_in">require</span>.main</pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Set the filename.</p>
</div>
<div class="content"><div class='highlight'><pre> mainModule.filename = process.argv[<span class="hljs-number">1</span>] =
<span class="hljs-keyword">if</span> options.filename <span class="hljs-keyword">then</span> fs.realpathSync(options.filename) <span class="hljs-keyword">else</span> <span class="hljs-string">'.'</span></pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Clear the module cache.</p>
</div>
<div class="content"><div class='highlight'><pre> mainModule.moduleCache <span class="hljs-keyword">and</span>= {}</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Assign paths for node_modules loading</p>
</div>
<div class="content"><div class='highlight'><pre> dir = <span class="hljs-keyword">if</span> options.filename
path.dirname fs.realpathSync options.filename
<span class="hljs-keyword">else</span>
fs.realpathSync <span class="hljs-string">'.'</span>
mainModule.paths = <span class="hljs-built_in">require</span>(<span class="hljs-string">'module'</span>)._nodeModulePaths dir</pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Compile.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> helpers.isCoffee(mainModule.filename) <span class="hljs-keyword">or</span> <span class="hljs-built_in">require</span>.extensions
answer = compile code, options
code = answer.js ? answer
mainModule._compile code, mainModule.filename</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
The CoffeeScript REPL uses this to run the input.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> code = code.trim()
createContext = vm.Script.createContext ? vm.createContext
isContext = vm.isContext ? (ctx) -&gt;
options.sandbox <span class="hljs-keyword">instanceof</span> createContext().constructor
<span class="hljs-keyword">if</span> createContext
<span class="hljs-keyword">if</span> options.sandbox?
<span class="hljs-keyword">if</span> isContext options.sandbox
sandbox = options.sandbox
<span class="hljs-keyword">else</span>
sandbox = createContext()
sandbox[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options.sandbox
sandbox.<span class="hljs-built_in">global</span> = sandbox.root = sandbox.GLOBAL = sandbox
<span class="hljs-keyword">else</span>
sandbox = <span class="hljs-built_in">global</span>
sandbox.__filename = options.filename || <span class="hljs-string">'eval'</span>
sandbox.__dirname = path.dirname sandbox.__filename</pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>define module/require only if they chose not to specify their own</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> sandbox <span class="hljs-keyword">isnt</span> <span class="hljs-built_in">global</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">module</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">require</span>
Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
sandbox.<span class="hljs-built_in">module</span> = _module = <span class="hljs-keyword">new</span> Module(options.modulename || <span class="hljs-string">'eval'</span>)
sandbox.<span class="hljs-built_in">require</span> = _require = <span class="hljs-function"><span class="hljs-params">(path)</span> -&gt;</span> Module._load path, _module, <span class="hljs-literal">true</span>
_module.filename = sandbox.__filename
<span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'paths'</span>, <span class="hljs-string">'arguments'</span>, <span class="hljs-string">'caller'</span>]
_require[r] = <span class="hljs-built_in">require</span>[r]</pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>use the same hack node currently uses for their own REPL</p>
</div>
<div class="content"><div class='highlight'><pre> _require.paths = _module.paths = Module._nodeModulePaths process.cwd()
_require.resolve = <span class="hljs-function"><span class="hljs-params">(request)</span> -&gt;</span> Module._resolveFilename request, _module
o = {}
o[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options
o.bare = <span class="hljs-literal">on</span> <span class="hljs-comment"># ensure return value</span>
js = compile code, o
<span class="hljs-keyword">if</span> sandbox <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
vm.runInThisContext js
<span class="hljs-keyword">else</span>
vm.runInContext js, sandbox
exports.register = <span class="hljs-function">-&gt;</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</span></pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Throw error with deprecation warning when depending upon implicit <code>require.extensions</code> registration</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.extensions
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> @FILE_EXTENSIONS <span class="hljs-keyword">then</span> <span class="hljs-keyword">do</span> (ext) -&gt;
<span class="hljs-built_in">require</span>.extensions[ext] ?= <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"""
Use CoffeeScript.register() or require the coffee-script/register module to require <span class="hljs-subst">#{ext}</span> files.
"""</span>
exports._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, sourceMap = <span class="hljs-literal">no</span>, inlineMap = <span class="hljs-literal">no</span>)</span> -&gt;</span>
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span>
stripped = <span class="hljs-keyword">if</span> raw.charCodeAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-number">0xFEFF</span> <span class="hljs-keyword">then</span> raw.substring <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> raw
<span class="hljs-keyword">try</span>
answer = compile stripped, {
filename, sourceMap, inlineMap
sourceFiles: [filename]
literate: helpers.isLiterate filename
}
<span class="hljs-keyword">catch</span> err</pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>As the filename and code of a dynamically loaded file will be different
from the original file compiled with CoffeeScript.run, add that
information to error so it can be pretty-printed later.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, stripped, filename
answer</pre></div></div>
</li>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Instantiate a Lexer for our use here.</p>
</div>
<div class="content"><div class='highlight'><pre>lexer = <span class="hljs-keyword">new</span> Lexer</pre></div></div>
</li>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>The real Lexer produces a generic stream of tokens. This object provides a
thin wrapper around it, compatible with the Jison API. We can then pass it
directly as a “Jison lexer”.</p>
</div>
<div class="content"><div class='highlight'><pre>parser.lexer =
lex: <span class="hljs-function">-&gt;</span>
token = parser.tokens[@pos++]
<span class="hljs-keyword">if</span> token
[tag, @yytext, @yylloc] = token
parser.errorToken = token.origin <span class="hljs-keyword">or</span> token
@yylineno = @yylloc.first_line
<span class="hljs-keyword">else</span>
tag = <span class="hljs-string">''</span>
tag
setInput: <span class="hljs-function"><span class="hljs-params">(tokens)</span> -&gt;</span>
parser.tokens = tokens
@pos = <span class="hljs-number">0</span>
upcomingInput: <span class="hljs-function">-&gt;</span>
<span class="hljs-string">""</span></pre></div></div>
</li>
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Make all the AST nodes visible to the parser.</p>
</div>
<div class="content"><div class='highlight'><pre>parser.yy = <span class="hljs-built_in">require</span> <span class="hljs-string">'./nodes'</span></pre></div></div>
</li>
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>Override Jisons default error handling function.</p>
</div>
<div class="content"><div class='highlight'><pre>parser.yy.parseError = <span class="hljs-function"><span class="hljs-params">(message, {token})</span> -&gt;</span></pre></div></div>
</li>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>Disregard Jisons message, it contains redundant line number information.
Disregard the token, we take its value directly from the lexer in case
the error is caused by a generated token which might refer to its origin.</p>
</div>
<div class="content"><div class='highlight'><pre> {errorToken, tokens} = parser
[errorTag, errorText, errorLoc] = errorToken
errorText = <span class="hljs-keyword">switch</span>
<span class="hljs-keyword">when</span> errorToken <span class="hljs-keyword">is</span> tokens[tokens.length - <span class="hljs-number">1</span>]
<span class="hljs-string">'end of input'</span>
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'INDENT'</span>, <span class="hljs-string">'OUTDENT'</span>]
<span class="hljs-string">'indentation'</span>
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'INFINITY'</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>]
errorTag.replace(<span class="hljs-regexp">/_START$/</span>, <span class="hljs-string">''</span>).toLowerCase()
<span class="hljs-keyword">else</span>
helpers.nameWhitespaceCharacter errorText</pre></div></div>
</li>
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>The second argument has a <code>loc</code> property, which should have the location
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
(from the previous token), so we take the location information directly
from the lexer.</p>
</div>
<div class="content"><div class='highlight'><pre> helpers.throwSyntaxError <span class="hljs-string">"unexpected <span class="hljs-subst">#{errorText}</span>"</span>, errorLoc</pre></div></div>
</li>
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
</div>
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
Modified to handle sourceMap</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">formatSourcePosition</span> = <span class="hljs-params">(frame, getSourceMapping)</span> -&gt;</span>
fileName = <span class="hljs-literal">undefined</span>
fileLocation = <span class="hljs-string">''</span>
<span class="hljs-keyword">if</span> frame.isNative()
fileLocation = <span class="hljs-string">"native"</span>
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">if</span> frame.isEval()
fileName = frame.getScriptNameOrSourceURL()
fileLocation = <span class="hljs-string">"<span class="hljs-subst">#{frame.getEvalOrigin()}</span>, "</span> <span class="hljs-keyword">unless</span> fileName
<span class="hljs-keyword">else</span>
fileName = frame.getFileName()
fileName <span class="hljs-keyword">or</span>= <span class="hljs-string">"&lt;anonymous&gt;"</span>
line = frame.getLineNumber()
column = frame.getColumnNumber()</pre></div></div>
</li>
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
</div>
<p>Check for a sourceMap position</p>
</div>
<div class="content"><div class='highlight'><pre> source = getSourceMapping fileName, line, column
fileLocation =
<span class="hljs-keyword">if</span> source
<span class="hljs-string">"<span class="hljs-subst">#{fileName}</span>:<span class="hljs-subst">#{source[<span class="hljs-number">0</span>]}</span>:<span class="hljs-subst">#{source[<span class="hljs-number">1</span>]}</span>"</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"<span class="hljs-subst">#{fileName}</span>:<span class="hljs-subst">#{line}</span>:<span class="hljs-subst">#{column}</span>"</span>
functionName = frame.getFunctionName()
isConstructor = frame.isConstructor()
isMethodCall = <span class="hljs-keyword">not</span> (frame.isToplevel() <span class="hljs-keyword">or</span> isConstructor)
<span class="hljs-keyword">if</span> isMethodCall
methodName = frame.getMethodName()
typeName = frame.getTypeName()
<span class="hljs-keyword">if</span> functionName
tp = <span class="hljs-keyword">as</span> = <span class="hljs-string">''</span>
<span class="hljs-keyword">if</span> typeName <span class="hljs-keyword">and</span> functionName.indexOf typeName
tp = <span class="hljs-string">"<span class="hljs-subst">#{typeName}</span>."</span>
<span class="hljs-keyword">if</span> methodName <span class="hljs-keyword">and</span> functionName.indexOf(<span class="hljs-string">".<span class="hljs-subst">#{methodName}</span>"</span>) <span class="hljs-keyword">isnt</span> functionName.length - methodName.length - <span class="hljs-number">1</span>
<span class="hljs-keyword">as</span> = <span class="hljs-string">" [as <span class="hljs-subst">#{methodName}</span>]"</span>
<span class="hljs-string">"<span class="hljs-subst">#{tp}</span><span class="hljs-subst">#{functionName}</span><span class="hljs-subst">#{<span class="hljs-keyword">as</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)"</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"<span class="hljs-subst">#{typeName}</span>.<span class="hljs-subst">#{methodName <span class="hljs-keyword">or</span> <span class="hljs-string">'&lt;anonymous&gt;'</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)"</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> isConstructor
<span class="hljs-string">"new <span class="hljs-subst">#{functionName <span class="hljs-keyword">or</span> <span class="hljs-string">'&lt;anonymous&gt;'</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)"</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> functionName
<span class="hljs-string">"<span class="hljs-subst">#{functionName}</span> (<span class="hljs-subst">#{fileLocation}</span>)"</span>
<span class="hljs-keyword">else</span>
fileLocation</pre></div></div>
</li>
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
</div>
<p>Map of filenames -&gt; sourceMap object.</p>
</div>
<div class="content"><div class='highlight'><pre>sourceMaps = {}</pre></div></div>
</li>
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
</div>
<p>Generates the source map for a coffee file and stores it in the local cache variable.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">getSourceMap</span> = <span class="hljs-params">(filename)</span> -&gt;</span>
<span class="hljs-keyword">return</span> sourceMaps[filename] <span class="hljs-keyword">if</span> sourceMaps[filename]
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> exports.FILE_EXTENSIONS
<span class="hljs-keyword">if</span> helpers.ends filename, ext
answer = exports._compileFile filename, <span class="hljs-literal">true</span>
<span class="hljs-keyword">return</span> sourceMaps[filename] = answer.sourceMap
<span class="hljs-keyword">return</span> <span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-35">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a>
</div>
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
NodeJS / V8 have no support for transforming positions in stack traces using
sourceMap, so we must monkey-patch Error to display CoffeeScript source
positions.</p>
</div>
<div class="content"><div class='highlight'><pre>Error.prepareStackTrace = <span class="hljs-function"><span class="hljs-params">(err, stack)</span> -&gt;</span>
<span class="hljs-function"> <span class="hljs-title">getSourceMapping</span> = <span class="hljs-params">(filename, line, column)</span> -&gt;</span>
sourceMap = getSourceMap filename
answer = sourceMap.sourceLocation [line - <span class="hljs-number">1</span>, column - <span class="hljs-number">1</span>] <span class="hljs-keyword">if</span> sourceMap
<span class="hljs-keyword">if</span> answer <span class="hljs-keyword">then</span> [answer[<span class="hljs-number">0</span>] + <span class="hljs-number">1</span>, answer[<span class="hljs-number">1</span>] + <span class="hljs-number">1</span>] <span class="hljs-keyword">else</span> <span class="hljs-literal">null</span>
frames = <span class="hljs-keyword">for</span> frame <span class="hljs-keyword">in</span> stack
<span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> frame.getFunction() <span class="hljs-keyword">is</span> exports.run
<span class="hljs-string">" at <span class="hljs-subst">#{formatSourcePosition frame, getSourceMapping}</span>"</span>
<span class="hljs-string">"<span class="hljs-subst">#{err.toString()}</span>\n<span class="hljs-subst">#{frames.join <span class="hljs-string">'\n'</span>}</span>\n"</span></pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,882 @@
<!DOCTYPE html>
<html>
<head>
<title>command.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>command.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>The <code>coffee</code> utility. Handles command-line compilation of CoffeeScript
into various forms: saved into <code>.js</code> files or printed to stdout
or recompiled every time the source is saved,
printed as a token stream or as the syntax tree, or launch an
interactive REPL.</p>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>External dependencies.</p>
</div>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">'./optparse'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
{spawn, exec} = <span class="hljs-built_in">require</span> <span class="hljs-string">'child_process'</span>
{EventEmitter} = <span class="hljs-built_in">require</span> <span class="hljs-string">'events'</span>
useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs-string">'\\'</span></pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Allow CoffeeScript to emit Node.js events.</p>
</div>
<div class="content"><div class='highlight'><pre>helpers.extend CoffeeScript, <span class="hljs-keyword">new</span> EventEmitter
<span class="hljs-function">
<span class="hljs-title">printLine</span> = <span class="hljs-params">(line)</span> -&gt;</span> process.stdout.write line + <span class="hljs-string">'\n'</span>
<span class="hljs-function"><span class="hljs-title">printWarn</span> = <span class="hljs-params">(line)</span> -&gt;</span> process.stderr.write line + <span class="hljs-string">'\n'</span>
<span class="hljs-function">
<span class="hljs-title">hidden</span> = <span class="hljs-params">(file)</span> -&gt;</span> <span class="hljs-regexp">/^\.|~$/</span>.test file</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>The help banner that is printed in conjunction with <code>-h</code>/<code>--help</code>.</p>
</div>
<div class="content"><div class='highlight'><pre>BANNER = <span class="hljs-string">'''
Usage: coffee [options] path/to/script.coffee -- [args]
If called without options, `coffee` will run your script.
'''</span></pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>The list of all the valid option flags that <code>coffee</code> knows how to handle.</p>
</div>
<div class="content"><div class='highlight'><pre>SWITCHES = [
[<span class="hljs-string">'-b'</span>, <span class="hljs-string">'--bare'</span>, <span class="hljs-string">'compile without a top-level function wrapper'</span>]
[<span class="hljs-string">'-c'</span>, <span class="hljs-string">'--compile'</span>, <span class="hljs-string">'compile to JavaScript and save as .js files'</span>]
[<span class="hljs-string">'-e'</span>, <span class="hljs-string">'--eval'</span>, <span class="hljs-string">'pass a string from the command line as input'</span>]
[<span class="hljs-string">'-h'</span>, <span class="hljs-string">'--help'</span>, <span class="hljs-string">'display this help message'</span>]
[<span class="hljs-string">'-i'</span>, <span class="hljs-string">'--interactive'</span>, <span class="hljs-string">'run an interactive CoffeeScript REPL'</span>]
[<span class="hljs-string">'-j'</span>, <span class="hljs-string">'--join [FILE]'</span>, <span class="hljs-string">'concatenate the source CoffeeScript before compiling'</span>]
[<span class="hljs-string">'-m'</span>, <span class="hljs-string">'--map'</span>, <span class="hljs-string">'generate source map and save as .js.map files'</span>]
[<span class="hljs-string">'-M'</span>, <span class="hljs-string">'--inline-map'</span>, <span class="hljs-string">'generate source map and include it directly in output'</span>]
[<span class="hljs-string">'-n'</span>, <span class="hljs-string">'--nodes'</span>, <span class="hljs-string">'print out the parse tree that the parser produces'</span>]
[ <span class="hljs-string">'--nodejs [ARGS]'</span>, <span class="hljs-string">'pass options directly to the "node" binary'</span>]
[ <span class="hljs-string">'--no-header'</span>, <span class="hljs-string">'suppress the "Generated by" header'</span>]
[<span class="hljs-string">'-o'</span>, <span class="hljs-string">'--output [DIR]'</span>, <span class="hljs-string">'set the output directory for compiled JavaScript'</span>]
[<span class="hljs-string">'-p'</span>, <span class="hljs-string">'--print'</span>, <span class="hljs-string">'print out the compiled JavaScript'</span>]
[<span class="hljs-string">'-r'</span>, <span class="hljs-string">'--require [MODULE*]'</span>, <span class="hljs-string">'require the given module before eval or REPL'</span>]
[<span class="hljs-string">'-s'</span>, <span class="hljs-string">'--stdio'</span>, <span class="hljs-string">'listen for and compile scripts over stdio'</span>]
[<span class="hljs-string">'-l'</span>, <span class="hljs-string">'--literate'</span>, <span class="hljs-string">'treat stdio as literate style coffee-script'</span>]
[<span class="hljs-string">'-t'</span>, <span class="hljs-string">'--tokens'</span>, <span class="hljs-string">'print out the tokens that the lexer/rewriter produce'</span>]
[<span class="hljs-string">'-v'</span>, <span class="hljs-string">'--version'</span>, <span class="hljs-string">'display the version number'</span>]
[<span class="hljs-string">'-w'</span>, <span class="hljs-string">'--watch'</span>, <span class="hljs-string">'watch scripts for changes and rerun commands'</span>]
]</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Top-level objects shared by all the functions.</p>
</div>
<div class="content"><div class='highlight'><pre>opts = {}
sources = []
sourceCode = []
notSources = {}
watchedDirs = {}
optionParser = <span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Run <code>coffee</code> by parsing passed options and determining what action to take.
Many flags cause us to divert before compiling anything. Flags passed after
<code>--</code> will be passed verbatim to your script as arguments in <code>process.argv</code></p>
</div>
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function">-&gt;</span>
parseOptions()</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Make the REPL <em>CLI</em> use the global context so as to (a) be consistent with the
<code>node</code> REPL CLI and, therefore, (b) make packages that modify native prototypes
(such as colors and sugar) work as expected.</p>
</div>
<div class="content"><div class='highlight'><pre> replCliOpts = useGlobal: <span class="hljs-literal">yes</span>
opts.prelude = makePrelude opts.<span class="hljs-built_in">require</span> <span class="hljs-keyword">if</span> opts.<span class="hljs-built_in">require</span>
replCliOpts.prelude = opts.prelude
<span class="hljs-keyword">return</span> forkNode() <span class="hljs-keyword">if</span> opts.nodejs
<span class="hljs-keyword">return</span> usage() <span class="hljs-keyword">if</span> opts.help
<span class="hljs-keyword">return</span> version() <span class="hljs-keyword">if</span> opts.version
<span class="hljs-keyword">return</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'./repl'</span>).start(replCliOpts) <span class="hljs-keyword">if</span> opts.interactive
<span class="hljs-keyword">return</span> compileStdio() <span class="hljs-keyword">if</span> opts.stdio
<span class="hljs-keyword">return</span> compileScript <span class="hljs-literal">null</span>, opts.arguments[<span class="hljs-number">0</span>] <span class="hljs-keyword">if</span> opts.eval
<span class="hljs-keyword">return</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'./repl'</span>).start(replCliOpts) <span class="hljs-keyword">unless</span> opts.arguments.length
literals = <span class="hljs-keyword">if</span> opts.run <span class="hljs-keyword">then</span> opts.arguments.splice <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> []
process.argv = process.argv[<span class="hljs-number">0.</span><span class="hljs-number">.1</span>].concat literals
process.argv[<span class="hljs-number">0</span>] = <span class="hljs-string">'coffee'</span>
opts.output = path.resolve opts.output <span class="hljs-keyword">if</span> opts.output
<span class="hljs-keyword">if</span> opts.join
opts.join = path.resolve opts.join
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
The --join option is deprecated and will be removed in a future version.
If for some reason it's necessary to share local variables between files,
replace...
$ coffee --compile --join bundle.js -- a.coffee b.coffee c.coffee
with...
$ cat a.coffee b.coffee c.coffee | coffee --compile --stdio &gt; bundle.js
'''</span>
<span class="hljs-keyword">for</span> source <span class="hljs-keyword">in</span> opts.arguments
source = path.resolve source
compilePath source, <span class="hljs-literal">yes</span>, source
<span class="hljs-function">
<span class="hljs-title">makePrelude</span> = <span class="hljs-params">(requires)</span> -&gt;</span>
requires.map (<span class="hljs-built_in">module</span>) -&gt;
[_, name, <span class="hljs-built_in">module</span>] = match <span class="hljs-keyword">if</span> match = <span class="hljs-built_in">module</span>.match(<span class="hljs-regexp">/^(.*)=(.*)$/</span>)
name ||= helpers.baseFileName <span class="hljs-built_in">module</span>, <span class="hljs-literal">yes</span>, useWinPathSep
<span class="hljs-string">"<span class="hljs-subst">#{name}</span> = require('<span class="hljs-subst">#{<span class="hljs-built_in">module</span>}</span>')"</span>
.join <span class="hljs-string">';'</span></pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Compile a path, which could be a script or a directory. If a directory
is passed, recursively compile all .coffee, .litcoffee, and .coffee.md
extension source files in it and all subdirectories.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compilePath</span> = <span class="hljs-params">(source, topLevel, base)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> source <span class="hljs-keyword">in</span> sources <span class="hljs-keyword">or</span>
watchedDirs[source] <span class="hljs-keyword">or</span>
<span class="hljs-keyword">not</span> topLevel <span class="hljs-keyword">and</span> (notSources[source] <span class="hljs-keyword">or</span> hidden source)
<span class="hljs-keyword">try</span>
stats = fs.statSync source
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"File not found: <span class="hljs-subst">#{source}</span>"</span>
process.exit <span class="hljs-number">1</span>
<span class="hljs-keyword">throw</span> err
<span class="hljs-keyword">if</span> stats.isDirectory()
<span class="hljs-keyword">if</span> path.basename(source) <span class="hljs-keyword">is</span> <span class="hljs-string">'node_modules'</span>
notSources[source] = <span class="hljs-literal">yes</span>
<span class="hljs-keyword">return</span>
<span class="hljs-keyword">if</span> opts.run
compilePath findDirectoryIndex(source), topLevel, base
<span class="hljs-keyword">return</span>
watchDir source, base <span class="hljs-keyword">if</span> opts.watch
<span class="hljs-keyword">try</span>
files = fs.readdirSync source
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span> <span class="hljs-keyword">then</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> err
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> files
compilePath (path.join source, file), <span class="hljs-literal">no</span>, base
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> topLevel <span class="hljs-keyword">or</span> helpers.isCoffee source
sources.push source
sourceCode.push <span class="hljs-literal">null</span>
<span class="hljs-keyword">delete</span> notSources[source]
watch source, base <span class="hljs-keyword">if</span> opts.watch
<span class="hljs-keyword">try</span>
code = fs.readFileSync source
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span> <span class="hljs-keyword">then</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> err
compileScript(source, code.toString(), base)
<span class="hljs-keyword">else</span>
notSources[source] = <span class="hljs-literal">yes</span>
<span class="hljs-function">
<span class="hljs-title">findDirectoryIndex</span> = <span class="hljs-params">(source)</span> -&gt;</span>
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> CoffeeScript.FILE_EXTENSIONS
index = path.join source, <span class="hljs-string">"index<span class="hljs-subst">#{ext}</span>"</span>
<span class="hljs-keyword">try</span>
<span class="hljs-keyword">return</span> index <span class="hljs-keyword">if</span> (fs.statSync index).isFile()
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"Missing index.coffee or index.litcoffee in <span class="hljs-subst">#{source}</span>"</span>
process.exit <span class="hljs-number">1</span></pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Compile a single source script, containing the given code, according to the
requested options. If evaluating the script directly sets <code>__filename</code>,
<code>__dirname</code> and <code>module.filename</code> to be correct relative to the scripts path.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compileScript</span> = <span class="hljs-params">(file, input, base = <span class="hljs-literal">null</span>)</span> -&gt;</span>
o = opts
options = compileOptions file, base
<span class="hljs-keyword">try</span>
t = task = {file, input, options}
CoffeeScript.emit <span class="hljs-string">'compile'</span>, task
<span class="hljs-keyword">if</span> o.tokens
printTokens CoffeeScript.tokens t.input, t.options
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.nodes
printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.run
CoffeeScript.register()
CoffeeScript.eval opts.prelude, t.options <span class="hljs-keyword">if</span> opts.prelude
CoffeeScript.run t.input, t.options
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.join <span class="hljs-keyword">and</span> t.file <span class="hljs-keyword">isnt</span> o.join
t.input = helpers.invertLiterate t.input <span class="hljs-keyword">if</span> helpers.isLiterate file
sourceCode[sources.indexOf(t.file)] = t.input
compileJoin()
<span class="hljs-keyword">else</span>
compiled = CoffeeScript.compile t.input, t.options
t.output = compiled
<span class="hljs-keyword">if</span> o.map
t.output = compiled.js
t.sourceMap = compiled.v3SourceMap
CoffeeScript.emit <span class="hljs-string">'success'</span>, task
<span class="hljs-keyword">if</span> o.<span class="hljs-built_in">print</span>
printLine t.output.trim()
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.compile <span class="hljs-keyword">or</span> o.map
writeJs base, t.file, t.output, options.jsPath, t.sourceMap
<span class="hljs-keyword">catch</span> err
CoffeeScript.emit <span class="hljs-string">'failure'</span>, err, task
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> CoffeeScript.listeners(<span class="hljs-string">'failure'</span>).length
message = err?.stack <span class="hljs-keyword">or</span> <span class="hljs-string">"<span class="hljs-subst">#{err}</span>"</span>
<span class="hljs-keyword">if</span> o.watch
printLine message + <span class="hljs-string">'\x07'</span>
<span class="hljs-keyword">else</span>
printWarn message
process.exit <span class="hljs-number">1</span></pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>,
and write them back to <strong>stdout</strong>.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compileStdio</span> = -&gt;</span>
buffers = []
stdin = process.openStdin()
stdin.<span class="hljs-literal">on</span> <span class="hljs-string">'data'</span>, <span class="hljs-function"><span class="hljs-params">(buffer)</span> -&gt;</span>
buffers.push buffer <span class="hljs-keyword">if</span> buffer
stdin.<span class="hljs-literal">on</span> <span class="hljs-string">'end'</span>, <span class="hljs-function">-&gt;</span>
compileScript <span class="hljs-literal">null</span>, Buffer.concat(buffers).toString()</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>If all of the source files are done being read, concatenate and compile
them together.</p>
</div>
<div class="content"><div class='highlight'><pre>joinTimeout = <span class="hljs-literal">null</span>
<span class="hljs-function"><span class="hljs-title">compileJoin</span> = -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> opts.join
<span class="hljs-keyword">unless</span> sourceCode.some(<span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span> code <span class="hljs-keyword">is</span> <span class="hljs-literal">null</span>)
clearTimeout joinTimeout
joinTimeout = wait <span class="hljs-number">100</span>, <span class="hljs-function">-&gt;</span>
compileScript opts.join, sourceCode.join(<span class="hljs-string">'\n'</span>), opts.join</pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Watch a source CoffeeScript file using <code>fs.watch</code>, recompiling it every
time the file is updated. May be used in combination with other options,
such as <code>--print</code>.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">watch</span> = <span class="hljs-params">(source, base)</span> -&gt;</span>
watcher = <span class="hljs-literal">null</span>
prevStats = <span class="hljs-literal">null</span>
compileTimeout = <span class="hljs-literal">null</span>
<span class="hljs-function">
<span class="hljs-title">watchErr</span> = <span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> source <span class="hljs-keyword">in</span> sources
<span class="hljs-keyword">try</span>
rewatch()
compile()
<span class="hljs-keyword">catch</span>
removeSource source, base
compileJoin()
<span class="hljs-function">
<span class="hljs-title">compile</span> = -&gt;</span>
clearTimeout compileTimeout
compileTimeout = wait <span class="hljs-number">25</span>, <span class="hljs-function">-&gt;</span>
fs.stat source, <span class="hljs-function"><span class="hljs-params">(err, stats)</span> -&gt;</span>
<span class="hljs-keyword">return</span> watchErr err <span class="hljs-keyword">if</span> err
<span class="hljs-keyword">return</span> rewatch() <span class="hljs-keyword">if</span> prevStats <span class="hljs-keyword">and</span>
stats.size <span class="hljs-keyword">is</span> prevStats.size <span class="hljs-keyword">and</span>
stats.mtime.getTime() <span class="hljs-keyword">is</span> prevStats.mtime.getTime()
prevStats = stats
fs.readFile source, <span class="hljs-function"><span class="hljs-params">(err, code)</span> -&gt;</span>
<span class="hljs-keyword">return</span> watchErr err <span class="hljs-keyword">if</span> err
compileScript(source, code.toString(), base)
rewatch()
<span class="hljs-function">
<span class="hljs-title">startWatcher</span> = -&gt;</span>
watcher = fs.watch source
.<span class="hljs-literal">on</span> <span class="hljs-string">'change'</span>, compile
.<span class="hljs-literal">on</span> <span class="hljs-string">'error'</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'EPERM'</span>
removeSource source, base
<span class="hljs-function">
<span class="hljs-title">rewatch</span> = -&gt;</span>
watcher?.close()
startWatcher()
<span class="hljs-keyword">try</span>
startWatcher()
<span class="hljs-keyword">catch</span> err
watchErr err</pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Watch a directory of files for new additions.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">watchDir</span> = <span class="hljs-params">(source, base)</span> -&gt;</span>
watcher = <span class="hljs-literal">null</span>
readdirTimeout = <span class="hljs-literal">null</span>
<span class="hljs-function">
<span class="hljs-title">startWatcher</span> = -&gt;</span>
watcher = fs.watch source
.<span class="hljs-literal">on</span> <span class="hljs-string">'error'</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'EPERM'</span>
stopWatcher()
.<span class="hljs-literal">on</span> <span class="hljs-string">'change'</span>, <span class="hljs-function">-&gt;</span>
clearTimeout readdirTimeout
readdirTimeout = wait <span class="hljs-number">25</span>, <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">try</span>
files = fs.readdirSync source
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-keyword">return</span> stopWatcher()
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> files
compilePath (path.join source, file), <span class="hljs-literal">no</span>, base
<span class="hljs-function">
<span class="hljs-title">stopWatcher</span> = -&gt;</span>
watcher.close()
removeSourceDir source, base
watchedDirs[source] = <span class="hljs-literal">yes</span>
<span class="hljs-keyword">try</span>
startWatcher()
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-function">
<span class="hljs-title">removeSourceDir</span> = <span class="hljs-params">(source, base)</span> -&gt;</span>
<span class="hljs-keyword">delete</span> watchedDirs[source]
sourcesChanged = <span class="hljs-literal">no</span>
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> sources <span class="hljs-keyword">when</span> source <span class="hljs-keyword">is</span> path.dirname file
removeSource file, base
sourcesChanged = <span class="hljs-literal">yes</span>
compileJoin() <span class="hljs-keyword">if</span> sourcesChanged</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Remove a file from our source list, and source code cache. Optionally remove
the compiled JS version as well.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">removeSource</span> = <span class="hljs-params">(source, base)</span> -&gt;</span>
index = sources.indexOf source
sources.splice index, <span class="hljs-number">1</span>
sourceCode.splice index, <span class="hljs-number">1</span>
<span class="hljs-keyword">unless</span> opts.join
silentUnlink outputPath source, base
silentUnlink outputPath source, base, <span class="hljs-string">'.js.map'</span>
timeLog <span class="hljs-string">"removed <span class="hljs-subst">#{source}</span>"</span>
<span class="hljs-function">
<span class="hljs-title">silentUnlink</span> = <span class="hljs-params">(path)</span> -&gt;</span>
<span class="hljs-keyword">try</span>
fs.unlinkSync path
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">in</span> [<span class="hljs-string">'ENOENT'</span>, <span class="hljs-string">'EPERM'</span>]</pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Get the corresponding output JavaScript path for a source file.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">outputPath</span> = <span class="hljs-params">(source, base, extension=<span class="hljs-string">".js"</span>)</span> -&gt;</span>
basename = helpers.baseFileName source, <span class="hljs-literal">yes</span>, useWinPathSep
srcDir = path.dirname source
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> opts.output
dir = srcDir
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> source <span class="hljs-keyword">is</span> base
dir = opts.output
<span class="hljs-keyword">else</span>
dir = path.join opts.output, path.relative base, srcDir
path.join dir, basename + extension</pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Recursively mkdir, like <code>mkdir -p</code>.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">mkdirp</span> = <span class="hljs-params">(dir, fn)</span> -&gt;</span>
mode = <span class="hljs-number">0</span>o777 &amp; ~process.umask()
<span class="hljs-keyword">do</span> mkdirs = <span class="hljs-function"><span class="hljs-params">(p = dir, fn)</span> -&gt;</span>
fs.exists p, <span class="hljs-function"><span class="hljs-params">(exists)</span> -&gt;</span>
<span class="hljs-keyword">if</span> exists
fn()
<span class="hljs-keyword">else</span>
mkdirs path.dirname(p), <span class="hljs-function">-&gt;</span>
fs.mkdir p, mode, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">return</span> fn err <span class="hljs-keyword">if</span> err
fn()</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Write out a JavaScript source file with the compiled code. By default, files
are written out in <code>cwd</code> as <code>.js</code> files with the same name, but the output
directory can be customized with <code>--output</code>.</p>
<p>If <code>generatedSourceMap</code> is provided, this will write a <code>.js.map</code> file into the
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">writeJs</span> = <span class="hljs-params">(base, sourcePath, js, jsPath, generatedSourceMap = <span class="hljs-literal">null</span>)</span> -&gt;</span>
sourceMapPath = outputPath sourcePath, base, <span class="hljs-string">".js.map"</span>
jsDir = path.dirname jsPath
<span class="hljs-function"> <span class="hljs-title">compile</span> = -&gt;</span>
<span class="hljs-keyword">if</span> opts.compile
js = <span class="hljs-string">' '</span> <span class="hljs-keyword">if</span> js.length &lt;= <span class="hljs-number">0</span>
<span class="hljs-keyword">if</span> generatedSourceMap <span class="hljs-keyword">then</span> js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n//# sourceMappingURL=<span class="hljs-subst">#{helpers.baseFileName sourceMapPath, <span class="hljs-literal">no</span>, useWinPathSep}</span>\n"</span>
fs.writeFile jsPath, js, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">if</span> err
printLine err.message
process.exit <span class="hljs-number">1</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.compile <span class="hljs-keyword">and</span> opts.watch
timeLog <span class="hljs-string">"compiled <span class="hljs-subst">#{sourcePath}</span>"</span>
<span class="hljs-keyword">if</span> generatedSourceMap
fs.writeFile sourceMapPath, generatedSourceMap, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">if</span> err
printLine <span class="hljs-string">"Could not write source map: <span class="hljs-subst">#{err.message}</span>"</span>
process.exit <span class="hljs-number">1</span>
fs.exists jsDir, <span class="hljs-function"><span class="hljs-params">(itExists)</span> -&gt;</span>
<span class="hljs-keyword">if</span> itExists <span class="hljs-keyword">then</span> compile() <span class="hljs-keyword">else</span> mkdirp jsDir, compile</pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Convenience for cleaner setTimeouts.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">wait</span> = <span class="hljs-params">(milliseconds, func)</span> -&gt;</span> setTimeout func, milliseconds</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>When watching scripts, its useful to log changes with the timestamp.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">timeLog</span> = <span class="hljs-params">(message)</span> -&gt;</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"<span class="hljs-subst">#{(<span class="hljs-keyword">new</span> Date).toLocaleTimeString()}</span> - <span class="hljs-subst">#{message}</span>"</span></pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Pretty-print a stream of tokens, sans location data.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">printTokens</span> = <span class="hljs-params">(tokens)</span> -&gt;</span>
strings = <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens
tag = token[<span class="hljs-number">0</span>]
value = token[<span class="hljs-number">1</span>].toString().replace(<span class="hljs-regexp">/\n/</span>, <span class="hljs-string">'\\n'</span>)
<span class="hljs-string">"[<span class="hljs-subst">#{tag}</span> <span class="hljs-subst">#{value}</span>]"</span>
printLine strings.join(<span class="hljs-string">' '</span>)</pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Use the <a href="optparse.html">OptionParser module</a> to extract all options from
<code>process.argv</code> that are specified in <code>SWITCHES</code>.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">parseOptions</span> = -&gt;</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)
o.<span class="hljs-built_in">print</span> = !! (o.<span class="hljs-built_in">print</span> <span class="hljs-keyword">or</span> (o.eval <span class="hljs-keyword">or</span> o.stdio <span class="hljs-keyword">and</span> o.compile))</pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>The compile-time options to pass to the CoffeeScript compiler.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compileOptions</span> = <span class="hljs-params">(filename, base)</span> -&gt;</span>
answer = {
filename
literate: opts.literate <span class="hljs-keyword">or</span> helpers.isLiterate(filename)
bare: opts.bare
header: opts.compile <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> opts[<span class="hljs-string">'no-header'</span>]
sourceMap: opts.map
inlineMap: opts[<span class="hljs-string">'inline-map'</span>]
}
<span class="hljs-keyword">if</span> filename
<span class="hljs-keyword">if</span> base
cwd = process.cwd()
jsPath = outputPath filename, base
jsDir = path.dirname jsPath
answer = helpers.merge answer, {
jsPath
sourceRoot: path.relative jsDir, cwd
sourceFiles: [path.relative cwd, filename]
generatedFile: helpers.baseFileName(jsPath, <span class="hljs-literal">no</span>, useWinPathSep)
}
<span class="hljs-keyword">else</span>
answer = helpers.merge answer,
sourceRoot: <span class="hljs-string">""</span>
sourceFiles: [helpers.baseFileName filename, <span class="hljs-literal">no</span>, useWinPathSep]
generatedFile: helpers.baseFileName(filename, <span class="hljs-literal">yes</span>, useWinPathSep) + <span class="hljs-string">".js"</span>
answer</pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Start up a new Node.js instance with the arguments in <code>--nodejs</code> passed to
the <code>node</code> binary, preserving the other options.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">forkNode</span> = -&gt;</span>
nodeArgs = opts.nodejs.split <span class="hljs-regexp">/\s+/</span>
args = process.argv[<span class="hljs-number">1.</span>.]
args.splice args.indexOf(<span class="hljs-string">'--nodejs'</span>), <span class="hljs-number">2</span>
p = spawn process.execPath, nodeArgs.concat(args),
cwd: process.cwd()
env: process.env
stdio: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
p.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span> process.exit code</pre></div></div>
</li>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Print the <code>--help</code> usage message and exit. Deprecated switches are not
shown.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">usage</span> = -&gt;</span>
printLine (<span class="hljs-keyword">new</span> optparse.OptionParser SWITCHES, BANNER).help()</pre></div></div>
</li>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Print the <code>--version</code> message and exit.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">version</span> = -&gt;</span>
printLine <span class="hljs-string">"CoffeeScript version <span class="hljs-subst">#{CoffeeScript.VERSION}</span>"</span></pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,518 @@
/*--------------------- Typography ----------------------------*/
@font-face {
font-family: 'aller-light';
src: url('public/fonts/aller-light.eot');
src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'),
url('public/fonts/aller-light.woff') format('woff'),
url('public/fonts/aller-light.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'aller-bold';
src: url('public/fonts/aller-bold.eot');
src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'),
url('public/fonts/aller-bold.woff') format('woff'),
url('public/fonts/aller-bold.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'roboto-black';
src: url('public/fonts/roboto-black.eot');
src: url('public/fonts/roboto-black.eot?#iefix') format('embedded-opentype'),
url('public/fonts/roboto-black.woff') format('woff'),
url('public/fonts/roboto-black.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
/*--------------------- Layout ----------------------------*/
html { height: 100%; }
body {
font-family: "aller-light";
font-size: 14px;
line-height: 18px;
color: #30404f;
margin: 0; padding: 0;
height:100%;
}
#container { min-height: 100%; }
a {
color: #000;
}
b, strong {
font-weight: normal;
font-family: "aller-bold";
}
p {
margin: 15px 0 0px;
}
.annotation ul, .annotation ol {
margin: 25px 0;
}
.annotation ul li, .annotation ol li {
font-size: 14px;
line-height: 18px;
margin: 10px 0;
}
h1, h2, h3, h4, h5, h6 {
color: #112233;
line-height: 1em;
font-weight: normal;
font-family: "roboto-black";
text-transform: uppercase;
margin: 30px 0 15px 0;
}
h1 {
margin-top: 40px;
}
h2 {
font-size: 1.26em;
}
hr {
border: 0;
background: 1px #ddd;
height: 1px;
margin: 20px 0;
}
pre, tt, code {
font-size: 12px; line-height: 16px;
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
margin: 0; padding: 0;
}
.annotation pre {
display: block;
margin: 0;
padding: 7px 10px;
background: #fcfcfc;
-moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
-webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
overflow-x: auto;
}
.annotation pre code {
border: 0;
padding: 0;
background: transparent;
}
blockquote {
border-left: 5px solid #ccc;
margin: 0;
padding: 1px 0 1px 1em;
}
.sections blockquote p {
font-family: Menlo, Consolas, Monaco, monospace;
font-size: 12px; line-height: 16px;
color: #999;
margin: 10px 0 0;
white-space: pre-wrap;
}
ul.sections {
list-style: none;
padding:0 0 5px 0;;
margin:0;
}
/*
Force border-box so that % widths fit the parent
container without overlap because of margin/padding.
More Info : http://www.quirksmode.org/css/box.html
*/
ul.sections > li > div {
-moz-box-sizing: border-box; /* firefox */
-ms-box-sizing: border-box; /* ie */
-webkit-box-sizing: border-box; /* webkit */
-khtml-box-sizing: border-box; /* konqueror */
box-sizing: border-box; /* css3 */
}
/*---------------------- Jump Page -----------------------------*/
#jump_to, #jump_page {
margin: 0;
background: white;
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
font: 16px Arial;
cursor: pointer;
text-align: right;
list-style: none;
}
#jump_to a {
text-decoration: none;
}
#jump_to a.large {
display: none;
}
#jump_to a.small {
font-size: 22px;
font-weight: bold;
color: #676767;
}
#jump_to, #jump_wrapper {
position: fixed;
right: 0; top: 0;
padding: 10px 15px;
margin:0;
}
#jump_wrapper {
display: none;
padding:0;
}
#jump_to:hover #jump_wrapper {
display: block;
}
#jump_page_wrapper{
position: fixed;
right: 0;
top: 0;
bottom: 0;
}
#jump_page {
padding: 5px 0 3px;
margin: 0 0 25px 25px;
max-height: 100%;
overflow: auto;
}
#jump_page .source {
display: block;
padding: 15px;
text-decoration: none;
border-top: 1px solid #eee;
}
#jump_page .source:hover {
background: #f5f5ff;
}
#jump_page .source:first-child {
}
/*---------------------- Low resolutions (> 320px) ---------------------*/
@media only screen and (min-width: 320px) {
.pilwrap { display: none; }
ul.sections > li > div {
display: block;
padding:5px 10px 0 10px;
}
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol {
padding-left: 30px;
}
ul.sections > li > div.content {
overflow-x:auto;
-webkit-box-shadow: inset 0 0 5px #e5e5ee;
box-shadow: inset 0 0 5px #e5e5ee;
border: 1px solid #dedede;
margin:5px 10px 5px 10px;
padding-bottom: 5px;
}
ul.sections > li > div.annotation pre {
margin: 7px 0 7px;
padding-left: 15px;
}
ul.sections > li > div.annotation p tt, .annotation code {
background: #f8f8ff;
border: 1px solid #dedede;
font-size: 12px;
padding: 0 0.2em;
}
}
/*---------------------- (> 481px) ---------------------*/
@media only screen and (min-width: 481px) {
#container {
position: relative;
}
body {
background-color: #F5F5FF;
font-size: 15px;
line-height: 21px;
}
pre, tt, code {
line-height: 18px;
}
p, ul, ol {
margin: 0 0 15px;
}
#jump_to {
padding: 5px 10px;
}
#jump_wrapper {
padding: 0;
}
#jump_to, #jump_page {
font: 10px Arial;
text-transform: uppercase;
}
#jump_page .source {
padding: 5px 10px;
}
#jump_to a.large {
display: inline-block;
}
#jump_to a.small {
display: none;
}
#background {
position: absolute;
top: 0; bottom: 0;
width: 350px;
background: #fff;
border-right: 1px solid #e5e5ee;
z-index: -1;
}
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol {
padding-left: 40px;
}
ul.sections > li {
white-space: nowrap;
}
ul.sections > li > div {
display: inline-block;
}
ul.sections > li > div.annotation {
max-width: 350px;
min-width: 350px;
min-height: 5px;
padding: 13px;
overflow-x: hidden;
white-space: normal;
vertical-align: top;
text-align: left;
}
ul.sections > li > div.annotation pre {
margin: 15px 0 15px;
padding-left: 15px;
}
ul.sections > li > div.content {
padding: 13px;
vertical-align: top;
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.pilwrap {
position: relative;
display: inline;
}
.pilcrow {
font: 12px Arial;
text-decoration: none;
color: #454545;
position: absolute;
top: 3px; left: -20px;
padding: 1px 2px;
opacity: 0;
-webkit-transition: opacity 0.2s linear;
}
.for-h1 .pilcrow {
top: 47px;
}
.for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow {
top: 35px;
}
ul.sections > li > div.annotation:hover .pilcrow {
opacity: 1;
}
}
/*---------------------- (> 1025px) ---------------------*/
@media only screen and (min-width: 1025px) {
body {
font-size: 16px;
line-height: 24px;
}
#background {
width: 525px;
}
ul.sections > li > div.annotation {
max-width: 525px;
min-width: 525px;
padding: 10px 25px 1px 50px;
}
ul.sections > li > div.content {
padding: 9px 15px 16px 25px;
}
}
/*---------------------- Syntax Highlighting -----------------------------*/
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
/*
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
*/
pre code {
display: block; padding: 0.5em;
color: #000;
background: #f8f8ff
}
pre .hljs-comment,
pre .hljs-template_comment,
pre .hljs-diff .hljs-header,
pre .hljs-javadoc {
color: #408080;
font-style: italic
}
pre .hljs-keyword,
pre .hljs-assignment,
pre .hljs-literal,
pre .hljs-css .hljs-rule .hljs-keyword,
pre .hljs-winutils,
pre .hljs-javascript .hljs-title,
pre .hljs-lisp .hljs-title,
pre .hljs-subst {
color: #954121;
/*font-weight: bold*/
}
pre .hljs-number,
pre .hljs-hexcolor {
color: #40a070
}
pre .hljs-string,
pre .hljs-tag .hljs-value,
pre .hljs-phpdoc,
pre .hljs-tex .hljs-formula {
color: #219161;
}
pre .hljs-title,
pre .hljs-id {
color: #19469D;
}
pre .hljs-params {
color: #00F;
}
pre .hljs-javascript .hljs-title,
pre .hljs-lisp .hljs-title,
pre .hljs-subst {
font-weight: normal
}
pre .hljs-class .hljs-title,
pre .hljs-haskell .hljs-label,
pre .hljs-tex .hljs-command {
color: #458;
font-weight: bold
}
pre .hljs-tag,
pre .hljs-tag .hljs-title,
pre .hljs-rules .hljs-property,
pre .hljs-django .hljs-tag .hljs-keyword {
color: #000080;
font-weight: normal
}
pre .hljs-attribute,
pre .hljs-variable,
pre .hljs-instancevar,
pre .hljs-lisp .hljs-body {
color: #008080
}
pre .hljs-regexp {
color: #B68
}
pre .hljs-class {
color: #458;
font-weight: bold
}
pre .hljs-symbol,
pre .hljs-ruby .hljs-symbol .hljs-string,
pre .hljs-ruby .hljs-symbol .hljs-keyword,
pre .hljs-ruby .hljs-symbol .hljs-keymethods,
pre .hljs-lisp .hljs-keyword,
pre .hljs-tex .hljs-special,
pre .hljs-input_number {
color: #990073
}
pre .hljs-builtin,
pre .hljs-constructor,
pre .hljs-built_in,
pre .hljs-lisp .hljs-title {
color: #0086b3
}
pre .hljs-preprocessor,
pre .hljs-pi,
pre .hljs-doctype,
pre .hljs-shebang,
pre .hljs-cdata {
color: #999;
font-weight: bold
}
pre .hljs-deletion {
background: #fdd
}
pre .hljs-addition {
background: #dfd
}
pre .hljs-diff .hljs-change {
background: #0086b3
}
pre .hljs-chunk {
color: #aaa
}
pre .hljs-tex .hljs-formula {
opacity: 0.5;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,612 @@
<!DOCTYPE html>
<html>
<head>
<title>helpers.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>helpers.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>This file contains the common helper functions that wed like to share among
the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten
arrays, count characters, that sort of thing.</p>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Peek at the beginning of a given string to see if it matches a sequence.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.starts = <span class="hljs-function"><span class="hljs-params">(string, literal, start)</span> -&gt;</span>
literal <span class="hljs-keyword">is</span> string.substr start, literal.length</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Peek at the end of a given string to see if it matches a sequence.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.ends = <span class="hljs-function"><span class="hljs-params">(string, literal, back)</span> -&gt;</span>
len = literal.length
literal <span class="hljs-keyword">is</span> string.substr string.length - len - (back <span class="hljs-keyword">or</span> <span class="hljs-number">0</span>), len</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Repeat a string <code>n</code> times.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.repeat = repeat = <span class="hljs-function"><span class="hljs-params">(str, n)</span> -&gt;</span></pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Use clever algorithm to have O(log(n)) string concatenation operations.</p>
</div>
<div class="content"><div class='highlight'><pre> res = <span class="hljs-string">''</span>
<span class="hljs-keyword">while</span> n &gt; <span class="hljs-number">0</span>
res += str <span class="hljs-keyword">if</span> n &amp; <span class="hljs-number">1</span>
n &gt;&gt;&gt;= <span class="hljs-number">1</span>
str += str
res</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Trim out all falsy values from an array.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.compact = <span class="hljs-function"><span class="hljs-params">(array)</span> -&gt;</span>
item <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> array <span class="hljs-keyword">when</span> item</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Count the number of occurrences of a string in a string.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.count = <span class="hljs-function"><span class="hljs-params">(string, substr)</span> -&gt;</span>
num = pos = <span class="hljs-number">0</span>
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>/<span class="hljs-number">0</span> <span class="hljs-keyword">unless</span> substr.length
num++ <span class="hljs-keyword">while</span> pos = <span class="hljs-number">1</span> + string.indexOf substr, pos
num</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Merge objects, returning a fresh copy with attributes from both sides.
Used every time <code>Base#compile</code> is called, to allow properties in the
options hash to propagate down the tree without polluting other branches.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.merge = <span class="hljs-function"><span class="hljs-params">(options, overrides)</span> -&gt;</span>
extend (extend {}, options), overrides</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Extend a source object with the properties of another object (shallow copy).</p>
</div>
<div class="content"><div class='highlight'><pre>extend = exports.extend = <span class="hljs-function"><span class="hljs-params">(object, properties)</span> -&gt;</span>
<span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> properties
object[key] = val
object</pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Return a flattened version of an array.
Handy for getting a list of <code>children</code> from the nodes.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.flatten = flatten = <span class="hljs-function"><span class="hljs-params">(array)</span> -&gt;</span>
flattened = []
<span class="hljs-keyword">for</span> element <span class="hljs-keyword">in</span> array
<span class="hljs-keyword">if</span> <span class="hljs-string">'[object Array]'</span> <span class="hljs-keyword">is</span> Object::toString.call element
flattened = flattened.concat flatten element
<span class="hljs-keyword">else</span>
flattened.push element
flattened</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Delete a key from an object, returning the value. Useful when a node is
looking for a particular method in an options hash.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.del = <span class="hljs-function"><span class="hljs-params">(obj, key)</span> -&gt;</span>
val = obj[key]
<span class="hljs-keyword">delete</span> obj[key]
val</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Typical Array::some</p>
</div>
<div class="content"><div class='highlight'><pre>exports.some = Array::some ? (fn) -&gt;
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">for</span> e <span class="hljs-keyword">in</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">when</span> fn e
<span class="hljs-literal">false</span></pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Simple function for inverting Literate CoffeeScript code by putting the
documentation in comments, producing a string of CoffeeScript code that
can be compiled “normally”.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.invertLiterate = <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
maybe_code = <span class="hljs-literal">true</span>
lines = <span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> code.split(<span class="hljs-string">'\n'</span>)
<span class="hljs-keyword">if</span> maybe_code <span class="hljs-keyword">and</span> <span class="hljs-regexp">/^([ ]{4}|[ ]{0,3}\t)/</span>.test line
line
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> maybe_code = <span class="hljs-regexp">/^\s*$/</span>.test line
line
<span class="hljs-keyword">else</span>
<span class="hljs-string">'# '</span> + line
lines.join <span class="hljs-string">'\n'</span></pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Merge two jison-style location data objects together.
If <code>last</code> is not provided, this will simply return <code>first</code>.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildLocationData</span> = <span class="hljs-params">(first, last)</span> -&gt;</span>
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> last
first
<span class="hljs-keyword">else</span>
first_line: first.first_line
first_column: first.first_column
last_line: last.last_line
last_column: last.last_column</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>This returns a function which takes an object as a parameter, and if that
object is an AST node, updates that objects locationData.
The object is returned either way.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.addLocationDataFn = <span class="hljs-function"><span class="hljs-params">(first, last)</span> -&gt;</span>
(obj) -&gt;
<span class="hljs-keyword">if</span> ((<span class="hljs-keyword">typeof</span> obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span>) <span class="hljs-keyword">and</span> (!!obj[<span class="hljs-string">'updateLocationDataIfMissing'</span>])
obj.updateLocationDataIfMissing buildLocationData(first, last)
<span class="hljs-keyword">return</span> obj</pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Convert jison location data to a string.
<code>obj</code> can be a token, or a locationData.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.locationDataToString = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span>
<span class="hljs-keyword">if</span> (<span class="hljs-string">"2"</span> <span class="hljs-keyword">of</span> obj) <span class="hljs-keyword">and</span> (<span class="hljs-string">"first_line"</span> <span class="hljs-keyword">of</span> obj[<span class="hljs-number">2</span>]) <span class="hljs-keyword">then</span> locationData = obj[<span class="hljs-number">2</span>]
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-string">"first_line"</span> <span class="hljs-keyword">of</span> obj <span class="hljs-keyword">then</span> locationData = obj
<span class="hljs-keyword">if</span> locationData
<span class="hljs-string">"<span class="hljs-subst">#{locationData.first_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{locationData.first_column + <span class="hljs-number">1</span>}</span>-"</span> +
<span class="hljs-string">"<span class="hljs-subst">#{locationData.last_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{locationData.last_column + <span class="hljs-number">1</span>}</span>"</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"No location data"</span></pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.baseFileName = <span class="hljs-function"><span class="hljs-params">(file, stripExt = <span class="hljs-literal">no</span>, useWinPathSep = <span class="hljs-literal">no</span>)</span> -&gt;</span>
pathSep = <span class="hljs-keyword">if</span> useWinPathSep <span class="hljs-keyword">then</span> <span class="hljs-regexp">/\\|\//</span> <span class="hljs-keyword">else</span> <span class="hljs-regexp">/\//</span>
parts = file.split(pathSep)
file = parts[parts.length - <span class="hljs-number">1</span>]
<span class="hljs-keyword">return</span> file <span class="hljs-keyword">unless</span> stripExt <span class="hljs-keyword">and</span> file.indexOf(<span class="hljs-string">'.'</span>) &gt;= <span class="hljs-number">0</span>
parts = file.split(<span class="hljs-string">'.'</span>)
parts.pop()
parts.pop() <span class="hljs-keyword">if</span> parts[parts.length - <span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'coffee'</span> <span class="hljs-keyword">and</span> parts.length &gt; <span class="hljs-number">1</span>
parts.join(<span class="hljs-string">'.'</span>)</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Determine if a filename represents a CoffeeScript file.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.isCoffee = <span class="hljs-function"><span class="hljs-params">(file)</span> -&gt;</span> <span class="hljs-regexp">/\.((lit)?coffee|coffee\.md)$/</span>.test file</pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.isLiterate = <span class="hljs-function"><span class="hljs-params">(file)</span> -&gt;</span> <span class="hljs-regexp">/\.(litcoffee|coffee\.md)$/</span>.test file</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Throws a SyntaxError from a given location.
The errors <code>toString</code> will return an error message following the “standard”
format <code>&lt;filename&gt;:&lt;line&gt;:&lt;col&gt;: &lt;message&gt;</code> plus the line with the error and a
marker showing where the error is.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.throwSyntaxError = <span class="hljs-function"><span class="hljs-params">(message, location)</span> -&gt;</span>
error = <span class="hljs-keyword">new</span> SyntaxError message
error.location = location
error.toString = syntaxErrorToString</pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Instead of showing the compilers stacktrace, show our custom error message
(this is useful when the error bubbles up in Node.js applications that
compile CoffeeScript for example).</p>
</div>
<div class="content"><div class='highlight'><pre> error.stack = error.toString()
<span class="hljs-keyword">throw</span> error</pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Update a compiler SyntaxError with source code information if it didnt have
it already.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.updateSyntaxError = <span class="hljs-function"><span class="hljs-params">(error, code, filename)</span> -&gt;</span></pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Avoid screwing up the <code>stack</code> property of other errors (i.e. possible bugs).</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> error.toString <span class="hljs-keyword">is</span> syntaxErrorToString
error.code <span class="hljs-keyword">or</span>= code
error.filename <span class="hljs-keyword">or</span>= filename
error.stack = error.toString()
error
<span class="hljs-function">
<span class="hljs-title">syntaxErrorToString</span> = -&gt;</span>
<span class="hljs-keyword">return</span> Error::toString.call @ <span class="hljs-keyword">unless</span> @code <span class="hljs-keyword">and</span> @location
{first_line, first_column, last_line, last_column} = @location
last_line ?= first_line
last_column ?= first_column
filename = @filename <span class="hljs-keyword">or</span> <span class="hljs-string">'[stdin]'</span>
codeLine = @code.split(<span class="hljs-string">'\n'</span>)[first_line]
start = first_column</pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Show only the first line on multi-line errors.</p>
</div>
<div class="content"><div class='highlight'><pre> end = <span class="hljs-keyword">if</span> first_line <span class="hljs-keyword">is</span> last_line <span class="hljs-keyword">then</span> last_column + <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> codeLine.length
marker = codeLine[...start].replace(<span class="hljs-regexp">/[^\s]/g</span>, <span class="hljs-string">' '</span>) + repeat(<span class="hljs-string">'^'</span>, end - start)</pre></div></div>
</li>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Check to see if were running on a color-enabled TTY.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> process?
colorsEnabled = process.stdout?.isTTY <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> process.env?.NODE_DISABLE_COLORS
<span class="hljs-keyword">if</span> @colorful ? colorsEnabled
<span class="hljs-function"> <span class="hljs-title">colorize</span> = <span class="hljs-params">(str)</span> -&gt;</span> <span class="hljs-string">"\x1B[1;31m<span class="hljs-subst">#{str}</span>\x1B[0m"</span>
codeLine = codeLine[...start] + colorize(codeLine[start...end]) + codeLine[end..]
marker = colorize marker
<span class="hljs-string">"""
<span class="hljs-subst">#{filename}</span>:<span class="hljs-subst">#{first_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{first_column + <span class="hljs-number">1</span>}</span>: error: <span class="hljs-subst">#{@message}</span>
<span class="hljs-subst">#{codeLine}</span>
<span class="hljs-subst">#{marker}</span>
"""</span>
exports.nameWhitespaceCharacter = <span class="hljs-function"><span class="hljs-params">(string)</span> -&gt;</span>
<span class="hljs-keyword">switch</span> string
<span class="hljs-keyword">when</span> <span class="hljs-string">' '</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'space'</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'\n'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'newline'</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'\r'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'carriage return'</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'\t'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'tab'</span>
<span class="hljs-keyword">else</span> string</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,129 @@
<!DOCTYPE html>
<html>
<head>
<title>index.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>index.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>Loader for CoffeeScript as a Node.js library.</p>
</div>
<div class="content"><div class='highlight'><pre>exports[key] = val <span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span></pre></div></div>
</li>
</ul>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,366 @@
<!DOCTYPE html>
<html>
<head>
<title>optparse.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>optparse.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre>{repeat} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
Use it like so:</p>
<pre><code>parser = <span class="hljs-keyword">new</span> OptionParser switches, helpBanner
options = parser.parse process.argv
</code></pre><p>The first non-option is considered to be the start of the file (and file
option) list, and all subsequent arguments are left unparsed.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.OptionParser = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OptionParser</span></span></pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Initialize with a list of valid options, in the form:</p>
<pre><code>[short-flag, long-flag, description]
</code></pre><p>Along with an optional banner for the usage help.</p>
</div>
<div class="content"><div class='highlight'><pre> constructor: <span class="hljs-function"><span class="hljs-params">(rules, @banner)</span> -&gt;</span>
@rules = buildRules rules</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Parse the list of arguments, populating an <code>options</code> object with all of the
specified options, and return it. Options after the first non-option
argument are treated as arguments. <code>options.arguments</code> will be an array
containing the remaining arguments. This is a simpler API than many option
parsers that allow you to attach callback actions for every flag. Instead,
youre responsible for interpreting the options object.</p>
</div>
<div class="content"><div class='highlight'><pre> parse: <span class="hljs-function"><span class="hljs-params">(args)</span> -&gt;</span>
options = arguments: []
skippingArgument = <span class="hljs-literal">no</span>
originalArgs = args
args = normalizeArguments args
<span class="hljs-keyword">for</span> arg, i <span class="hljs-keyword">in</span> args
<span class="hljs-keyword">if</span> skippingArgument
skippingArgument = <span class="hljs-literal">no</span>
<span class="hljs-keyword">continue</span>
<span class="hljs-keyword">if</span> arg <span class="hljs-keyword">is</span> <span class="hljs-string">'--'</span>
pos = originalArgs.indexOf <span class="hljs-string">'--'</span>
options.arguments = options.arguments.concat originalArgs[(pos + <span class="hljs-number">1</span>)..]
<span class="hljs-keyword">break</span>
isOption = !!(arg.match(LONG_FLAG) <span class="hljs-keyword">or</span> arg.match(SHORT_FLAG))</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>the CS option parser is a little odd; options after the first
non-option argument are treated as non-option arguments themselves</p>
</div>
<div class="content"><div class='highlight'><pre> seenNonOptionArg = options.arguments.length &gt; <span class="hljs-number">0</span>
<span class="hljs-keyword">unless</span> seenNonOptionArg
matchedRule = <span class="hljs-literal">no</span>
<span class="hljs-keyword">for</span> rule <span class="hljs-keyword">in</span> @rules
<span class="hljs-keyword">if</span> rule.shortFlag <span class="hljs-keyword">is</span> arg <span class="hljs-keyword">or</span> rule.longFlag <span class="hljs-keyword">is</span> arg
value = <span class="hljs-literal">true</span>
<span class="hljs-keyword">if</span> rule.hasArgument
skippingArgument = <span class="hljs-literal">yes</span>
value = args[i + <span class="hljs-number">1</span>]
options[rule.name] = <span class="hljs-keyword">if</span> rule.isList <span class="hljs-keyword">then</span> (options[rule.name] <span class="hljs-keyword">or</span> []).concat value <span class="hljs-keyword">else</span> value
matchedRule = <span class="hljs-literal">yes</span>
<span class="hljs-keyword">break</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"unrecognized option: <span class="hljs-subst">#{arg}</span>"</span> <span class="hljs-keyword">if</span> isOption <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> matchedRule
<span class="hljs-keyword">if</span> seenNonOptionArg <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> isOption
options.arguments.push arg
options</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Return the help text for this <strong>OptionParser</strong>, listing and describing all
of the valid options, for <code>--help</code> and such.</p>
</div>
<div class="content"><div class='highlight'><pre> help: <span class="hljs-function">-&gt;</span>
lines = []
lines.unshift <span class="hljs-string">"<span class="hljs-subst">#{@banner}</span>\n"</span> <span class="hljs-keyword">if</span> @banner
<span class="hljs-keyword">for</span> rule <span class="hljs-keyword">in</span> @rules
spaces = <span class="hljs-number">15</span> - rule.longFlag.length
spaces = <span class="hljs-keyword">if</span> spaces &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> repeat <span class="hljs-string">' '</span>, spaces <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
letPart = <span class="hljs-keyword">if</span> rule.shortFlag <span class="hljs-keyword">then</span> rule.shortFlag + <span class="hljs-string">', '</span> <span class="hljs-keyword">else</span> <span class="hljs-string">' '</span>
lines.push <span class="hljs-string">' '</span> + letPart + rule.longFlag + spaces + rule.description
<span class="hljs-string">"\n<span class="hljs-subst">#{ lines.join(<span class="hljs-string">'\n'</span>) }</span>\n"</span></pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<h2 id="helpers">Helpers</h2>
</div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
</div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Regex matchers for option flags.</p>
</div>
<div class="content"><div class='highlight'><pre>LONG_FLAG = <span class="hljs-regexp">/^(--\w[\w\-]*)/</span>
SHORT_FLAG = <span class="hljs-regexp">/^(-\w)$/</span>
MULTI_FLAG = <span class="hljs-regexp">/^-(\w{2,})/</span>
OPTIONAL = <span class="hljs-regexp">/\[(\w+(\*?))\]/</span></pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Build and return the list of option rules. If the optional <em>short-flag</em> is
unspecified, leave it out by padding with <code>null</code>.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildRules</span> = <span class="hljs-params">(rules)</span> -&gt;</span>
<span class="hljs-keyword">for</span> tuple <span class="hljs-keyword">in</span> rules
tuple.unshift <span class="hljs-literal">null</span> <span class="hljs-keyword">if</span> tuple.length &lt; <span class="hljs-number">3</span>
buildRule tuple...</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Build a rule from a <code>-o</code> short flag, a <code>--output [DIR]</code> long flag, and the
description of what the option does.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildRule</span> = <span class="hljs-params">(shortFlag, longFlag, description, options = {})</span> -&gt;</span>
match = longFlag.match(OPTIONAL)
longFlag = longFlag.match(LONG_FLAG)[<span class="hljs-number">1</span>]
{
name: longFlag.substr <span class="hljs-number">2</span>
shortFlag: shortFlag
longFlag: longFlag
description: description
hasArgument: !!(match <span class="hljs-keyword">and</span> match[<span class="hljs-number">1</span>])
isList: !!(match <span class="hljs-keyword">and</span> match[<span class="hljs-number">2</span>])
}</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Normalize arguments by expanding merged flags into multiple flags. This allows
you to have <code>-wl</code> be the same as <code>--watch --lint</code>.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">normalizeArguments</span> = <span class="hljs-params">(args)</span> -&gt;</span>
args = args[..]
result = []
<span class="hljs-keyword">for</span> arg <span class="hljs-keyword">in</span> args
<span class="hljs-keyword">if</span> match = arg.match MULTI_FLAG
result.push <span class="hljs-string">'-'</span> + l <span class="hljs-keyword">for</span> l <span class="hljs-keyword">in</span> match[<span class="hljs-number">1</span>].split <span class="hljs-string">''</span>
<span class="hljs-keyword">else</span>
result.push arg
result</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,375 @@
/*! normalize.css v2.0.1 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/*
* Corrects `block` display not defined in IE 8/9.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section,
summary {
display: block;
}
/*
* Corrects `inline-block` display not defined in IE 8/9.
*/
audio,
canvas,
video {
display: inline-block;
}
/*
* Prevents modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/*
* Addresses styling for `hidden` attribute not present in IE 8/9.
*/
[hidden] {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/*
* 1. Sets default font family to sans-serif.
* 2. Prevents iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-family: sans-serif; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-ms-text-size-adjust: 100%; /* 2 */
}
/*
* Removes default margin.
*/
body {
margin: 0;
}
/* ==========================================================================
Links
========================================================================== */
/*
* Addresses `outline` inconsistency between Chrome and other browsers.
*/
a:focus {
outline: thin dotted;
}
/*
* Improves readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}
/* ==========================================================================
Typography
========================================================================== */
/*
* Addresses `h1` font sizes within `section` and `article` in Firefox 4+,
* Safari 5, and Chrome.
*/
h1 {
font-size: 2em;
}
/*
* Addresses styling not present in IE 8/9, Safari 5, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/*
* Addresses style set to `bolder` in Firefox 4+, Safari 5, and Chrome.
*/
b,
strong {
font-weight: bold;
}
/*
* Addresses styling not present in Safari 5 and Chrome.
*/
dfn {
font-style: italic;
}
/*
* Addresses styling not present in IE 8/9.
*/
mark {
background: #ff0;
color: #000;
}
/*
* Corrects font family set oddly in Safari 5 and Chrome.
*/
code,
kbd,
pre,
samp {
font-family: monospace, serif;
font-size: 1em;
}
/*
* Improves readability of pre-formatted text in all browsers.
*/
pre {
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}
/*
* Sets consistent quote types.
*/
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
/*
* Addresses inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/*
* Prevents `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* ==========================================================================
Embedded content
========================================================================== */
/*
* Removes border when inside `a` element in IE 8/9.
*/
img {
border: 0;
}
/*
* Corrects overflow displayed oddly in IE 9.
*/
svg:not(:root) {
overflow: hidden;
}
/* ==========================================================================
Figures
========================================================================== */
/*
* Addresses margin not present in IE 8/9 and Safari 5.
*/
figure {
margin: 0;
}
/* ==========================================================================
Forms
========================================================================== */
/*
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/*
* 1. Corrects color not being inherited in IE 8/9.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/*
* 1. Corrects font family not being inherited in all browsers.
* 2. Corrects font size not being inherited in all browsers.
* 3. Addresses margins set differently in Firefox 4+, Safari 5, and Chrome
*/
button,
input,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 2 */
margin: 0; /* 3 */
}
/*
* Addresses Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
button,
input {
line-height: normal;
}
/*
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Corrects inability to style clickable `input` types in iOS.
* 3. Improves usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
}
/*
* Re-set default cursor for disabled elements.
*/
button[disabled],
input[disabled] {
cursor: default;
}
/*
* 1. Addresses box sizing set to `content-box` in IE 8/9.
* 2. Removes excess padding in IE 8/9.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/*
* 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome.
* 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome
* (include `-moz` to future-proof).
*/
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box; /* 2 */
box-sizing: content-box;
}
/*
* Removes inner padding and search cancel button in Safari 5 and Chrome
* on OS X.
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/*
* Removes inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/*
* 1. Removes default vertical scrollbar in IE 8/9.
* 2. Improves readability and alignment in all browsers.
*/
textarea {
overflow: auto; /* 1 */
vertical-align: top; /* 2 */
}
/* ==========================================================================
Tables
========================================================================== */
/*
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}

View File

@@ -0,0 +1,251 @@
<!DOCTYPE html>
<html>
<head>
<title>register.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>register.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
child_process = <span class="hljs-built_in">require</span> <span class="hljs-string">'child_process'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Load and run a CoffeeScript file for Node, stripping any <code>BOM</code>s.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">loadFile</span> = <span class="hljs-params">(<span class="hljs-built_in">module</span>, filename)</span> -&gt;</span>
answer = CoffeeScript._compileFile filename, <span class="hljs-literal">no</span>, <span class="hljs-literal">yes</span>
<span class="hljs-built_in">module</span>._compile answer, filename</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>If the installed version of Node supports <code>require.extensions</code>, register
CoffeeScript as an extension.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.extensions
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> CoffeeScript.FILE_EXTENSIONS
<span class="hljs-built_in">require</span>.extensions[ext] = loadFile</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Patch Nodes module loader to be able to handle multi-dot extensions.
This is a horrible thing that should not be required.</p>
</div>
<div class="content"><div class='highlight'><pre> Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
<span class="hljs-function">
<span class="hljs-title">findExtension</span> = <span class="hljs-params">(filename)</span> -&gt;</span>
extensions = path.basename(filename).split <span class="hljs-string">'.'</span></pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Remove the initial dot from dotfiles.</p>
</div>
<div class="content"><div class='highlight'><pre> extensions.shift() <span class="hljs-keyword">if</span> extensions[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span></pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Start with the longest possible extension and work our way shortwards.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">while</span> extensions.shift()
curExtension = <span class="hljs-string">'.'</span> + extensions.join <span class="hljs-string">'.'</span>
<span class="hljs-keyword">return</span> curExtension <span class="hljs-keyword">if</span> Module._extensions[curExtension]
<span class="hljs-string">'.js'</span>
Module::load = <span class="hljs-function"><span class="hljs-params">(filename)</span> -&gt;</span>
@filename = filename
@paths = Module._nodeModulePaths path.dirname filename
extension = findExtension filename
Module._extensions[extension](<span class="hljs-keyword">this</span>, filename)
@loaded = <span class="hljs-literal">true</span></pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>If were on Node, patch <code>child_process.fork</code> so that Coffee scripts are able
to fork both CoffeeScript files, and JavaScript files, directly.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> child_process
{fork} = child_process
binary = <span class="hljs-built_in">require</span>.resolve <span class="hljs-string">'../../bin/coffee'</span>
child_process.fork = <span class="hljs-function"><span class="hljs-params">(path, args, options)</span> -&gt;</span>
<span class="hljs-keyword">if</span> helpers.isCoffee path
<span class="hljs-keyword">unless</span> Array.isArray args
options = args <span class="hljs-keyword">or</span> {}
args = []
args = [path].concat args
path = binary
fork path, args, options</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,608 @@
<!DOCTYPE html>
<html>
<head>
<title>repl.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>repl.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
nodeREPL = <span class="hljs-built_in">require</span> <span class="hljs-string">'repl'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
{merge, updateSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
replDefaults =
prompt: <span class="hljs-string">'coffee&gt; '</span>,
historyFile: path.join process.env.HOME, <span class="hljs-string">'.coffee_history'</span> <span class="hljs-keyword">if</span> process.env.HOME
historyMaxInputSize: <span class="hljs-number">10240</span>
eval: <span class="hljs-function"><span class="hljs-params">(input, context, filename, cb)</span> -&gt;</span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>XXX: multiline hack.</p>
</div>
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/\uFF00/g</span>, <span class="hljs-string">'\n'</span></pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Nodes REPL sends the input ending with a newline and then wrapped in
parens. Unwrap all that.</p>
</div>
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/^\(([\s\S]*)\n\)$/m</span>, <span class="hljs-string">'$1'</span></pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Require AST nodes to do some AST manipulation.</p>
</div>
<div class="content"><div class='highlight'><pre> {Block, Assign, Value, Literal} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./nodes'</span>
<span class="hljs-keyword">try</span></pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Tokenize the clean input.</p>
</div>
<div class="content"><div class='highlight'><pre> tokens = CoffeeScript.tokens input</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Collect referenced variable names just like in <code>CoffeeScript.compile</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> referencedVars = (
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'IDENTIFIER'</span>
)</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Generate the AST of the tokens.</p>
</div>
<div class="content"><div class='highlight'><pre> ast = CoffeeScript.nodes tokens</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Add assignment to <code>_</code> variable to force the input to be an expression.</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>
]
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
<span class="hljs-keyword">catch</span> err</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>ASTs <code>compile</code> does not add source code information to syntax errors.</p>
</div>
<div class="content"><div class='highlight'><pre> updateSyntaxError err, input
cb err
<span class="hljs-function">
<span class="hljs-title">runInContext</span> = <span class="hljs-params">(js, context, filename)</span> -&gt;</span>
<span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
vm.runInThisContext js, filename
<span class="hljs-keyword">else</span>
vm.runInContext js, context, filename
<span class="hljs-function">
<span class="hljs-title">addMultilineHandler</span> = <span class="hljs-params">(repl)</span> -&gt;</span>
{rli, inputStream, outputStream} = repl</pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Node 0.11.12 changed API, prompt is now _prompt.</p>
</div>
<div class="content"><div class='highlight'><pre> origPrompt = repl._prompt ? repl.prompt
multiline =
enabled: <span class="hljs-literal">off</span>
initialPrompt: origPrompt.replace <span class="hljs-regexp">/^[^&gt; ]*/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'-'</span>
prompt: origPrompt.replace <span class="hljs-regexp">/^[^&gt; ]*&gt;?/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'.'</span>
buffer: <span class="hljs-string">''</span></pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Proxy nodes line listener</p>
</div>
<div class="content"><div class='highlight'><pre> nodeLineListener = rli.listeners(<span class="hljs-string">'line'</span>)[<span class="hljs-number">0</span>]
rli.removeListener <span class="hljs-string">'line'</span>, nodeLineListener
rli.<span class="hljs-literal">on</span> <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(cmd)</span> -&gt;</span>
<span class="hljs-keyword">if</span> multiline.enabled
multiline.buffer += <span class="hljs-string">"<span class="hljs-subst">#{cmd}</span>\n"</span>
rli.setPrompt multiline.prompt
rli.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">else</span>
rli.setPrompt origPrompt
nodeLineListener cmd
<span class="hljs-keyword">return</span></pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Handle Ctrl-v</p>
</div>
<div class="content"><div class='highlight'><pre> inputStream.<span class="hljs-literal">on</span> <span class="hljs-string">'keypress'</span>, <span class="hljs-function"><span class="hljs-params">(char, key)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> key <span class="hljs-keyword">and</span> key.ctrl <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> key.meta <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> key.shift <span class="hljs-keyword">and</span> key.name <span class="hljs-keyword">is</span> <span class="hljs-string">'v'</span>
<span class="hljs-keyword">if</span> multiline.enabled</pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>allow arbitrarily switching between modes any time before multiple lines are entered</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> multiline.buffer.match <span class="hljs-regexp">/\n/</span>
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
rli.setPrompt origPrompt
rli.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">return</span></pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>no-op unless the current line is empty</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> rli.line? <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> rli.line.match <span class="hljs-regexp">/^\s*$/</span></pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>eval, print, loop</p>
</div>
<div class="content"><div class='highlight'><pre> multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
rli.line = <span class="hljs-string">''</span>
rli.cursor = <span class="hljs-number">0</span>
rli.output.cursorTo <span class="hljs-number">0</span>
rli.output.clearLine <span class="hljs-number">1</span></pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>XXX: multiline hack</p>
</div>
<div class="content"><div class='highlight'><pre> multiline.buffer = multiline.buffer.replace <span class="hljs-regexp">/\n/g</span>, <span class="hljs-string">'\uFF00'</span>
rli.emit <span class="hljs-string">'line'</span>, multiline.buffer
multiline.buffer = <span class="hljs-string">''</span>
<span class="hljs-keyword">else</span>
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
rli.setPrompt multiline.initialPrompt
rli.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">return</span></pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Store and load command history from a file</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">addHistory</span> = <span class="hljs-params">(repl, filename, maxSize)</span> -&gt;</span>
lastLine = <span class="hljs-literal">null</span>
<span class="hljs-keyword">try</span></pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Get file info and at most maxSize of command history</p>
</div>
<div class="content"><div class='highlight'><pre> stat = fs.statSync filename
size = Math.min maxSize, stat.size</pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Read last <code>size</code> bytes from the file</p>
</div>
<div class="content"><div class='highlight'><pre> readFd = fs.openSync filename, <span class="hljs-string">'r'</span>
buffer = <span class="hljs-keyword">new</span> Buffer(size)
fs.readSync readFd, buffer, <span class="hljs-number">0</span>, size, stat.size - size
fs.closeSync readFd</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Set the history on the interpreter</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history = buffer.toString().split(<span class="hljs-string">'\n'</span>).reverse()</pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>If the history file was truncated we should pop off a potential partial line</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history.pop() <span class="hljs-keyword">if</span> stat.size &gt; maxSize</pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Shift off the final blank newline</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history.shift() <span class="hljs-keyword">if</span> repl.rli.history[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
repl.rli.historyIndex = <span class="hljs-number">-1</span>
lastLine = repl.rli.history[<span class="hljs-number">0</span>]
fd = fs.openSync filename, <span class="hljs-string">'a'</span>
repl.rli.addListener <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
<span class="hljs-keyword">if</span> code <span class="hljs-keyword">and</span> code.length <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.history'</span> <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.exit'</span> <span class="hljs-keyword">and</span> lastLine <span class="hljs-keyword">isnt</span> code</pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Save the latest command in the file</p>
</div>
<div class="content"><div class='highlight'><pre> fs.writeSync fd, <span class="hljs-string">"<span class="hljs-subst">#{code}</span>\n"</span>
lastLine = code
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-&gt;</span> fs.closeSync fd</pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Add a command to show the history stack</p>
</div>
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'history'</span>)] =
help: <span class="hljs-string">'Show command history'</span>
action: <span class="hljs-function">-&gt;</span>
repl.outputStream.write <span class="hljs-string">"<span class="hljs-subst">#{repl.rli.history[..].reverse().join <span class="hljs-string">'\n'</span>}</span>\n"</span>
repl.displayPrompt()
<span class="hljs-function">
<span class="hljs-title">getCommandId</span> = <span class="hljs-params">(repl, commandName)</span> -&gt;</span></pre></div></div>
</li>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Node 0.11 changed API, a command such as .help is now stored as help</p>
</div>
<div class="content"><div class='highlight'><pre> commandsHaveLeadingDot = repl.commands[<span class="hljs-string">'.help'</span>]?
<span class="hljs-keyword">if</span> commandsHaveLeadingDot <span class="hljs-keyword">then</span> <span class="hljs-string">".<span class="hljs-subst">#{commandName}</span>"</span> <span class="hljs-keyword">else</span> commandName
<span class="hljs-built_in">module</span>.exports =
start: <span class="hljs-function"><span class="hljs-params">(opts = {})</span> -&gt;</span>
[major, minor, build] = process.versions.node.split(<span class="hljs-string">'.'</span>).map (n) -&gt; parseInt(n)
<span class="hljs-keyword">if</span> major <span class="hljs-keyword">is</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> minor &lt; <span class="hljs-number">8</span>
<span class="hljs-built_in">console</span>.warn <span class="hljs-string">"Node 0.8.0+ required for CoffeeScript REPL"</span>
process.exit <span class="hljs-number">1</span>
CoffeeScript.register()
process.argv = [<span class="hljs-string">'coffee'</span>].concat process.argv[<span class="hljs-number">2.</span>.]
opts = merge replDefaults, opts
repl = nodeREPL.start opts
runInContext opts.prelude, repl.context, <span class="hljs-string">'prelude'</span> <span class="hljs-keyword">if</span> opts.prelude
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-&gt;</span> repl.outputStream.write <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.rli.closed
addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile</pre></div></div>
</li>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Adapt help inherited from the node REPL</p>
</div>
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'load'</span>)].help = <span class="hljs-string">'Load code from a file into this REPL session'</span>
repl</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,398 @@
<!DOCTYPE html>
<html>
<head>
<title>scope.litcoffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>scope.litcoffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>The <strong>Scope</strong> class regulates lexical scoping within CoffeeScript. As you
generate code, you create a tree of scopes in the same shape as the nested
function bodies. Each scope knows about the variables declared within it,
and has a reference to its parent enclosing scope. In this way, we know which
variables are new and need to be declared with <code>var</code>, and which are shared
with external scopes.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.Scope = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Scope</span></span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the <strong>Block</strong> node it belongs to, which is
where it should declare its variables, a reference to the function that
it belongs to, and a list of variables referenced in the source code
and therefore should be avoided when generating variables.</p>
</div>
<div class="content"><div class='highlight'><pre> constructor: <span class="hljs-function"><span class="hljs-params">(@parent, @expressions, @method, @referencedVars)</span> -&gt;</span>
@variables = [{name: <span class="hljs-string">'arguments'</span>, type: <span class="hljs-string">'arguments'</span>}]
@positions = {}
@utilities = {} <span class="hljs-keyword">unless</span> @parent</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>The <code>@root</code> is the top-level <strong>Scope</strong> object for a given file.</p>
</div>
<div class="content"><div class='highlight'><pre> @root = @parent?.root ? <span class="hljs-keyword">this</span></pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Adds a new variable or overrides an existing one.</p>
</div>
<div class="content"><div class='highlight'><pre> add: <span class="hljs-function"><span class="hljs-params">(name, type, immediate)</span> -&gt;</span>
<span class="hljs-keyword">return</span> @parent.add name, type, immediate <span class="hljs-keyword">if</span> @shared <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> immediate
<span class="hljs-keyword">if</span> Object::hasOwnProperty.call @positions, name
@variables[@positions[name]].type = type
<span class="hljs-keyword">else</span>
@positions[name] = @variables.push({name, type}) - <span class="hljs-number">1</span></pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>When <code>super</code> is called, we need to find the name of the current method were
in, so that we know how to invoke the same method of the parent class. This
can get complicated if super is being called from an inner function.
<code>namedMethod</code> will walk up the scope tree until it either finds the first
function object that has a name filled in, or bottoms out.</p>
</div>
<div class="content"><div class='highlight'><pre> namedMethod: <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">return</span> @method <span class="hljs-keyword">if</span> @method?.name <span class="hljs-keyword">or</span> !@parent
@parent.namedMethod()</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Look up a variable name in lexical scope, and declare it if it does not
already exist.</p>
</div>
<div class="content"><div class='highlight'><pre> find: <span class="hljs-function"><span class="hljs-params">(name)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> @check name
@add name, <span class="hljs-string">'var'</span>
<span class="hljs-literal">no</span></pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Reserve a variable name as originating from a function parameter for this
scope. No <code>var</code> required for internal references.</p>
</div>
<div class="content"><div class='highlight'><pre> parameter: <span class="hljs-function"><span class="hljs-params">(name)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> @shared <span class="hljs-keyword">and</span> @parent.check name, <span class="hljs-literal">yes</span>
@add name, <span class="hljs-string">'param'</span></pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Just check to see if a variable has already been declared, without reserving,
walks up to the root scope.</p>
</div>
<div class="content"><div class='highlight'><pre> check: <span class="hljs-function"><span class="hljs-params">(name)</span> -&gt;</span>
!!(@type(name) <span class="hljs-keyword">or</span> @parent?.check(name))</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Generate a temporary variable name at the given index.</p>
</div>
<div class="content"><div class='highlight'><pre> temporary: <span class="hljs-function"><span class="hljs-params">(name, index, single=<span class="hljs-literal">false</span>)</span> -&gt;</span>
<span class="hljs-keyword">if</span> single
startCode = name.charCodeAt(<span class="hljs-number">0</span>)
endCode = <span class="hljs-string">'z'</span>.charCodeAt(<span class="hljs-number">0</span>)
diff = endCode - startCode
newCode = startCode + index % (diff + <span class="hljs-number">1</span>)
letter = String.fromCharCode(newCode)
num = index <span class="hljs-regexp">//</span> (diff + <span class="hljs-number">1</span>)
<span class="hljs-string">"<span class="hljs-subst">#{letter}</span><span class="hljs-subst">#{num <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>}</span>"</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"<span class="hljs-subst">#{name}</span><span class="hljs-subst">#{index <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>}</span>"</span></pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Gets the type of a variable.</p>
</div>
<div class="content"><div class='highlight'><pre> type: <span class="hljs-function"><span class="hljs-params">(name)</span> -&gt;</span>
<span class="hljs-keyword">return</span> v.type <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.name <span class="hljs-keyword">is</span> name
<span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>If we need to store an intermediate result, find an available name for a
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on…</p>
</div>
<div class="content"><div class='highlight'><pre> freeVariable: <span class="hljs-function"><span class="hljs-params">(name, options={})</span> -&gt;</span>
index = <span class="hljs-number">0</span>
<span class="hljs-keyword">loop</span>
temp = @temporary name, index, options.single
<span class="hljs-keyword">break</span> <span class="hljs-keyword">unless</span> @check(temp) <span class="hljs-keyword">or</span> temp <span class="hljs-keyword">in</span> @root.referencedVars
index++
@add temp, <span class="hljs-string">'var'</span>, <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> options.reserve ? <span class="hljs-literal">true</span>
temp</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Ensure that an assignment is made at the top of this scope
(or at the top-level scope, if requested).</p>
</div>
<div class="content"><div class='highlight'><pre> assign: <span class="hljs-function"><span class="hljs-params">(name, value)</span> -&gt;</span>
@add name, {value, assigned: <span class="hljs-literal">yes</span>}, <span class="hljs-literal">yes</span>
@hasAssignments = <span class="hljs-literal">yes</span></pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Does this scope have any declared variables?</p>
</div>
<div class="content"><div class='highlight'><pre> hasDeclarations: <span class="hljs-function">-&gt;</span>
!!@declaredVariables().length</pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Return the list of variables first declared in this scope.</p>
</div>
<div class="content"><div class='highlight'><pre> declaredVariables: <span class="hljs-function">-&gt;</span>
(v.name <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.type <span class="hljs-keyword">is</span> <span class="hljs-string">'var'</span>).sort()</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Return the list of assignments that are supposed to be made at the top
of this scope.</p>
</div>
<div class="content"><div class='highlight'><pre> assignedVariables: <span class="hljs-function">-&gt;</span>
<span class="hljs-string">"<span class="hljs-subst">#{v.name}</span> = <span class="hljs-subst">#{v.type.value}</span>"</span> <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.type.assigned</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,523 @@
<!DOCTYPE html>
<html>
<head>
<title>sourcemap.litcoffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="browser.html">
browser.coffee
</a>
<a class="source" href="cake.html">
cake.coffee
</a>
<a class="source" href="coffee-script.html">
coffee-script.coffee
</a>
<a class="source" href="command.html">
command.coffee
</a>
<a class="source" href="grammar.html">
grammar.coffee
</a>
<a class="source" href="helpers.html">
helpers.coffee
</a>
<a class="source" href="index.html">
index.coffee
</a>
<a class="source" href="lexer.html">
lexer.coffee
</a>
<a class="source" href="nodes.html">
nodes.coffee
</a>
<a class="source" href="optparse.html">
optparse.coffee
</a>
<a class="source" href="register.html">
register.coffee
</a>
<a class="source" href="repl.html">
repl.coffee
</a>
<a class="source" href="rewriter.html">
rewriter.coffee
</a>
<a class="source" href="scope.html">
scope.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.litcoffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>sourcemap.litcoffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>Source maps allow JavaScript runtimes to match running JavaScript back to
the original source code that corresponds to it. This can be minified
JavaScript, but in our case, were concerned with mapping pretty-printed
JavaScript back to CoffeeScript.</p>
<p>In order to produce maps, we must keep track of positions (line number, column number)
that originated every node in the syntax tree, and be able to generate a
<a href="https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit">map file</a>
— which is a compact, VLQ-encoded representation of the JSON serialization
of this information — to write out alongside the generated JavaScript.</p>
<h2 id="linemap">LineMap</h2>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>A <strong>LineMap</strong> object keeps track of information about original line and column
positions for a single line of output JavaScript code.
<strong>SourceMaps</strong> are implemented in terms of <strong>LineMaps</strong>.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">LineMap</span></span>
constructor: <span class="hljs-function"><span class="hljs-params">(@line)</span> -&gt;</span>
@columns = []
add: <span class="hljs-function"><span class="hljs-params">(column, [sourceLine, sourceColumn], options={})</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> @columns[column] <span class="hljs-keyword">and</span> options.noReplace
@columns[column] = {line: @line, column, sourceLine, sourceColumn}
sourceLocation: <span class="hljs-function"><span class="hljs-params">(column)</span> -&gt;</span>
column-- <span class="hljs-keyword">until</span> (mapping = @columns[column]) <span class="hljs-keyword">or</span> (column &lt;= <span class="hljs-number">0</span>)
mapping <span class="hljs-keyword">and</span> [mapping.sourceLine, mapping.sourceColumn]</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<h2 id="sourcemap">SourceMap</h2>
</div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Maps locations in a single generated JavaScript file back to locations in
the original CoffeeScript source file.</p>
<p>This is intentionally agnostic towards how a source map might be represented on
disk. Once the compiler is ready to produce a “v3”-style source map, we can walk
through the arrays of line and column buffer to produce it.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SourceMap</span></span>
constructor: <span class="hljs-function">-&gt;</span>
@lines = []</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<p>Adds a mapping to this SourceMap. <code>sourceLocation</code> and <code>generatedLocation</code>
are both <code>[line, column]</code> arrays. If <code>options.noReplace</code> is true, then if there
is already a mapping for the specified <code>line</code> and <code>column</code>, this will have no
effect.</p>
</div>
<div class="content"><div class='highlight'><pre> add: <span class="hljs-function"><span class="hljs-params">(sourceLocation, generatedLocation, options = {})</span> -&gt;</span>
[line, column] = generatedLocation
lineMap = (@lines[line] <span class="hljs-keyword">or</span>= <span class="hljs-keyword">new</span> LineMap(line))
lineMap.add column, sourceLocation, options</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Look up the original position of a given <code>line</code> and <code>column</code> in the generated
code.</p>
</div>
<div class="content"><div class='highlight'><pre> sourceLocation: <span class="hljs-function"><span class="hljs-params">([line, column])</span> -&gt;</span>
line-- <span class="hljs-keyword">until</span> (lineMap = @lines[line]) <span class="hljs-keyword">or</span> (line &lt;= <span class="hljs-number">0</span>)
lineMap <span class="hljs-keyword">and</span> lineMap.sourceLocation column</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<h2 id="v3-sourcemap-generation">V3 SourceMap Generation</h2>
</div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
</div>
<p>Builds up a V3 source map, returning the generated JSON as a string.
<code>options.sourceRoot</code> may be used to specify the sourceRoot written to the source
map. Also, <code>options.sourceFiles</code> and <code>options.generatedFile</code> may be passed to
set “sources” and “file”, respectively.</p>
</div>
<div class="content"><div class='highlight'><pre> generate: <span class="hljs-function"><span class="hljs-params">(options = {}, code = <span class="hljs-literal">null</span>)</span> -&gt;</span>
writingline = <span class="hljs-number">0</span>
lastColumn = <span class="hljs-number">0</span>
lastSourceLine = <span class="hljs-number">0</span>
lastSourceColumn = <span class="hljs-number">0</span>
needComma = <span class="hljs-literal">no</span>
buffer = <span class="hljs-string">""</span>
<span class="hljs-keyword">for</span> lineMap, lineNumber <span class="hljs-keyword">in</span> @lines <span class="hljs-keyword">when</span> lineMap
<span class="hljs-keyword">for</span> mapping <span class="hljs-keyword">in</span> lineMap.columns <span class="hljs-keyword">when</span> mapping
<span class="hljs-keyword">while</span> writingline &lt; mapping.line
lastColumn = <span class="hljs-number">0</span>
needComma = <span class="hljs-literal">no</span>
buffer += <span class="hljs-string">";"</span>
writingline++</pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Write a comma if weve already written a segment on this line.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> needComma
buffer += <span class="hljs-string">","</span>
needComma = <span class="hljs-literal">no</span></pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Write the next segment. Segments can be 1, 4, or 5 values. If just one, then it
is a generated column which doesnt match anything in the source code.</p>
<p>The starting column in the generated source, relative to any previous recorded
column for the current line:</p>
</div>
<div class="content"><div class='highlight'><pre> buffer += @encodeVlq mapping.column - lastColumn
lastColumn = mapping.column</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>The index into the list of sources:</p>
</div>
<div class="content"><div class='highlight'><pre> buffer += @encodeVlq <span class="hljs-number">0</span></pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>The starting line in the original source, relative to the previous source line.</p>
</div>
<div class="content"><div class='highlight'><pre> buffer += @encodeVlq mapping.sourceLine - lastSourceLine
lastSourceLine = mapping.sourceLine</pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>The starting column in the original source, relative to the previous column.</p>
</div>
<div class="content"><div class='highlight'><pre> buffer += @encodeVlq mapping.sourceColumn - lastSourceColumn
lastSourceColumn = mapping.sourceColumn
needComma = <span class="hljs-literal">yes</span></pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Produce the canonical JSON object format for a “v3” source map.</p>
</div>
<div class="content"><div class='highlight'><pre> v3 =
version: <span class="hljs-number">3</span>
file: options.generatedFile <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>
sourceRoot: options.sourceRoot <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>
sources: options.sourceFiles <span class="hljs-keyword">or</span> [<span class="hljs-string">''</span>]
names: []
mappings: buffer
v3.sourcesContent = [code] <span class="hljs-keyword">if</span> options.inlineMap
v3</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<h2 id="base64-vlq-encoding">Base64 VLQ Encoding</h2>
</div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Note that SourceMap VLQ encoding is “backwards”. MIDI-style VLQ encoding puts
the most-significant-bit (MSB) from the original value into the MSB of the VLQ
encoded value (see <a href="http://en.wikipedia.org/wiki/File:Uintvar_coding.svg">Wikipedia</a>).
SourceMap VLQ does things the other way around, with the least significat four
bits of the original value encoded into the first byte of the VLQ encoded value.</p>
</div>
<div class="content"><div class='highlight'><pre> VLQ_SHIFT = <span class="hljs-number">5</span>
VLQ_CONTINUATION_BIT = <span class="hljs-number">1</span> &lt;&lt; VLQ_SHIFT <span class="hljs-comment"># 0010 0000</span>
VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - <span class="hljs-number">1</span> <span class="hljs-comment"># 0001 1111</span>
encodeVlq: <span class="hljs-function"><span class="hljs-params">(value)</span> -&gt;</span>
answer = <span class="hljs-string">''</span></pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Least significant bit represents the sign.</p>
</div>
<div class="content"><div class='highlight'><pre> signBit = <span class="hljs-keyword">if</span> value &lt; <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span></pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>The next bits are the actual value.</p>
</div>
<div class="content"><div class='highlight'><pre> valueToEncode = (Math.abs(value) &lt;&lt; <span class="hljs-number">1</span>) + signBit</pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Make sure we encode at least one character, even if valueToEncode is 0.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">while</span> valueToEncode <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> answer
nextChunk = valueToEncode &amp; VLQ_VALUE_MASK
valueToEncode = valueToEncode &gt;&gt; VLQ_SHIFT
nextChunk |= VLQ_CONTINUATION_BIT <span class="hljs-keyword">if</span> valueToEncode
answer += @encodeBase64 nextChunk
answer</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<h2 id="regular-base64-encoding">Regular Base64 Encoding</h2>
</div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre> BASE64_CHARS = <span class="hljs-string">'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'</span>
encodeBase64: <span class="hljs-function"><span class="hljs-params">(value)</span> -&gt;</span>
BASE64_CHARS[value] <span class="hljs-keyword">or</span> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Cannot Base64 encode value: <span class="hljs-subst">#{value}</span>"</span></pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Our API for source maps is just the <code>SourceMap</code> class.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">module</span>.exports = SourceMap</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,395 @@
/**
* CoffeeScript Compiler v1.12.0
* http://coffeescript.org
*
* Copyright 2011, Jeremy Ashkenas
* Released under the MIT License
*/
var $jscomp={scope:{},checkStringArgs:function(t,ya,pa){if(null==t)throw new TypeError("The 'this' value for String.prototype."+pa+" must not be null or undefined");if(ya instanceof RegExp)throw new TypeError("First argument to String.prototype."+pa+" must not be a regular expression");return t+""}};
$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(t,ya,pa){if(pa.get||pa.set)throw new TypeError("ES3 does not support getters and setters.");t!=Array.prototype&&t!=Object.prototype&&(t[ya]=pa.value)};$jscomp.getGlobal=function(t){return"undefined"!=typeof window&&window===t?t:"undefined"!=typeof global&&null!=global?global:t};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(t,ya,pa,f){if(ya){pa=$jscomp.global;t=t.split(".");for(f=0;f<t.length-1;f++){var ta=t[f];ta in pa||(pa[ta]={});pa=pa[ta]}t=t[t.length-1];f=pa[t];ya=ya(f);ya!=f&&null!=ya&&$jscomp.defineProperty(pa,t,{configurable:!0,writable:!0,value:ya})}};
$jscomp.polyfill("String.prototype.repeat",function(t){return t?t:function(t){var pa=$jscomp.checkStringArgs(this,null,"repeat");if(0>t||1342177279<t)throw new RangeError("Invalid count value");t|=0;for(var f="";t;)if(t&1&&(f+=pa),t>>>=1)pa+=pa;return f}},"es6-impl","es3");$jscomp.findInternal=function(t,ya,pa){t instanceof String&&(t=String(t));for(var f=t.length,ta=0;ta<f;ta++){var xa=t[ta];if(ya.call(pa,xa,ta,t))return{i:ta,v:xa}}return{i:-1,v:void 0}};
$jscomp.polyfill("Array.prototype.find",function(t){return t?t:function(t,pa){return $jscomp.findInternal(this,t,pa).v}},"es6-impl","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(t){return $jscomp.SYMBOL_PREFIX+(t||"")+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var t=$jscomp.global.Symbol.iterator;t||(t=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[t]&&$jscomp.defineProperty(Array.prototype,t,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};
$jscomp.arrayIterator=function(t){var ya=0;return $jscomp.iteratorPrototype(function(){return ya<t.length?{done:!1,value:t[ya++]}:{done:!0}})};$jscomp.iteratorPrototype=function(t){$jscomp.initSymbolIterator();t={next:t};t[$jscomp.global.Symbol.iterator]=function(){return this};return t};$jscomp.array=$jscomp.array||{};
$jscomp.iteratorFromArray=function(t,ya){$jscomp.initSymbolIterator();t instanceof String&&(t+="");var pa=0,f={next:function(){if(pa<t.length){var ta=pa++;return{value:ya(ta,t[ta]),done:!1}}f.next=function(){return{done:!0,value:void 0}};return f.next()}};f[Symbol.iterator]=function(){return f};return f};$jscomp.polyfill("Array.prototype.keys",function(t){return t?t:function(){return $jscomp.iteratorFromArray(this,function(t){return t})}},"es6-impl","es3");
(function(t){var ya=function(){function t(f){return t[f]}t["./helpers"]=function(){var f={};(function(){var t,xa,D,a,c,Ca;f.starts=function(a,c,l){return c===a.substr(l,c.length)};f.ends=function(a,c,l){var d;d=c.length;return c===a.substr(a.length-d-(l||0),d)};f.repeat=c=function(a,c){var d;for(d="";0<c;)c&1&&(d+=a),c>>>=1,a+=a;return d};f.compact=function(a){var d,c,f,D;D=[];d=0;for(f=a.length;d<f;d++)(c=a[d])&&D.push(c);return D};f.count=function(a,c){var d,v;d=v=0;if(!c.length)return 1/0;for(;v=
1+a.indexOf(c,v);)d++;return d};f.merge=function(a,c){return xa(xa({},a),c)};xa=f.extend=function(a,c){var d,v;for(d in c)v=c[d],a[d]=v;return a};f.flatten=D=function(a){var d,c,f,F;c=[];f=0;for(F=a.length;f<F;f++)d=a[f],"[object Array]"===Object.prototype.toString.call(d)?c=c.concat(D(d)):c.push(d);return c};f.del=function(a,c){var d;d=a[c];delete a[c];return d};f.some=null!=(a=Array.prototype.some)?a:function(a){var d,c,f;c=0;for(f=this.length;c<f;c++)if(d=this[c],a(d))return!0;return!1};f.invertLiterate=
function(a){var d;d=!0;var c,f,D,w;D=a.split("\n");w=[];c=0;for(f=D.length;c<f;c++)a=D[c],d&&/^([ ]{4}|[ ]{0,3}\t)/.test(a)?w.push(a):(d=/^\s*$/.test(a))?w.push(a):w.push("# "+a);return w.join("\n")};t=function(a,c){return c?{first_line:a.first_line,first_column:a.first_column,last_line:c.last_line,last_column:c.last_column}:a};f.addLocationDataFn=function(a,c){return function(d){"object"===typeof d&&d.updateLocationDataIfMissing&&d.updateLocationDataIfMissing(t(a,c));return d}};f.locationDataToString=
function(a){var d;"2"in a&&"first_line"in a[2]?d=a[2]:"first_line"in a&&(d=a);return d?d.first_line+1+":"+(d.first_column+1)+"-"+(d.last_line+1+":"+(d.last_column+1)):"No location data"};f.baseFileName=function(a,c,f){null==c&&(c=!1);null==f&&(f=!1);a=a.split(f?/\\|\//:/\//);a=a[a.length-1];if(!(c&&0<=a.indexOf(".")))return a;a=a.split(".");a.pop();"coffee"===a[a.length-1]&&1<a.length&&a.pop();return a.join(".")};f.isCoffee=function(a){return/\.((lit)?coffee|coffee\.md)$/.test(a)};f.isLiterate=function(a){return/\.(litcoffee|coffee\.md)$/.test(a)};
f.throwSyntaxError=function(a,c){a=new SyntaxError(a);a.location=c;a.toString=Ca;a.stack=a.toString();throw a;};f.updateSyntaxError=function(a,c,f){a.toString===Ca&&(a.code||(a.code=c),a.filename||(a.filename=f),a.stack=a.toString());return a};Ca=function(){var a,f,l,D,F,w,z,n,G,t;if(!this.code||!this.location)return Error.prototype.toString.call(this);a=this.location;w=a.first_line;F=a.first_column;l=a.last_line;z=a.last_column;null==l&&(l=w);null==z&&(z=F);D=this.filename||"[stdin]";a=this.code.split("\n")[w];
l=w===l?z+1:a.length;z=a.slice(0,F).replace(/[^\s]/g," ")+c("^",l-F);"undefined"!==typeof process&&null!==process&&(f=(null!=(n=process.stdout)?n.isTTY:void 0)&&!(null!=(G=process.env)&&G.NODE_DISABLE_COLORS));if(null!=(t=this.colorful)?t:f)f=function(a){return"\u001b[1;31m"+a+"\u001b[0m"},a=a.slice(0,F)+f(a.slice(F,l))+a.slice(l),z=f(z);return D+":"+(w+1)+":"+(F+1)+": error: "+this.message+"\n"+a+"\n"+z};f.nameWhitespaceCharacter=function(a){switch(a){case " ":return"space";case "\n":return"newline";
case "\r":return"carriage return";case "\t":return"tab";default:return a}}}).call(this);return f}();t["./rewriter"]=function(){var f={};(function(){var t,xa,D,a,c,Ca,d,v,l,u,F,w,z,n,G,L,I,x,E=[].indexOf||function(a){for(var c=0,d=this.length;c<d;c++)if(c in this&&this[c]===a)return c;return-1},m=[].slice;n=function(a,c,d){a=[a,c];a.generated=!0;d&&(a.origin=d);return a};f.Rewriter=function(){function g(){}g.prototype.rewrite=function(a){this.tokens=a;this.removeLeadingNewlines();this.closeOpenCalls();
this.closeOpenIndexes();this.normalizeLines();this.tagPostfixConditionals();this.addImplicitBracesAndParens();this.addLocationDataToGeneratedTokens();this.fixOutdentLocationData();return this.tokens};g.prototype.scanTokens=function(a){var c,d,h;h=this.tokens;for(c=0;d=h[c];)c+=a.call(this,d,c,h);return!0};g.prototype.detectEnd=function(d,q,k){var h,r,g,f,m;m=this.tokens;for(h=0;f=m[d];){if(0===h&&q.call(this,f,d))return k.call(this,f,d);if(!f||0>h)return k.call(this,f,d-1);(r=f[0],0<=E.call(c,r))?
h+=1:(g=f[0],0<=E.call(a,g))&&--h;d+=1}return d-1};g.prototype.removeLeadingNewlines=function(){var a,c,d,h,g;h=this.tokens;a=c=0;for(d=h.length;c<d&&(g=h[a][0],"TERMINATOR"===g);a=++c);if(a)return this.tokens.splice(0,a)};g.prototype.closeOpenCalls=function(){var a,c;c=function(a,c){var h;return")"===(h=a[0])||"CALL_END"===h||"OUTDENT"===a[0]&&")"===this.tag(c-1)};a=function(a,c){return this.tokens["OUTDENT"===a[0]?c-1:c][0]="CALL_END"};return this.scanTokens(function(d,h){"CALL_START"===d[0]&&this.detectEnd(h+
1,c,a);return 1})};g.prototype.closeOpenIndexes=function(){var a,c;c=function(a,c){var h;return"]"===(h=a[0])||"INDEX_END"===h};a=function(a,c){return a[0]="INDEX_END"};return this.scanTokens(function(d,h){"INDEX_START"===d[0]&&this.detectEnd(h+1,c,a);return 1})};g.prototype.indexOfTag=function(){var a,c,d,h,g,f,H;c=arguments[0];g=2<=arguments.length?m.call(arguments,1):[];d=h=a=0;for(f=g.length;0<=f?h<f:h>f;d=0<=f?++h:--h){for(;"HERECOMMENT"===this.tag(c+d+a);)a+=2;if(null!=g[d]&&("string"===typeof g[d]&&
(g[d]=[g[d]]),H=this.tag(c+d+a),0>E.call(g[d],H)))return-1}return c+d+a-1};g.prototype.looksObjectish=function(d){var g;if(-1<this.indexOfTag(d,"@",null,":")||-1<this.indexOfTag(d,null,":"))return!0;d=this.indexOfTag(d,c);return-1<d&&(g=null,this.detectEnd(d+1,function(c){var d;return d=c[0],0<=E.call(a,d)},function(a,c){return g=c}),":"===this.tag(g+1))?!0:!1};g.prototype.findTagsBackwards=function(d,g){var f,h,r,q,H,m,l;for(f=[];0<=d&&(f.length||(q=this.tag(d),0>E.call(g,q))&&((H=this.tag(d),0>
E.call(c,H))||this.tokens[d].generated)&&(m=this.tag(d),0>E.call(F,m)));)(h=this.tag(d),0<=E.call(a,h))&&f.push(this.tag(d)),(r=this.tag(d),0<=E.call(c,r))&&f.length&&f.pop(),--d;return l=this.tag(d),0<=E.call(g,l)};g.prototype.addImplicitBracesAndParens=function(){var g,f;g=[];f=null;return this.scanTokens(function(q,h,r){var k,m,y,K,D,x,u,z,C,A,G,B,t,w,I,L,U,J;J=q[0];A=(G=0<h?r[h-1]:[])[0];C=(h<r.length-1?r[h+1]:[])[0];I=function(){return g[g.length-1]};L=h;y=function(a){return h-L+a};K=function(){var a,
c;return null!=(a=I())?null!=(c=a[2])?c.ours:void 0:void 0};D=function(){var a;return K()&&"("===(null!=(a=I())?a[0]:void 0)};u=function(){var a;return K()&&"{"===(null!=(a=I())?a[0]:void 0)};x=function(){var a;return K&&"CONTROL"===(null!=(a=I())?a[0]:void 0)};U=function(a){var c;c=null!=a?a:h;g.push(["(",c,{ours:!0}]);r.splice(c,0,n("CALL_START","("));if(null==a)return h+=1};k=function(){g.pop();r.splice(h,0,n("CALL_END",")",["","end of input",q[2]]));return h+=1};z=function(a,c){var d;null==c&&
(c=!0);d=null!=a?a:h;g.push(["{",d,{sameLine:!0,startsLine:c,ours:!0}]);c=new String("{");c.generated=!0;r.splice(d,0,n("{",c,q));if(null==a)return h+=1};m=function(a){a=null!=a?a:h;g.pop();r.splice(a,0,n("}","}",q));return h+=1};if(D()&&("IF"===J||"TRY"===J||"FINALLY"===J||"CATCH"===J||"CLASS"===J||"SWITCH"===J))return g.push(["CONTROL",h,{ours:!0}]),y(1);if("INDENT"===J&&K()){if("\x3d\x3e"!==A&&"-\x3e"!==A&&"["!==A&&"("!==A&&","!==A&&"{"!==A&&"TRY"!==A&&"ELSE"!==A&&"\x3d"!==A)for(;D();)k();x()&&
g.pop();g.push([J,h]);return y(1)}if(0<=E.call(c,J))return g.push([J,h]),y(1);if(0<=E.call(a,J)){for(;K();)D()?k():u()?m():g.pop();f=g.pop()}if((0<=E.call(v,J)&&q.spaced||"?"===J&&0<h&&!r[h-1].spaced)&&(0<=E.call(Ca,C)||0<=E.call(l,C)&&(null==(B=r[h+1])||!B.spaced)&&(null==(t=r[h+1])||!t.newLine)))return"?"===J&&(J=q[0]="FUNC_EXIST"),U(h+1),y(2);if(0<=E.call(v,J)&&-1<this.indexOfTag(h+1,"INDENT")&&this.looksObjectish(h+2)&&!this.findTagsBackwards(h,"CLASS EXTENDS IF CATCH SWITCH LEADING_WHEN FOR WHILE UNTIL".split(" ")))return U(h+
1),g.push(["INDENT",h+2]),y(3);if(":"===J){for(m=function(){var c;switch(!1){case c=this.tag(h-1),0>E.call(a,c):return f[1];case "@"!==this.tag(h-2):return h-2;default:return h-1}}.call(this);"HERECOMMENT"===this.tag(m-2);)m-=2;this.insideForDeclaration="FOR"===C;x=0===m||(w=this.tag(m-1),0<=E.call(F,w))||r[m-1].newLine;if(I()&&(u=I(),w=u[0],G=u[1],("{"===w||"INDENT"===w&&"{"===this.tag(G-1))&&(x||","===this.tag(m-1)||"{"===this.tag(m-1))))return y(1);z(m,!!x);return y(2)}u()&&0<=E.call(F,J)&&(I()[2].sameLine=
!1);z="OUTDENT"===A||G.newLine;if(0<=E.call(d,J)||0<=E.call(xa,J)&&z)for(;K();)if(z=I(),w=z[0],G=z[1],w=z[2],z=w.sameLine,x=w.startsLine,D()&&","!==A)k();else if(u()&&!this.insideForDeclaration&&z&&"TERMINATOR"!==J&&":"!==A)m();else if(!u()||"TERMINATOR"!==J||","===A||x&&this.looksObjectish(h+1))break;else{if("HERECOMMENT"===C)return y(1);m()}if(!(","!==J||this.looksObjectish(h+1)||!u()||this.insideForDeclaration||"TERMINATOR"===C&&this.looksObjectish(h+2)))for(C="OUTDENT"===C?1:0;u();)m(h+C);return y(1)})};
g.prototype.addLocationDataToGeneratedTokens=function(){return this.scanTokens(function(a,c,d){var h,g,f;if(a[2]||!a.generated&&!a.explicit)return 1;"{"===a[0]&&(h=null!=(f=d[c+1])?f[2]:void 0)?(g=h.first_line,h=h.first_column):(h=null!=(g=d[c-1])?g[2]:void 0)?(g=h.last_line,h=h.last_column):g=h=0;a[2]={first_line:g,first_column:h,last_line:g,last_column:h};return 1})};g.prototype.fixOutdentLocationData=function(){return this.scanTokens(function(a,c,d){if(!("OUTDENT"===a[0]||a.generated&&"CALL_END"===
a[0]||a.generated&&"}"===a[0]))return 1;c=d[c-1][2];a[2]={first_line:c.last_line,first_column:c.last_column,last_line:c.last_line,last_column:c.last_column};return 1})};g.prototype.normalizeLines=function(){var a,c,d,h,g;g=d=h=null;c=function(a,c){var d,h,f,m;return";"!==a[1]&&(d=a[0],0<=E.call(w,d))&&!("TERMINATOR"===a[0]&&(h=this.tag(c+1),0<=E.call(D,h)))&&!("ELSE"===a[0]&&"THEN"!==g)&&!!("CATCH"!==(f=a[0])&&"FINALLY"!==f||"-\x3e"!==g&&"\x3d\x3e"!==g)||(m=a[0],0<=E.call(xa,m))&&this.tokens[c-1].newLine};
a=function(a,c){return this.tokens.splice(","===this.tag(c-1)?c-1:c,0,h)};return this.scanTokens(function(f,q,r){var k,l,x;f=f[0];if("TERMINATOR"===f){if("ELSE"===this.tag(q+1)&&"OUTDENT"!==this.tag(q-1))return r.splice.apply(r,[q,1].concat(m.call(this.indentation()))),1;if(k=this.tag(q+1),0<=E.call(D,k))return r.splice(q,1),0}if("CATCH"===f)for(k=l=1;2>=l;k=++l)if("OUTDENT"===(x=this.tag(q+k))||"TERMINATOR"===x||"FINALLY"===x)return r.splice.apply(r,[q+k,0].concat(m.call(this.indentation()))),2+
k;0<=E.call(z,f)&&"INDENT"!==this.tag(q+1)&&("ELSE"!==f||"IF"!==this.tag(q+1))&&(g=f,x=this.indentation(r[q]),d=x[0],h=x[1],"THEN"===g&&(d.fromThen=!0),r.splice(q+1,0,d),this.detectEnd(q+2,c,a),"THEN"===f&&r.splice(q,1));return 1})};g.prototype.tagPostfixConditionals=function(){var a,c,d;d=null;c=function(a,c){a=a[0];c=this.tokens[c-1][0];return"TERMINATOR"===a||"INDENT"===a&&0>E.call(z,c)};a=function(a,c){if("INDENT"!==a[0]||a.generated&&!a.fromThen)return d[0]="POST_"+d[0]};return this.scanTokens(function(h,
g){if("IF"!==h[0])return 1;d=h;this.detectEnd(g+1,c,a);return 1})};g.prototype.indentation=function(a){var c,d;c=["INDENT",2];d=["OUTDENT",2];a?(c.generated=d.generated=!0,c.origin=d.origin=a):c.explicit=d.explicit=!0;return[c,d]};g.prototype.generate=n;g.prototype.tag=function(a){var c;return null!=(c=this.tokens[a])?c[0]:void 0};return g}();t=[["(",")"],["[","]"],["{","}"],["INDENT","OUTDENT"],["CALL_START","CALL_END"],["PARAM_START","PARAM_END"],["INDEX_START","INDEX_END"],["STRING_START","STRING_END"],
["REGEX_START","REGEX_END"]];f.INVERSES=u={};c=[];a=[];G=0;for(I=t.length;G<I;G++)x=t[G],L=x[0],x=x[1],c.push(u[x]=L),a.push(u[L]=x);D=["CATCH","THEN","ELSE","FINALLY"].concat(a);v="IDENTIFIER PROPERTY SUPER ) CALL_END ] INDEX_END @ THIS".split(" ");Ca="IDENTIFIER PROPERTY NUMBER INFINITY NAN STRING STRING_START REGEX REGEX_START JS NEW PARAM_START CLASS IF TRY SWITCH THIS UNDEFINED NULL BOOL UNARY YIELD UNARY_MATH SUPER THROW @ -\x3e \x3d\x3e [ ( { -- ++".split(" ");l=["+","-"];d="POST_IF FOR WHILE UNTIL WHEN BY LOOP TERMINATOR".split(" ");
z="ELSE -\x3e \x3d\x3e TRY FINALLY THEN".split(" ");w="TERMINATOR CATCH FINALLY ELSE OUTDENT LEADING_WHEN".split(" ");F=["TERMINATOR","INDENT","OUTDENT"];xa=[".","?.","::","?::"]}).call(this);return f}();t["./lexer"]=function(){var f={};(function(){var ta,xa,D,a,c,Ca,d,v,l,u,F,w,z,n,G,L,I,x,E,m,g,r,q,k,h,K,O,H,y,T,S,P,Z,R,C,A,W,B,N,X,Y,V,U,J,aa,Q,pa,ya,Xa,ia,ba,da,ga,fa,ka,ja,M,ha,ca=[].indexOf||function(a){for(var c=0,d=this.length;c<d;c++)if(c in this&&this[c]===a)return c;return-1},oa=[].slice;
ja=t("./rewriter");B=ja.Rewriter;g=ja.INVERSES;ja=t("./helpers");da=ja.count;M=ja.repeat;ga=ja.invertLiterate;ha=ja.throwSyntaxError;f.Lexer=function(){function f(){}f.prototype.tokenize=function(a,c){var d,f,qa,h;null==c&&(c={});this.literate=c.literate;this.outdebt=this.indebt=this.baseIndent=this.indent=0;this.indents=[];this.ends=[];this.tokens=[];this.exportSpecifierList=this.seenExport=this.seenImport=this.seenFor=!1;this.chunkLine=c.line||0;this.chunkColumn=c.column||0;a=this.clean(a);for(qa=
0;this.chunk=a.slice(qa);)if(d=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.numberToken()||this.regexToken()||this.jsToken()||this.literalToken(),h=this.getLineAndColumnFromChunk(d),this.chunkLine=h[0],this.chunkColumn=h[1],qa+=d,c.untilBalanced&&0===this.ends.length)return{tokens:this.tokens,index:qa};this.closeIndentation();(f=this.ends.pop())&&this.error("missing "+f.tag,f.origin[2]);return!1===c.rewrite?this.tokens:(new B).rewrite(this.tokens)};
f.prototype.clean=function(a){a.charCodeAt(0)===ta&&(a=a.slice(1));a=a.replace(/\r/g,"").replace(pa,"");ba.test(a)&&(a="\n"+a,this.chunkLine--);this.literate&&(a=ga(a));return a};f.prototype.identifierToken=function(){var d,f,g,m,r,k,l,x,D,y,n;if(!(f=I.exec(this.chunk)))return 0;r=f[0];g=f[1];f=f[2];m=g.length;k=void 0;if("own"===g&&"FOR"===this.tag())return this.token("OWN",g),g.length;if("from"===g&&"YIELD"===this.tag())return this.token("FROM",g),g.length;if("as"===g&&this.seenImport){if("*"===
this.value())this.tokens[this.tokens.length-1][0]="IMPORT_ALL";else if(l=this.value(),0<=ca.call(Ca,l))this.tokens[this.tokens.length-1][0]="IDENTIFIER";if("IMPORT_ALL"===(x=this.tag())||"IDENTIFIER"===x)return this.token("AS",g),g.length}if("as"===g&&this.seenExport&&"IDENTIFIER"===this.tag())return this.token("AS",g),g.length;if("default"===g&&this.seenExport)return this.token("DEFAULT",g),g.length;l=this.tokens;l=l[l.length-1];n=f||null!=l&&("."===(D=l[0])||"?."===D||"::"===D||"?::"===D||!l.spaced&&
"@"===l[0])?"PROPERTY":"IDENTIFIER";"IDENTIFIER"!==n||!(0<=ca.call(q,g)||0<=ca.call(Ca,g))||this.exportSpecifierList&&0<=ca.call(Ca,g)?"IDENTIFIER"===n&&this.seenFor&&"from"===g&&(n="FORFROM",this.seenFor=!1):(n=g.toUpperCase(),"WHEN"===n&&(y=this.tag(),0<=ca.call(h,y))?n="LEADING_WHEN":"FOR"===n?this.seenFor=!0:"UNLESS"===n?n="IF":"IMPORT"===n?this.seenImport=!0:"EXPORT"===n?this.seenExport=!0:0<=ca.call(ya,n)?n="UNARY":0<=ca.call(A,n)&&("INSTANCEOF"!==n&&this.seenFor?(n="FOR"+n,this.seenFor=!1):
(n="RELATION","!"===this.value()&&(k=this.tokens.pop(),g="!"+g))));"IDENTIFIER"===n&&0<=ca.call(W,g)&&this.error("reserved word '"+g+"'",{length:g.length});"PROPERTY"!==n&&(0<=ca.call(a,g)&&(d=g,g=c[g]),n=function(){switch(g){case "!":return"UNARY";case "\x3d\x3d":case "!\x3d":return"COMPARE";case "true":case "false":return"BOOL";case "break":case "continue":case "debugger":return"STATEMENT";case "\x26\x26":case "||":return g;default:return n}}());D=this.token(n,g,0,m);d&&(D.origin=[n,d,D[2]]);k&&
(d=[k[2].first_line,k[2].first_column],D[2].first_line=d[0],D[2].first_column=d[1]);f&&(d=r.lastIndexOf(":"),this.token(":",":",d,f.length));return r.length};f.prototype.numberToken=function(){var a,c,d,g;if(!(c=T.exec(this.chunk)))return 0;d=c[0];c=d.length;switch(!1){case !/^0[BOX]/.test(d):this.error("radix prefix in '"+d+"' must be lowercase",{offset:1});break;case !/^(?!0x).*E/.test(d):this.error("exponential notation in '"+d+"' must be indicated with a lowercase 'e'",{offset:d.indexOf("E")});
break;case !/^0\d*[89]/.test(d):this.error("decimal literal '"+d+"' must not be prefixed with '0'",{length:c});break;case !/^0\d+/.test(d):this.error("octal literal '"+d+"' must be prefixed with '0o'",{length:c})}a=function(){switch(d.charAt(1)){case "b":return 2;case "o":return 8;case "x":return 16;default:return null}}();a=null!=a?parseInt(d.slice(2),a):parseFloat(d);if("b"===(g=d.charAt(1))||"o"===g)d="0x"+a.toString(16);this.token(Infinity===a?"INFINITY":"NUMBER",d,0,c);return c};f.prototype.stringToken=
function(){var a,c,d,g,f,h,m,q,r,n,l,D;r=(aa.exec(this.chunk)||[])[0];if(!r)return 0;this.tokens.length&&"from"===this.value()&&(this.seenImport||this.seenExport)&&(this.tokens[this.tokens.length-1][0]="FROM");d=function(){switch(r){case "'":return J;case '"':return V;case "'''":return z;case '"""':return F}}();g=3===r.length;d=this.matchWithInterpolations(d,r);D=d.tokens;f=d.index;a=D.length-1;d=r.charAt(0);if(g){m=null;for(g=function(){var a,c,d;d=[];h=a=0;for(c=D.length;a<c;h=++a)l=D[h],"NEOSTRING"===
l[0]&&d.push(l[1]);return d}().join("#{}");c=w.exec(g);)if(c=c[1],null===m||0<(n=c.length)&&n<m.length)m=c;m&&(q=RegExp("\\n"+m,"g"));this.mergeInterpolationTokens(D,{delimiter:d},function(c){return function(d,g){d=c.formatString(d);q&&(d=d.replace(q,"\n"));0===g&&(d=d.replace(k,""));g===a&&(d=d.replace(Q,""));return d}}(this))}else this.mergeInterpolationTokens(D,{delimiter:d},function(c){return function(d,g){d=c.formatString(d);return d=d.replace(X,function(c,f){return 0===g&&0===f||g===a&&f+c.length===
d.length?"":" "})}}(this));return f};f.prototype.commentToken=function(){var a,c,g;if(!(g=this.chunk.match(d)))return 0;a=g[0];if(c=g[1])(g=u.exec(a))&&this.error("block comments cannot contain "+g[0],{offset:g.index,length:g[0].length}),0<=c.indexOf("\n")&&(c=c.replace(RegExp("\\n"+M(" ",this.indent),"g"),"\n")),this.token("HERECOMMENT",c,0,a.length);return a.length};f.prototype.jsToken=function(){var a,c;if("`"!==this.chunk.charAt(0)||!(a=L.exec(this.chunk)||r.exec(this.chunk)))return 0;c=a[1].replace(/\\+(`|$)/g,
function(a){return a.slice(-Math.ceil(a.length/2))});this.token("JS",c,0,a[0].length);return a[0].length};f.prototype.regexToken=function(){var a,c,d,g,f,h,m,r;switch(!1){case !(c=C.exec(this.chunk)):this.error("regular expressions cannot begin with "+c[2],{offset:c.index+c[1].length});break;case !(c=this.matchWithInterpolations(n,"///")):r=c.tokens;f=c.index;break;case !(c=Z.exec(this.chunk)):m=c[0];a=c[1];c=c[2];this.validateEscapes(a,{isRegex:!0,offsetInChunk:1});f=m.length;h=this.tokens;if(h=
h[h.length-1])if(h.spaced&&(d=h[0],0<=ca.call(xa,d))){if(!c||P.test(m))return 0}else if(g=h[0],0<=ca.call(y,g))return 0;c||this.error("missing / (unclosed regex)");break;default:return 0}g=R.exec(this.chunk.slice(f))[0];d=f+g.length;c=this.makeToken("REGEX",null,0,d);switch(!1){case !!ia.test(g):this.error("invalid regular expression flags "+g,{offset:f,length:g.length});break;case !(m||1===r.length):null==a&&(a=this.formatHeregex(r[0][1]));this.token("REGEX",""+this.makeDelimitedLiteral(a,{delimiter:"/"})+
g,0,d,c);break;default:this.token("REGEX_START","(",0,0,c),this.token("IDENTIFIER","RegExp",0,0),this.token("CALL_START","(",0,0),this.mergeInterpolationTokens(r,{delimiter:'"',double:!0},this.formatHeregex),g&&(this.token(",",",",f,0),this.token("STRING",'"'+g+'"',f,g.length)),this.token(")",")",d,0),this.token("REGEX_END",")",d,0)}return d};f.prototype.lineToken=function(){var a,c,d;if(!(c=H.exec(this.chunk)))return 0;c=c[0];this.seenFor=!1;d=c.length-1-c.lastIndexOf("\n");a=this.unfinished();if(d-
this.indebt===this.indent)return a?this.suppressNewlines():this.newlineToken(0),c.length;if(d>this.indent){if(a)return this.indebt=d-this.indent,this.suppressNewlines(),c.length;if(!this.tokens.length)return this.baseIndent=this.indent=d,c.length;a=d-this.indent+this.outdebt;this.token("INDENT",a,c.length-d,d);this.indents.push(a);this.ends.push({tag:"OUTDENT"});this.outdebt=this.indebt=0;this.indent=d}else d<this.baseIndent?this.error("missing indentation",{offset:c.length}):(this.indebt=0,this.outdentToken(this.indent-
d,a,c.length));return c.length};f.prototype.outdentToken=function(a,c,d){var g,f,h,m;for(g=this.indent-a;0<a;)(h=this.indents[this.indents.length-1])?h===this.outdebt?(a-=this.outdebt,this.outdebt=0):h<this.outdebt?(this.outdebt-=h,a-=h):(f=this.indents.pop()+this.outdebt,d&&(m=this.chunk[d],0<=ca.call(x,m))&&(g-=f-a,a=f),this.outdebt=0,this.pair("OUTDENT"),this.token("OUTDENT",a,0,d),a-=f):a=0;f&&(this.outdebt-=a);for(;";"===this.value();)this.tokens.pop();"TERMINATOR"===this.tag()||c||this.token("TERMINATOR",
"\n",d,0);this.indent=g;return this};f.prototype.whitespaceToken=function(){var a,c;if(!(a=ba.exec(this.chunk))&&"\n"!==this.chunk.charAt(0))return 0;c=this.tokens;(c=c[c.length-1])&&(c[a?"spaced":"newLine"]=!0);return a?a[0].length:0};f.prototype.newlineToken=function(a){for(;";"===this.value();)this.tokens.pop();"TERMINATOR"!==this.tag()&&this.token("TERMINATOR","\n",a,0);return this};f.prototype.suppressNewlines=function(){"\\"===this.value()&&this.tokens.pop();return this};f.prototype.literalToken=
function(){var a,c,d,f,h,m,r,q;(a=S.exec(this.chunk))?(a=a[0],D.test(a)&&this.tagParameters()):a=this.chunk.charAt(0);q=a;f=this.tokens;if((f=f[f.length-1])&&0<=ca.call(["\x3d"].concat(oa.call(l)),a)&&(r=!1,"\x3d"!==a||"||"!==(d=f[1])&&"\x26\x26"!==d||f.spaced||(f[0]="COMPOUND_ASSIGN",f[1]+="\x3d",f=this.tokens[this.tokens.length-2],r=!0),f&&"PROPERTY"!==f[0]&&(d=null!=(c=f.origin)?c:f,(c=fa(f[1],d[1]))&&this.error(c,d[2])),r))return a.length;"{"===a&&"EXPORT"===(null!=f?f[0]:void 0)?this.exportSpecifierList=
!0:this.exportSpecifierList&&"}"===a&&(this.exportSpecifierList=!1);if(";"===a)this.seenFor=this.seenImport=this.seenExport=!1,q="TERMINATOR";else if("*"===a&&"EXPORT"===f[0])q="EXPORT_ALL";else if(0<=ca.call(O,a))q="MATH";else if(0<=ca.call(v,a))q="COMPARE";else if(0<=ca.call(l,a))q="COMPOUND_ASSIGN";else if(0<=ca.call(ya,a))q="UNARY";else if(0<=ca.call(Xa,a))q="UNARY_MATH";else if(0<=ca.call(N,a))q="SHIFT";else if("?"===a&&null!=f&&f.spaced)q="BIN?";else if(f&&!f.spaced)if("("===a&&(h=f[0],0<=ca.call(xa,
h)))"?"===f[0]&&(f[0]="FUNC_EXIST"),q="CALL_START";else if("["===a&&(m=f[0],0<=ca.call(E,m)))switch(q="INDEX_START",f[0]){case "?":f[0]="INDEX_SOAK"}h=this.makeToken(q,a);switch(a){case "(":case "{":case "[":this.ends.push({tag:g[a],origin:h});break;case ")":case "}":case "]":this.pair(a)}this.tokens.push(h);return a.length};f.prototype.tagParameters=function(){var a,c,d,f;if(")"!==this.tag())return this;c=[];f=this.tokens;a=f.length;for(f[--a][0]="PARAM_END";d=f[--a];)switch(d[0]){case ")":c.push(d);
break;case "(":case "CALL_START":if(c.length)c.pop();else return"("===d[0]&&(d[0]="PARAM_START"),this}return this};f.prototype.closeIndentation=function(){return this.outdentToken(this.indent)};f.prototype.matchWithInterpolations=function(a,c){var d,g,h,m,q,r,k,n;n=[];q=c.length;if(this.chunk.slice(0,q)!==c)return null;for(k=this.chunk.slice(q);;){m=a.exec(k)[0];this.validateEscapes(m,{isRegex:"/"===c.charAt(0),offsetInChunk:q});n.push(this.makeToken("NEOSTRING",m,q));k=k.slice(m.length);q+=m.length;
if("#{"!==k.slice(0,2))break;d=this.getLineAndColumnFromChunk(q+1);m=d[0];d=d[1];d=(new f).tokenize(k.slice(1),{line:m,column:d,untilBalanced:!0});m=d.tokens;g=d.index;g+=1;r=m[0];d=m[m.length-1];r[0]=r[1]="(";d[0]=d[1]=")";d.origin=["","end of interpolation",d[2]];"TERMINATOR"===(null!=(h=m[1])?h[0]:void 0)&&m.splice(1,1);n.push(["TOKENS",m]);k=k.slice(g);q+=g}k.slice(0,c.length)!==c&&this.error("missing "+c,{length:c.length});a=n[0];h=n[n.length-1];a[2].first_column-=c.length;"\n"===h[1].substr(-1)?
(h[2].last_line+=1,h[2].last_column=c.length-1):h[2].last_column+=c.length;0===h[1].length&&--h[2].last_column;return{tokens:n,index:q+c.length}};f.prototype.mergeInterpolationTokens=function(a,c,d){var f,g,h,m,q,r,k,n,l,D,x,y;1<a.length&&(n=this.token("STRING_START","(",0,0));h=this.tokens.length;m=q=0;for(r=a.length;q<r;m=++q){D=a[m];f=D[0];y=D[1];switch(f){case "TOKENS":if(2===y.length)continue;k=y[0];x=y;break;case "NEOSTRING":f=d(D[1],m);if(0===f.length)if(0===m)g=this.tokens.length;else continue;
2===m&&null!=g&&this.tokens.splice(g,2);D[0]="STRING";D[1]=this.makeDelimitedLiteral(f,c);k=D;x=[D]}this.tokens.length>h&&(m=this.token("+","+"),m[2]={first_line:k[2].first_line,first_column:k[2].first_column,last_line:k[2].first_line,last_column:k[2].first_column});(l=this.tokens).push.apply(l,x)}if(n)return a=a[a.length-1],n.origin=["STRING",null,{first_line:n[2].first_line,first_column:n[2].first_column,last_line:a[2].last_line,last_column:a[2].last_column}],n=this.token("STRING_END",")"),n[2]=
{first_line:a[2].last_line,first_column:a[2].last_column,last_line:a[2].last_line,last_column:a[2].last_column}};f.prototype.pair=function(a){var c;c=this.ends;c=c[c.length-1];return a!==(c=null!=c?c.tag:void 0)?("OUTDENT"!==c&&this.error("unmatched "+a),c=this.indents,c=c[c.length-1],this.outdentToken(c,!0),this.pair(a)):this.ends.pop()};f.prototype.getLineAndColumnFromChunk=function(a){var c,d;if(0===a)return[this.chunkLine,this.chunkColumn];d=a>=this.chunk.length?this.chunk:this.chunk.slice(0,
+(a-1)+1||9E9);a=da(d,"\n");c=this.chunkColumn;0<a?(c=d.split("\n"),c=c[c.length-1],c=c.length):c+=d.length;return[this.chunkLine+a,c]};f.prototype.makeToken=function(a,c,d,f){var g,h;null==d&&(d=0);null==f&&(f=c.length);g={};h=this.getLineAndColumnFromChunk(d);g.first_line=h[0];g.first_column=h[1];d=this.getLineAndColumnFromChunk(d+(0<f?f-1:0));g.last_line=d[0];g.last_column=d[1];return[a,c,g]};f.prototype.token=function(a,c,d,f,g){a=this.makeToken(a,c,d,f);g&&(a.origin=g);this.tokens.push(a);return a};
f.prototype.tag=function(){var a;a=this.tokens;a=a[a.length-1];return null!=a?a[0]:void 0};f.prototype.value=function(){var a;a=this.tokens;a=a[a.length-1];return null!=a?a[1]:void 0};f.prototype.unfinished=function(){var a;return K.test(this.chunk)||"\\"===(a=this.tag())||"."===a||"?."===a||"?::"===a||"UNARY"===a||"MATH"===a||"UNARY_MATH"===a||"+"===a||"-"===a||"**"===a||"SHIFT"===a||"RELATION"===a||"COMPARE"===a||"\x26"===a||"^"===a||"|"===a||"\x26\x26"===a||"||"===a||"BIN?"===a||"THROW"===a||"EXTENDS"===
a};f.prototype.formatString=function(a){return a.replace(U,"$1")};f.prototype.formatHeregex=function(a){return a.replace(G,"$1$2")};f.prototype.validateEscapes=function(a,c){var d,f,g,h,q;null==c&&(c={});if(f=m.exec(a))if(f[0],a=f[1],g=f[2],d=f[3],q=f[4],!c.isRegex||!g||"0"===g.charAt(0))return d="\\"+(g||d||q),this.error((g?"octal escape sequences are not allowed":"invalid escape sequence")+" "+d,{offset:(null!=(h=c.offsetInChunk)?h:0)+f.index+a.length,length:d.length})};f.prototype.makeDelimitedLiteral=
function(a,c){null==c&&(c={});""===a&&"/"===c.delimiter&&(a="(?:)");a=a.replace(RegExp("(\\\\\\\\)|(\\\\0(?\x3d[1-7]))|\\\\?("+c.delimiter+")|\\\\?(?:(\\n)|(\\r)|(\\u2028)|(\\u2029))|(\\\\.)","g"),function(a,d,f,g,h,m,q,r,k){switch(!1){case !d:return c.double?d+d:d;case !f:return"\\x00";case !g:return"\\"+g;case !h:return"\\n";case !m:return"\\r";case !q:return"\\u2028";case !r:return"\\u2029";case !k:return c.double?"\\"+k:k}});return""+c.delimiter+a+c.delimiter};f.prototype.error=function(a,c){var d,
f,g,h,m;null==c&&(c={});c="first_line"in c?c:(h=this.getLineAndColumnFromChunk(null!=(g=c.offset)?g:0),f=h[0],d=h[1],h,{first_line:f,first_column:d,last_column:d+(null!=(m=c.length)?m:1)-1});return ha(a,c)};return f}();fa=function(a,c){null==c&&(c=a);switch(!1){case 0>ca.call(oa.call(q).concat(oa.call(Ca)),a):return"keyword '"+c+"' can't be assigned";case 0>ca.call(Y,a):return"'"+c+"' can't be assigned";case 0>ca.call(W,a):return"reserved word '"+c+"' can't be assigned";default:return!1}};f.isUnassignable=
fa;q="true false null this new delete typeof in instanceof return throw break continue debugger yield if else switch for while do try catch finally class extends super import export default".split(" ");Ca="undefined Infinity NaN then unless until loop of by when".split(" ");c={and:"\x26\x26",or:"||",is:"\x3d\x3d",isnt:"!\x3d",not:"!",yes:"true",no:"false",on:"true",off:"false"};a=function(){var a;a=[];for(ka in c)a.push(ka);return a}();Ca=Ca.concat(a);W="case function var void with const let enum native implements interface package private protected public static".split(" ");
Y=["arguments","eval"];f.JS_FORBIDDEN=q.concat(W).concat(Y);ta=65279;I=/^(?!\d)((?:(?!\s)[$\w\x7f-\uffff])+)([^\n\S]*:(?!:))?/;T=/^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i;S=/^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/;ba=/^[^\n\S]+/;d=/^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/;D=/^[-=]>/;H=/^(?:\n[^\n\S]*)+/;r=/^`(?!``)((?:[^`\\]|\\[\s\S])*)`/;L=/^```((?:[^`\\]|\\[\s\S]|`(?!``))*)```/;aa=/^(?:'''|"""|'|")/;J=/^(?:[^\\']|\\[\s\S])*/;
V=/^(?:[^\\"#]|\\[\s\S]|\#(?!\{))*/;z=/^(?:[^\\']|\\[\s\S]|'(?!''))*/;F=/^(?:[^\\"#]|\\[\s\S]|"(?!"")|\#(?!\{))*/;U=/((?:\\\\)+)|\\[^\S\n]*\n\s*/g;X=/\s*\n\s*/g;w=/\n+([^\n\S]*)(?=\S)/g;Z=/^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/;R=/^\w*/;ia=/^(?!.*(.).*\1)[imgy]*$/;n=/^(?:[^\\\/#]|\\[\s\S]|\/(?!\/\/)|\#(?!\{))*/;G=/((?:\\\\)+)|\\(\s)|\s+(?:#.*)?/g;C=/^(\/|\/{3}\s*)(\*)/;P=/^\/=?\s/;u=/\*\//;K=/^\s*(?:,|\??\.(?![.\d])|::)/;m=/((?:^|[^\\])(?:\\\\)*)\\(?:(0[0-7]|[1-7])|(x(?![\da-fA-F]{2}).{0,2})|(u(?![\da-fA-F]{4}).{0,4}))/;
k=/^[^\n\S]*\n/;Q=/\n[^\n\S]*$/;pa=/\s+$/;l="-\x3d +\x3d /\x3d *\x3d %\x3d ||\x3d \x26\x26\x3d ?\x3d \x3c\x3c\x3d \x3e\x3e\x3d \x3e\x3e\x3e\x3d \x26\x3d ^\x3d |\x3d **\x3d //\x3d %%\x3d".split(" ");ya=["NEW","TYPEOF","DELETE","DO"];Xa=["!","~"];N=["\x3c\x3c","\x3e\x3e","\x3e\x3e\x3e"];v="\x3d\x3d !\x3d \x3c \x3e \x3c\x3d \x3e\x3d".split(" ");O=["*","/","%","//","%%"];A=["IN","OF","INSTANCEOF"];xa="IDENTIFIER PROPERTY ) ] ? @ THIS SUPER".split(" ");E=xa.concat("NUMBER INFINITY NAN STRING STRING_END REGEX REGEX_END BOOL NULL UNDEFINED } ::".split(" "));
y=E.concat(["++","--"]);h=["INDENT","OUTDENT","TERMINATOR"];x=[")","}","]"]}).call(this);return f}();t["./parser"]=function(){var f={},ta={exports:f},xa=function(){function f(){this.yy={}}var a=function(a,p,ra,b){ra=ra||{};for(b=a.length;b--;ra[a[b]]=p);return ra},c=[1,22],t=[1,25],d=[1,83],v=[1,79],l=[1,84],u=[1,85],F=[1,81],w=[1,82],z=[1,56],n=[1,58],G=[1,59],L=[1,60],I=[1,61],x=[1,62],E=[1,49],m=[1,50],g=[1,32],r=[1,68],q=[1,69],k=[1,78],h=[1,47],K=[1,51],O=[1,52],H=[1,67],y=[1,65],T=[1,66],S=
[1,64],P=[1,42],Z=[1,48],R=[1,63],C=[1,73],A=[1,74],W=[1,75],B=[1,76],N=[1,46],X=[1,72],Y=[1,34],V=[1,35],U=[1,36],J=[1,37],aa=[1,38],Q=[1,39],xa=[1,86],ta=[1,6,32,42,131],pa=[1,101],ia=[1,89],ba=[1,88],da=[1,87],ga=[1,90],fa=[1,91],ka=[1,92],ja=[1,93],M=[1,94],ha=[1,95],ca=[1,96],oa=[1,97],na=[1,98],qa=[1,99],la=[1,100],ya=[1,104],sa=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Ja=[2,162],Ta=[1,110],Ga=[1,111],Ua=[1,
112],Fa=[1,113],Pa=[1,115],Qa=[1,116],Na=[1,109],za=[1,6,32,42,131,133,135,139,156],ma=[2,27],ea=[1,123],Ha=[1,121],Aa=[1,6,31,32,40,41,42,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Ia=[2,94],b=[1,6,31,32,42,46,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],p=[2,73],ra=[1,128],ua=[1,133],e=[1,134],va=[1,136],Ka=[1,
6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],wa=[2,91],Eb=[1,6,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],$a=[2,63],Fb=[1,166],ab=[1,178],Wa=[1,180],Gb=[1,175],Oa=[1,182],sb=[1,184],La=[1,6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,96,113,114,115,120,122,131,133,134,135,139,140,156,159,160,161,162,163,164,
165,166,167,168,169,170,171,172,173,174,175],Hb=[2,110],Ib=[1,6,31,32,40,41,42,58,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Jb=[1,6,31,32,40,41,42,46,58,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Kb=[40,41,114],Lb=[1,241],tb=[1,240],Ma=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156],Ea=[2,
71],Mb=[1,250],Va=[6,31,32,65,70],fb=[6,31,32,55,65,70,73],bb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,164,166,167,168,169,170,171,172,173,174],Nb=[40,41,82,83,84,85,87,90,113,114],gb=[1,269],cb=[2,62],hb=[1,279],ub=[1,285],Ob=[2,183],vb=[1,6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],ib=[1,295],Ra=[6,31,32,70,115,120],Pb=[1,6,31,32,40,41,
42,55,58,65,70,73,82,83,84,85,87,89,90,94,96,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175],Qb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,140,156],Ya=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,134,140,156],jb=[146,147,148],kb=[70,146,147,148],lb=[6,31,94],Rb=[1,309],Ba=[6,31,32,70,94],Sb=[6,31,32,58,70,94],wb=[6,31,32,55,58,70,94],Tb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,166,
167,168,169,170,171,172,173,174],Ub=[12,28,34,38,40,41,44,45,48,49,50,51,52,53,61,62,63,67,68,89,92,95,97,104,112,117,118,119,125,129,130,133,135,137,139,149,155,157,158,159,160,161,162],Vb=[2,172],Sa=[6,31,32],db=[2,72],Wb=[1,321],Xb=[1,322],Yb=[1,6,31,32,42,65,70,73,89,94,115,120,122,127,128,131,133,134,135,139,140,151,153,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],mb=[32,151,153],Zb=[1,6,32,42,65,70,73,89,94,115,120,122,131,134,140,156],nb=[1,348],xb=[1,353],yb=[1,6,32,42,131,
156],eb=[2,86],ob=[1,363],pb=[1,364],$b=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,151,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],zb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,135,139,140,156],ac=[1,377],bc=[1,378],Ab=[6,31,32,94],cc=[6,31,32,70],Bb=[1,6,31,32,42,65,70,73,89,94,115,120,122,127,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],dc=[31,70],qb=[1,404],rb=[1,405],Cb=[1,410],Db=[1,411],ec={trace:function(){},
yy:{},symbols_:{error:2,Root:3,Body:4,Line:5,TERMINATOR:6,Expression:7,Statement:8,YieldReturn:9,Return:10,Comment:11,STATEMENT:12,Import:13,Export:14,Value:15,Invocation:16,Code:17,Operation:18,Assign:19,If:20,Try:21,While:22,For:23,Switch:24,Class:25,Throw:26,Yield:27,YIELD:28,FROM:29,Block:30,INDENT:31,OUTDENT:32,Identifier:33,IDENTIFIER:34,Property:35,PROPERTY:36,AlphaNumeric:37,NUMBER:38,String:39,STRING:40,STRING_START:41,STRING_END:42,Regex:43,REGEX:44,REGEX_START:45,REGEX_END:46,Literal:47,
JS:48,UNDEFINED:49,NULL:50,BOOL:51,INFINITY:52,NAN:53,Assignable:54,"\x3d":55,AssignObj:56,ObjAssignable:57,":":58,SimpleObjAssignable:59,ThisProperty:60,RETURN:61,HERECOMMENT:62,PARAM_START:63,ParamList:64,PARAM_END:65,FuncGlyph:66,"-\x3e":67,"\x3d\x3e":68,OptComma:69,",":70,Param:71,ParamVar:72,"...":73,Array:74,Object:75,Splat:76,SimpleAssignable:77,Accessor:78,Parenthetical:79,Range:80,This:81,".":82,"?.":83,"::":84,"?::":85,Index:86,INDEX_START:87,IndexValue:88,INDEX_END:89,INDEX_SOAK:90,Slice:91,
"{":92,AssignList:93,"}":94,CLASS:95,EXTENDS:96,IMPORT:97,ImportDefaultSpecifier:98,ImportNamespaceSpecifier:99,ImportSpecifierList:100,ImportSpecifier:101,AS:102,IMPORT_ALL:103,EXPORT:104,ExportSpecifierList:105,DEFAULT:106,EXPORT_ALL:107,ExportSpecifier:108,OptFuncExist:109,Arguments:110,Super:111,SUPER:112,FUNC_EXIST:113,CALL_START:114,CALL_END:115,ArgList:116,THIS:117,"@":118,"[":119,"]":120,RangeDots:121,"..":122,Arg:123,SimpleArgs:124,TRY:125,Catch:126,FINALLY:127,CATCH:128,THROW:129,"(":130,
")":131,WhileSource:132,WHILE:133,WHEN:134,UNTIL:135,Loop:136,LOOP:137,ForBody:138,FOR:139,BY:140,ForStart:141,ForSource:142,ForVariables:143,OWN:144,ForValue:145,FORIN:146,FOROF:147,FORFROM:148,SWITCH:149,Whens:150,ELSE:151,When:152,LEADING_WHEN:153,IfBlock:154,IF:155,POST_IF:156,UNARY:157,UNARY_MATH:158,"-":159,"+":160,"--":161,"++":162,"?":163,MATH:164,"**":165,SHIFT:166,COMPARE:167,"\x26":168,"^":169,"|":170,"\x26\x26":171,"||":172,"BIN?":173,RELATION:174,COMPOUND_ASSIGN:175,$accept:0,$end:1},
terminals_:{2:"error",6:"TERMINATOR",12:"STATEMENT",28:"YIELD",29:"FROM",31:"INDENT",32:"OUTDENT",34:"IDENTIFIER",36:"PROPERTY",38:"NUMBER",40:"STRING",41:"STRING_START",42:"STRING_END",44:"REGEX",45:"REGEX_START",46:"REGEX_END",48:"JS",49:"UNDEFINED",50:"NULL",51:"BOOL",52:"INFINITY",53:"NAN",55:"\x3d",58:":",61:"RETURN",62:"HERECOMMENT",63:"PARAM_START",65:"PARAM_END",67:"-\x3e",68:"\x3d\x3e",70:",",73:"...",82:".",83:"?.",84:"::",85:"?::",87:"INDEX_START",89:"INDEX_END",90:"INDEX_SOAK",92:"{",
94:"}",95:"CLASS",96:"EXTENDS",97:"IMPORT",102:"AS",103:"IMPORT_ALL",104:"EXPORT",106:"DEFAULT",107:"EXPORT_ALL",112:"SUPER",113:"FUNC_EXIST",114:"CALL_START",115:"CALL_END",117:"THIS",118:"@",119:"[",120:"]",122:"..",125:"TRY",127:"FINALLY",128:"CATCH",129:"THROW",130:"(",131:")",133:"WHILE",134:"WHEN",135:"UNTIL",137:"LOOP",139:"FOR",140:"BY",144:"OWN",146:"FORIN",147:"FOROF",148:"FORFROM",149:"SWITCH",151:"ELSE",153:"LEADING_WHEN",155:"IF",156:"POST_IF",157:"UNARY",158:"UNARY_MATH",159:"-",160:"+",
161:"--",162:"++",163:"?",164:"MATH",165:"**",166:"SHIFT",167:"COMPARE",168:"\x26",169:"^",170:"|",171:"\x26\x26",172:"||",173:"BIN?",174:"RELATION",175:"COMPOUND_ASSIGN"},productions_:[0,[3,0],[3,1],[4,1],[4,3],[4,2],[5,1],[5,1],[5,1],[8,1],[8,1],[8,1],[8,1],[8,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[27,1],[27,2],[27,3],[30,2],[30,3],[33,1],[35,1],[37,1],[37,1],[39,1],[39,3],[43,1],[43,3],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[19,3],[19,
4],[19,5],[56,1],[56,3],[56,5],[56,3],[56,5],[56,1],[59,1],[59,1],[59,1],[57,1],[57,1],[10,2],[10,1],[9,3],[9,2],[11,1],[17,5],[17,2],[66,1],[66,1],[69,0],[69,1],[64,0],[64,1],[64,3],[64,4],[64,6],[71,1],[71,2],[71,3],[71,1],[72,1],[72,1],[72,1],[72,1],[76,2],[77,1],[77,2],[77,2],[77,1],[54,1],[54,1],[54,1],[15,1],[15,1],[15,1],[15,1],[15,1],[78,2],[78,2],[78,2],[78,2],[78,1],[78,1],[86,3],[86,2],[88,1],[88,1],[75,4],[93,0],[93,1],[93,3],[93,4],[93,6],[25,1],[25,2],[25,3],[25,4],[25,2],[25,3],[25,
4],[25,5],[13,2],[13,4],[13,4],[13,5],[13,7],[13,6],[13,9],[100,1],[100,3],[100,4],[100,4],[100,6],[101,1],[101,3],[98,1],[99,3],[14,3],[14,5],[14,2],[14,4],[14,5],[14,6],[14,3],[14,4],[14,7],[105,1],[105,3],[105,4],[105,4],[105,6],[108,1],[108,3],[108,3],[16,3],[16,3],[16,3],[16,1],[111,1],[111,2],[109,0],[109,1],[110,2],[110,4],[81,1],[81,1],[60,2],[74,2],[74,4],[121,1],[121,1],[80,5],[91,3],[91,2],[91,2],[91,1],[116,1],[116,3],[116,4],[116,4],[116,6],[123,1],[123,1],[123,1],[124,1],[124,3],[21,
2],[21,3],[21,4],[21,5],[126,3],[126,3],[126,2],[26,2],[79,3],[79,5],[132,2],[132,4],[132,2],[132,4],[22,2],[22,2],[22,2],[22,1],[136,2],[136,2],[23,2],[23,2],[23,2],[138,2],[138,4],[138,2],[141,2],[141,3],[145,1],[145,1],[145,1],[145,1],[143,1],[143,3],[142,2],[142,2],[142,4],[142,4],[142,4],[142,6],[142,6],[142,2],[142,4],[24,5],[24,7],[24,4],[24,6],[150,1],[150,2],[152,3],[152,4],[154,3],[154,5],[20,1],[20,3],[20,3],[20,3],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,3],[18,
3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,5],[18,4],[18,3]],performAction:function(a,p,ra,b,ua,c,e){a=c.length-1;switch(ua){case 1:return this.$=b.addLocationDataFn(e[a],e[a])(new b.Block);case 2:return this.$=c[a];case 3:this.$=b.addLocationDataFn(e[a],e[a])(b.Block.wrap([c[a]]));break;case 4:this.$=b.addLocationDataFn(e[a-2],e[a])(c[a-2].push(c[a]));break;case 5:this.$=c[a-1];break;case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 35:case 40:case 42:case 56:case 57:case 58:case 59:case 60:case 61:case 71:case 72:case 82:case 83:case 84:case 85:case 90:case 91:case 94:case 98:case 104:case 159:case 183:case 184:case 186:case 216:case 217:case 235:case 241:this.$=
c[a];break;case 11:this.$=b.addLocationDataFn(e[a],e[a])(new b.StatementLiteral(c[a]));break;case 27:this.$=b.addLocationDataFn(e[a],e[a])(new b.Op(c[a],new b.Value(new b.Literal(""))));break;case 28:case 245:case 246:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Op(c[a-1],c[a]));break;case 29:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Op(c[a-2].concat(c[a-1]),c[a]));break;case 30:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Block);break;case 31:case 105:this.$=b.addLocationDataFn(e[a-2],e[a])(c[a-
1]);break;case 32:this.$=b.addLocationDataFn(e[a],e[a])(new b.IdentifierLiteral(c[a]));break;case 33:this.$=b.addLocationDataFn(e[a],e[a])(new b.PropertyName(c[a]));break;case 34:this.$=b.addLocationDataFn(e[a],e[a])(new b.NumberLiteral(c[a]));break;case 36:this.$=b.addLocationDataFn(e[a],e[a])(new b.StringLiteral(c[a]));break;case 37:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.StringWithInterpolations(c[a-1]));break;case 38:this.$=b.addLocationDataFn(e[a],e[a])(new b.RegexLiteral(c[a]));break;
case 39:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.RegexWithInterpolations(c[a-1].args));break;case 41:this.$=b.addLocationDataFn(e[a],e[a])(new b.PassthroughLiteral(c[a]));break;case 43:this.$=b.addLocationDataFn(e[a],e[a])(new b.UndefinedLiteral);break;case 44:this.$=b.addLocationDataFn(e[a],e[a])(new b.NullLiteral);break;case 45:this.$=b.addLocationDataFn(e[a],e[a])(new b.BooleanLiteral(c[a]));break;case 46:this.$=b.addLocationDataFn(e[a],e[a])(new b.InfinityLiteral(c[a]));break;case 47:this.$=
b.addLocationDataFn(e[a],e[a])(new b.NaNLiteral);break;case 48:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Assign(c[a-2],c[a]));break;case 49:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.Assign(c[a-3],c[a]));break;case 50:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Assign(c[a-4],c[a-1]));break;case 51:case 87:case 92:case 93:case 95:case 96:case 97:case 218:case 219:this.$=b.addLocationDataFn(e[a],e[a])(new b.Value(c[a]));break;case 52:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Assign(b.addLocationDataFn(e[a-
2])(new b.Value(c[a-2])),c[a],"object",{operatorToken:b.addLocationDataFn(e[a-1])(new b.Literal(c[a-1]))}));break;case 53:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Assign(b.addLocationDataFn(e[a-4])(new b.Value(c[a-4])),c[a-1],"object",{operatorToken:b.addLocationDataFn(e[a-3])(new b.Literal(c[a-3]))}));break;case 54:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Assign(b.addLocationDataFn(e[a-2])(new b.Value(c[a-2])),c[a],null,{operatorToken:b.addLocationDataFn(e[a-1])(new b.Literal(c[a-1]))}));
break;case 55:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Assign(b.addLocationDataFn(e[a-4])(new b.Value(c[a-4])),c[a-1],null,{operatorToken:b.addLocationDataFn(e[a-3])(new b.Literal(c[a-3]))}));break;case 62:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Return(c[a]));break;case 63:this.$=b.addLocationDataFn(e[a],e[a])(new b.Return);break;case 64:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.YieldReturn(c[a]));break;case 65:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.YieldReturn);break;case 66:this.$=
b.addLocationDataFn(e[a],e[a])(new b.Comment(c[a]));break;case 67:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Code(c[a-3],c[a],c[a-1]));break;case 68:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Code([],c[a],c[a-1]));break;case 69:this.$=b.addLocationDataFn(e[a],e[a])("func");break;case 70:this.$=b.addLocationDataFn(e[a],e[a])("boundfunc");break;case 73:case 110:this.$=b.addLocationDataFn(e[a],e[a])([]);break;case 74:case 111:case 130:case 148:case 178:case 220:this.$=b.addLocationDataFn(e[a],
e[a])([c[a]]);break;case 75:case 112:case 131:case 149:case 179:this.$=b.addLocationDataFn(e[a-2],e[a])(c[a-2].concat(c[a]));break;case 76:case 113:case 132:case 150:case 180:this.$=b.addLocationDataFn(e[a-3],e[a])(c[a-3].concat(c[a]));break;case 77:case 114:case 134:case 152:case 182:this.$=b.addLocationDataFn(e[a-5],e[a])(c[a-5].concat(c[a-2]));break;case 78:this.$=b.addLocationDataFn(e[a],e[a])(new b.Param(c[a]));break;case 79:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Param(c[a-1],null,!0));
break;case 80:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Param(c[a-2],c[a]));break;case 81:case 185:this.$=b.addLocationDataFn(e[a],e[a])(new b.Expansion);break;case 86:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Splat(c[a-1]));break;case 88:this.$=b.addLocationDataFn(e[a-1],e[a])(c[a-1].add(c[a]));break;case 89:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Value(c[a-1],[].concat(c[a])));break;case 99:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Access(c[a]));break;case 100:this.$=b.addLocationDataFn(e[a-
1],e[a])(new b.Access(c[a],"soak"));break;case 101:this.$=b.addLocationDataFn(e[a-1],e[a])([b.addLocationDataFn(e[a-1])(new b.Access(new b.PropertyName("prototype"))),b.addLocationDataFn(e[a])(new b.Access(c[a]))]);break;case 102:this.$=b.addLocationDataFn(e[a-1],e[a])([b.addLocationDataFn(e[a-1])(new b.Access(new b.PropertyName("prototype"),"soak")),b.addLocationDataFn(e[a])(new b.Access(c[a]))]);break;case 103:this.$=b.addLocationDataFn(e[a],e[a])(new b.Access(new b.PropertyName("prototype")));
break;case 106:this.$=b.addLocationDataFn(e[a-1],e[a])(b.extend(c[a],{soak:!0}));break;case 107:this.$=b.addLocationDataFn(e[a],e[a])(new b.Index(c[a]));break;case 108:this.$=b.addLocationDataFn(e[a],e[a])(new b.Slice(c[a]));break;case 109:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.Obj(c[a-2],c[a-3].generated));break;case 115:this.$=b.addLocationDataFn(e[a],e[a])(new b.Class);break;case 116:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Class(null,null,c[a]));break;case 117:this.$=b.addLocationDataFn(e[a-
2],e[a])(new b.Class(null,c[a]));break;case 118:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.Class(null,c[a-1],c[a]));break;case 119:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Class(c[a]));break;case 120:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Class(c[a-1],null,c[a]));break;case 121:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.Class(c[a-2],c[a]));break;case 122:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Class(c[a-3],c[a-1],c[a]));break;case 123:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.ImportDeclaration(null,
c[a]));break;case 124:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.ImportDeclaration(new b.ImportClause(c[a-2],null),c[a]));break;case 125:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.ImportDeclaration(new b.ImportClause(null,c[a-2]),c[a]));break;case 126:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.ImportDeclaration(new b.ImportClause(null,new b.ImportSpecifierList([])),c[a]));break;case 127:this.$=b.addLocationDataFn(e[a-6],e[a])(new b.ImportDeclaration(new b.ImportClause(null,new b.ImportSpecifierList(c[a-
4])),c[a]));break;case 128:this.$=b.addLocationDataFn(e[a-5],e[a])(new b.ImportDeclaration(new b.ImportClause(c[a-4],c[a-2]),c[a]));break;case 129:this.$=b.addLocationDataFn(e[a-8],e[a])(new b.ImportDeclaration(new b.ImportClause(c[a-7],new b.ImportSpecifierList(c[a-4])),c[a]));break;case 133:case 151:case 165:case 181:this.$=b.addLocationDataFn(e[a-3],e[a])(c[a-2]);break;case 135:this.$=b.addLocationDataFn(e[a],e[a])(new b.ImportSpecifier(c[a]));break;case 136:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.ImportSpecifier(c[a-
2],c[a]));break;case 137:this.$=b.addLocationDataFn(e[a],e[a])(new b.ImportDefaultSpecifier(c[a]));break;case 138:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.ImportNamespaceSpecifier(new b.Literal(c[a-2]),c[a]));break;case 139:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.ExportNamedDeclaration(new b.ExportSpecifierList([])));break;case 140:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.ExportNamedDeclaration(new b.ExportSpecifierList(c[a-2])));break;case 141:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.ExportNamedDeclaration(c[a]));
break;case 142:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.ExportNamedDeclaration(new b.Assign(c[a-2],c[a],null,{moduleDeclaration:"export"})));break;case 143:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.ExportNamedDeclaration(new b.Assign(c[a-3],c[a],null,{moduleDeclaration:"export"})));break;case 144:this.$=b.addLocationDataFn(e[a-5],e[a])(new b.ExportNamedDeclaration(new b.Assign(c[a-4],c[a-1],null,{moduleDeclaration:"export"})));break;case 145:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.ExportDefaultDeclaration(c[a]));
break;case 146:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.ExportAllDeclaration(new b.Literal(c[a-2]),c[a]));break;case 147:this.$=b.addLocationDataFn(e[a-6],e[a])(new b.ExportNamedDeclaration(new b.ExportSpecifierList(c[a-4]),c[a]));break;case 153:this.$=b.addLocationDataFn(e[a],e[a])(new b.ExportSpecifier(c[a]));break;case 154:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.ExportSpecifier(c[a-2],c[a]));break;case 155:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.ExportSpecifier(c[a-2],new b.Literal(c[a])));
break;case 156:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.TaggedTemplateCall(c[a-2],c[a],c[a-1]));break;case 157:case 158:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Call(c[a-2],c[a],c[a-1]));break;case 160:this.$=b.addLocationDataFn(e[a],e[a])(new b.SuperCall);break;case 161:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.SuperCall(c[a]));break;case 162:this.$=b.addLocationDataFn(e[a],e[a])(!1);break;case 163:this.$=b.addLocationDataFn(e[a],e[a])(!0);break;case 164:this.$=b.addLocationDataFn(e[a-
1],e[a])([]);break;case 166:case 167:this.$=b.addLocationDataFn(e[a],e[a])(new b.Value(new b.ThisLiteral));break;case 168:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Value(b.addLocationDataFn(e[a-1])(new b.ThisLiteral),[b.addLocationDataFn(e[a])(new b.Access(c[a]))],"this"));break;case 169:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Arr([]));break;case 170:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.Arr(c[a-2]));break;case 171:this.$=b.addLocationDataFn(e[a],e[a])("inclusive");break;case 172:this.$=
b.addLocationDataFn(e[a],e[a])("exclusive");break;case 173:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Range(c[a-3],c[a-1],c[a-2]));break;case 174:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Range(c[a-2],c[a],c[a-1]));break;case 175:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Range(c[a-1],null,c[a]));break;case 176:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Range(null,c[a],c[a-1]));break;case 177:this.$=b.addLocationDataFn(e[a],e[a])(new b.Range(null,null,c[a]));break;case 187:this.$=b.addLocationDataFn(e[a-
2],e[a])([].concat(c[a-2],c[a]));break;case 188:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Try(c[a]));break;case 189:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Try(c[a-1],c[a][0],c[a][1]));break;case 190:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.Try(c[a-2],null,null,c[a]));break;case 191:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Try(c[a-3],c[a-2][0],c[a-2][1],c[a]));break;case 192:this.$=b.addLocationDataFn(e[a-2],e[a])([c[a-1],c[a]]);break;case 193:this.$=b.addLocationDataFn(e[a-2],
e[a])([b.addLocationDataFn(e[a-1])(new b.Value(c[a-1])),c[a]]);break;case 194:this.$=b.addLocationDataFn(e[a-1],e[a])([null,c[a]]);break;case 195:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Throw(c[a]));break;case 196:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Parens(c[a-1]));break;case 197:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Parens(c[a-2]));break;case 198:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.While(c[a]));break;case 199:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.While(c[a-
2],{guard:c[a]}));break;case 200:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.While(c[a],{invert:!0}));break;case 201:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.While(c[a-2],{invert:!0,guard:c[a]}));break;case 202:this.$=b.addLocationDataFn(e[a-1],e[a])(c[a-1].addBody(c[a]));break;case 203:case 204:this.$=b.addLocationDataFn(e[a-1],e[a])(c[a].addBody(b.addLocationDataFn(e[a-1])(b.Block.wrap([c[a-1]]))));break;case 205:this.$=b.addLocationDataFn(e[a],e[a])(c[a]);break;case 206:this.$=b.addLocationDataFn(e[a-
1],e[a])((new b.While(b.addLocationDataFn(e[a-1])(new b.BooleanLiteral("true")))).addBody(c[a]));break;case 207:this.$=b.addLocationDataFn(e[a-1],e[a])((new b.While(b.addLocationDataFn(e[a-1])(new b.BooleanLiteral("true")))).addBody(b.addLocationDataFn(e[a])(b.Block.wrap([c[a]]))));break;case 208:case 209:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.For(c[a-1],c[a]));break;case 210:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.For(c[a],c[a-1]));break;case 211:this.$=b.addLocationDataFn(e[a-1],e[a])({source:b.addLocationDataFn(e[a])(new b.Value(c[a]))});
break;case 212:this.$=b.addLocationDataFn(e[a-3],e[a])({source:b.addLocationDataFn(e[a-2])(new b.Value(c[a-2])),step:c[a]});break;case 213:b=b.addLocationDataFn(e[a-1],e[a]);c[a].own=c[a-1].own;c[a].ownTag=c[a-1].ownTag;c[a].name=c[a-1][0];c[a].index=c[a-1][1];this.$=b(c[a]);break;case 214:this.$=b.addLocationDataFn(e[a-1],e[a])(c[a]);break;case 215:ua=b.addLocationDataFn(e[a-2],e[a]);c[a].own=!0;c[a].ownTag=b.addLocationDataFn(e[a-1])(new b.Literal(c[a-1]));this.$=ua(c[a]);break;case 221:this.$=
b.addLocationDataFn(e[a-2],e[a])([c[a-2],c[a]]);break;case 222:this.$=b.addLocationDataFn(e[a-1],e[a])({source:c[a]});break;case 223:this.$=b.addLocationDataFn(e[a-1],e[a])({source:c[a],object:!0});break;case 224:this.$=b.addLocationDataFn(e[a-3],e[a])({source:c[a-2],guard:c[a]});break;case 225:this.$=b.addLocationDataFn(e[a-3],e[a])({source:c[a-2],guard:c[a],object:!0});break;case 226:this.$=b.addLocationDataFn(e[a-3],e[a])({source:c[a-2],step:c[a]});break;case 227:this.$=b.addLocationDataFn(e[a-
5],e[a])({source:c[a-4],guard:c[a-2],step:c[a]});break;case 228:this.$=b.addLocationDataFn(e[a-5],e[a])({source:c[a-4],step:c[a-2],guard:c[a]});break;case 229:this.$=b.addLocationDataFn(e[a-1],e[a])({source:c[a],from:!0});break;case 230:this.$=b.addLocationDataFn(e[a-3],e[a])({source:c[a-2],guard:c[a],from:!0});break;case 231:this.$=b.addLocationDataFn(e[a-4],e[a])(new b.Switch(c[a-3],c[a-1]));break;case 232:this.$=b.addLocationDataFn(e[a-6],e[a])(new b.Switch(c[a-5],c[a-3],c[a-1]));break;case 233:this.$=
b.addLocationDataFn(e[a-3],e[a])(new b.Switch(null,c[a-1]));break;case 234:this.$=b.addLocationDataFn(e[a-5],e[a])(new b.Switch(null,c[a-3],c[a-1]));break;case 236:this.$=b.addLocationDataFn(e[a-1],e[a])(c[a-1].concat(c[a]));break;case 237:this.$=b.addLocationDataFn(e[a-2],e[a])([[c[a-1],c[a]]]);break;case 238:this.$=b.addLocationDataFn(e[a-3],e[a])([[c[a-2],c[a-1]]]);break;case 239:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.If(c[a-1],c[a],{type:c[a-2]}));break;case 240:this.$=b.addLocationDataFn(e[a-
4],e[a])(c[a-4].addElse(b.addLocationDataFn(e[a-2],e[a])(new b.If(c[a-1],c[a],{type:c[a-2]}))));break;case 242:this.$=b.addLocationDataFn(e[a-2],e[a])(c[a-2].addElse(c[a]));break;case 243:case 244:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.If(c[a],b.addLocationDataFn(e[a-2])(b.Block.wrap([c[a-2]])),{type:c[a-1],statement:!0}));break;case 247:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Op("-",c[a]));break;case 248:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Op("+",c[a]));break;case 249:this.$=
b.addLocationDataFn(e[a-1],e[a])(new b.Op("--",c[a]));break;case 250:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Op("++",c[a]));break;case 251:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Op("--",c[a-1],null,!0));break;case 252:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Op("++",c[a-1],null,!0));break;case 253:this.$=b.addLocationDataFn(e[a-1],e[a])(new b.Existence(c[a-1]));break;case 254:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Op("+",c[a-2],c[a]));break;case 255:this.$=b.addLocationDataFn(e[a-
2],e[a])(new b.Op("-",c[a-2],c[a]));break;case 256:case 257:case 258:case 259:case 260:case 261:case 262:case 263:case 264:case 265:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Op(c[a-1],c[a-2],c[a]));break;case 266:e=b.addLocationDataFn(e[a-2],e[a]);c="!"===c[a-1].charAt(0)?(new b.Op(c[a-1].slice(1),c[a-2],c[a])).invert():new b.Op(c[a-1],c[a-2],c[a]);this.$=e(c);break;case 267:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Assign(c[a-2],c[a],c[a-1]));break;case 268:this.$=b.addLocationDataFn(e[a-
4],e[a])(new b.Assign(c[a-4],c[a-1],c[a-3]));break;case 269:this.$=b.addLocationDataFn(e[a-3],e[a])(new b.Assign(c[a-3],c[a],c[a-2]));break;case 270:this.$=b.addLocationDataFn(e[a-2],e[a])(new b.Extends(c[a-2],c[a]))}},table:[{1:[2,1],3:1,4:2,5:3,7:4,8:5,9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,
74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{1:[3]},{1:[2,2],6:xa},a(ta,[2,3]),a(ta,[2,6],{141:77,132:102,138:103,133:C,135:A,139:B,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(ta,[2,7],{141:77,132:105,138:106,133:C,135:A,139:B,156:ya}),a(ta,[2,8]),a(sa,[2,14],{109:107,
78:108,86:114,40:Ja,41:Ja,114:Ja,82:Ta,83:Ga,84:Ua,85:Fa,87:Pa,90:Qa,113:Na}),a(sa,[2,15],{86:114,109:117,78:118,82:Ta,83:Ga,84:Ua,85:Fa,87:Pa,90:Qa,113:Na,114:Ja}),a(sa,[2,16]),a(sa,[2,17]),a(sa,[2,18]),a(sa,[2,19]),a(sa,[2,20]),a(sa,[2,21]),a(sa,[2,22]),a(sa,[2,23]),a(sa,[2,24]),a(sa,[2,25]),a(sa,[2,26]),a(za,[2,9]),a(za,[2,10]),a(za,[2,11]),a(za,[2,12]),a(za,[2,13]),a([1,6,32,42,131,133,135,139,156,163,164,165,166,167,168,169,170,171,172,173,174],ma,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,
23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,7:120,8:122,12:c,28:ea,29:Ha,34:d,38:v,40:l,41:u,44:F,45:w,48:z,49:n,50:G,51:L,52:I,53:x,61:[1,119],62:m,63:g,67:r,68:q,92:k,95:h,97:K,104:O,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,137:W,149:N,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q}),a(Aa,Ia,{55:[1,124]}),a(Aa,[2,95]),a(Aa,[2,96]),a(Aa,[2,97]),a(Aa,[2,98]),a(b,[2,
159]),a([6,31,65,70],p,{64:125,71:126,72:127,33:129,60:130,74:131,75:132,34:d,73:ra,92:k,118:ua,119:e}),{30:135,31:va},{7:137,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,
137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:138,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,
154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:139,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,
160:J,161:aa,162:Q},{7:140,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{15:142,16:143,
33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:144,60:71,74:53,75:54,77:141,79:28,80:29,81:30,92:k,111:31,112:H,117:y,118:T,119:S,130:R},{15:142,16:143,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:144,60:71,74:53,75:54,77:145,79:28,80:29,81:30,92:k,111:31,112:H,117:y,118:T,119:S,130:R},a(Ka,wa,{96:[1,149],161:[1,146],162:[1,147],175:[1,148]}),a(sa,[2,241],{151:[1,150]}),{30:151,31:va},{30:152,31:va},a(sa,
[2,205]),{30:153,31:va},{7:154,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,155],33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},
a(Eb,[2,115],{47:27,79:28,80:29,81:30,111:31,74:53,75:54,37:55,43:57,33:70,60:71,39:80,15:142,16:143,54:144,30:156,77:158,31:va,34:d,38:v,40:l,41:u,44:F,45:w,48:z,49:n,50:G,51:L,52:I,53:x,92:k,96:[1,157],112:H,117:y,118:T,119:S,130:R}),{7:159,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,
77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(za,$a,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,7:160,12:c,28:ea,34:d,38:v,40:l,41:u,44:F,45:w,48:z,49:n,50:G,
51:L,52:I,53:x,61:E,62:m,63:g,67:r,68:q,92:k,95:h,97:K,104:O,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,137:W,149:N,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q}),a([1,6,31,32,42,70,94,131,133,135,139,156],[2,66]),{33:165,34:d,39:161,40:l,41:u,92:[1,164],98:162,99:163,103:Fb},{25:168,33:169,34:d,92:[1,167],95:h,106:[1,170],107:[1,171]},a(Ka,[2,92]),a(Ka,[2,93]),a(Aa,[2,40]),a(Aa,[2,41]),a(Aa,[2,42]),a(Aa,[2,43]),a(Aa,[2,44]),a(Aa,[2,45]),a(Aa,[2,46]),a(Aa,[2,47]),{4:172,5:3,7:4,8:5,9:6,10:20,11:21,12:c,
13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,31:[1,173],33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:174,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,
17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:ab,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,73:Wa,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,116:176,117:y,118:T,119:S,120:Gb,123:177,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Aa,[2,166]),a(Aa,[2,167],{35:181,36:Oa}),
a([1,6,31,32,42,46,65,70,73,82,83,84,85,87,89,90,94,113,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],[2,160],{110:183,114:sb}),{31:[2,69]},{31:[2,70]},a(La,[2,87]),a(La,[2,90]),{7:185,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,
79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:186,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,
104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:187,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,
119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:189,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,30:188,31:va,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,
130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{33:194,34:d,60:195,74:196,75:197,80:190,92:k,118:ua,119:S,143:191,144:[1,192],145:193},{142:198,146:[1,199],147:[1,200],148:[1,201]},a([6,31,70,94],Hb,{39:80,93:202,56:203,57:204,59:205,11:206,37:207,33:208,35:209,60:210,34:d,36:Oa,38:v,40:l,41:u,62:m,118:ua}),a(Ib,[2,34]),a(Ib,[2,35]),a(Aa,[2,38]),{15:142,16:211,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,
50:G,51:L,52:I,53:x,54:144,60:71,74:53,75:54,77:212,79:28,80:29,81:30,92:k,111:31,112:H,117:y,118:T,119:S,130:R},a([1,6,29,31,32,40,41,42,55,58,65,70,73,82,83,84,85,87,89,90,94,96,102,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175],[2,32]),a(Jb,[2,36]),{4:213,5:3,7:4,8:5,9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,33:70,34:d,37:55,38:v,39:80,40:l,41:u,
43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(ta,[2,5],{7:4,8:5,9:6,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,
138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,5:214,12:c,28:t,34:d,38:v,40:l,41:u,44:F,45:w,48:z,49:n,50:G,51:L,52:I,53:x,61:E,62:m,63:g,67:r,68:q,92:k,95:h,97:K,104:O,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,133:C,135:A,137:W,139:B,149:N,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q}),a(sa,[2,253]),{7:215,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,
50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:216,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,
61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:217,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,
74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:218,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,
81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:219,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,
112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:220,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,
129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:221,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,
136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:222,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,
149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:223,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,
159:U,160:J,161:aa,162:Q},{7:224,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:225,
8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:226,8:122,10:20,11:21,12:c,13:23,14:24,
15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:227,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,
21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:228,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,
26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(sa,[2,204]),a(sa,[2,209]),{7:229,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,
27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(sa,[2,203]),a(sa,[2,208]),{39:230,40:l,41:u,110:231,114:sb},a(La,[2,88]),a(Kb,[2,163]),{35:232,36:Oa},{35:233,36:Oa},a(La,[2,103],{35:234,36:Oa}),
{35:235,36:Oa},a(La,[2,104]),{7:237,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,73:Lb,74:53,75:54,77:40,79:28,80:29,81:30,88:236,91:238,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,121:239,122:tb,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,
158:V,159:U,160:J,161:aa,162:Q},{86:242,87:Pa,90:Qa},{110:243,114:sb},a(La,[2,89]),a(ta,[2,65],{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,7:244,12:c,28:ea,34:d,38:v,40:l,41:u,44:F,45:w,48:z,49:n,50:G,51:L,52:I,53:x,61:E,62:m,63:g,67:r,68:q,92:k,95:h,97:K,104:O,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,133:$a,135:$a,
139:$a,156:$a,137:W,149:N,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q}),a(Ma,[2,28],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),{7:245,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,
95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{132:105,133:C,135:A,138:106,139:B,141:77,156:ya},a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,163,164,165,166,167,168,169,170,171,172,173,174],ma,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,
132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,7:120,8:122,12:c,28:ea,29:Ha,34:d,38:v,40:l,41:u,44:F,45:w,48:z,49:n,50:G,51:L,52:I,53:x,61:E,62:m,63:g,67:r,68:q,92:k,95:h,97:K,104:O,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,137:W,149:N,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q}),{6:[1,247],7:246,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,248],33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,
47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a([6,31],Ea,{69:251,65:[1,249],70:Mb}),a(Va,[2,74]),a(Va,[2,78],{55:[1,253],73:[1,252]}),a(Va,[2,81]),a(fb,[2,82]),a(fb,[2,83]),a(fb,[2,84]),a(fb,[2,85]),{35:181,36:Oa},{7:254,8:122,10:20,11:21,12:c,13:23,14:24,
15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:ab,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,73:Wa,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,116:176,117:y,118:T,119:S,120:Gb,123:177,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(sa,[2,68]),{4:256,5:3,7:4,8:5,
9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,32:[1,255],33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a([1,6,31,32,42,65,70,73,89,94,
115,120,122,131,133,134,135,139,140,156,159,160,164,165,166,167,168,169,170,171,172,173,174],[2,245],{141:77,132:102,138:103,163:da}),a(bb,[2,246],{141:77,132:102,138:103,163:da,165:fa}),a(bb,[2,247],{141:77,132:102,138:103,163:da,165:fa}),a(bb,[2,248],{141:77,132:102,138:103,163:da,165:fa}),a(sa,[2,249],{40:wa,41:wa,82:wa,83:wa,84:wa,85:wa,87:wa,90:wa,113:wa,114:wa}),a(Kb,Ja,{109:107,78:108,86:114,82:Ta,83:Ga,84:Ua,85:Fa,87:Pa,90:Qa,113:Na}),{78:118,82:Ta,83:Ga,84:Ua,85:Fa,86:114,87:Pa,90:Qa,109:117,
113:Na,114:Ja},a(Nb,Ia),a(sa,[2,250],{40:wa,41:wa,82:wa,83:wa,84:wa,85:wa,87:wa,90:wa,113:wa,114:wa}),a(sa,[2,251]),a(sa,[2,252]),{6:[1,259],7:257,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,258],33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,
129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:260,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,
136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{30:261,31:va,155:[1,262]},a(sa,[2,188],{126:263,127:[1,264],128:[1,265]}),a(sa,[2,202]),a(sa,[2,210]),{31:[1,266],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},{150:267,152:268,153:gb},a(sa,[2,116]),{7:270,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,
27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Eb,[2,119],{30:271,31:va,40:wa,41:wa,82:wa,83:wa,84:wa,85:wa,87:wa,90:wa,113:wa,114:wa,96:[1,272]}),a(Ma,[2,195],{141:77,132:102,138:103,159:ia,
160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(za,cb,{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(za,[2,123]),{29:[1,273],70:[1,274]},{29:[1,275]},{31:hb,33:280,34:d,94:[1,276],100:277,101:278},a([29,70],[2,137]),{102:[1,281]},{31:ub,33:286,34:d,94:[1,282],105:283,108:284},a(za,[2,141]),{55:[1,287]},{7:288,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,
21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{29:[1,289]},{6:xa,131:[1,290]},{4:291,5:3,7:4,8:5,9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,
19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a([6,31,70,120],Ob,{141:77,132:102,138:103,121:292,73:[1,293],122:tb,133:C,135:A,139:B,156:pa,
159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(vb,[2,169]),a([6,31,120],Ea,{69:294,70:ib}),a(Ra,[2,178]),{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:ab,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,73:Wa,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,
116:296,117:y,118:T,119:S,123:177,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Ra,[2,184]),a(Ra,[2,185]),a(Pb,[2,168]),a(Pb,[2,33]),a(b,[2,161]),{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:ab,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,73:Wa,74:53,
75:54,76:179,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,115:[1,297],116:298,117:y,118:T,119:S,123:177,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{30:299,31:va,132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},a(Qb,[2,198],{141:77,132:102,138:103,133:C,134:[1,300],135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,
166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Qb,[2,200],{141:77,132:102,138:103,133:C,134:[1,301],135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(sa,[2,206]),a(Ya,[2,207],{141:77,132:102,138:103,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,156,159,160,163,164,165,166,167,168,169,
170,171,172,173,174],[2,211],{140:[1,302]}),a(jb,[2,214]),{33:194,34:d,60:195,74:196,75:197,92:k,118:ua,119:e,143:303,145:193},a(jb,[2,220],{70:[1,304]}),a(kb,[2,216]),a(kb,[2,217]),a(kb,[2,218]),a(kb,[2,219]),a(sa,[2,213]),{7:305,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,
80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:306,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,
111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:307,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,
125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(lb,Ea,{69:308,70:Rb}),a(Ba,[2,111]),a(Ba,[2,51],{58:[1,310]}),a(Sb,[2,60],{55:[1,311]}),a(Ba,[2,56]),a(Sb,[2,61]),a(wb,[2,57]),a(wb,[2,58]),a(wb,[2,59]),{46:[1,312],78:118,82:Ta,83:Ga,84:Ua,85:Fa,86:114,87:Pa,90:Qa,109:117,113:Na,114:Ja},a(Nb,wa),{6:xa,42:[1,313]},a(ta,[2,4]),a(Tb,[2,254],{141:77,132:102,138:103,163:da,164:ga,165:fa}),a(Tb,[2,255],{141:77,132:102,138:103,
163:da,164:ga,165:fa}),a(bb,[2,256],{141:77,132:102,138:103,163:da,165:fa}),a(bb,[2,257],{141:77,132:102,138:103,163:da,165:fa}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,166,167,168,169,170,171,172,173,174],[2,258],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,167,168,169,170,171,172,173],[2,259],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,174:la}),a([1,6,31,32,
42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,168,169,170,171,172,173],[2,260],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,174:la}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,169,170,171,172,173],[2,261],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,174:la}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,170,171,172,173],[2,262],{141:77,132:102,138:103,159:ia,160:ba,163:da,
164:ga,165:fa,166:ka,167:ja,168:M,169:ha,174:la}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,171,172,173],[2,263],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,174:la}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,172,173],[2,264],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,174:la}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,
140,156,173],[2,265],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,174:la}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,167,168,169,170,171,172,173,174],[2,266],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka}),a(Ya,[2,244],{141:77,132:102,138:103,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ya,[2,243],{141:77,132:102,138:103,
133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(b,[2,156]),a(b,[2,157]),a(La,[2,99]),a(La,[2,100]),a(La,[2,101]),a(La,[2,102]),{89:[1,314]},{73:Lb,89:[2,107],121:315,122:tb,132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},{89:[2,108]},{7:316,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,
25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,89:[2,177],92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Ub,[2,171]),a(Ub,Vb),a(La,[2,106]),a(b,[2,158]),a(ta,[2,64],{141:77,132:102,138:103,133:cb,135:cb,139:cb,156:cb,159:ia,
160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ma,[2,29],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ma,[2,48],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),{7:317,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,
38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:318,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,
45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{66:319,67:r,68:q},a(Sa,db,{72:127,33:129,60:130,74:131,75:132,71:320,34:d,73:ra,92:k,118:ua,119:e}),{6:Wb,31:Xb},a(Va,[2,79]),{7:323,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,
21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Ra,Ob,{141:77,132:102,138:103,73:[1,324],133:C,135:A,139:B,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,
167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Yb,[2,30]),{6:xa,32:[1,325]},a(Ma,[2,267],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),{7:326,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,
80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:327,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,
111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Ma,[2,270],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(sa,[2,242]),{7:328,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,
50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(sa,[2,189],{127:[1,329]}),{30:330,31:va},{30:333,31:va,33:331,34:d,75:332,92:k},{150:334,152:268,153:gb},{32:[1,335],151:[1,336],152:337,153:gb},a(mb,[2,235]),{7:339,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,
19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,124:338,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Zb,[2,117],{141:77,132:102,138:103,30:340,31:va,133:C,135:A,139:B,159:ia,160:ba,163:da,
164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(sa,[2,120]),{7:341,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,
149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{39:342,40:l,41:u},{92:[1,344],99:343,103:Fb},{39:345,40:l,41:u},{29:[1,346]},a(lb,Ea,{69:347,70:nb}),a(Ba,[2,130]),{31:hb,33:280,34:d,100:349,101:278},a(Ba,[2,135],{102:[1,350]}),{33:351,34:d},a(za,[2,139]),a(lb,Ea,{69:352,70:xb}),a(Ba,[2,148]),{31:ub,33:286,34:d,105:354,108:284},a(Ba,[2,153],{102:[1,355]}),{6:[1,357],7:356,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,
358],33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(yb,[2,145],{141:77,132:102,138:103,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),
{39:359,40:l,41:u},a(Aa,[2,196]),{6:xa,32:[1,360]},{7:361,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,
160:J,161:aa,162:Q},a([12,28,34,38,40,41,44,45,48,49,50,51,52,53,61,62,63,67,68,92,95,97,104,112,117,118,119,125,129,130,133,135,137,139,149,155,157,158,159,160,161,162],Vb,{6:eb,31:eb,70:eb,120:eb}),{6:ob,31:pb,120:[1,362]},a([6,31,32,115,120],db,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,76:179,7:254,123:365,
12:c,28:ea,34:d,38:v,40:l,41:u,44:F,45:w,48:z,49:n,50:G,51:L,52:I,53:x,61:E,62:m,63:g,67:r,68:q,73:Wa,92:k,95:h,97:K,104:O,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,133:C,135:A,137:W,139:B,149:N,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q}),a(Sa,Ea,{69:366,70:ib}),a(b,[2,164]),a([6,31,115],Ea,{69:367,70:ib}),a($b,[2,239]),{7:368,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,
48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:369,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,
54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:370,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,
67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(jb,[2,215]),{33:194,34:d,60:195,74:196,75:197,92:k,118:ua,119:e,145:371},a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,135,139,156],[2,222],{141:77,132:102,138:103,134:[1,372],140:[1,373],159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,
173:qa,174:la}),a(zb,[2,223],{141:77,132:102,138:103,134:[1,374],159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(zb,[2,229],{141:77,132:102,138:103,134:[1,375],159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),{6:ac,31:bc,94:[1,376]},a(Ab,db,{39:80,57:204,59:205,11:206,37:207,33:208,35:209,60:210,56:379,34:d,36:Oa,38:v,40:l,41:u,62:m,118:ua}),{7:380,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,
18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,381],33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:382,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,
22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:[1,383],33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Aa,[2,39]),a(Jb,[2,37]),a(La,[2,105]),{7:384,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,
19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,89:[2,175],92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{89:[2,176],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,
165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},a(Ma,[2,49],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),{32:[1,385],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},{30:386,31:va},a(Va,[2,75]),{33:129,34:d,60:130,71:387,72:127,73:ra,74:131,75:132,92:k,118:ua,119:e},a(cc,p,{71:126,72:127,33:129,60:130,74:131,
75:132,64:388,34:d,73:ra,92:k,118:ua,119:e}),a(Va,[2,80],{141:77,132:102,138:103,133:C,135:A,139:B,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ra,eb),a(Yb,[2,31]),{32:[1,389],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},a(Ma,[2,269],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,
173:qa,174:la}),{30:390,31:va,132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},{30:391,31:va},a(sa,[2,190]),{30:392,31:va},{30:393,31:va},a(Bb,[2,194]),{32:[1,394],151:[1,395],152:337,153:gb},a(sa,[2,233]),{30:396,31:va},a(mb,[2,236]),{30:397,31:va,70:[1,398]},a(dc,[2,186],{141:77,132:102,138:103,133:C,135:A,139:B,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,
173:qa,174:la}),a(sa,[2,118]),a(Zb,[2,121],{141:77,132:102,138:103,30:399,31:va,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(za,[2,124]),{29:[1,400]},{31:hb,33:280,34:d,100:401,101:278},a(za,[2,125]),{39:402,40:l,41:u},{6:qb,31:rb,94:[1,403]},a(Ab,db,{33:280,101:406,34:d}),a(Sa,Ea,{69:407,70:nb}),{33:408,34:d},{29:[2,138]},{6:Cb,31:Db,94:[1,409]},a(Ab,db,{33:286,108:412,34:d}),a(Sa,Ea,{69:413,70:xb}),{33:414,34:d,106:[1,415]},
a(yb,[2,142],{141:77,132:102,138:103,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),{7:416,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,
129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:417,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,
136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(za,[2,146]),{131:[1,418]},{120:[1,419],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},a(vb,[2,170]),{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,
54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,73:Wa,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,123:420,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,31:ab,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,
60:71,61:E,62:m,63:g,66:33,67:r,68:q,73:Wa,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,116:421,117:y,118:T,119:S,123:177,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Ra,[2,179]),{6:ob,31:pb,32:[1,422]},{6:ob,31:pb,115:[1,423]},a(Ya,[2,199],{141:77,132:102,138:103,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ya,
[2,201],{141:77,132:102,138:103,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ya,[2,212],{141:77,132:102,138:103,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(jb,[2,221]),{7:424,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,
49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:425,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,
60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:426,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,
68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:427,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,
81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(vb,[2,109]),{11:206,33:208,34:d,35:209,36:Oa,37:207,38:v,39:80,40:l,41:u,56:428,57:204,59:205,60:210,62:m,118:ua},a(cc,Hb,{39:80,56:203,57:204,59:205,11:206,37:207,33:208,35:209,60:210,93:429,34:d,36:Oa,38:v,40:l,41:u,62:m,118:ua}),a(Ba,[2,112]),a(Ba,[2,52],{141:77,132:102,138:103,133:C,135:A,139:B,156:pa,159:ia,
160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),{7:430,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,
149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},a(Ba,[2,54],{141:77,132:102,138:103,133:C,135:A,139:B,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),{7:431,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,
81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{89:[2,174],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},a(sa,[2,50]),a(sa,[2,67]),a(Va,[2,76]),a(Sa,Ea,{69:432,70:Mb}),a(sa,[2,268]),a($b,[2,240]),a(sa,[2,191]),a(Bb,[2,192]),a(Bb,[2,193]),a(sa,[2,231]),{30:433,31:va},
{32:[1,434]},a(mb,[2,237],{6:[1,435]}),{7:436,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,
162:Q},a(sa,[2,122]),{39:437,40:l,41:u},a(lb,Ea,{69:438,70:nb}),a(za,[2,126]),{29:[1,439]},{33:280,34:d,101:440},{31:hb,33:280,34:d,100:441,101:278},a(Ba,[2,131]),{6:qb,31:rb,32:[1,442]},a(Ba,[2,136]),a(za,[2,140],{29:[1,443]}),{33:286,34:d,108:444},{31:ub,33:286,34:d,105:445,108:284},a(Ba,[2,149]),{6:Cb,31:Db,32:[1,446]},a(Ba,[2,154]),a(Ba,[2,155]),a(yb,[2,143],{141:77,132:102,138:103,133:C,135:A,139:B,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),
{32:[1,447],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},a(Aa,[2,197]),a(Aa,[2,173]),a(Ra,[2,180]),a(Sa,Ea,{69:448,70:ib}),a(Ra,[2,181]),a(b,[2,165]),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,156],[2,224],{141:77,132:102,138:103,140:[1,449],159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(zb,[2,226],{141:77,132:102,138:103,134:[1,
450],159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ma,[2,225],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ma,[2,230],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ba,[2,113]),a(Sa,Ea,{69:451,70:Rb}),{32:[1,452],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,
165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},{32:[1,453],132:102,133:C,135:A,138:103,139:B,141:77,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la},{6:Wb,31:Xb,32:[1,454]},{32:[1,455]},a(sa,[2,234]),a(mb,[2,238]),a(dc,[2,187],{141:77,132:102,138:103,133:C,135:A,139:B,156:pa,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(za,[2,128]),{6:qb,31:rb,94:[1,456]},{39:457,40:l,
41:u},a(Ba,[2,132]),a(Sa,Ea,{69:458,70:nb}),a(Ba,[2,133]),{39:459,40:l,41:u},a(Ba,[2,150]),a(Sa,Ea,{69:460,70:xb}),a(Ba,[2,151]),a(za,[2,144]),{6:ob,31:pb,32:[1,461]},{7:462,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,
119:S,125:P,129:Z,130:R,132:43,133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{7:463,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ea,33:70,34:d,37:55,38:v,39:80,40:l,41:u,43:57,44:F,45:w,47:27,48:z,49:n,50:G,51:L,52:I,53:x,54:26,60:71,61:E,62:m,63:g,66:33,67:r,68:q,74:53,75:54,77:40,79:28,80:29,81:30,92:k,95:h,97:K,104:O,111:31,112:H,117:y,118:T,119:S,125:P,129:Z,130:R,132:43,
133:C,135:A,136:44,137:W,138:45,139:B,141:77,149:N,154:41,155:X,157:Y,158:V,159:U,160:J,161:aa,162:Q},{6:ac,31:bc,32:[1,464]},a(Ba,[2,53]),a(Ba,[2,55]),a(Va,[2,77]),a(sa,[2,232]),{29:[1,465]},a(za,[2,127]),{6:qb,31:rb,32:[1,466]},a(za,[2,147]),{6:Cb,31:Db,32:[1,467]},a(Ra,[2,182]),a(Ma,[2,227],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ma,[2,228],{141:77,132:102,138:103,159:ia,160:ba,163:da,164:ga,165:fa,166:ka,167:ja,
168:M,169:ha,170:ca,171:oa,172:na,173:qa,174:la}),a(Ba,[2,114]),{39:468,40:l,41:u},a(Ba,[2,134]),a(Ba,[2,152]),a(za,[2,129])],defaultActions:{68:[2,69],69:[2,70],238:[2,108],351:[2,138]},parseError:function(a,b){if(b.recoverable)this.trace(a);else{var e=function(a,b){this.message=a;this.hash=b};e.prototype=Error;throw new e(a,b);}},parse:function(a){var b=[0],e=[null],c=[],p=this.table,ra="",ua=0,d=0,f=0,g=c.slice.call(arguments,1),va=Object.create(this.lexer),h={},Ka;for(Ka in this.yy)Object.prototype.hasOwnProperty.call(this.yy,
Ka)&&(h[Ka]=this.yy[Ka]);va.setInput(a,h);h.lexer=va;h.parser=this;"undefined"==typeof va.yylloc&&(va.yylloc={});Ka=va.yylloc;c.push(Ka);var m=va.options&&va.options.ranges;this.parseError="function"===typeof h.parseError?h.parseError:Object.getPrototypeOf(this).parseError;for(var q,r,Ia,k,n={},l,D;;){Ia=b[b.length-1];if(this.defaultActions[Ia])k=this.defaultActions[Ia];else{if(null===q||"undefined"==typeof q)q=va.lex()||1,"number"!==typeof q&&(q=this.symbols_[q]||q);k=p[Ia]&&p[Ia][q]}if("undefined"===
typeof k||!k.length||!k[0]){var wa;D=[];for(l in p[Ia])this.terminals_[l]&&2<l&&D.push("'"+this.terminals_[l]+"'");wa=va.showPosition?"Parse error on line "+(ua+1)+":\n"+va.showPosition()+"\nExpecting "+D.join(", ")+", got '"+(this.terminals_[q]||q)+"'":"Parse error on line "+(ua+1)+": Unexpected "+(1==q?"end of input":"'"+(this.terminals_[q]||q)+"'");this.parseError(wa,{text:va.match,token:this.terminals_[q]||q,line:va.yylineno,loc:Ka,expected:D})}if(k[0]instanceof Array&&1<k.length)throw Error("Parse Error: multiple actions possible at state: "+
Ia+", token: "+q);switch(k[0]){case 1:b.push(q);e.push(va.yytext);c.push(va.yylloc);b.push(k[1]);q=null;r?(q=r,r=null):(d=va.yyleng,ra=va.yytext,ua=va.yylineno,Ka=va.yylloc,0<f&&f--);break;case 2:D=this.productions_[k[1]][1];n.$=e[e.length-D];n._$={first_line:c[c.length-(D||1)].first_line,last_line:c[c.length-1].last_line,first_column:c[c.length-(D||1)].first_column,last_column:c[c.length-1].last_column};m&&(n._$.range=[c[c.length-(D||1)].range[0],c[c.length-1].range[1]]);Ia=this.performAction.apply(n,
[ra,d,ua,h,k[1],e,c].concat(g));if("undefined"!==typeof Ia)return Ia;D&&(b=b.slice(0,-2*D),e=e.slice(0,-1*D),c=c.slice(0,-1*D));b.push(this.productions_[k[1]][0]);e.push(n.$);c.push(n._$);k=p[b[b.length-2]][b[b.length-1]];b.push(k);break;case 3:return!0}}}};f.prototype=ec;ec.Parser=f;return new f}();"undefined"!==typeof t&&"undefined"!==typeof f&&(f.parser=xa,f.Parser=xa.Parser,f.parse=function(){return xa.parse.apply(xa,arguments)},f.main=function(D){D[1]||(console.log("Usage: "+D[0]+" FILE"),process.exit(1));
D=t("fs").readFileSync(t("path").normalize(D[1]),"utf8");return f.parser.parse(D)},"undefined"!==typeof ta&&t.main===ta&&f.main(process.argv.slice(1)));return ta.exports}();t["./scope"]=function(){var f={};(function(){var t=[].indexOf||function(f){for(var D=0,a=this.length;D<a;D++)if(D in this&&this[D]===f)return D;return-1};f.Scope=function(){function f(f,a,c,t){var d,D;this.parent=f;this.expressions=a;this.method=c;this.referencedVars=t;this.variables=[{name:"arguments",type:"arguments"}];this.positions=
{};this.parent||(this.utilities={});this.root=null!=(d=null!=(D=this.parent)?D.root:void 0)?d:this}f.prototype.add=function(f,a,c){return this.shared&&!c?this.parent.add(f,a,c):Object.prototype.hasOwnProperty.call(this.positions,f)?this.variables[this.positions[f]].type=a:this.positions[f]=this.variables.push({name:f,type:a})-1};f.prototype.namedMethod=function(){var f;return null!=(f=this.method)&&f.name||!this.parent?this.method:this.parent.namedMethod()};f.prototype.find=function(f){if(this.check(f))return!0;
this.add(f,"var");return!1};f.prototype.parameter=function(f){if(!this.shared||!this.parent.check(f,!0))return this.add(f,"param")};f.prototype.check=function(f){var a;return!!(this.type(f)||null!=(a=this.parent)&&a.check(f))};f.prototype.temporary=function(f,a,c){null==c&&(c=!1);return c?(c=f.charCodeAt(0),f=122-c,c=String.fromCharCode(c+a%(f+1)),a=Math.floor(a/(f+1)),""+c+(a||"")):""+f+(a||"")};f.prototype.type=function(f){var a,c,D,d;D=this.variables;a=0;for(c=D.length;a<c;a++)if(d=D[a],d.name===
f)return d.type;return null};f.prototype.freeVariable=function(f,a){var c,D,d;null==a&&(a={});for(c=0;;){d=this.temporary(f,c,a.single);if(!(this.check(d)||0<=t.call(this.root.referencedVars,d)))break;c++}(null!=(D=a.reserve)?D:1)&&this.add(d,"var",!0);return d};f.prototype.assign=function(f,a){this.add(f,{value:a,assigned:!0},!0);return this.hasAssignments=!0};f.prototype.hasDeclarations=function(){return!!this.declaredVariables().length};f.prototype.declaredVariables=function(){var f,a,c,t,d;t=
this.variables;d=[];a=0;for(c=t.length;a<c;a++)f=t[a],"var"===f.type&&d.push(f.name);return d.sort()};f.prototype.assignedVariables=function(){var f,a,c,t,d;c=this.variables;t=[];f=0;for(a=c.length;f<a;f++)d=c[f],d.type.assigned&&t.push(d.name+" \x3d "+d.type.value);return t};return f}()}).call(this);return f}();t["./nodes"]=function(){var f={};(function(){var ta,pa,D,a,c,Ca,d,v,l,u,F,w,z,n,G,L,I,x,E,m,g,r,q,k,h,K,O,H,y,T,S,P,Z,R,C,A,W,B,N,X,Y,V,U,J,aa,Q,ya,Za,Xa,ia,ba,da,ga,fa,ka,ja,M,ha,ca,oa,na,
qa,la,Da,sa,Ja,Ta,Ga,Ua,Fa,Pa,Qa,Na,za,ma=function(a,b){function c(){this.constructor=a}for(var ra in b)ea.call(b,ra)&&(a[ra]=b[ra]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a},ea={}.hasOwnProperty,Ha=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},Aa=[].slice;Error.stackTraceLimit=Infinity;J=t("./scope").Scope;a=t("./lexer");Ga=a.isUnassignable;r=a.JS_FORBIDDEN;n=t("./helpers");oa=n.compact;la=n.flatten;qa=n.extend;
Fa=n.merge;na=n.del;a=n.addLocationDataFn;Ua=n.locationDataToString;Qa=n.throwSyntaxError;f.extend=qa;f.addLocationDataFn=a;ha=function(){return!0};P=function(){return!1};da=function(){return this};S=function(){this.negated=!this.negated;return this};f.CodeFragment=u=function(){function a(a,c){var b;this.code=""+c;this.locationData=null!=a?a.locationData:void 0;this.type=(null!=a?null!=(b=a.constructor)?b.name:void 0:void 0)||"unknown"}a.prototype.toString=function(){return""+this.code+(this.locationData?
": "+Ua(this.locationData):"")};return a}();Da=function(a){var b,c,ra,ua;ua=[];c=0;for(ra=a.length;c<ra;c++)b=a[c],ua.push(b.code);return ua.join("")};f.Base=a=function(){function a(){}a.prototype.compile=function(a,c){return Da(this.compileToFragments(a,c))};a.prototype.compileToFragments=function(a,c){a=qa({},a);c&&(a.level=c);c=this.unfoldSoak(a)||this;c.tab=a.indent;return a.level!==H&&c.isStatement(a)?c.compileClosure(a):c.compileNode(a)};a.prototype.compileClosure=function(a){var b,ra,ua,e;
(ua=this.jumps())&&ua.error("cannot use a pure statement in an expression");a.sharedScope=!0;ua=new l([],c.wrap([this]));b=[];if((ra=this.contains(Ja))||this.contains(Ta))b=[new ga],ra?(ra="apply",b.push(new x("arguments"))):ra="call",ua=new M(ua,[new ta(new N(ra))]);a=(new d(ua,b)).compileNode(a);if(ua.isGenerator||null!=(e=ua.base)&&e.isGenerator)a.unshift(this.makeCode("(yield* ")),a.push(this.makeCode(")"));return a};a.prototype.cache=function(a,c,ra){var b;if(null!=ra?ra(this):this.isComplex())return ra=
new x(a.scope.freeVariable("ref")),b=new D(ra,this),c?[b.compileToFragments(a,c),[this.makeCode(ra.value)]]:[b,ra];ra=c?this.compileToFragments(a,c):this;return[ra,ra]};a.prototype.cacheToCodeFragments=function(a){return[Da(a[0]),Da(a[1])]};a.prototype.makeReturn=function(a){var b;b=this.unwrapAll();return a?new d(new y(a+".push"),[b]):new V(b)};a.prototype.contains=function(a){var b;b=void 0;this.traverseChildren(!1,function(c){if(a(c))return b=c,!1});return b};a.prototype.lastNonComment=function(a){var b;
for(b=a.length;b--;)if(!(a[b]instanceof F))return a[b];return null};a.prototype.toString=function(a,c){var b;null==a&&(a="");null==c&&(c=this.constructor.name);b="\n"+a+c;this.soak&&(b+="?");this.eachChild(function(c){return b+=c.toString(a+ba)});return b};a.prototype.eachChild=function(a){var b,c,ua,e,d,f,g;if(!this.children)return this;f=this.children;c=0;for(e=f.length;c<e;c++)if(b=f[c],this[b])for(g=la([this[b]]),ua=0,d=g.length;ua<d;ua++)if(b=g[ua],!1===a(b))return this;return this};a.prototype.traverseChildren=
function(a,c){return this.eachChild(function(b){if(!1!==c(b))return b.traverseChildren(a,c)})};a.prototype.invert=function(){return new A("!",this)};a.prototype.unwrapAll=function(){var a;for(a=this;a!==(a=a.unwrap()););return a};a.prototype.children=[];a.prototype.isStatement=P;a.prototype.jumps=P;a.prototype.isComplex=ha;a.prototype.isChainable=P;a.prototype.isAssignable=P;a.prototype.isNumber=P;a.prototype.unwrap=da;a.prototype.unfoldSoak=P;a.prototype.assigns=P;a.prototype.updateLocationDataIfMissing=
function(a){if(this.locationData)return this;this.locationData=a;return this.eachChild(function(b){return b.updateLocationDataIfMissing(a)})};a.prototype.error=function(a){return Qa(a,this.locationData)};a.prototype.makeCode=function(a){return new u(this,a)};a.prototype.wrapInBraces=function(a){return[].concat(this.makeCode("("),a,this.makeCode(")"))};a.prototype.joinFragmentArrays=function(a,c){var b,p,e,d,f;b=[];e=d=0;for(f=a.length;d<f;e=++d)p=a[e],e&&b.push(this.makeCode(c)),b=b.concat(p);return b};
return a}();f.Block=c=function(a){function b(a){this.expressions=oa(la(a||[]))}ma(b,a);b.prototype.children=["expressions"];b.prototype.push=function(a){this.expressions.push(a);return this};b.prototype.pop=function(){return this.expressions.pop()};b.prototype.unshift=function(a){this.expressions.unshift(a);return this};b.prototype.unwrap=function(){return 1===this.expressions.length?this.expressions[0]:this};b.prototype.isEmpty=function(){return!this.expressions.length};b.prototype.isStatement=function(a){var b,
c,e,p;p=this.expressions;c=0;for(e=p.length;c<e;c++)if(b=p[c],b.isStatement(a))return!0;return!1};b.prototype.jumps=function(a){var b,c,e,p;p=this.expressions;c=0;for(e=p.length;c<e;c++)if(b=p[c],b=b.jumps(a))return b};b.prototype.makeReturn=function(a){var b,c;for(c=this.expressions.length;c--;)if(b=this.expressions[c],!(b instanceof F)){this.expressions[c]=b.makeReturn(a);b instanceof V&&!b.expression&&this.expressions.splice(c,1);break}return this};b.prototype.compileToFragments=function(a,c){null==
a&&(a={});return a.scope?b.__super__.compileToFragments.call(this,a,c):this.compileRoot(a)};b.prototype.compileNode=function(a){var c,p,e,d,f,g,m;this.tab=a.indent;m=a.level===H;p=[];g=this.expressions;e=c=0;for(d=g.length;c<d;e=++c)f=g[e],f=f.unwrapAll(),f=f.unfoldSoak(a)||f,f instanceof b?p.push(f.compileNode(a)):m?(f.front=!0,e=f.compileToFragments(a),f.isStatement(a)||(e.unshift(this.makeCode(""+this.tab)),e.push(this.makeCode(";"))),p.push(e)):p.push(f.compileToFragments(a,h));if(m)return this.spaced?
[].concat(this.joinFragmentArrays(p,"\n\n"),this.makeCode("\n")):this.joinFragmentArrays(p,"\n");c=p.length?this.joinFragmentArrays(p,", "):[this.makeCode("void 0")];return 1<p.length&&a.level>=h?this.wrapInBraces(c):c};b.prototype.compileRoot=function(a){var b,c,e,p,d;a.indent=a.bare?"":ba;a.level=H;this.spaced=!0;a.scope=new J(null,this,null,null!=(e=a.referencedVars)?e:[]);d=a.locals||[];e=0;for(c=d.length;e<c;e++)p=d[e],a.scope.parameter(p);e=[];if(!a.bare){var f;f=this.expressions;c=[];b=p=0;
for(d=f.length;p<d;b=++p){b=f[b];if(!(b.unwrap()instanceof F))break;c.push(b)}p=this.expressions.slice(c.length);this.expressions=c;c.length&&(e=this.compileNode(Fa(a,{indent:""})),e.push(this.makeCode("\n")));this.expressions=p}c=this.compileWithDeclarations(a);return a.bare?c:[].concat(e,this.makeCode("(function() {\n"),c,this.makeCode("\n}).call(this);\n"))};b.prototype.compileWithDeclarations=function(a){var b,c,e,p,d,f;e=[];f=this.expressions;p=d=0;for(b=f.length;d<b&&(c=f[p],c=c.unwrap(),c instanceof
F||c instanceof y);p=++d);a=Fa(a,{level:H});p&&(c=this.expressions.splice(p,9E9),e=[this.spaced,!1],d=e[0],this.spaced=e[1],d=[this.compileNode(a),d],e=d[0],this.spaced=d[1],this.expressions=c);c=this.compileNode(a);d=a.scope;d.expressions===this&&(b=a.scope.hasDeclarations(),a=d.hasAssignments,b||a?(p&&e.push(this.makeCode("\n")),e.push(this.makeCode(this.tab+"var ")),b&&e.push(this.makeCode(d.declaredVariables().join(", "))),a&&(b&&e.push(this.makeCode(",\n"+(this.tab+ba))),e.push(this.makeCode(d.assignedVariables().join(",\n"+
(this.tab+ba))))),e.push(this.makeCode(";\n"+(this.spaced?"\n":"")))):e.length&&c.length&&e.push(this.makeCode("\n")));return e.concat(c)};b.wrap=function(a){return 1===a.length&&a[0]instanceof b?a[0]:new b(a)};return b}(a);f.Literal=y=function(a){function b(a){this.value=a}ma(b,a);b.prototype.isComplex=P;b.prototype.assigns=function(a){return a===this.value};b.prototype.compileNode=function(a){return[this.makeCode(this.value)]};b.prototype.toString=function(){return" "+(this.isStatement()?b.__super__.toString.apply(this,
arguments):this.constructor.name)+": "+this.value};return b}(a);f.NumberLiteral=R=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(y);f.InfinityLiteral=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);b.prototype.compileNode=function(){return[this.makeCode("2e308")]};return b}(R);f.NaNLiteral=function(a){function b(){b.__super__.constructor.call(this,"NaN")}ma(b,a);b.prototype.compileNode=function(a){var b;b=[this.makeCode("0/0")];
return a.level>=K?this.wrapInBraces(b):b};return b}(R);f.StringLiteral=Za=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(y);f.RegexLiteral=Y=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(y);f.PassthroughLiteral=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(y);f.IdentifierLiteral=x=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}
ma(b,a);b.prototype.isAssignable=ha;return b}(y);f.PropertyName=N=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);b.prototype.isAssignable=ha;return b}(y);f.StatementLiteral=ya=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);b.prototype.isStatement=ha;b.prototype.makeReturn=da;b.prototype.jumps=function(a){if("break"===this.value&&!(null!=a&&a.loop||null!=a&&a.block)||"continue"===this.value&&(null==a||!a.loop))return this};
b.prototype.compileNode=function(a){return[this.makeCode(""+this.tab+this.value+";")]};return b}(y);f.ThisLiteral=ga=function(a){function b(){b.__super__.constructor.call(this,"this")}ma(b,a);b.prototype.compileNode=function(a){var b;a=null!=(b=a.scope.method)&&b.bound?a.scope.method.context:this.value;return[this.makeCode(a)]};return b}(y);f.UndefinedLiteral=ja=function(a){function b(){b.__super__.constructor.call(this,"undefined")}ma(b,a);b.prototype.compileNode=function(a){return[this.makeCode(a.level>=
q?"(void 0)":"void 0")]};return b}(y);f.NullLiteral=Z=function(a){function b(){b.__super__.constructor.call(this,"null")}ma(b,a);return b}(y);f.BooleanLiteral=Ca=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(y);f.Return=V=function(a){function b(a){this.expression=a}ma(b,a);b.prototype.children=["expression"];b.prototype.isStatement=ha;b.prototype.makeReturn=da;b.prototype.jumps=da;b.prototype.compileToFragments=function(a,c){var ra,e;ra=null!=(e=this.expression)?
e.makeReturn():void 0;return!ra||ra instanceof b?b.__super__.compileToFragments.call(this,a,c):ra.compileToFragments(a,c)};b.prototype.compileNode=function(a){var b;b=[];b.push(this.makeCode(this.tab+("return"+(this.expression?" ":""))));this.expression&&(b=b.concat(this.expression.compileToFragments(a,O)));b.push(this.makeCode(";"));return b};return b}(a);f.YieldReturn=ca=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);b.prototype.compileNode=function(a){null==
a.scope.parent&&this.error("yield can only occur inside functions");return b.__super__.compileNode.apply(this,arguments)};return b}(V);f.Value=M=function(a){function b(a,c,d){if(!c&&a instanceof b)return a;this.base=a;this.properties=c||[];d&&(this[d]=!0);return this}ma(b,a);b.prototype.children=["base","properties"];b.prototype.add=function(a){this.properties=this.properties.concat(a);return this};b.prototype.hasProperties=function(){return!!this.properties.length};b.prototype.bareLiteral=function(a){return!this.properties.length&&
this.base instanceof a};b.prototype.isArray=function(){return this.bareLiteral(pa)};b.prototype.isRange=function(){return this.bareLiteral(X)};b.prototype.isComplex=function(){return this.hasProperties()||this.base.isComplex()};b.prototype.isAssignable=function(){return this.hasProperties()||this.base.isAssignable()};b.prototype.isNumber=function(){return this.bareLiteral(R)};b.prototype.isString=function(){return this.bareLiteral(Za)};b.prototype.isRegex=function(){return this.bareLiteral(Y)};b.prototype.isUndefined=
function(){return this.bareLiteral(ja)};b.prototype.isNull=function(){return this.bareLiteral(Z)};b.prototype.isBoolean=function(){return this.bareLiteral(Ca)};b.prototype.isAtomic=function(){var a,b,c,e;e=this.properties.concat(this.base);a=0;for(b=e.length;a<b;a++)if(c=e[a],c.soak||c instanceof d)return!1;return!0};b.prototype.isNotCallable=function(){return this.isNumber()||this.isString()||this.isRegex()||this.isArray()||this.isRange()||this.isSplice()||this.isObject()||this.isUndefined()||this.isNull()||
this.isBoolean()};b.prototype.isStatement=function(a){return!this.properties.length&&this.base.isStatement(a)};b.prototype.assigns=function(a){return!this.properties.length&&this.base.assigns(a)};b.prototype.jumps=function(a){return!this.properties.length&&this.base.jumps(a)};b.prototype.isObject=function(a){return this.properties.length?!1:this.base instanceof C&&(!a||this.base.generated)};b.prototype.isSplice=function(){var a;a=this.properties;return a[a.length-1]instanceof aa};b.prototype.looksStatic=
function(a){var b;return this.base.value===a&&1===this.properties.length&&"prototype"!==(null!=(b=this.properties[0].name)?b.value:void 0)};b.prototype.unwrap=function(){return this.properties.length?this:this.base};b.prototype.cacheReference=function(a){var c,p,e,d;c=this.properties;e=c[c.length-1];if(2>this.properties.length&&!this.base.isComplex()&&(null==e||!e.isComplex()))return[this,this];c=new b(this.base,this.properties.slice(0,-1));c.isComplex()&&(p=new x(a.scope.freeVariable("base")),c=
new b(new B(new D(p,c))));if(!e)return[c,p];e.isComplex()&&(d=new x(a.scope.freeVariable("name")),e=new g(new D(d,e.index)),d=new g(d));return[c.add(e),new b(p||c.base,[d||e])]};b.prototype.compileNode=function(a){var b,c,e,p,d;this.base.front=this.front;d=this.properties;b=this.base.compileToFragments(a,d.length?q:null);d.length&&U.test(Da(b))&&b.push(this.makeCode("."));c=0;for(e=d.length;c<e;c++)p=d[c],b.push.apply(b,p.compileToFragments(a));return b};b.prototype.unfoldSoak=function(a){return null!=
this.unfoldedSoak?this.unfoldedSoak:this.unfoldedSoak=function(c){return function(){var p,e,ra,d,f;if(e=c.base.unfoldSoak(a))return(p=e.body.properties).push.apply(p,c.properties),e;f=c.properties;e=p=0;for(ra=f.length;p<ra;e=++p)if(d=f[e],d.soak)return d.soak=!1,p=new b(c.base,c.properties.slice(0,e)),ra=new b(c.base,c.properties.slice(e)),p.isComplex()&&(e=new x(a.scope.freeVariable("ref")),p=new B(new D(e,p)),ra.base=e),new E(new w(p),ra,{soak:!0});return!1}}(this)()};return b}(a);f.Comment=F=
function(a){function b(a){this.comment=a}ma(b,a);b.prototype.isStatement=ha;b.prototype.makeReturn=da;b.prototype.compileNode=function(a,b){var c;c=this.comment.replace(/^(\s*)#(?=\s)/gm,"$1 *");c="/*"+Pa(c,this.tab)+(0<=Ha.call(c,"\n")?"\n"+this.tab:"")+" */";(b||a.level)===H&&(c=a.indent+c);return[this.makeCode("\n"),this.makeCode(c)]};return b}(a);f.Call=d=function(a){function b(a,b,c){this.variable=a;this.args=null!=b?b:[];this.soak=c;this.isNew=!1;this.variable instanceof M&&this.variable.isNotCallable()&&
this.variable.error("literal is not a function")}ma(b,a);b.prototype.children=["variable","args"];b.prototype.newInstance=function(){var a,c;a=(null!=(c=this.variable)?c.base:void 0)||this.variable;a instanceof b&&!a.isNew?a.newInstance():this.isNew=!0;return this};b.prototype.unfoldSoak=function(a){var c,p,e,d,f;if(this.soak){if(this instanceof ia)c=new y(this.superReference(a)),p=new M(c);else{if(p=Na(a,this,"variable"))return p;p=(new M(this.variable)).cacheReference(a);c=p[0];p=p[1]}p=new b(p,
this.args);p.isNew=this.isNew;c=new y("typeof "+c.compile(a)+' \x3d\x3d\x3d "function"');return new E(c,new M(p),{soak:!0})}c=this;for(e=[];;)if(c.variable instanceof b)e.push(c),c=c.variable;else{if(!(c.variable instanceof M))break;e.push(c);if(!((c=c.variable.base)instanceof b))break}f=e.reverse();e=0;for(d=f.length;e<d;e++)c=f[e],p&&(c.variable instanceof b?c.variable=p:c.variable.base=p),p=Na(a,c,"variable");return p};b.prototype.compileNode=function(a){var b,c,e,p,d,f;null!=(e=this.variable)&&
(e.front=this.front);e=Q.compileSplattedArray(a,this.args,!0);if(e.length)return this.compileSplat(a,e);e=[];f=this.args;c=p=0;for(d=f.length;p<d;c=++p)b=f[c],c&&e.push(this.makeCode(", ")),e.push.apply(e,b.compileToFragments(a,h));b=[];this instanceof ia?(a=this.superReference(a)+(".call("+this.superThis(a)),e.length&&(a+=", "),b.push(this.makeCode(a))):(this.isNew&&b.push(this.makeCode("new ")),b.push.apply(b,this.variable.compileToFragments(a,q)),b.push(this.makeCode("(")));b.push.apply(b,e);b.push(this.makeCode(")"));
return b};b.prototype.compileSplat=function(a,b){var c,e,p,ra;if(this instanceof ia)return[].concat(this.makeCode(this.superReference(a)+".apply("+this.superThis(a)+", "),b,this.makeCode(")"));if(this.isNew)return c=this.tab+ba,[].concat(this.makeCode("(function(func, args, ctor) {\n"+c+"ctor.prototype \x3d func.prototype;\n"+c+"var child \x3d new ctor, result \x3d func.apply(child, args);\n"+c+"return Object(result) \x3d\x3d\x3d result ? result : child;\n"+this.tab+"})("),this.variable.compileToFragments(a,
h),this.makeCode(", "),b,this.makeCode(", function(){})"));c=[];e=new M(this.variable);(p=e.properties.pop())&&e.isComplex()?(ra=a.scope.freeVariable("ref"),c=c.concat(this.makeCode("("+ra+" \x3d "),e.compileToFragments(a,h),this.makeCode(")"),p.compileToFragments(a))):(e=e.compileToFragments(a,q),U.test(Da(e))&&(e=this.wrapInBraces(e)),p?(ra=Da(e),e.push.apply(e,p.compileToFragments(a))):ra="null",c=c.concat(e));return c.concat(this.makeCode(".apply("+ra+", "),b,this.makeCode(")"))};return b}(a);
f.SuperCall=ia=function(a){function b(a){b.__super__.constructor.call(this,null,null!=a?a:[new Q(new x("arguments"))]);this.isBare=null!=a}ma(b,a);b.prototype.superReference=function(a){var b,c,e,p,d,f,h;p=a.scope.namedMethod();if(null!=p&&p.klass){e=p.klass;d=p.name;h=p.variable;e.isComplex()&&(c=new x(a.scope.parent.freeVariable("base")),b=new M(new B(new D(c,e))),h.base=b,h.properties.splice(0,e.properties.length));if(d.isComplex()||d instanceof g&&d.index.isAssignable())f=new x(a.scope.parent.freeVariable("name")),
d=new g(new D(f,d.index)),h.properties.pop(),h.properties.push(d);b=[new ta(new N("__super__"))];p["static"]&&b.push(new ta(new N("constructor")));b.push(null!=f?new g(f):d);return(new M(null!=c?c:e,b)).compile(a)}return null!=p&&p.ctor?p.name+".__super__.constructor":this.error("cannot call super outside of an instance method.")};b.prototype.superThis=function(a){return(a=a.scope.method)&&!a.klass&&a.context||"this"};return b}(d);f.RegexWithInterpolations=function(a){function b(a){null==a&&(a=[]);
b.__super__.constructor.call(this,new M(new x("RegExp")),a,!1)}ma(b,a);return b}(d);f.TaggedTemplateCall=function(a){function b(a,d,f){d instanceof Za&&(d=new Xa(c.wrap([new M(d)])));b.__super__.constructor.call(this,a,[d],f)}ma(b,a);b.prototype.compileNode=function(a){a.inTaggedTemplateCall=!0;return this.variable.compileToFragments(a,q).concat(this.args[0].compileToFragments(a,h))};return b}(d);f.Extends=L=function(a){function b(a,b){this.child=a;this.parent=b}ma(b,a);b.prototype.children=["child",
"parent"];b.prototype.compileToFragments=function(a){return(new d(new M(new y(za("extend",a))),[this.child,this.parent])).compileToFragments(a)};return b}(a);f.Access=ta=function(a){function b(a,b){this.name=a;this.soak="soak"===b}ma(b,a);b.prototype.children=["name"];b.prototype.compileToFragments=function(a){var b,c;a=this.name.compileToFragments(a);b=this.name.unwrap();return b instanceof N?(c=b.value,0<=Ha.call(r,c))?[this.makeCode('["')].concat(Aa.call(a),[this.makeCode('"]')]):[this.makeCode(".")].concat(Aa.call(a)):
[this.makeCode("[")].concat(Aa.call(a),[this.makeCode("]")])};b.prototype.isComplex=P;return b}(a);f.Index=g=function(a){function b(a){this.index=a}ma(b,a);b.prototype.children=["index"];b.prototype.compileToFragments=function(a){return[].concat(this.makeCode("["),this.index.compileToFragments(a,O),this.makeCode("]"))};b.prototype.isComplex=function(){return this.index.isComplex()};return b}(a);f.Range=X=function(a){function b(a,b,c){this.from=a;this.to=b;this.equals=(this.exclusive="exclusive"===
c)?"":"\x3d"}ma(b,a);b.prototype.children=["from","to"];b.prototype.compileVariables=function(a){var b,c;a=Fa(a,{top:!0});b=na(a,"isComplex");c=this.cacheToCodeFragments(this.from.cache(a,h,b));this.fromC=c[0];this.fromVar=c[1];c=this.cacheToCodeFragments(this.to.cache(a,h,b));this.toC=c[0];this.toVar=c[1];if(c=na(a,"step"))a=this.cacheToCodeFragments(c.cache(a,h,b)),this.step=a[0],this.stepVar=a[1];this.fromNum=this.from.isNumber()?Number(this.fromVar):null;this.toNum=this.to.isNumber()?Number(this.toVar):
null;return this.stepNum=null!=c&&c.isNumber()?Number(this.stepVar):null};b.prototype.compileNode=function(a){var b,c,e,d,p,f,g,h,m,q;this.fromVar||this.compileVariables(a);if(!a.index)return this.compileArray(a);f=null!=this.fromNum&&null!=this.toNum;p=na(a,"index");g=(a=na(a,"name"))&&a!==p;q=p+" \x3d "+this.fromC;this.toC!==this.toVar&&(q+=", "+this.toC);this.step!==this.stepVar&&(q+=", "+this.step);d=[p+" \x3c"+this.equals,p+" \x3e"+this.equals];c=d[0];d=d[1];c=null!=this.stepNum?0<this.stepNum?
c+" "+this.toVar:d+" "+this.toVar:f?(h=[this.fromNum,this.toNum],e=h[0],m=h[1],h,e<=m?c+" "+m:d+" "+m):(b=this.stepVar?this.stepVar+" \x3e 0":this.fromVar+" \x3c\x3d "+this.toVar,b+" ? "+c+" "+this.toVar+" : "+d+" "+this.toVar);b=this.stepVar?p+" +\x3d "+this.stepVar:f?g?e<=m?"++"+p:"--"+p:e<=m?p+"++":p+"--":g?b+" ? ++"+p+" : --"+p:b+" ? "+p+"++ : "+p+"--";g&&(q=a+" \x3d "+q);g&&(b=a+" \x3d "+b);return[this.makeCode(q+"; "+c+"; "+b)]};b.prototype.compileArray=function(a){var b,c,e,d,p,f,g,h,m;if((c=
null!=this.fromNum&&null!=this.toNum)&&20>=Math.abs(this.fromNum-this.toNum))return b=function(){h=[];for(var a=f=this.fromNum,b=this.toNum;f<=b?a<=b:a>=b;f<=b?a++:a--)h.push(a);return h}.apply(this),this.exclusive&&b.pop(),[this.makeCode("["+b.join(", ")+"]")];d=this.tab+ba;e=a.scope.freeVariable("i",{single:!0});g=a.scope.freeVariable("results");p="\n"+d+g+" \x3d [];";c?(a.index=e,c=Da(this.compileNode(a))):(m=e+" \x3d "+this.fromC+(this.toC!==this.toVar?", "+this.toC:""),c=this.fromVar+" \x3c\x3d "+
this.toVar,c="var "+m+"; "+c+" ? "+e+" \x3c"+this.equals+" "+this.toVar+" : "+e+" \x3e"+this.equals+" "+this.toVar+"; "+c+" ? "+e+"++ : "+e+"--");e="{ "+g+".push("+e+"); }\n"+d+"return "+g+";\n"+a.indent;a=function(a){return null!=a?a.contains(Ja):void 0};if(a(this.from)||a(this.to))b=", arguments";return[this.makeCode("(function() {"+p+"\n"+d+"for ("+c+")"+e+"}).apply(this"+(null!=b?b:"")+")")]};return b}(a);f.Slice=aa=function(a){function b(a){this.range=a;b.__super__.constructor.call(this)}ma(b,
a);b.prototype.children=["range"];b.prototype.compileNode=function(a){var b,c,e,d,p;b=this.range;d=b.to;e=(b=b.from)&&b.compileToFragments(a,O)||[this.makeCode("0")];d&&(b=d.compileToFragments(a,O),c=Da(b),this.range.exclusive||-1!==+c)&&(p=", "+(this.range.exclusive?c:d.isNumber()?""+(+c+1):(b=d.compileToFragments(a,q),"+"+Da(b)+" + 1 || 9e9")));return[this.makeCode(".slice("+Da(e)+(p||"")+")")]};return b}(a);f.Obj=C=function(a){function b(a,b){this.generated=null!=b?b:!1;this.objects=this.properties=
a||[]}ma(b,a);b.prototype.children=["properties"];b.prototype.compileNode=function(a){var b,c,e,d,p,f,g,h,m,q,r,k,n;n=this.properties;if(this.generated)for(c=0,b=n.length;c<b;c++)e=n[c],e instanceof M&&e.error("cannot have an implicit value in an implicit object");c=b=0;for(e=n.length;b<e&&!(k=n[c],(k.variable||k).base instanceof B);c=++b);e=c<n.length;p=a.indent+=ba;m=this.lastNonComment(this.properties);b=[];e&&(r=a.scope.freeVariable("obj"),b.push(this.makeCode("(\n"+p+r+" \x3d ")));b.push(this.makeCode("{"+
(0===n.length||0===c?"}":"\n")));d=h=0;for(q=n.length;h<q;d=++h)k=n[d],d===c&&(0!==d&&b.push(this.makeCode("\n"+p+"}")),b.push(this.makeCode(",\n"))),g=d===n.length-1||d===c-1?"":k===m||k instanceof F?"\n":",\n",f=k instanceof F?"":p,e&&d<c&&(f+=ba),k instanceof D&&("object"!==k.context&&k.operatorToken.error("unexpected "+k.operatorToken.value),k.variable instanceof M&&k.variable.hasProperties()&&k.variable.error("invalid object key")),k instanceof M&&k["this"]&&(k=new D(k.properties[0].name,k,"object")),
k instanceof F||(d<c?k instanceof D||(k=new D(k,k,"object")):(k instanceof D?(d=k.variable,k=k.value):(k=k.base.cache(a),d=k[0],k=k[1],d instanceof x&&(d=new N(d.value))),k=new D(new M(new x(r),[new ta(d)]),k))),f&&b.push(this.makeCode(f)),b.push.apply(b,k.compileToFragments(a,H)),g&&b.push(this.makeCode(g));e?b.push(this.makeCode(",\n"+p+r+"\n"+this.tab+")")):0!==n.length&&b.push(this.makeCode("\n"+this.tab+"}"));return this.front&&!e?this.wrapInBraces(b):b};b.prototype.assigns=function(a){var b,
c,e,d;d=this.properties;b=0;for(c=d.length;b<c;b++)if(e=d[b],e.assigns(a))return!0;return!1};return b}(a);f.Arr=pa=function(a){function b(a){this.objects=a||[]}ma(b,a);b.prototype.children=["objects"];b.prototype.compileNode=function(a){var b,c,e,d,p;if(!this.objects.length)return[this.makeCode("[]")];a.indent+=ba;b=Q.compileSplattedArray(a,this.objects);if(b.length)return b;b=[];var f;p=this.objects;f=[];e=0;for(d=p.length;e<d;e++)c=p[e],f.push(c.compileToFragments(a,h));e=d=0;for(p=f.length;d<p;e=
++d)c=f[e],e&&b.push(this.makeCode(", ")),b.push.apply(b,c);0<=Da(b).indexOf("\n")?(b.unshift(this.makeCode("[\n"+a.indent)),b.push(this.makeCode("\n"+this.tab+"]"))):(b.unshift(this.makeCode("[")),b.push(this.makeCode("]")));return b};b.prototype.assigns=function(a){var b,c,e,d;d=this.objects;b=0;for(c=d.length;b<c;b++)if(e=d[b],e.assigns(a))return!0;return!1};return b}(a);f.Class=v=function(a){function b(a,b,d){this.variable=a;this.parent=b;this.body=null!=d?d:new c;this.boundFuncs=[];this.body.classBody=
!0}ma(b,a);b.prototype.children=["variable","parent","body"];b.prototype.defaultClassVariableName="_Class";b.prototype.determineName=function(){var a,b;if(!this.variable)return this.defaultClassVariableName;b=this.variable.properties;b=(a=b[b.length-1])?a instanceof ta&&a.name:this.variable.base;if(!(b instanceof x||b instanceof N))return this.defaultClassVariableName;b=b.value;a||(a=Ga(b))&&this.variable.error(a);return 0<=Ha.call(r,b)?"_"+b:b};b.prototype.setContext=function(a){return this.body.traverseChildren(!1,
function(b){if(b.classBody)return!1;if(b instanceof ga)return b.value=a;if(b instanceof l&&b.bound)return b.context=a})};b.prototype.addBoundFunctions=function(a){var b,c,e,d;d=this.boundFuncs;c=0;for(e=d.length;c<e;c++)b=d[c],b=(new M(new ga,[new ta(b)])).compile(a),this.ctor.body.unshift(new y(b+" \x3d "+za("bind",a)+"("+b+", this)"))};b.prototype.addProperties=function(a,b,c){var e,d,p,f;f=a.base.properties.slice(0);var ra;for(ra=[];e=f.shift();)e instanceof D&&(d=e.variable.base,delete e.context,
p=e.value,"constructor"===d.value?(this.ctor&&e.error("cannot define more than one constructor in a class"),p.bound&&e.error("cannot define a constructor as a bound function"),p instanceof l?e=this.ctor=p:(this.externalCtor=c.classScope.freeVariable("ctor"),e=new D(new x(this.externalCtor),p))):e.variable["this"]?p["static"]=!0:(a=d.isComplex()?new g(d):new ta(d),e.variable=new M(new x(b),[new ta(new N("prototype")),a]),p instanceof l&&p.bound&&(this.boundFuncs.push(d),p.bound=!1))),ra.push(e);return oa(ra)};
b.prototype.walkBody=function(a,d){return this.traverseChildren(!1,function(p){return function(e){var f,ra,g,h,ua,m,q;f=!0;if(e instanceof b)return!1;if(e instanceof c){q=ra=e.expressions;g=h=0;for(ua=q.length;h<ua;g=++h)m=q[g],m instanceof D&&m.variable.looksStatic(a)?m.value["static"]=!0:m instanceof M&&m.isObject(!0)&&(f=!1,ra[g]=p.addProperties(m,a,d));e.expressions=la(ra)}return f&&!(e instanceof b)}}(this))};b.prototype.hoistDirectivePrologue=function(){var a,b,c;b=0;for(a=this.body.expressions;(c=
a[b])&&c instanceof F||c instanceof M&&c.isString();)++b;return this.directives=a.splice(0,b)};b.prototype.ensureConstructor=function(a){this.ctor||(this.ctor=new l,this.externalCtor?this.ctor.body.push(new y(this.externalCtor+".apply(this, arguments)")):this.parent&&this.ctor.body.push(new y(a+".__super__.constructor.apply(this, arguments)")),this.ctor.body.makeReturn(),this.body.expressions.unshift(this.ctor));this.ctor.ctor=this.ctor.name=a;this.ctor.klass=null;return this.ctor.noReturn=!0};b.prototype.compileNode=
function(a){var b,p,e,f,g;(p=this.body.jumps())&&p.error("Class bodies cannot contain pure statements");(b=this.body.contains(Ja))&&b.error("Class bodies shouldn't reference arguments");g=this.determineName();f=new x(g);p=new l([],c.wrap([this.body]));b=[];a.classScope=p.makeScope(a.scope);this.hoistDirectivePrologue();this.setContext(g);this.walkBody(g,a);this.ensureConstructor(g);this.addBoundFunctions(a);this.body.spaced=!0;this.body.expressions.push(f);this.parent&&(g=new x(a.classScope.freeVariable("superClass",
{reserve:!1})),this.body.expressions.unshift(new L(f,g)),p.params.push(new W(g)),b.push(this.parent));(e=this.body.expressions).unshift.apply(e,this.directives);e=new B(new d(p,b));this.variable&&(e=new D(this.variable,e,null,{moduleDeclaration:this.moduleDeclaration}));return e.compileToFragments(a)};return b}(a);f.ModuleDeclaration=n=function(a){function b(a,b){this.clause=a;this.source=b;this.checkSource()}ma(b,a);b.prototype.children=["clause","source"];b.prototype.isStatement=ha;b.prototype.jumps=
da;b.prototype.makeReturn=da;b.prototype.checkSource=function(){if(null!=this.source&&this.source instanceof Xa)return this.source.error("the name of the module to be imported from must be an uninterpolated string")};b.prototype.checkScope=function(a,b){if(0!==a.indent.length)return this.error(b+" statements must be at top-level scope")};return b}(a);f.ImportDeclaration=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);b.prototype.compileNode=function(a){var b,
c;this.checkScope(a,"import");a.importedSymbols=[];b=[];b.push(this.makeCode(this.tab+"import "));null!=this.clause&&b.push.apply(b,this.clause.compileNode(a));null!=(null!=(c=this.source)?c.value:void 0)&&(null!==this.clause&&b.push(this.makeCode(" from ")),b.push(this.makeCode(this.source.value)));b.push(this.makeCode(";"));return b};return b}(n);f.ImportClause=function(a){function b(a,b){this.defaultBinding=a;this.namedImports=b}ma(b,a);b.prototype.children=["defaultBinding","namedImports"];b.prototype.compileNode=
function(a){var b;b=[];null!=this.defaultBinding&&(b.push.apply(b,this.defaultBinding.compileNode(a)),null!=this.namedImports&&b.push(this.makeCode(", ")));null!=this.namedImports&&b.push.apply(b,this.namedImports.compileNode(a));return b};return b}(a);f.ExportDeclaration=n=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);b.prototype.compileNode=function(a){var b,d;this.checkScope(a,"export");b=[];b.push(this.makeCode(this.tab+"export "));this instanceof G&&b.push(this.makeCode("default "));
this instanceof G||!(this.clause instanceof D||this.clause instanceof v)||(this.clause instanceof v&&!this.clause.variable&&this.clause.error("anonymous classes cannot be exported"),b.push(this.makeCode("var ")),this.clause.moduleDeclaration="export");b=null!=this.clause.body&&this.clause.body instanceof c?b.concat(this.clause.compileToFragments(a,H)):b.concat(this.clause.compileNode(a));null!=(null!=(d=this.source)?d.value:void 0)&&b.push(this.makeCode(" from "+this.source.value));b.push(this.makeCode(";"));
return b};return b}(n);f.ExportNamedDeclaration=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(n);f.ExportDefaultDeclaration=G=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(n);f.ExportAllDeclaration=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(n);f.ModuleSpecifierList=n=function(a){function b(a){this.specifiers=a}ma(b,a);b.prototype.children=["specifiers"];
b.prototype.compileNode=function(a){var b,c,e,d,f;b=[];a.indent+=ba;var p;f=this.specifiers;p=[];e=0;for(d=f.length;e<d;e++)c=f[e],p.push(c.compileToFragments(a,h));if(0!==this.specifiers.length){b.push(this.makeCode("{\n"+a.indent));e=d=0;for(f=p.length;d<f;e=++d)c=p[e],e&&b.push(this.makeCode(",\n"+a.indent)),b.push.apply(b,c);b.push(this.makeCode("\n}"))}else b.push(this.makeCode("{}"));return b};return b}(a);f.ImportSpecifierList=function(a){function b(){return b.__super__.constructor.apply(this,
arguments)}ma(b,a);return b}(n);f.ExportSpecifierList=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(n);f.ModuleSpecifier=T=function(a){function b(a,b,c){this.original=a;this.alias=b;this.moduleDeclarationType=c;this.identifier=null!=this.alias?this.alias.value:this.original.value}ma(b,a);b.prototype.children=["original","alias"];b.prototype.compileNode=function(a){a.scope.add(this.identifier,this.moduleDeclarationType);a=[];a.push(this.makeCode(this.original.value));
null!=this.alias&&a.push(this.makeCode(" as "+this.alias.value));return a};return b}(a);f.ImportSpecifier=n=function(a){function b(a,c){b.__super__.constructor.call(this,a,c,"import")}ma(b,a);b.prototype.compileNode=function(a){var c;(c=this.identifier,0<=Ha.call(a.importedSymbols,c))||a.scope.check(this.identifier)?this.error("'"+this.identifier+"' has already been declared"):a.importedSymbols.push(this.identifier);return b.__super__.compileNode.call(this,a)};return b}(T);f.ImportDefaultSpecifier=
function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(n);f.ImportNamespaceSpecifier=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);return b}(n);f.ExportSpecifier=function(a){function b(a,c){b.__super__.constructor.call(this,a,c,"export")}ma(b,a);return b}(T);f.Assign=D=function(a){function b(a,b,c,e){this.variable=a;this.value=b;this.context=c;null==e&&(e={});this.param=e.param;this.subpattern=e.subpattern;this.operatorToken=
e.operatorToken;this.moduleDeclaration=e.moduleDeclaration}ma(b,a);b.prototype.children=["variable","value"];b.prototype.isStatement=function(a){return(null!=a?a.level:void 0)===H&&null!=this.context&&(this.moduleDeclaration||0<=Ha.call(this.context,"?"))};b.prototype.checkAssignability=function(a,b){if(Object.prototype.hasOwnProperty.call(a.scope.positions,b.value)&&"import"===a.scope.variables[a.scope.positions[b.value]].type)return b.error("'"+b.value+"' is read-only")};b.prototype.assigns=function(a){return this["object"===
this.context?"value":"variable"].assigns(a)};b.prototype.unfoldSoak=function(a){return Na(a,this,"variable")};b.prototype.compileNode=function(a){var b,c,e,d,f,p,g;if(c=this.variable instanceof M){if(this.variable.isArray()||this.variable.isObject())return this.compilePatternMatch(a);if(this.variable.isSplice())return this.compileSplice(a);if("||\x3d"===(d=this.context)||"\x26\x26\x3d"===d||"?\x3d"===d)return this.compileConditional(a);if("**\x3d"===(f=this.context)||"//\x3d"===f||"%%\x3d"===f)return this.compileSpecialMath(a)}this.value instanceof
l&&(this.value["static"]?(this.value.klass=this.variable.base,this.value.name=this.variable.properties[0],this.value.variable=this.variable):2<=(null!=(p=this.variable.properties)?p.length:void 0)&&(p=this.variable.properties,d=3<=p.length?Aa.call(p,0,e=p.length-2):(e=0,[]),f=p[e++],e=p[e++],"prototype"===(null!=(g=f.name)?g.value:void 0)&&(this.value.klass=new M(this.variable.base,d),this.value.name=e,this.value.variable=this.variable)));this.context||(g=this.variable.unwrapAll(),g.isAssignable()||
this.variable.error("'"+this.variable.compile(a)+"' can't be assigned"),"function"===typeof g.hasProperties&&g.hasProperties()||(this.moduleDeclaration?(this.checkAssignability(a,g),a.scope.add(g.value,this.moduleDeclaration)):this.param?a.scope.add(g.value,"var"):(this.checkAssignability(a,g),a.scope.find(g.value))));g=this.value.compileToFragments(a,h);c&&this.variable.base instanceof C&&(this.variable.front=!0);c=this.variable.compileToFragments(a,h);if("object"===this.context){if(b=Da(c),0<=Ha.call(r,
b))c.unshift(this.makeCode('"')),c.push(this.makeCode('"'));return c.concat(this.makeCode(": "),g)}b=c.concat(this.makeCode(" "+(this.context||"\x3d")+" "),g);return a.level<=h?b:this.wrapInBraces(b)};b.prototype.compilePatternMatch=function(a){var c,d,e,f,p,m,q,k,r,n,l,D,t,u,B,v;u=a.level===H;k=this.value;D=this.variable.base.objects;if(!(t=D.length))return d=k.compileToFragments(a),a.level>=K?this.wrapInBraces(d):d;l=D[0];1===t&&l instanceof z&&l.error("Destructuring assignment has no target");
m=this.variable.isObject();if(u&&1===t&&!(l instanceof Q))return e=null,l instanceof b&&"object"===l.context?(d=l,f=d.variable,p=f.base,l=d.value,l instanceof b&&(e=l.value,l=l.variable)):(l instanceof b&&(e=l.value,l=l.variable),p=m?l["this"]?l.properties[0].name:new N(l.unwrap().value):new R(0)),c=p.unwrap()instanceof N,k=new M(k),k.properties.push(new (c?ta:g)(p)),(n=Ga(l.unwrap().value))&&l.error(n),e&&(k=new A("?",k,e)),(new b(l,k,null,{param:this.param})).compileToFragments(a,H);B=k.compileToFragments(a,
h);v=Da(B);d=[];f=!1;k.unwrap()instanceof x&&!this.variable.assigns(v)||(d.push([this.makeCode((e=a.scope.freeVariable("ref"))+" \x3d ")].concat(Aa.call(B))),B=[this.makeCode(e)],v=e);e=k=0;for(r=D.length;k<r;e=++k){l=D[e];p=e;if(!f&&l instanceof Q)n=l.name.unwrap().value,l=l.unwrap(),p=t+" \x3c\x3d "+v+".length ? "+za("slice",a)+".call("+v+", "+e,(c=t-e-1)?(q=a.scope.freeVariable("i",{single:!0}),p+=", "+q+" \x3d "+v+".length - "+c+") : ("+q+" \x3d "+e+", [])"):p+=") : []",p=new y(p),f=q+"++";else if(!f&&
l instanceof z){if(c=t-e-1)1===c?f=v+".length - 1":(q=a.scope.freeVariable("i",{single:!0}),p=new y(q+" \x3d "+v+".length - "+c),f=q+"++",d.push(p.compileToFragments(a,h)));continue}else(l instanceof Q||l instanceof z)&&l.error("multiple splats/expansions are disallowed in an assignment"),e=null,l instanceof b&&"object"===l.context?(p=l.variable,p=p.base,l=l.value,l instanceof b&&(e=l.value,l=l.variable)):(l instanceof b&&(e=l.value,l=l.variable),p=m?l["this"]?l.properties[0].name:new N(l.unwrap().value):
new y(f||p)),n=l.unwrap().value,c=p.unwrap()instanceof N,p=new M(new y(v),[new (c?ta:g)(p)]),e&&(p=new A("?",p,e));null!=n&&(n=Ga(n))&&l.error(n);d.push((new b(l,p,null,{param:this.param,subpattern:!0})).compileToFragments(a,h))}u||this.subpattern||d.push(B);d=this.joinFragmentArrays(d,", ");return a.level<h?d:this.wrapInBraces(d)};b.prototype.compileConditional=function(a){var c,d;d=this.variable.cacheReference(a);c=d[0];d=d[1];c.properties.length||!(c.base instanceof y)||c.base instanceof ga||a.scope.check(c.base.value)||
this.variable.error('the variable "'+c.base.value+"\" can't be assigned with "+this.context+" because it has not been declared before");if(0<=Ha.call(this.context,"?"))return a.isExistentialEquals=!0,(new E(new w(c),d,{type:"if"})).addElse(new b(d,this.value,"\x3d")).compileToFragments(a);c=(new A(this.context.slice(0,-1),c,new b(d,this.value,"\x3d"))).compileToFragments(a);return a.level<=h?c:this.wrapInBraces(c)};b.prototype.compileSpecialMath=function(a){var c,d;d=this.variable.cacheReference(a);
c=d[0];d=d[1];return(new b(c,new A(this.context.slice(0,-1),d,this.value))).compileToFragments(a)};b.prototype.compileSplice=function(a){var b,c,e,d,f,p;d=this.variable.properties.pop().range;e=d.from;b=d.to;c=d.exclusive;p=this.variable.compile(a);e?(f=this.cacheToCodeFragments(e.cache(a,K)),d=f[0],f=f[1]):d=f="0";b?null!=e&&e.isNumber()&&b.isNumber()?(b=b.compile(a)-f,c||(b+=1)):(b=b.compile(a,q)+" - "+f,c||(b+=" + 1")):b="9e9";c=this.value.cache(a,h);e=c[0];c=c[1];b=[].concat(this.makeCode("[].splice.apply("+
p+", ["+d+", "+b+"].concat("),e,this.makeCode(")), "),c);return a.level>H?this.wrapInBraces(b):b};return b}(a);f.Code=l=function(a){function b(a,b,d){this.params=a||[];this.body=b||new c;this.bound="boundfunc"===d;this.isGenerator=!!this.body.contains(function(a){return a instanceof A&&a.isYield()||a instanceof ca})}ma(b,a);b.prototype.children=["params","body"];b.prototype.isStatement=function(){return!!this.ctor};b.prototype.jumps=P;b.prototype.makeScope=function(a){return new J(a,this.body,this)};
b.prototype.compileNode=function(a){var f,p,e,g,h,m,k,l,r,n,t,u,v;this.bound&&null!=(p=a.scope.method)&&p.bound&&(this.context=a.scope.method.context);if(this.bound&&!this.context)return this.context="_this",p=new b([new W(new x(this.context))],new c([this])),p=new d(p,[new ga]),p.updateLocationDataIfMissing(this.locationData),p.compileNode(a);a.scope=na(a,"classScope")||this.makeScope(a.scope);a.scope.shared=na(a,"sharedScope");a.indent+=ba;delete a.bare;delete a.isExistentialEquals;p=[];f=[];l=
this.params;g=0;for(m=l.length;g<m;g++)k=l[g],k instanceof z||a.scope.parameter(k.asReference(a));l=this.params;g=0;for(m=l.length;g<m;g++)if(k=l[g],k.splat||k instanceof z){g=this.params;h=0;for(k=g.length;h<k;h++)r=g[h],r instanceof z||!r.name.value||a.scope.add(r.name.value,"var",!0);h=new D(new M(new pa(function(){var b,c,e,d;e=this.params;d=[];c=0;for(b=e.length;c<b;c++)r=e[c],d.push(r.asReference(a));return d}.call(this))),new M(new x("arguments")));break}t=this.params;l=0;for(g=t.length;l<
g;l++)k=t[l],k.isComplex()?(v=n=k.asReference(a),k.value&&(v=new A("?",n,k.value)),f.push(new D(new M(k.name),v,"\x3d",{param:!0}))):(n=k,k.value&&(m=new y(n.name.value+" \x3d\x3d null"),v=new D(new M(k.name),k.value,"\x3d"),f.push(new E(m,v)))),h||p.push(n);k=this.body.isEmpty();h&&f.unshift(h);f.length&&(e=this.body.expressions).unshift.apply(e,f);e=h=0;for(f=p.length;h<f;e=++h)r=p[e],p[e]=r.compileToFragments(a),a.scope.parameter(Da(p[e]));u=[];this.eachParamName(function(a,b){0<=Ha.call(u,a)&&
b.error("multiple parameters named "+a);return u.push(a)});k||this.noReturn||this.body.makeReturn();e="function";this.isGenerator&&(e+="*");this.ctor&&(e+=" "+this.name);f=[this.makeCode(e+"(")];e=k=0;for(h=p.length;k<h;e=++k)r=p[e],e&&f.push(this.makeCode(", ")),f.push.apply(f,r);f.push(this.makeCode(") {"));this.body.isEmpty()||(f=f.concat(this.makeCode("\n"),this.body.compileWithDeclarations(a),this.makeCode("\n"+this.tab)));f.push(this.makeCode("}"));return this.ctor?[this.makeCode(this.tab)].concat(Aa.call(f)):
this.front||a.level>=q?this.wrapInBraces(f):f};b.prototype.eachParamName=function(a){var b,c,e,d,f;d=this.params;f=[];b=0;for(c=d.length;b<c;b++)e=d[b],f.push(e.eachName(a));return f};b.prototype.traverseChildren=function(a,c){if(a)return b.__super__.traverseChildren.call(this,a,c)};return b}(a);f.Param=W=function(a){function b(a,b,c){this.name=a;this.value=b;this.splat=c;(a=Ga(this.name.unwrapAll().value))&&this.name.error(a);this.name instanceof C&&this.name.generated&&(a=this.name.objects[0].operatorToken,
a.error("unexpected "+a.value))}ma(b,a);b.prototype.children=["name","value"];b.prototype.compileToFragments=function(a){return this.name.compileToFragments(a,h)};b.prototype.asReference=function(a){var b;if(this.reference)return this.reference;b=this.name;b["this"]?(b=b.properties[0].name.value,0<=Ha.call(r,b)&&(b="_"+b),b=new x(a.scope.freeVariable(b))):b.isComplex()&&(b=new x(a.scope.freeVariable("arg")));b=new M(b);this.splat&&(b=new Q(b));b.updateLocationDataIfMissing(this.locationData);return this.reference=
b};b.prototype.isComplex=function(){return this.name.isComplex()};b.prototype.eachName=function(a,b){var c,e,d,f;null==b&&(b=this.name);c=function(b){return a("@"+b.properties[0].name.value,b)};if(b instanceof y)return a(b.value,b);if(b instanceof M)return c(b);b=null!=(e=b.objects)?e:[];e=0;for(d=b.length;e<d;e++)f=b[e],f instanceof D&&null==f.context&&(f=f.variable),f instanceof D?(f.value instanceof D&&(f=f.value),this.eachName(a,f.value.unwrap())):f instanceof Q?(f=f.name.unwrap(),a(f.value,f)):
f instanceof M?f.isArray()||f.isObject()?this.eachName(a,f.base):f["this"]?c(f):a(f.base.value,f.base):f instanceof z||f.error("illegal parameter "+f.compile())};return b}(a);f.Splat=Q=function(a){function b(a){this.name=a.compile?a:new y(a)}ma(b,a);b.prototype.children=["name"];b.prototype.isAssignable=ha;b.prototype.assigns=function(a){return this.name.assigns(a)};b.prototype.compileToFragments=function(a){return this.name.compileToFragments(a)};b.prototype.unwrap=function(){return this.name};b.compileSplattedArray=
function(a,c,d){var e,f,g,p,k,m;for(p=-1;(e=c[++p])&&!(e instanceof b););if(p>=c.length)return[];if(1===c.length)return e=c[0],c=e.compileToFragments(a,h),d?c:[].concat(e.makeCode(za("slice",a)+".call("),c,e.makeCode(")"));d=c.slice(p);g=k=0;for(m=d.length;k<m;g=++k)e=d[g],f=e.compileToFragments(a,h),d[g]=e instanceof b?[].concat(e.makeCode(za("slice",a)+".call("),f,e.makeCode(")")):[].concat(e.makeCode("["),f,e.makeCode("]"));if(0===p)return e=c[0],a=e.joinFragmentArrays(d.slice(1),", "),d[0].concat(e.makeCode(".concat("),
a,e.makeCode(")"));k=c.slice(0,p);m=[];f=0;for(g=k.length;f<g;f++)e=k[f],m.push(e.compileToFragments(a,h));e=c[0].joinFragmentArrays(m,", ");a=c[p].joinFragmentArrays(d,", ");d=c[c.length-1];return[].concat(c[0].makeCode("["),e,c[p].makeCode("].concat("),a,d.makeCode(")"))};return b}(a);f.Expansion=z=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);b.prototype.isComplex=P;b.prototype.compileNode=function(a){return this.error("Expansion must be used inside a destructuring assignment or parameter list")};
b.prototype.asReference=function(a){return this};b.prototype.eachName=function(a){};return b}(a);f.While=n=function(a){function b(a,b){this.condition=null!=b&&b.invert?a.invert():a;this.guard=null!=b?b.guard:void 0}ma(b,a);b.prototype.children=["condition","guard","body"];b.prototype.isStatement=ha;b.prototype.makeReturn=function(a){if(a)return b.__super__.makeReturn.apply(this,arguments);this.returns=!this.jumps({loop:!0});return this};b.prototype.addBody=function(a){this.body=a;return this};b.prototype.jumps=
function(){var a,b,c,e;a=this.body.expressions;if(!a.length)return!1;b=0;for(e=a.length;b<e;b++)if(c=a[b],c=c.jumps({loop:!0}))return c;return!1};b.prototype.compileNode=function(a){var b,d,e;a.indent+=ba;e="";b=this.body;b.isEmpty()?b=this.makeCode(""):(this.returns&&(b.makeReturn(d=a.scope.freeVariable("results")),e=""+this.tab+d+" \x3d [];\n"),this.guard&&(1<b.expressions.length?b.expressions.unshift(new E((new B(this.guard)).invert(),new ya("continue"))):this.guard&&(b=c.wrap([new E(this.guard,
b)]))),b=[].concat(this.makeCode("\n"),b.compileToFragments(a,H),this.makeCode("\n"+this.tab)));a=[].concat(this.makeCode(e+this.tab+"while ("),this.condition.compileToFragments(a,O),this.makeCode(") {"),b,this.makeCode("}"));this.returns&&a.push(this.makeCode("\n"+this.tab+"return "+d+";"));return a};return b}(a);f.Op=A=function(a){function b(a,b,f,g){if("in"===a)return new m(b,f);if("do"===a)return this.generateDo(b);if("new"===a){if(b instanceof d&&!b["do"]&&!b.isNew)return b.newInstance();if(b instanceof
l&&b.bound||b["do"])b=new B(b)}this.operator=c[a]||a;this.first=b;this.second=f;this.flip=!!g;return this}var c,f;ma(b,a);c={"\x3d\x3d":"\x3d\x3d\x3d","!\x3d":"!\x3d\x3d",of:"in",yieldfrom:"yield*"};f={"!\x3d\x3d":"\x3d\x3d\x3d","\x3d\x3d\x3d":"!\x3d\x3d"};b.prototype.children=["first","second"];b.prototype.isNumber=function(){var a;return this.isUnary()&&("+"===(a=this.operator)||"-"===a)&&this.first instanceof M&&this.first.isNumber()};b.prototype.isYield=function(){var a;return"yield"===(a=this.operator)||
"yield*"===a};b.prototype.isUnary=function(){return!this.second};b.prototype.isComplex=function(){return!this.isNumber()};b.prototype.isChainable=function(){var a;return"\x3c"===(a=this.operator)||"\x3e"===a||"\x3e\x3d"===a||"\x3c\x3d"===a||"\x3d\x3d\x3d"===a||"!\x3d\x3d"===a};b.prototype.invert=function(){var a,c,d;if(this.isChainable()&&this.first.isChainable()){a=!0;for(c=this;c&&c.operator;)a&&(a=c.operator in f),c=c.first;if(!a)return(new B(this)).invert();for(c=this;c&&c.operator;)c.invert=
!c.invert,c.operator=f[c.operator],c=c.first;return this}return(c=f[this.operator])?(this.operator=c,this.first.unwrap()instanceof b&&this.first.invert(),this):this.second?(new B(this)).invert():"!"===this.operator&&(a=this.first.unwrap())instanceof b&&("!"===(d=a.operator)||"in"===d||"instanceof"===d)?a:new b("!",this)};b.prototype.unfoldSoak=function(a){var b;return("++"===(b=this.operator)||"--"===b||"delete"===b)&&Na(a,this,"first")};b.prototype.generateDo=function(a){var b,c,f,g,p;g=[];p=(a instanceof
D&&(b=a.value.unwrap())instanceof l?b:a).params||[];b=0;for(c=p.length;b<c;b++)f=p[b],f.value?(g.push(f.value),delete f.value):g.push(f);a=new d(a,g);a["do"]=!0;return a};b.prototype.compileNode=function(a){var b,c;b=this.isChainable()&&this.first.isChainable();b||(this.first.front=this.front);"delete"===this.operator&&a.scope.check(this.first.unwrapAll().value)&&this.error("delete operand may not be argument or var");("--"===(c=this.operator)||"++"===c)&&(c=Ga(this.first.unwrapAll().value))&&this.first.error(c);
if(this.isYield())return this.compileYield(a);if(this.isUnary())return this.compileUnary(a);if(b)return this.compileChain(a);switch(this.operator){case "?":return this.compileExistence(a);case "**":return this.compilePower(a);case "//":return this.compileFloorDivision(a);case "%%":return this.compileModulo(a);default:return b=this.first.compileToFragments(a,K),c=this.second.compileToFragments(a,K),b=[].concat(b,this.makeCode(" "+this.operator+" "),c),a.level<=K?b:this.wrapInBraces(b)}};b.prototype.compileChain=
function(a){var b;b=this.first.second.cache(a);this.first.second=b[0];b=b[1];a=this.first.compileToFragments(a,K).concat(this.makeCode(" "+(this.invert?"\x26\x26":"||")+" "),b.compileToFragments(a),this.makeCode(" "+this.operator+" "),this.second.compileToFragments(a,K));return this.wrapInBraces(a)};b.prototype.compileExistence=function(a){var b,c;this.first.isComplex()?(c=new x(a.scope.freeVariable("ref")),b=new B(new D(c,this.first))):c=b=this.first;return(new E(new w(b),c,{type:"if"})).addElse(this.second).compileToFragments(a)};
b.prototype.compileUnary=function(a){var c,d,f;d=[];c=this.operator;d.push([this.makeCode(c)]);if("!"===c&&this.first instanceof w)return this.first.negated=!this.first.negated,this.first.compileToFragments(a);if(a.level>=q)return(new B(this)).compileToFragments(a);f="+"===c||"-"===c;("new"===c||"typeof"===c||"delete"===c||f&&this.first instanceof b&&this.first.operator===c)&&d.push([this.makeCode(" ")]);if(f&&this.first instanceof b||"new"===c&&this.first.isStatement(a))this.first=new B(this.first);
d.push(this.first.compileToFragments(a,K));this.flip&&d.reverse();return this.joinFragmentArrays(d,"")};b.prototype.compileYield=function(a){var b,c,d;c=[];b=this.operator;null==a.scope.parent&&this.error("yield can only occur inside functions");0<=Ha.call(Object.keys(this.first),"expression")&&!(this.first instanceof fa)?null!=this.first.expression&&c.push(this.first.expression.compileToFragments(a,K)):(a.level>=O&&c.push([this.makeCode("(")]),c.push([this.makeCode(b)]),""!==(null!=(d=this.first.base)?
d.value:void 0)&&c.push([this.makeCode(" ")]),c.push(this.first.compileToFragments(a,K)),a.level>=O&&c.push([this.makeCode(")")]));return this.joinFragmentArrays(c,"")};b.prototype.compilePower=function(a){var b;b=new M(new x("Math"),[new ta(new N("pow"))]);return(new d(b,[this.first,this.second])).compileToFragments(a)};b.prototype.compileFloorDivision=function(a){var c,f;f=new M(new x("Math"),[new ta(new N("floor"))]);c=new b("/",this.first,this.second);return(new d(f,[c])).compileToFragments(a)};
b.prototype.compileModulo=function(a){var b;b=new M(new y(za("modulo",a)));return(new d(b,[this.first,this.second])).compileToFragments(a)};b.prototype.toString=function(a){return b.__super__.toString.call(this,a,this.constructor.name+" "+this.operator)};return b}(a);f.In=m=function(a){function b(a,b){this.object=a;this.array=b}ma(b,a);b.prototype.children=["object","array"];b.prototype.invert=S;b.prototype.compileNode=function(a){var b,c,e,d,f;if(this.array instanceof M&&this.array.isArray()&&this.array.base.objects.length){f=
this.array.base.objects;c=0;for(e=f.length;c<e;c++)if(d=f[c],d instanceof Q){b=!0;break}if(!b)return this.compileOrTest(a)}return this.compileLoopTest(a)};b.prototype.compileOrTest=function(a){var b,c,e,d,f,g,p,h,k,m;b=this.object.cache(a,K);k=b[0];p=b[1];c=this.negated?[" !\x3d\x3d "," \x26\x26 "]:[" \x3d\x3d\x3d "," || "];b=c[0];c=c[1];m=[];h=this.array.base.objects;e=f=0;for(g=h.length;f<g;e=++f)d=h[e],e&&m.push(this.makeCode(c)),m=m.concat(e?p:k,this.makeCode(b),d.compileToFragments(a,q));return a.level<
K?m:this.wrapInBraces(m)};b.prototype.compileLoopTest=function(a){var b,c,e;b=this.object.cache(a,h);e=b[0];c=b[1];b=[].concat(this.makeCode(za("indexOf",a)+".call("),this.array.compileToFragments(a,h),this.makeCode(", "),c,this.makeCode(") "+(this.negated?"\x3c 0":"\x3e\x3d 0")));if(Da(e)===Da(c))return b;b=e.concat(this.makeCode(", "),b);return a.level<h?b:this.wrapInBraces(b)};b.prototype.toString=function(a){return b.__super__.toString.call(this,a,this.constructor.name+(this.negated?"!":""))};
return b}(a);f.Try=function(a){function b(a,b,c,e){this.attempt=a;this.errorVariable=b;this.recovery=c;this.ensure=e}ma(b,a);b.prototype.children=["attempt","recovery","ensure"];b.prototype.isStatement=ha;b.prototype.jumps=function(a){var b;return this.attempt.jumps(a)||(null!=(b=this.recovery)?b.jumps(a):void 0)};b.prototype.makeReturn=function(a){this.attempt&&(this.attempt=this.attempt.makeReturn(a));this.recovery&&(this.recovery=this.recovery.makeReturn(a));return this};b.prototype.compileNode=
function(a){var b,c,e,d,f;a.indent+=ba;f=this.attempt.compileToFragments(a,H);b=this.recovery?(c=a.scope.freeVariable("error",{reserve:!1}),d=new x(c),this.errorVariable?(e=Ga(this.errorVariable.unwrapAll().value),e?this.errorVariable.error(e):void 0,this.recovery.unshift(new D(this.errorVariable,d))):void 0,[].concat(this.makeCode(" catch ("),d.compileToFragments(a),this.makeCode(") {\n"),this.recovery.compileToFragments(a,H),this.makeCode("\n"+this.tab+"}"))):this.ensure||this.recovery?[]:(c=a.scope.freeVariable("error",
{reserve:!1}),[this.makeCode(" catch ("+c+") {}")]);a=this.ensure?[].concat(this.makeCode(" finally {\n"),this.ensure.compileToFragments(a,H),this.makeCode("\n"+this.tab+"}")):[];return[].concat(this.makeCode(this.tab+"try {\n"),f,this.makeCode("\n"+this.tab+"}"),b,a)};return b}(a);f.Throw=fa=function(a){function b(a){this.expression=a}ma(b,a);b.prototype.children=["expression"];b.prototype.isStatement=ha;b.prototype.jumps=P;b.prototype.makeReturn=da;b.prototype.compileNode=function(a){return[].concat(this.makeCode(this.tab+
"throw "),this.expression.compileToFragments(a),this.makeCode(";"))};return b}(a);f.Existence=w=function(a){function b(a){this.expression=a}ma(b,a);b.prototype.children=["expression"];b.prototype.invert=S;b.prototype.compileNode=function(a){var b,c,e;this.expression.front=this.front;e=this.expression.compile(a,K);this.expression.unwrap()instanceof x&&!a.scope.check(e)?(c=this.negated?["\x3d\x3d\x3d","||"]:["!\x3d\x3d","\x26\x26"],b=c[0],c=c[1],e="typeof "+e+" "+b+' "undefined" '+c+" "+e+" "+b+" null"):
e=e+" "+(this.negated?"\x3d\x3d":"!\x3d")+" null";return[this.makeCode(a.level<=k?e:"("+e+")")]};return b}(a);f.Parens=B=function(a){function b(a){this.body=a}ma(b,a);b.prototype.children=["body"];b.prototype.unwrap=function(){return this.body};b.prototype.isComplex=function(){return this.body.isComplex()};b.prototype.compileNode=function(a){var b,c;b=this.body.unwrap();if(b instanceof M&&b.isAtomic())return b.front=this.front,b.compileToFragments(a);c=b.compileToFragments(a,O);return a.level<K&&
(b instanceof A||b instanceof d||b instanceof I&&b.returns)?c:this.wrapInBraces(c)};return b}(a);f.StringWithInterpolations=Xa=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}ma(b,a);b.prototype.compileNode=function(a){var c,d,e,f,g;if(!a.inTaggedTemplateCall)return b.__super__.compileNode.apply(this,arguments);e=this.body.unwrap();d=[];e.traverseChildren(!1,function(a){if(a instanceof Za)d.push(a);else if(a instanceof B)return d.push(a),!1;return!0});e=[];e.push(this.makeCode("`"));
f=0;for(g=d.length;f<g;f++)c=d[f],c instanceof Za?(c=c.value.slice(1,-1),c=c.replace(/(\\*)(`|\$\{)/g,function(a,b,c){return 0===b.length%2?b+"\\"+c:a}),e.push(this.makeCode(c))):(e.push(this.makeCode("${")),e.push.apply(e,c.compileToFragments(a,O)),e.push(this.makeCode("}")));e.push(this.makeCode("`"));return e};return b}(B);f.For=I=function(a){function b(a,b){this.source=b.source;this.guard=b.guard;this.step=b.step;this.name=b.name;this.index=b.index;this.body=c.wrap([a]);this.own=!!b.own;this.object=
!!b.object;(this.from=!!b.from)&&this.index&&this.index.error("cannot use index with for-from");this.own&&!this.object&&b.ownTag.error("cannot use own with for-"+(this.from?"from":"in"));this.object&&(a=[this.index,this.name],this.name=a[0],this.index=a[1]);this.index instanceof M&&this.index.error("index cannot be a pattern matching expression");this.range=this.source instanceof M&&this.source.base instanceof X&&!this.source.properties.length&&!this.from;this.pattern=this.name instanceof M;this.range&&
this.index&&this.index.error("indexes do not apply to range loops");this.range&&this.pattern&&this.name.error("cannot pattern match over range loops");this.returns=!1}ma(b,a);b.prototype.children=["body","source","guard","step"];b.prototype.compileNode=function(a){var b,d,e,f,g,p,k,m,q,l,r,n,t,v,u,K,A,z,C,w,G;b=c.wrap([this.body]);q=b.expressions;q=q[q.length-1];(null!=q?q.jumps():void 0)instanceof V&&(this.returns=!1);u=this.range?this.source.base:this.source;e=a.scope;this.pattern||(m=this.name&&
this.name.compile(a,h));q=this.index&&this.index.compile(a,h);m&&!this.pattern&&e.find(m);q&&e.find(q);this.returns&&(k=e.freeVariable("results"));this.from?this.pattern&&(r=e.freeVariable("x",{single:!0})):r=this.object&&q||e.freeVariable("i",{single:!0});n=(this.range||this.from)&&m||q||r;t=n!==r?n+" \x3d ":"";this.step&&!this.range&&(q=this.cacheToCodeFragments(this.step.cache(a,h,sa)),g=q[0],C=q[1],this.step.isNumber()&&(z=Number(C)));this.pattern&&(m=r);p=q=G="";l=this.tab+ba;this.range?f=u.compileToFragments(Fa(a,
{index:r,name:m,step:this.step,isComplex:sa})):(w=this.source.compile(a,h),!m&&!this.own||this.source.unwrap()instanceof x||(p+=""+this.tab+(u=e.freeVariable("ref"))+" \x3d "+w+";\n",w=u),!m||this.pattern||this.from||(v=m+" \x3d "+w+"["+n+"]"),this.object||this.from||(g!==C&&(p+=""+this.tab+g+";\n"),m=0>z,this.step&&null!=z&&m||(d=e.freeVariable("len")),f=""+t+r+" \x3d 0, "+d+" \x3d "+w+".length",g=""+t+r+" \x3d "+w+".length - 1",d=r+" \x3c "+d,e=r+" \x3e\x3d 0",this.step?(null!=z?m&&(d=e,f=g):(d=
C+" \x3e 0 ? "+d+" : "+e,f="("+C+" \x3e 0 ? ("+f+") : "+g+")"),r=r+" +\x3d "+C):r=""+(n!==r?"++"+r:r+"++"),f=[this.makeCode(f+"; "+d+"; "+t+r)]));this.returns&&(K=""+this.tab+k+" \x3d [];\n",A="\n"+this.tab+"return "+k+";",b.makeReturn(k));this.guard&&(1<b.expressions.length?b.expressions.unshift(new E((new B(this.guard)).invert(),new ya("continue"))):this.guard&&(b=c.wrap([new E(this.guard,b)])));this.pattern&&b.expressions.unshift(new D(this.name,this.from?new x(n):new y(w+"["+n+"]")));k=[].concat(this.makeCode(p),
this.pluckDirectCall(a,b));v&&(G="\n"+l+v+";");this.object?(f=[this.makeCode(n+" in "+w)],this.own&&(q="\n"+l+"if (!"+za("hasProp",a)+".call("+w+", "+n+")) continue;")):this.from&&(f=[this.makeCode(n+" of "+w)]);(a=b.compileToFragments(Fa(a,{indent:l}),H))&&0<a.length&&(a=[].concat(this.makeCode("\n"),a,this.makeCode("\n")));return[].concat(k,this.makeCode(""+(K||"")+this.tab+"for ("),f,this.makeCode(") {"+q+G),a,this.makeCode(this.tab+"}"+(A||"")))};b.prototype.pluckDirectCall=function(a,b){var c,
e,f,g,h,m,p,k,q,r,n,t,y,v,u;e=[];q=b.expressions;h=m=0;for(p=q.length;m<p;h=++m)if(f=q[h],f=f.unwrapAll(),f instanceof d&&(u=null!=(r=f.variable)?r.unwrapAll():void 0,u instanceof l||u instanceof M&&(null!=(n=u.base)?n.unwrapAll():void 0)instanceof l&&1===u.properties.length&&("call"===(t=null!=(y=u.properties[0].name)?y.value:void 0)||"apply"===t)))g=(null!=(v=u.base)?v.unwrapAll():void 0)||u,k=new x(a.scope.freeVariable("fn")),c=new M(k),u.base&&(c=[c,u],u.base=c[0],c=c[1]),b.expressions[h]=new d(c,
f.args),e=e.concat(this.makeCode(this.tab),(new D(k,g)).compileToFragments(a,H),this.makeCode(";\n"));return e};return b}(n);f.Switch=function(a){function b(a,b,c){this.subject=a;this.cases=b;this.otherwise=c}ma(b,a);b.prototype.children=["subject","cases","otherwise"];b.prototype.isStatement=ha;b.prototype.jumps=function(a){var b,c,e,d,f;null==a&&(a={block:!0});d=this.cases;c=0;for(e=d.length;c<e;c++)if(b=d[c],b=b[1],b=b.jumps(a))return b;return null!=(f=this.otherwise)?f.jumps(a):void 0};b.prototype.makeReturn=
function(a){var b,d,e,f,g;f=this.cases;b=0;for(d=f.length;b<d;b++)e=f[b],e[1].makeReturn(a);a&&(this.otherwise||(this.otherwise=new c([new y("void 0")])));null!=(g=this.otherwise)&&g.makeReturn(a);return this};b.prototype.compileNode=function(a){var b,c,e,d,f,g,h,m,k,p,q,r,l;h=a.indent+ba;m=a.indent=h+ba;g=[].concat(this.makeCode(this.tab+"switch ("),this.subject?this.subject.compileToFragments(a,O):this.makeCode("false"),this.makeCode(") {\n"));r=this.cases;f=k=0;for(p=r.length;k<p;f=++k){b=r[f];
d=b[0];b=b[1];l=la([d]);d=0;for(q=l.length;d<q;d++)e=l[d],this.subject||(e=e.invert()),g=g.concat(this.makeCode(h+"case "),e.compileToFragments(a,O),this.makeCode(":\n"));0<(c=b.compileToFragments(a,H)).length&&(g=g.concat(c,this.makeCode("\n")));if(f===this.cases.length-1&&!this.otherwise)break;f=this.lastNonComment(b.expressions);f instanceof V||f instanceof y&&f.jumps()&&"debugger"!==f.value||g.push(e.makeCode(m+"break;\n"))}this.otherwise&&this.otherwise.expressions.length&&g.push.apply(g,[this.makeCode(h+
"default:\n")].concat(Aa.call(this.otherwise.compileToFragments(a,H)),[this.makeCode("\n")]));g.push(this.makeCode(this.tab+"}"));return g};return b}(a);f.If=E=function(a){function b(a,b,c){this.body=b;null==c&&(c={});this.condition="unless"===c.type?a.invert():a;this.elseBody=null;this.isChain=!1;this.soak=c.soak}ma(b,a);b.prototype.children=["condition","body","elseBody"];b.prototype.bodyNode=function(){var a;return null!=(a=this.body)?a.unwrap():void 0};b.prototype.elseBodyNode=function(){var a;
return null!=(a=this.elseBody)?a.unwrap():void 0};b.prototype.addElse=function(a){this.isChain?this.elseBodyNode().addElse(a):(this.isChain=a instanceof b,this.elseBody=this.ensureBlock(a),this.elseBody.updateLocationDataIfMissing(a.locationData));return this};b.prototype.isStatement=function(a){var b;return(null!=a?a.level:void 0)===H||this.bodyNode().isStatement(a)||(null!=(b=this.elseBodyNode())?b.isStatement(a):void 0)};b.prototype.jumps=function(a){var b;return this.body.jumps(a)||(null!=(b=
this.elseBody)?b.jumps(a):void 0)};b.prototype.compileNode=function(a){return this.isStatement(a)?this.compileStatement(a):this.compileExpression(a)};b.prototype.makeReturn=function(a){a&&(this.elseBody||(this.elseBody=new c([new y("void 0")])));this.body&&(this.body=new c([this.body.makeReturn(a)]));this.elseBody&&(this.elseBody=new c([this.elseBody.makeReturn(a)]));return this};b.prototype.ensureBlock=function(a){return a instanceof c?a:new c([a])};b.prototype.compileStatement=function(a){var c,
d,e,f;c=na(a,"chainChild");if(na(a,"isExistentialEquals"))return(new b(this.condition.invert(),this.elseBodyNode(),{type:"if"})).compileToFragments(a);f=a.indent+ba;e=this.condition.compileToFragments(a,O);d=this.ensureBlock(this.body).compileToFragments(Fa(a,{indent:f}));d=[].concat(this.makeCode("if ("),e,this.makeCode(") {\n"),d,this.makeCode("\n"+this.tab+"}"));c||d.unshift(this.makeCode(this.tab));if(!this.elseBody)return d;c=d.concat(this.makeCode(" else "));this.isChain?(a.chainChild=!0,c=
c.concat(this.elseBody.unwrap().compileToFragments(a,H))):c=c.concat(this.makeCode("{\n"),this.elseBody.compileToFragments(Fa(a,{indent:f}),H),this.makeCode("\n"+this.tab+"}"));return c};b.prototype.compileExpression=function(a){var b,c,e;e=this.condition.compileToFragments(a,k);c=this.bodyNode().compileToFragments(a,h);b=this.elseBodyNode()?this.elseBodyNode().compileToFragments(a,h):[this.makeCode("void 0")];b=e.concat(this.makeCode(" ? "),c,this.makeCode(" : "),b);return a.level>=k?this.wrapInBraces(b):
b};b.prototype.unfoldSoak=function(){return this.soak&&this};return b}(a);ka={extend:function(a){return"function(child, parent) { for (var key in parent) { if ("+za("hasProp",a)+".call(parent, key)) child[key] \x3d parent[key]; } function ctor() { this.constructor \x3d child; } ctor.prototype \x3d parent.prototype; child.prototype \x3d new ctor(); child.__super__ \x3d parent.prototype; return child; }"},bind:function(){return"function(fn, me){ return function(){ return fn.apply(me, arguments); }; }"},
indexOf:function(){return"[].indexOf || function(item) { for (var i \x3d 0, l \x3d this.length; i \x3c l; i++) { if (i in this \x26\x26 this[i] \x3d\x3d\x3d item) return i; } return -1; }"},modulo:function(){return"function(a, b) { return (+a % (b \x3d +b) + b) % b; }"},hasProp:function(){return"{}.hasOwnProperty"},slice:function(){return"[].slice"}};H=1;O=2;h=3;k=4;K=5;q=6;ba=" ";U=/^[+-]?\d+$/;za=function(a,b){var c,d;d=b.scope.root;if(a in d.utilities)return d.utilities[a];c=d.freeVariable(a);
d.assign(c,ka[a](b));return d.utilities[a]=c};Pa=function(a,b){a=a.replace(/\n/g,"$\x26"+b);return a.replace(/\s+$/,"")};Ja=function(a){return a instanceof x&&"arguments"===a.value};Ta=function(a){return a instanceof ga||a instanceof l&&a.bound||a instanceof ia};sa=function(a){return a.isComplex()||("function"===typeof a.isAssignable?a.isAssignable():void 0)};Na=function(a,b,c){if(a=b[c].unfoldSoak(a))return b[c]=a.body,a.body=new M(b),a}}).call(this);return f}();t["./sourcemap"]=function(){var f=
{};(function(){var t;t=function(){function f(f){this.line=f;this.columns=[]}f.prototype.add=function(f,a,c){var t;t=a[0];a=a[1];null==c&&(c={});if(!this.columns[f]||!c.noReplace)return this.columns[f]={line:this.line,column:f,sourceLine:t,sourceColumn:a}};f.prototype.sourceLocation=function(f){for(var a;!((a=this.columns[f])||0>=f);)f--;return a&&[a.sourceLine,a.sourceColumn]};return f}();f=function(){function f(){this.lines=[]}f.prototype.add=function(f,a,c){var D,d;null==c&&(c={});d=a[0];a=a[1];
return((D=this.lines)[d]||(D[d]=new t(d))).add(a,f,c)};f.prototype.sourceLocation=function(f){var a,c;a=f[0];for(f=f[1];!((c=this.lines[a])||0>=a);)a--;return c&&c.sourceLocation(f)};f.prototype.generate=function(f,a){var c,t,d,v,l,u,D,w,z,n,G,L,I;null==f&&(f={});null==a&&(a=null);l=u=v=I=0;n=!1;c="";G=this.lines;d=t=0;for(D=G.length;t<D;d=++t)if(d=G[d])for(L=d.columns,d=0,w=L.length;d<w;d++)if(z=L[d]){for(;I<z.line;)v=0,n=!1,c+=";",I++;n&&(c+=",");c+=this.encodeVlq(z.column-v);v=z.column;c+=this.encodeVlq(0);
c+=this.encodeVlq(z.sourceLine-u);u=z.sourceLine;c+=this.encodeVlq(z.sourceColumn-l);l=z.sourceColumn;n=!0}c={version:3,file:f.generatedFile||"",sourceRoot:f.sourceRoot||"",sources:f.sourceFiles||[""],names:[],mappings:c};f.inlineMap&&(c.sourcesContent=[a]);return c};f.prototype.encodeVlq=function(f){var a,c;a="";for(c=(Math.abs(f)<<1)+(0>f?1:0);c||!a;)f=c&31,(c>>=5)&&(f|=32),a+=this.encodeBase64(f);return a};f.prototype.encodeBase64=function(f){var a;if(!(a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f]))throw Error("Cannot Base64 encode value: "+
f);return a};return f}()}).call(this);return f}();t["./coffee-script"]=function(){var f={};(function(){var pa,xa,D,a,c,Ca,d,v,l,u,F,w,z,n,G,L,I,x,E={}.hasOwnProperty;v=t("fs");x=t("vm");G=t("path");pa=t("./lexer").Lexer;n=t("./parser").parser;u=t("./helpers");xa=t("./sourcemap");f.VERSION="1.12.0";f.FILE_EXTENSIONS=[".coffee",".litcoffee",".coffee.md"];f.helpers=u;D=function(a){switch(!1){case "function"!==typeof Buffer:return(new Buffer(a)).toString("base64");case "function"!==typeof btoa:return btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,
function(a,c){return String.fromCharCode("0x"+c)}));default:throw Error("Unable to base64 encode inline sourcemap.");}};Ca=function(a){return function(c,d){null==d&&(d={});try{return a.call(this,c,d)}catch(q){if("string"!==typeof c)throw q;throw u.updateSyntaxError(q,c,d.filename);}}};f.compile=a=Ca(function(a,c){var d,f,g,h,m,l,t,x,v,w,G,E;g=u.extend;c=g({},c);(g=c.sourceMap||c.inlineMap)&&(v=new xa);f=z.tokenize(a,c);h=c;x=[];m=0;for(l=f.length;m<l;m++)d=f[m],"IDENTIFIER"===d[0]&&x.push(d[1]);h.referencedVars=
x;if(null==c.bare||!0!==c.bare)for(h=0,m=f.length;h<m;h++)if(d=f[h],"IMPORT"===(t=d[0])||"EXPORT"===t){c.bare=!0;break}m=n.parse(f).compileToFragments(c);f=0;c.header&&(f+=1);c.shiftLine&&(f+=1);d=0;t="";l=0;for(x=m.length;l<x;l++)h=m[l],g&&(h.locationData&&!/^[;\s]*$/.test(h.code)&&v.add([h.locationData.first_line,h.locationData.first_column],[f,d],{noReplace:!0}),w=u.count(h.code,"\n"),f+=w,d=w?h.code.length-(h.code.lastIndexOf("\n")+1):d+h.code.length),t+=h.code;c.header&&(d="Generated by CoffeeScript "+
this.VERSION,t="// "+d+"\n"+t);g&&(E=v.generate(c,a));c.inlineMap&&(a=D(JSON.stringify(E)),g="//# sourceURL\x3d"+(null!=(G=c.filename)?G:"coffeescript"),t=t+"\n"+("//# sourceMappingURL\x3ddata:application/json;base64,"+a)+"\n"+g);return c.sourceMap?{js:t,sourceMap:v,v3SourceMap:JSON.stringify(E,null,2)}:t});f.tokens=Ca(function(a,c){return z.tokenize(a,c)});f.nodes=Ca(function(a,c){return"string"===typeof a?n.parse(z.tokenize(a,c)):n.parse(a)});f.run=function(c,d){var f,g,k;null==d&&(d={});g=t.main;
g.filename=process.argv[1]=d.filename?v.realpathSync(d.filename):".";g.moduleCache&&(g.moduleCache={});f=d.filename?G.dirname(v.realpathSync(d.filename)):v.realpathSync(".");g.paths=t("module")._nodeModulePaths(f);if(!u.isCoffee(g.filename)||t.extensions)c=a(c,d),c=null!=(k=c.js)?k:c;return g._compile(c,g.filename)};f.eval=function(c,d){var f,g,k,h,m,l,n,u,v,w;null==d&&(d={});if(c=c.trim()){h=null!=(m=x.Script.createContext)?m:x.createContext;m=null!=(k=x.isContext)?k:function(a){return d.sandbox instanceof
h().constructor};if(h){if(null!=d.sandbox){if(m(d.sandbox))w=d.sandbox;else for(l in w=h(),m=d.sandbox,m)E.call(m,l)&&(k=m[l],w[l]=k);w.global=w.root=w.GLOBAL=w}else w=global;w.__filename=d.filename||"eval";w.__dirname=G.dirname(w.__filename);if(w===global&&!w.module&&!w.require){f=t("module");w.module=g=new f(d.modulename||"eval");w.require=k=function(a){return f._load(a,g,!0)};g.filename=w.__filename;v=Object.getOwnPropertyNames(t);m=0;for(n=v.length;m<n;m++)u=v[m],"paths"!==u&&"arguments"!==u&&
"caller"!==u&&(k[u]=t[u]);k.paths=g.paths=f._nodeModulePaths(process.cwd());k.resolve=function(a){return f._resolveFilename(a,g)}}}m={};for(l in d)E.call(d,l)&&(k=d[l],m[l]=k);m.bare=!0;c=a(c,m);return w===global?x.runInThisContext(c):x.runInContext(c,w)}};f.register=function(){return t("./register")};if(t.extensions)for(L=this.FILE_EXTENSIONS,Ca=function(a){var c;return null!=(c=t.extensions)[a]?c[a]:c[a]=function(){throw Error("Use CoffeeScript.register() or require the coffee-script/register module to require "+
a+" files.");}},F=0,w=L.length;F<w;F++)c=L[F],Ca(c);f._compileFile=function(c,d,f){var g,k;null==d&&(d=!1);null==f&&(f=!1);k=v.readFileSync(c,"utf8");k=65279===k.charCodeAt(0)?k.substring(1):k;try{g=a(k,{filename:c,sourceMap:d,inlineMap:f,sourceFiles:[c],literate:u.isLiterate(c)})}catch(h){throw u.updateSyntaxError(h,k,c);}return g};z=new pa;n.lexer={lex:function(){var a,c;(c=n.tokens[this.pos++])?(a=c[0],this.yytext=c[1],this.yylloc=c[2],n.errorToken=c.origin||c,this.yylineno=this.yylloc.first_line):
a="";return a},setInput:function(a){n.tokens=a;return this.pos=0},upcomingInput:function(){return""}};n.yy=t("./nodes");n.yy.parseError=function(a,c){var d,f,g,h;g=n.errorToken;h=n.tokens;d=g[0];f=g[1];a=g[2];f=function(){switch(!1){case g!==h[h.length-1]:return"end of input";case "INDENT"!==d&&"OUTDENT"!==d:return"indentation";case "IDENTIFIER"!==d&&"NUMBER"!==d&&"INFINITY"!==d&&"STRING"!==d&&"STRING_START"!==d&&"REGEX"!==d&&"REGEX_START"!==d:return d.replace(/_START$/,"").toLowerCase();default:return u.nameWhitespaceCharacter(f)}}();
return u.throwSyntaxError("unexpected "+f,a)};d=function(a,c){var d,f,g,h;a.isNative()?d="native":(a.isEval()?(f=a.getScriptNameOrSourceURL())||a.getEvalOrigin():f=a.getFileName(),f||(f="\x3canonymous\x3e"),g=a.getLineNumber(),d=a.getColumnNumber(),d=(c=c(f,g,d))?f+":"+c[0]+":"+c[1]:f+":"+g+":"+d);f=a.getFunctionName();g=a.isConstructor();if(a.isToplevel()||g)return g?"new "+(f||"\x3canonymous\x3e")+" ("+d+")":f?f+" ("+d+")":d;g=a.getMethodName();h=a.getTypeName();return f?(c=a="",h&&f.indexOf(h)&&
(c=h+"."),g&&f.indexOf("."+g)!==f.length-g.length-1&&(a=" [as "+g+"]"),""+c+f+a+" ("+d+")"):h+"."+(g||"\x3canonymous\x3e")+" ("+d+")"};I={};l=function(a){var d,m,l;if(I[a])return I[a];l=f.FILE_EXTENSIONS;d=0;for(m=l.length;d<m;d++)if(c=l[d],u.ends(a,c))return d=f._compileFile(a,!0),I[a]=d.sourceMap;return null};Error.prepareStackTrace=function(a,c){var g,m,k;k=function(a,c,d){var f;(a=l(a))&&(f=a.sourceLocation([c-1,d-1]));return f?[f[0]+1,f[1]+1]:null};m=function(){var a,m,l;l=[];a=0;for(m=c.length;a<
m;a++){g=c[a];if(g.getFunction()===f.run)break;l.push(" at "+d(g,k))}return l}();return a.toString()+"\n"+m.join("\n")+"\n"}}).call(this);return f}();t["./browser"]=function(){(function(){var f,pa,xa,D=[].indexOf||function(a){for(var c=0,f=this.length;c<f;c++)if(c in this&&this[c]===a)return c;return-1};f=t("./coffee-script");f.require=t;pa=f.compile;f.eval=function(a,c){null==c&&(c={});null==c.bare&&(c.bare=!0);return eval(pa(a,c))};f.run=function(a,c){null==c&&(c={});c.bare=!0;c.shiftLine=!0;return Function(pa(a,
c))()};"undefined"!==typeof window&&null!==window&&("undefined"!==typeof btoa&&null!==btoa&&"undefined"!==typeof JSON&&null!==JSON&&(pa=function(a,c){null==c&&(c={});c.inlineMap=!0;return f.compile(a,c)}),f.load=function(a,c,t,d){var v;null==t&&(t={});null==d&&(d=!1);t.sourceFiles=[a];v=window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):new window.XMLHttpRequest;v.open("GET",a,!0);"overrideMimeType"in v&&v.overrideMimeType("text/plain");v.onreadystatechange=function(){var l;if(4===
v.readyState){if(0===(l=v.status)||200===l)l=[v.responseText,t],d||f.run.apply(f,l);else throw Error("Could not load "+a);if(c)return c(l)}};return v.send(null)},xa=function(){var a,c,t,d,v,l,u,F,w,z,n;n=window.document.getElementsByTagName("script");c=["text/coffeescript","text/literate-coffeescript"];a=function(){var a,d,f,l;l=[];a=0;for(d=n.length;a<d;a++)w=n[a],(f=w.type,0<=D.call(c,f))&&l.push(w);return l}();l=0;t=function(){var c;c=a[l];if(c instanceof Array)return f.run.apply(f,c),l++,t()};
d=function(d,l){var n,u;n={literate:d.type===c[1]};if(u=d.src||d.getAttribute("data-src"))return f.load(u,function(c){a[l]=c;return t()},n,!0);n.sourceFiles=["embedded"];return a[l]=[d.innerHTML,n]};v=u=0;for(F=a.length;u<F;v=++u)z=a[v],d(z,v);return t()},window.addEventListener?window.addEventListener("DOMContentLoaded",xa,!1):window.attachEvent("onload",xa))}).call(this);return{}}();return t["./coffee-script"]}();"function"===typeof define&&define.amd?define(function(){return ya}):t.CoffeeScript=
ya})(this);

View File

@@ -9,6 +9,7 @@ body {
width: 950px;
margin: 0;
padding: 80px 0px 50px 50px;
clear: both;
}
p, li {
width: 625px;
@@ -38,7 +39,7 @@ li {
}
table {
margin: 16px 0 0 13px; padding: 0;
width: 625px;
width: 690px;
}
tr, td {
margin: 0; padding: 0;
@@ -56,7 +57,7 @@ table.definitions {
text-align: center;
padding: 5px 20px;
}
code, pre, tt, textarea {
code, pre, textarea {
font-family: Monaco, Consolas, "Lucida Console", monospace;
font-size: 12px;
line-height: 18px;
@@ -64,7 +65,7 @@ code, pre, tt, textarea {
white-space: pre-wrap;
word-wrap: break-word;
}
tt {
p > code, li > code {
display: inline-block;
background: #fff;
border: 1px solid #dedede;
@@ -81,14 +82,15 @@ code, pre, tt, textarea {
padding-left: 0;
}
.timestamp {
font-size: 12px;
font-size: 11px;
font-weight: normal;
color: black;
text-transform: uppercase;
}
div.anchor {
position: relative;
top: -90px;
margin: 0 0 -20px;
}
.timestamp small {
font-size: 11px;
text-transform: uppercase;
}
div.code {
position: relative;
background: #fff;
@@ -110,9 +112,12 @@ div.code {
float: left;
width: 450px;
background: #fff;
border-left: 1px dotted #d0d0d0;
margin: 10px 0 15px 3px;
padding: 0 0 0 12px;
border: 1px dotted #d0d0d0;
border-top-width: 0;
border-bottom-width: 0;
border-right-width: 0;
margin: 15px 3px;
padding: 0 0 26px 12px;
}
div.code pre:first-child {
border-left: 0;
@@ -133,7 +138,6 @@ div.code {
height: 50px;
min-width: 490px;
left: 40px; right: 40px; top: 25px;
padding-left: 252px;
background: #eee;
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#dadada));
background: -moz-linear-gradient(top, #f8f8f8, #dadada);
@@ -147,27 +151,14 @@ div.code {
}
#logo {
display: block;
width: 225px; height: 50px;
background: url('../images/logo.png');
position: absolute;
top: 0px; left: 10px;
}
#error {
position: absolute;
-webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px;
-webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; border-top-left-radius: 0;
-webkit-border-bottom-left-radius: 0; -moz-border-radius-bottomleft: 0; border-bottom-left-radius: 0;
right: 0px; top: 0px; left: 726px; bottom: 0;
padding: 0 0 0 15px;
background: #fdcdcc;
background: -webkit-gradient(linear, left top, left bottom, from(#ffedec), to(#ff9a95));
background: -moz-linear-gradient(top, #f8f8f8, #dadada);
color: #862322;
font-size: 10px;
line-height: 50px;
overflow: hidden;
text-transform: uppercase;
outline: none;
float: left;
width: 242px;
margin-left: 10px;
}
#logo img {
margin: 5px 0 0 3px;
}
.navigation {
height: 50px;
font-size: 11px;
@@ -234,6 +225,7 @@ div.code {
display: block;
}
.navigation .contents.menu {
z-index: 100;
border-top: 0;
-webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; border-top-left-radius: 0;
-webkit-border-top-right-radius: 0; -moz-border-radius-topright: 0; border-top-right-radius: 0;
@@ -312,6 +304,10 @@ div.code {
outline: none;
margin: 5px 0 20px;
color: #def;
-webkit-tab-size: 2;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
#repl_results, #repl_source_wrap {
width: auto; height: auto;
@@ -319,6 +315,9 @@ div.code {
margin-bottom: 0;
top: 10px; left: 10px; right: 10px; bottom: 15px;
}
#repl_results.error {
color: red
}
#repl_source_wrap {
margin-left: 5px;
width: 47%; right: 50%;
@@ -380,4 +379,45 @@ div.code {
box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none;
background-image: url(../images/button_bg_dark.gif);
text-shadow: none;
}
}
.minibutton.error {
opacity: 0.5;
color: #600;
cursor: not-allowed;
}
@media (max-width: 820px) {
.container {
width: auto;
padding: 1em;
}
p, li, table {
width: auto;
}
#fadeout {
display: none;
}
#flybar {
position: static;
height: auto;
min-width: 245px;
}
#logo {
float: none;
}
.navigation {
float: none;
border: none;
}
div.code pre, div.code textarea {
border-left: none;
border-top-width: 1px;
width: auto;
float: none;
margin: 5px;
padding: 10px 5px;
}
div.code pre:first-child {
border-top: none;
}
}

66
docs/v1/css/tomorrow.css Normal file
View File

@@ -0,0 +1,66 @@
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
/* Original code:; http://softwaremaniacs.org/media/soft/highlight/styles/tomorrow.css */
/* But forked for CoffeeScript */
.tomorrow-comment, pre .comment, pre .title {
color: #8e908c;
}
.tomorrow-red, pre .variable, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo {
color: #c82829;
}
.tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .params, pre .constant {
color: #000000;
}
.tomorrow-yellow, pre .class, pre .ruby .class .title, pre .css .rules .attribute {
color: #eab700;
}
.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata {
color: #718c00;
}
.tomorrow-aqua, pre .css .hexcolor {
color: #3e999f;
}
.tomorrow-blue, pre .function, pre .function .title, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title {
color: #21439C;
}
.tomorrow-purple, pre .keyword, pre .reserved, pre .javascript .function {
color: #FF5600;
}
pre .subst {
color: #A535AE;
}
pre .literal {
color: #A535AE;
}
pre .property {
color: #A535AE;
}
pre .class .title {
color: #21439C;
}
pre code {
display: block;
background: white;
color: #000000;
}
pre .coffeescript .javascript,
pre .javascript .xml,
pre .tex .formula,
pre .xml .javascript,
pre .xml .vbscript,
pre .xml .css,
pre .xml .cdata {
opacity: 0.5;
}

View File

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 123 B

View File

Before

Width:  |  Height:  |  Size: 132 B

After

Width:  |  Height:  |  Size: 132 B

View File

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 138 B

View File

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 148 B

View File

Before

Width:  |  Height:  |  Size: 95 B

After

Width:  |  Height:  |  Size: 95 B

BIN
docs/v1/images/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-76 212 458 369" enable-background="new -76 212 458 369" xml:space="preserve">
<title>CoffeeScript Logo</title>
<g>
<g>
<path fill="#28334C" d="M106,228.6c0.5,2.3-0.9,4.4-5,6.5c-5.5-3.1-16.9-4.4-26.7-3.5c-10.4,0.9-19.4,4.2-17.9,11.3
c1.5,7.1,11.7,11,29.5,9.5c43.6-3.8,43.4-33.3,107.4-39c49.8-4.4,77.8,11,81.8,29.7c3.1,14.7-9.1,28.6-45.2,31.8
c-32,2.8-50.7-5.6-52.6-14.6c-1-4.5,1.8-11.3,17.2-13.1c1.5,7,10.6,14.4,31.1,12.6c14.8-1.3,27.6-6.6,25.9-14.9
c-1.8-8.6-17.7-13.7-42.6-11.5c-50.7,4.5-63.2,32.5-106.8,36.3c-30.8,2.7-55.9-8.5-59.4-25.1c-1.3-6.1-1.4-21,31.2-23.9
C91,219.2,104.6,222.2,106,228.6L106,228.6z M-56.4,402.5c-14.3,18-20.4,38.8-19.2,59.2c1.2,20.4,11.4,37.1,26.9,50.2
C-32,525-14,528.6,6.4,525c7.8-1.2,16.7-5.3,24.5-7.8c-16.7,0-31-5.3-44.9-16.7c-15.5-11.4-25.7-26.9-28.2-46.1
c-3.7-18,0-34.7,10.2-49c11.4-14.3,25.7-22,44.9-24.5c19.2-1.2,35.9,3.7,52.6,15.5c-3.7-5.3-9-9-14.3-14.3
c-16.7-11.4-34.7-16.7-56.7-11.4C-25.4,374.3-42.2,384.5-56.4,402.5z M167.2,306.2c-53.9,0-101.6-5.3-136.3-13.1
c-37.1-9-56.7-19.2-56.7-32.2c0-5.3,2.4-10.2,10.2-15.5c-23.3,9-35.9,16.7-35.9,28.2c1.2,13.1,22,25.7,64.5,35.9
c40,10.2,91.4,15.5,153,15.5c62.8,0,113-5.3,153-15.5c42.4-10.2,62.8-23.3,62.8-35.9c0-9-9-18-25.7-24.5c3.7,2.4,6.5,6.5,6.5,11.4
c0,13.1-19.2,23.3-57.9,32.2C268.7,300.9,222.6,306.2,167.2,306.2L167.2,306.2z M320.2,342.1c-40,9-91.4,15.5-153,15.5
c-62.8,0-114.2-6.5-154.2-15.5c-35.9-9-55.1-19.2-61.6-29.4c6.5,44.9,22,87.3,42.4,124.8c15.5,23.3,31,43.7,46.1,65.7
c6.5,13.1,11.4,25.7,14.3,38.8c10.2,14.3,24.5,23.3,42.4,28.2c22,7.8,44.9,11.4,68.1,10.2h2.4c23.3,1.2,47.7-2.4,70.6-10.2
c16.7-5.3,31-14.3,41.2-28.2h1.2c2.4-13.1,6.5-25.7,13.1-38.8c15.5-22,31-42.4,46.1-65.7c20.4-37.1,34.7-79.6,42.4-124.8
C374,324.1,354.8,334.3,320.2,342.1L320.2,342.1z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
docs/v1/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

59
docs/v1/images/logo.svg Normal file
View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-22 347 566 100" enable-background="new -22 347 566 100" xml:space="preserve">
<title>CoffeeScript Logo</title>
<g>
<g>
<path id="Shape" fill="#28334C" d="M21.7,351.1c0.1,0.6-0.2,1.1-1.2,1.6c-1.3-0.7-4.1-1.1-6.4-0.9c-2.5,0.2-4.6,1-4.3,2.7
c0.4,1.7,2.8,2.7,7.1,2.3c10.5-0.9,10.4-8,25.8-9.4c12-1.1,18.7,2.6,19.6,7.1c0.7,3.5-2.2,6.9-10.9,7.6
c-7.7,0.7-12.2-1.4-12.6-3.5c-0.2-1.1,0.4-2.7,4.1-3.1c0.4,1.7,2.5,3.5,7.5,3c3.6-0.3,6.6-1.6,6.2-3.6c-0.4-2.1-4.2-3.3-10.2-2.8
c-12.2,1.1-15.2,7.8-25.6,8.7c-7.4,0.7-13.4-2-14.2-6c-0.3-1.5-0.3-5,7.5-5.7C18.1,348.8,21.3,349.5,21.7,351.1z M-17.3,392.9
c-3.4,4.3-4.9,9.3-4.6,14.2c0.3,4.9,2.7,8.9,6.5,12c4,3.1,8.3,4,13.2,3.1c1.9-0.3,4-1.3,5.9-1.9c-4,0-7.4-1.3-10.8-4
c-3.7-2.7-6.2-6.5-6.8-11.1c-0.9-4.3,0-8.3,2.4-11.8c2.7-3.4,6.2-5.3,10.8-5.9c4.6-0.3,8.6,0.9,12.6,3.7c-0.9-1.3-2.2-2.2-3.4-3.4
c-4-2.7-8.3-4-13.6-2.7C-9.9,386.1-13.9,388.6-17.3,392.9z M36.3,369.8c-12.9,0-24.4-1.3-32.7-3.1c-8.9-2.2-13.6-4.6-13.6-7.7
c0-1.3,0.6-2.4,2.4-3.7c-5.6,2.2-8.6,4-8.6,6.8c0.3,3.1,5.3,6.2,15.5,8.6c9.6,2.4,21.9,3.7,36.7,3.7c15.1,0,27.1-1.3,36.7-3.7
c10.2-2.4,15.1-5.6,15.1-8.6c0-2.2-2.2-4.3-6.2-5.9c0.9,0.6,1.6,1.6,1.6,2.7c0,3.1-4.6,5.6-13.9,7.7
C60.7,368.5,49.7,369.8,36.3,369.8z M73.1,378.4c-9.6,2.2-21.9,3.7-36.7,3.7c-15.1,0-27.4-1.6-37-3.7c-8.6-2.2-13.2-4.6-14.8-7.1
c1.6,10.8,5.3,21,10.2,30c3.7,5.6,7.4,10.5,11.1,15.8c1.6,3.1,2.7,6.2,3.4,9.3c2.4,3.4,5.9,5.6,10.2,6.8
c5.3,1.9,10.8,2.7,16.4,2.4h0.6c5.6,0.3,11.5-0.6,16.9-2.4c4-1.3,7.4-3.4,9.9-6.8h0.3c0.6-3.1,1.6-6.2,3.1-9.3
c3.7-5.3,7.4-10.2,11.1-15.8c4.9-8.9,8.3-19.1,10.2-30C86,374.1,81.4,376.5,73.1,378.4z"/>
<g>
<path fill="#28334C" d="M179.3,408.5c-4.8,12.1-17.6,16.9-25.9,16.9c-13.4,0-19.9-6-19.9-22.3c0-16.5,7.9-47.3,31.7-47.3
c8.5,0,15.2,3.3,15.2,12.1c0,4.8-1.8,8.3-6.4,8.3c-1.5,0-3.4-0.4-5.2-2.4c2.2-1.1,4.2-4.9,4.2-8.3c0-2.9-1.5-5.6-5.6-5.6
c-10,0-18.9,23.9-18.9,42.4c0,8.3,2.2,14.2,10.9,14.2c7.1,0,13.5-3.4,17.7-9.1L179.3,408.5z M212.2,392.2c0.4,0.2,0.7,0.2,1,0.2
c4.2,0,10.1-2.7,14-5.5l0.8,2.4c-3.4,3.7-9.5,6.5-16.1,7.5c-1.5,16.8-10.6,27.3-21.7,27.3c-8.4,0-14.5-4-14.5-14.4
c0-10.5,6.2-32.2,24.9-32.2C208.4,377.8,212.2,382.8,212.2,392.2z M204.5,397.2c-1.9-0.5-2.4-2-2.4-3.8c0-2.5,1.2-4.2,2.8-4.9
c-0.2-3.8-1.1-5.3-3.4-5.3c-6.5,0-12,16.6-12,25.6c0,6,1.2,7.3,4.6,7.3C198.3,416.2,203,408.1,204.5,397.2L204.5,397.2z
M197.9,436.9c0-8.3,7.1-11,15.8-13.6l10.9-51.9c2.7-13,10.6-15.5,16.5-15.5c4.1,0,8,2.2,9.7,5.7c3.6-4.6,8.4-5.7,12.4-5.7
c5.6,0,10.8,3.9,10.8,9.8c0,1.5-0.1,2.6-0.3,3.7h-4.3c0.1-0.9,0.2-1.7,0.2-2.4c0-2.1-1.7-3.1-3.4-3.1c-2,0-4.8,1.1-6.2,7.1
l-1.7,7.4h9.1l-0.8,3.6h-9l-10.3,49.1c-2.7,13-10.6,15.5-16.5,15.5c-5.2,0-8.3-2.3-9.8-5.7c-3.5,4.6-8.3,5.7-12.3,5.7
C203.1,446.7,197.9,442.8,197.9,436.9L197.9,436.9z M207,438.7c1.9,0,4.2-1.8,5.4-7.1l1.1-5.3c-5.7,2-10.1,4.4-10.1,9.4
C203.4,436.9,205.1,438.7,207,438.7z M228.7,438.7c1.9,0,4.2-1.8,5.4-7.1l2.2-10.4l-9.4,1.8l-1.8,8.3c-0.5,2.1-1.1,4-1.8,5.6
C224.2,438.2,226.3,438.7,228.7,438.7L228.7,438.7z M227.3,420.7l9.4-1.7l7.7-36.8h-9L227.3,420.7L227.3,420.7z M243.9,364
c-2,0-4.8,1.1-6.2,7.1l-1.7,7.4h9l2.1-9.5c0.2-0.7,0.2-1.3,0.2-2C247.4,365,245.8,364,243.9,364z M281.8,417
c7.1,0,11.6-4,16.1-9.2h3.1c-5.2,8.3-12.9,16.8-25,16.8c-8.5,0-14.2-4.2-14.2-14.5c0-10.5,5.9-32.3,24.6-32.3
c8.1,0,10,4.2,10,8.7c0,10.5-10,18.5-20.9,19.2c-0.1,1.3-0.2,2.5-0.2,3.6C275.3,415.5,277.5,417,281.8,417z M287.1,382.6
c-4.6,0-9.1,9.7-10.9,18.7c7-0.5,13.2-7.4,13.2-15C289.4,384.1,288.9,382.6,287.1,382.6L287.1,382.6z M315.7,416
c3.4,0,7.8-2.3,10.8-4.8c-2,10.4-8.4,13.4-15.8,13.4c-8.4,0-14.1-4.2-14.1-14.5c0-10.5,5.9-32.3,24.6-32.3c8.1,0,10,4.2,10,8.7
c0,10.6-10,18.5-20.9,19.2c-0.1,0.9-0.2,2-0.2,2.7C310.1,414.1,312.6,416,315.7,416z M321.9,382.6c-4.5,0-9.1,10.1-11,18.7
c7.1-0.4,13.3-7.3,13.3-15C324.2,384.1,323.6,382.6,321.9,382.6z M373.2,375.9c-1.7,0-3-0.6-4.2-1.9c2.4-1.5,4.1-4.8,4.1-7.8
c0-3.1-1.8-6.1-6.8-6.1s-8.3,2.8-8.3,8.2c0,13.3,20.5,15.2,20.5,34.8c0,15.3-12.3,22.7-25.6,22.7c-10.4,0-19.3-4.5-19.3-15.7
c0-9.8,7-14.9,13.3-14.9c3.1,0,7.7,1.3,8,6c-4.9,0-10.7,2.3-10.7,8.5c0,4.5,2.9,8.7,8.7,8.7c6.1,0,10.6-4.4,10.6-12
c0-15.6-18.6-21.1-18.6-34.5c0-9.5,9.3-16.3,21-16.3c4.3,0,14.6,0.9,14.6,10.9C380.6,372,377.7,375.9,373.2,375.9L373.2,375.9z
M409.4,386.2c0-2.3-0.8-3.7-2.5-3.7c-5.7,0-11.7,16.6-11.7,26.7c0,6.2,2.2,7.6,6.6,7.6c7.1,0,11.6-4,16.1-9.2h3.1
c-5.2,8.3-12.9,16.8-25,16.8c-8.5,0-14.2-4.2-14.2-14.5c0-10.6,6-32.3,24.5-32.3c8.1,0,10.1,4.2,10.1,8.3c0,4.4-2.2,6.7-4.8,6.7
c-1,0-2.1-0.4-3.1-1.1C409,389.6,409.4,387.9,409.4,386.2z M437.1,378.6l-1.2,5.7c3.1-2.7,6.7-5.7,11-5.7c4.1,0,6.3,3.3,6.3,6.9
c0,3.1-2.1,6.7-6.6,6.7c-5.1,0-2.5-6-5.3-6c-2.7,0-4.4,1.4-6.7,3.4l-7.2,34.6h-13.1l9.6-45.4L437.1,378.6L437.1,378.6z
M471.3,378.6l-6.6,30.9c-0.3,1.2-0.4,2.1-0.4,2.9c0,2.5,1.2,3.3,3.7,3.3c3.5,0,6.9-3.4,8.1-8h3.8c-5.2,14.8-14.2,16.8-19.1,16.8
c-5.5,0-9.7-3.2-9.7-10.9c0-1.8,0.3-3.7,0.7-5.9l6.2-29.2C458,378.5,471.3,378.6,471.3,378.6z M467.2,359.2c4,0,7.2,3.2,7.2,7.2
s-3.2,7.1-7.2,7.1s-7.1-3.1-7.1-7.1C460,362.4,463.3,359.2,467.2,359.2z M496.3,375.2l-1.5,6.9c2.6-2.3,6.1-3.9,10.7-3.9
c6.2,0,11.1,3.5,11.1,14.4c0,12.2-4.7,32.1-22.3,32.1c-4.5,0-6.8-1.6-7.7-3.2l-4.7,22.1l-13.7,3.2l15.2-71.5
C483.4,375.3,496.3,375.2,496.3,375.2z M504.1,392.2c0-7-2.9-7.5-4.5-7.5c-2,0-4.5,1.6-6.3,4.4l-5.4,25.5c0.4,1,1.4,2.1,3.4,2.1
C501,416.7,504.1,400.8,504.1,392.2z M531.9,409.5c-0.3,1.1-0.5,2.2-0.5,3.1c0,1.9,0.7,3.2,3.1,3.2c0.7,0,1.7,0,2.4-0.3
c-2.5,7.8-6.6,8.9-9.6,8.9c-6.4,0-9.1-4.4-9.1-10.3c0-1.6,0.2-3.1,0.6-4.8l5.8-27.2h-3l0.7-3.6h3L528,366l13.4-1.9
c0,0-1.4,6.2-3.1,14.4h5.5l-0.7,3.6h-5.5L531.9,409.5z"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

4233
docs/v1/index.html Normal file

File diff suppressed because it is too large Load Diff

9897
docs/v1/test.html Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +0,0 @@
###
CoffeeScript Compiler v1.3.3
Released under the MIT License
###

View File

@@ -1,3 +0,0 @@
# The first ten global properties.
globals = (name for name of window)[0...10]

View File

@@ -1,6 +0,0 @@
Account = (customer, cart) ->
@customer = customer
@cart = cart
$('.shopping_cart').bind 'click', (event) =>
@customer.purchase @cart

View File

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

View File

@@ -1,64 +0,0 @@
pre.idle .InheritedClass {
}
pre.idle .TypeName {
color: #21439C;
}
pre.idle .Number {
}
pre.idle .LibraryVariable {
color: #A535AE;
}
pre.idle .Storage {
color: #FF5600;
}
pre.idle .line-numbers {
background-color: #BAD6FD;
color: #000000;
}
pre.idle {
background-color: #FFFFFF;
color: #000000;
}
pre.idle .StringInterpolation {
color: #990000;
}
pre.idle .TagName {
}
pre.idle .LibraryConstant {
color: #A535AE;
}
pre.idle .FunctionArgument {
color: #0076ad;
}
pre.idle .BuiltInConstant {
color: #A535AE;
}
pre.idle .Invalid {
background-color: #990000;
color: #FFFFFF;
}
pre.idle .LibraryClassType {
color: #A535AE;
}
pre.idle .LibraryFunction {
color: #A535AE;
}
pre.idle .TagAttribute {
}
pre.idle .Keyword {
color: #FF5600;
}
pre.idle .UserDefinedConstant {
}
pre.idle .String {
color: #00A33F;
}
pre.idle .FunctionName {
color: #21439C;
}
pre.idle .Variable {
color: #A535AE;
}
pre.idle .Comment {
color: #919191;
}

View File

@@ -1,37 +0,0 @@
<!DOCTYPE html> <html> <head> <title>browser.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> browser.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>Override exported methods for non-Node.js engines.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">CoffeeScript = </span><span class="nx">require</span> <span class="s1">&#39;./coffee-script&#39;</span>
<span class="nv">CoffeeScript.require = </span><span class="nx">require</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Use standard JavaScript <code>eval</code> to eval code.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">CoffeeScript.eval = </span><span class="nf">(code, options = {}) -&gt;</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">bare</span> <span class="o">?=</span> <span class="kc">on</span>
<span class="nb">eval</span> <span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">compile</span> <span class="nx">code</span><span class="p">,</span> <span class="nx">options</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Running code does not provide access to this scope.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">CoffeeScript.run = </span><span class="nf">(code, options = {}) -&gt;</span>
<span class="nv">options.bare = </span><span class="kc">on</span>
<span class="nb">Function</span><span class="p">(</span><span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">compile</span> <span class="nx">code</span><span class="p">,</span> <span class="nx">options</span><span class="p">)()</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>If we're not in a browser environment, we're finished with the public API.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">return</span> <span class="nx">unless</span> <span class="nb">window</span><span class="o">?</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Load a remote script from the current domain via XHR.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">CoffeeScript.load = </span><span class="nf">(url, callback) -&gt;</span>
<span class="nv">xhr = </span><span class="k">new</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">ActiveXObject</span> <span class="o">or</span> <span class="nx">XMLHttpRequest</span><span class="p">)(</span><span class="s1">&#39;Microsoft.XMLHTTP&#39;</span><span class="p">)</span>
<span class="nx">xhr</span><span class="p">.</span><span class="nx">open</span> <span class="s1">&#39;GET&#39;</span><span class="p">,</span> <span class="nx">url</span><span class="p">,</span> <span class="kc">true</span>
<span class="nx">xhr</span><span class="p">.</span><span class="nx">overrideMimeType</span> <span class="s1">&#39;text/plain&#39;</span> <span class="k">if</span> <span class="s1">&#39;overrideMimeType&#39;</span> <span class="k">of</span> <span class="nx">xhr</span>
<span class="nv">xhr.onreadystatechange = </span><span class="o">-&gt;</span>
<span class="k">if</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">is</span> <span class="mi">4</span>
<span class="k">if</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">status</span> <span class="k">in</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">200</span><span class="p">]</span>
<span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">run</span> <span class="nx">xhr</span><span class="p">.</span><span class="nx">responseText</span>
<span class="k">else</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s2">&quot;Could not load #{url}&quot;</span>
<span class="nx">callback</span><span class="p">()</span> <span class="k">if</span> <span class="nx">callback</span>
<span class="nx">xhr</span><span class="p">.</span><span class="nx">send</span> <span class="kc">null</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Activate CoffeeScript in the browser by having it compile and evaluate
all script tags with a content-type of <code>text/coffeescript</code>.
This happens on page load.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">runScripts = </span><span class="o">-&gt;</span>
<span class="nv">scripts = </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span> <span class="s1">&#39;script&#39;</span>
<span class="nv">coffees = </span><span class="p">(</span><span class="nx">s</span> <span class="k">for</span> <span class="nx">s</span> <span class="k">in</span> <span class="nx">scripts</span> <span class="k">when</span> <span class="nx">s</span><span class="p">.</span><span class="nx">type</span> <span class="o">is</span> <span class="s1">&#39;text/coffeescript&#39;</span><span class="p">)</span>
<span class="nv">index = </span><span class="mi">0</span>
<span class="nv">length = </span><span class="nx">coffees</span><span class="p">.</span><span class="nx">length</span>
<span class="nx">do</span> <span class="nv">execute = </span><span class="o">-&gt;</span>
<span class="nv">script = </span><span class="nx">coffees</span><span class="p">[</span><span class="nx">index</span><span class="o">++</span><span class="p">]</span>
<span class="k">if</span> <span class="nx">script</span><span class="o">?</span><span class="p">.</span><span class="nx">type</span> <span class="o">is</span> <span class="s1">&#39;text/coffeescript&#39;</span>
<span class="k">if</span> <span class="nx">script</span><span class="p">.</span><span class="nx">src</span>
<span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">load</span> <span class="nx">script</span><span class="p">.</span><span class="nx">src</span><span class="p">,</span> <span class="nx">execute</span>
<span class="k">else</span>
<span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">run</span> <span class="nx">script</span><span class="p">.</span><span class="nx">innerHTML</span>
<span class="nx">execute</span><span class="p">()</span>
<span class="kc">null</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Listen for window load, both in browsers and in IE.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">if</span> <span class="nb">window</span><span class="p">.</span><span class="nx">addEventListener</span>
<span class="nx">addEventListener</span> <span class="s1">&#39;DOMContentLoaded&#39;</span><span class="p">,</span> <span class="nx">runScripts</span><span class="p">,</span> <span class="kc">no</span>
<span class="k">else</span>
<span class="nx">attachEvent</span> <span class="s1">&#39;onload&#39;</span><span class="p">,</span> <span class="nx">runScripts</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,57 +0,0 @@
<!DOCTYPE html> <html> <head> <title>cake.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> cake.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p><code>cake</code> is a simplified version of <a href="http://www.gnu.org/software/make/">Make</a>
(<a href="http://rake.rubyforge.org/">Rake</a>, <a href="http://github.com/280north/jake">Jake</a>)
for CoffeeScript. You define tasks with names and descriptions in a Cakefile,
and can call them from the command line, or invoke them from other tasks.</p>
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the
current directory's Cakefile.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>External dependencies.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
<span class="nv">path = </span><span class="nx">require</span> <span class="s1">&#39;path&#39;</span>
<span class="nv">helpers = </span><span class="nx">require</span> <span class="s1">&#39;./helpers&#39;</span>
<span class="nv">optparse = </span><span class="nx">require</span> <span class="s1">&#39;./optparse&#39;</span>
<span class="nv">CoffeeScript = </span><span class="nx">require</span> <span class="s1">&#39;./coffee-script&#39;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Keep track of the list of defined tasks, the accepted options, and so on.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">tasks = </span><span class="p">{}</span>
<span class="nv">options = </span><span class="p">{}</span>
<span class="nv">switches = </span><span class="p">[]</span>
<span class="nv">oparse = </span><span class="kc">null</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Mixin the top-level Cake functions for Cakefiles to use directly.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">helpers</span><span class="p">.</span><span class="nx">extend</span> <span class="nx">global</span><span class="p">,</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Define a Cake task with a short name, an optional sentence description,
and the function to run as the action itself.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">task: </span><span class="nf">(name, description, action) -&gt;</span>
<span class="p">[</span><span class="nx">action</span><span class="p">,</span> <span class="nx">description</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="nx">description</span><span class="p">,</span> <span class="nx">action</span><span class="p">]</span> <span class="nx">unless</span> <span class="nx">action</span>
<span class="nx">tasks</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="nx">name</span><span class="p">,</span> <span class="nx">description</span><span class="p">,</span> <span class="nx">action</span><span class="p">}</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Define an option that the Cakefile accepts. The parsed options hash,
containing all of the command-line options passed, will be made available
as the first argument to the action.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">option: </span><span class="nf">(letter, flag, description) -&gt;</span>
<span class="nx">switches</span><span class="p">.</span><span class="nx">push</span> <span class="p">[</span><span class="nx">letter</span><span class="p">,</span> <span class="nx">flag</span><span class="p">,</span> <span class="nx">description</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Invoke another task in the current Cakefile.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">invoke: </span><span class="nf">(name) -&gt;</span>
<span class="nx">missingTask</span> <span class="nx">name</span> <span class="nx">unless</span> <span class="nx">tasks</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span>
<span class="nx">tasks</span><span class="p">[</span><span class="nx">name</span><span class="p">].</span><span class="nx">action</span> <span class="nx">options</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Node's
asynchrony may cause tasks to execute in a different order than you'd expect.
If no tasks are passed, print the help screen. Keep a reference to the
original directory name, when running Cake tasks from subdirectories.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.run = </span><span class="o">-&gt;</span>
<span class="nv">global.__originalDirname = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">realpathSync</span> <span class="s1">&#39;.&#39;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">chdir</span> <span class="nx">cakefileDirectory</span> <span class="nx">__originalDirname</span>
<span class="nv">args = </span><span class="nx">process</span><span class="p">.</span><span class="nx">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">..]</span>
<span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">run</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="s1">&#39;Cakefile&#39;</span><span class="p">).</span><span class="nx">toString</span><span class="p">(),</span> <span class="nv">filename: </span><span class="s1">&#39;Cakefile&#39;</span>
<span class="nv">oparse = </span><span class="k">new</span> <span class="nx">optparse</span><span class="p">.</span><span class="nx">OptionParser</span> <span class="nx">switches</span>
<span class="k">return</span> <span class="nx">printTasks</span><span class="p">()</span> <span class="nx">unless</span> <span class="nx">args</span><span class="p">.</span><span class="nx">length</span>
<span class="k">try</span>
<span class="nv">options = </span><span class="nx">oparse</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">args</span><span class="p">)</span>
<span class="k">catch</span> <span class="nx">e</span>
<span class="k">return</span> <span class="nx">fatalError</span> <span class="s2">&quot;#{e}&quot;</span>
<span class="nx">invoke</span> <span class="nx">arg</span> <span class="k">for</span> <span class="nx">arg</span> <span class="k">in</span> <span class="nx">options</span><span class="p">.</span><span class="nx">arguments</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Display the list of Cake tasks in a format similar to <code>rake -T</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">printTasks = </span><span class="o">-&gt;</span>
<span class="nv">relative = </span><span class="nx">path</span><span class="p">.</span><span class="nx">relative</span> <span class="o">or</span> <span class="nx">path</span><span class="p">.</span><span class="nx">resolve</span>
<span class="nv">cakefilePath = </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">relative</span><span class="p">(</span><span class="nx">__originalDirname</span><span class="p">,</span> <span class="nx">process</span><span class="p">.</span><span class="nx">cwd</span><span class="p">()),</span> <span class="s1">&#39;Cakefile&#39;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s2">&quot;#{cakefilePath} defines the following tasks:\n&quot;</span>
<span class="k">for</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">task</span> <span class="k">of</span> <span class="nx">tasks</span>
<span class="nv">spaces = </span><span class="mi">20</span> <span class="o">-</span> <span class="nx">name</span><span class="p">.</span><span class="nx">length</span>
<span class="nv">spaces = </span><span class="k">if</span> <span class="nx">spaces</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="k">then</span> <span class="nb">Array</span><span class="p">(</span><span class="nx">spaces</span> <span class="o">+</span> <span class="mi">1</span><span class="p">).</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
<span class="nv">desc = </span><span class="k">if</span> <span class="nx">task</span><span class="p">.</span><span class="nx">description</span> <span class="k">then</span> <span class="s2">&quot;# #{task.description}&quot;</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s2">&quot;cake #{name}#{spaces} #{desc}&quot;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="nx">oparse</span><span class="p">.</span><span class="nx">help</span><span class="p">()</span> <span class="k">if</span> <span class="nx">switches</span><span class="p">.</span><span class="nx">length</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Print an error and exit when attempting to use an invalid task/option.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">fatalError = </span><span class="nf">(message) -&gt;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">error</span> <span class="nx">message</span> <span class="o">+</span> <span class="s1">&#39;\n&#39;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s1">&#39;To see a list of all tasks/options, run &quot;cake&quot;&#39;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">exit</span> <span class="mi">1</span>
<span class="nv">missingTask = </span><span class="nf">(task) -&gt;</span> <span class="nx">fatalError</span> <span class="s2">&quot;No such task: #{task}&quot;</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>When <code>cake</code> is invoked, search in the current and all parent directories
to find the relevant Cakefile.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">cakefileDirectory = </span><span class="nf">(dir) -&gt;</span>
<span class="k">return</span> <span class="nx">dir</span> <span class="k">if</span> <span class="nx">path</span><span class="p">.</span><span class="nx">existsSync</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">dir</span><span class="p">,</span> <span class="s1">&#39;Cakefile&#39;</span>
<span class="nv">parent = </span><span class="nx">path</span><span class="p">.</span><span class="nx">normalize</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">dir</span><span class="p">,</span> <span class="s1">&#39;..&#39;</span>
<span class="k">return</span> <span class="nx">cakefileDirectory</span> <span class="nx">parent</span> <span class="nx">unless</span> <span class="nx">parent</span> <span class="o">is</span> <span class="nx">dir</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s2">&quot;Cakefile not found in #{process.cwd()}&quot;</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,81 +0,0 @@
<!DOCTYPE html> <html> <head> <title>coffee-script.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> coffee-script.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>CoffeeScript can be used both on the server, as a command-line compiler based
on Node.js/V8, or to run CoffeeScripts directly in the browser. This module
contains the main entry functions for tokenizing, parsing, and compiling
source CoffeeScript into JavaScript.</p>
<p>If included on a webpage, it will automatically sniff out, compile, and
execute all scripts present in <code>text/coffeescript</code> tags.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
<span class="nv">path = </span><span class="nx">require</span> <span class="s1">&#39;path&#39;</span>
<span class="p">{</span><span class="nx">Lexer</span><span class="p">,</span><span class="nx">RESERVED</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;./lexer&#39;</span>
<span class="p">{</span><span class="nx">parser</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;./parser&#39;</span>
<span class="nv">vm = </span><span class="nx">require</span> <span class="s1">&#39;vm&#39;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>TODO: Remove registerExtension when fully deprecated.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">if</span> <span class="nx">require</span><span class="p">.</span><span class="nx">extensions</span>
<span class="nx">require</span><span class="p">.</span><span class="nx">extensions</span><span class="p">[</span><span class="s1">&#39;.coffee&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nf">(module, filename) -&gt;</span>
<span class="nv">content = </span><span class="nx">compile</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">filename</span><span class="p">,</span> <span class="s1">&#39;utf8&#39;</span><span class="p">),</span> <span class="p">{</span><span class="nx">filename</span><span class="p">}</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">_compile</span> <span class="nx">content</span><span class="p">,</span> <span class="nx">filename</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">require</span><span class="p">.</span><span class="nx">registerExtension</span>
<span class="nx">require</span><span class="p">.</span><span class="nx">registerExtension</span> <span class="s1">&#39;.coffee&#39;</span><span class="p">,</span> <span class="nf">(content) -&gt;</span> <span class="nx">compile</span> <span class="nx">content</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>The current CoffeeScript version number.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.VERSION = </span><span class="s1">&#39;1.3.3&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Words that cannot be used as identifiers in CoffeeScript code</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.RESERVED = </span><span class="nx">RESERVED</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Expose helpers for testing.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.helpers = </span><span class="nx">require</span> <span class="s1">&#39;./helpers&#39;</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Compile a string of CoffeeScript code to JavaScript, using the Coffee/Jison
compiler.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.compile = compile = </span><span class="nf">(code, options = {}) -&gt;</span>
<span class="p">{</span><span class="nx">merge</span><span class="p">}</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">helpers</span>
<span class="k">try</span>
<span class="nv">js = </span><span class="p">(</span><span class="nx">parser</span><span class="p">.</span><span class="nx">parse</span> <span class="nx">lexer</span><span class="p">.</span><span class="nx">tokenize</span> <span class="nx">code</span><span class="p">).</span><span class="nx">compile</span> <span class="nx">options</span>
<span class="k">return</span> <span class="nx">js</span> <span class="nx">unless</span> <span class="nx">options</span><span class="p">.</span><span class="nx">header</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="nv">err.message = </span><span class="s2">&quot;In #{options.filename}, #{err.message}&quot;</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">filename</span>
<span class="k">throw</span> <span class="nx">err</span>
<span class="nv">header = </span><span class="s2">&quot;Generated by CoffeeScript #{@VERSION}&quot;</span>
<span class="s2">&quot;// #{header}\n#{js}&quot;</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.tokens = </span><span class="nf">(code, options) -&gt;</span>
<span class="nx">lexer</span><span class="p">.</span><span class="nx">tokenize</span> <span class="nx">code</span><span class="p">,</span> <span class="nx">options</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Parse a string of CoffeeScript code or an array of lexed tokens, and
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
or traverse it by using <code>.traverseChildren()</code> with a callback.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.nodes = </span><span class="nf">(source, options) -&gt;</span>
<span class="k">if</span> <span class="k">typeof</span> <span class="nx">source</span> <span class="o">is</span> <span class="s1">&#39;string&#39;</span>
<span class="nx">parser</span><span class="p">.</span><span class="nx">parse</span> <span class="nx">lexer</span><span class="p">.</span><span class="nx">tokenize</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">options</span>
<span class="k">else</span>
<span class="nx">parser</span><span class="p">.</span><span class="nx">parse</span> <span class="nx">source</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Compile and execute a string of CoffeeScript (on the server), correctly
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.run = </span><span class="nf">(code, options = {}) -&gt;</span>
<span class="nv">mainModule = </span><span class="nx">require</span><span class="p">.</span><span class="nx">main</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Set the filename.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">mainModule.filename = </span><span class="nx">process</span><span class="p">.</span><span class="nx">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span>
<span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">filename</span> <span class="k">then</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">realpathSync</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">filename</span><span class="p">)</span> <span class="k">else</span> <span class="s1">&#39;.&#39;</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Clear the module cache.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">mainModule</span><span class="p">.</span><span class="nx">moduleCache</span> <span class="o">and=</span> <span class="p">{}</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>Assign paths for node_modules loading</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">mainModule.paths = </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;module&#39;</span><span class="p">).</span><span class="nx">_nodeModulePaths</span> <span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">realpathSync</span> <span class="nx">options</span><span class="p">.</span><span class="nx">filename</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>Compile.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="nx">path</span><span class="p">.</span><span class="nx">extname</span><span class="p">(</span><span class="nx">mainModule</span><span class="p">.</span><span class="nx">filename</span><span class="p">)</span> <span class="o">isnt</span> <span class="s1">&#39;.coffee&#39;</span> <span class="o">or</span> <span class="nx">require</span><span class="p">.</span><span class="nx">extensions</span>
<span class="nx">mainModule</span><span class="p">.</span><span class="nx">_compile</span> <span class="nx">compile</span><span class="p">(</span><span class="nx">code</span><span class="p">,</span> <span class="nx">options</span><span class="p">),</span> <span class="nx">mainModule</span><span class="p">.</span><span class="nx">filename</span>
<span class="k">else</span>
<span class="nx">mainModule</span><span class="p">.</span><span class="nx">_compile</span> <span class="nx">code</span><span class="p">,</span> <span class="nx">mainModule</span><span class="p">.</span><span class="nx">filename</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
The CoffeeScript REPL uses this to run the input.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.eval = </span><span class="nf">(code, options = {}) -&gt;</span>
<span class="k">return</span> <span class="nx">unless</span> <span class="nv">code = </span><span class="nx">code</span><span class="p">.</span><span class="nx">trim</span><span class="p">()</span>
<span class="nv">Script = </span><span class="nx">vm</span><span class="p">.</span><span class="nx">Script</span>
<span class="k">if</span> <span class="nx">Script</span>
<span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">sandbox</span><span class="o">?</span>
<span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">sandbox</span> <span class="k">instanceof</span> <span class="nx">Script</span><span class="p">.</span><span class="nx">createContext</span><span class="p">().</span><span class="nx">constructor</span>
<span class="nv">sandbox = </span><span class="nx">options</span><span class="p">.</span><span class="nx">sandbox</span>
<span class="k">else</span>
<span class="nv">sandbox = </span><span class="nx">Script</span><span class="p">.</span><span class="nx">createContext</span><span class="p">()</span>
<span class="nx">sandbox</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span> <span class="k">for</span> <span class="nx">own</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">options</span><span class="p">.</span><span class="nx">sandbox</span>
<span class="nv">sandbox.global = sandbox.root = sandbox.GLOBAL = </span><span class="nx">sandbox</span>
<span class="k">else</span>
<span class="nv">sandbox = </span><span class="nx">global</span>
<span class="nv">sandbox.__filename = </span><span class="nx">options</span><span class="p">.</span><span class="nx">filename</span> <span class="o">||</span> <span class="s1">&#39;eval&#39;</span>
<span class="nv">sandbox.__dirname = </span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span> <span class="nx">sandbox</span><span class="p">.</span><span class="nx">__filename</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>define module/require only if they chose not to specify their own</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">unless</span> <span class="nx">sandbox</span> <span class="o">isnt</span> <span class="nx">global</span> <span class="o">or</span> <span class="nx">sandbox</span><span class="p">.</span><span class="nx">module</span> <span class="o">or</span> <span class="nx">sandbox</span><span class="p">.</span><span class="nx">require</span>
<span class="nv">Module = </span><span class="nx">require</span> <span class="s1">&#39;module&#39;</span>
<span class="nv">sandbox.module = _module = </span><span class="k">new</span> <span class="nx">Module</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">modulename</span> <span class="o">||</span> <span class="s1">&#39;eval&#39;</span><span class="p">)</span>
<span class="nv">sandbox.require = _require = </span><span class="nf">(path) -&gt;</span> <span class="nx">Module</span><span class="p">.</span><span class="nx">_load</span> <span class="nx">path</span><span class="p">,</span> <span class="nx">_module</span><span class="p">,</span> <span class="kc">true</span>
<span class="nv">_module.filename = </span><span class="nx">sandbox</span><span class="p">.</span><span class="nx">__filename</span>
<span class="nx">_require</span><span class="p">[</span><span class="nx">r</span><span class="p">]</span> <span class="o">=</span> <span class="nx">require</span><span class="p">[</span><span class="nx">r</span><span class="p">]</span> <span class="k">for</span> <span class="nx">r</span> <span class="k">in</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">getOwnPropertyNames</span> <span class="nx">require</span> <span class="k">when</span> <span class="nx">r</span> <span class="o">isnt</span> <span class="s1">&#39;paths&#39;</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>use the same hack node currently uses for their own REPL</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_require.paths = _module.paths = </span><span class="nx">Module</span><span class="p">.</span><span class="nx">_nodeModulePaths</span> <span class="nx">process</span><span class="p">.</span><span class="nx">cwd</span><span class="p">()</span>
<span class="nv">_require.resolve = </span><span class="nf">(request) -&gt;</span> <span class="nx">Module</span><span class="p">.</span><span class="nx">_resolveFilename</span> <span class="nx">request</span><span class="p">,</span> <span class="nx">_module</span>
<span class="nv">o = </span><span class="p">{}</span>
<span class="nx">o</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span> <span class="k">for</span> <span class="nx">own</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">options</span>
<span class="nv">o.bare = </span><span class="kc">on</span> <span class="c1"># ensure return value</span>
<span class="nv">js = </span><span class="nx">compile</span> <span class="nx">code</span><span class="p">,</span> <span class="nx">o</span>
<span class="k">if</span> <span class="nx">sandbox</span> <span class="o">is</span> <span class="nx">global</span>
<span class="nx">vm</span><span class="p">.</span><span class="nx">runInThisContext</span> <span class="nx">js</span>
<span class="k">else</span>
<span class="nx">vm</span><span class="p">.</span><span class="nx">runInContext</span> <span class="nx">js</span><span class="p">,</span> <span class="nx">sandbox</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>Instantiate a Lexer for our use here.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">lexer = </span><span class="k">new</span> <span class="nx">Lexer</span></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>The real Lexer produces a generic stream of tokens. This object provides a
thin wrapper around it, compatible with the Jison API. We can then pass it
directly as a "Jison lexer".</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">parser.lexer =</span>
<span class="nv">lex: </span><span class="o">-&gt;</span>
<span class="p">[</span><span class="nx">tag</span><span class="p">,</span> <span class="nx">@yytext</span><span class="p">,</span> <span class="nx">@yylineno</span><span class="p">]</span> <span class="o">=</span> <span class="nx">@tokens</span><span class="p">[</span><span class="nx">@pos</span><span class="o">++</span><span class="p">]</span> <span class="o">or</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">]</span>
<span class="nx">tag</span>
<span class="nv">setInput: </span><span class="nf">(@tokens) -&gt;</span>
<span class="vi">@pos = </span><span class="mi">0</span>
<span class="nv">upcomingInput: </span><span class="o">-&gt;</span>
<span class="s2">&quot;&quot;</span>
<span class="nv">parser.yy = </span><span class="nx">require</span> <span class="s1">&#39;./nodes&#39;</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,264 +0,0 @@
<!DOCTYPE html> <html> <head> <title>command.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> command.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>The <code>coffee</code> utility. Handles command-line compilation of CoffeeScript
into various forms: saved into <code>.js</code> files or printed to stdout, piped to
<a href="http://javascriptlint.com/">JavaScript Lint</a> or recompiled every time the source is
saved, printed as a token stream or as the syntax tree, or launch an
interactive REPL.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>External dependencies.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
<span class="nv">path = </span><span class="nx">require</span> <span class="s1">&#39;path&#39;</span>
<span class="nv">helpers = </span><span class="nx">require</span> <span class="s1">&#39;./helpers&#39;</span>
<span class="nv">optparse = </span><span class="nx">require</span> <span class="s1">&#39;./optparse&#39;</span>
<span class="nv">CoffeeScript = </span><span class="nx">require</span> <span class="s1">&#39;./coffee-script&#39;</span>
<span class="p">{</span><span class="nx">spawn</span><span class="p">,</span> <span class="nx">exec</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;child_process&#39;</span>
<span class="p">{</span><span class="nx">EventEmitter</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;events&#39;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Allow CoffeeScript to emit Node.js events.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">helpers</span><span class="p">.</span><span class="nx">extend</span> <span class="nx">CoffeeScript</span><span class="p">,</span> <span class="k">new</span> <span class="nx">EventEmitter</span>
<span class="nv">printLine = </span><span class="nf">(line) -&gt;</span> <span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span> <span class="nx">line</span> <span class="o">+</span> <span class="s1">&#39;\n&#39;</span>
<span class="nv">printWarn = </span><span class="nf">(line) -&gt;</span> <span class="nx">process</span><span class="p">.</span><span class="nx">stderr</span><span class="p">.</span><span class="nx">write</span> <span class="nx">line</span> <span class="o">+</span> <span class="s1">&#39;\n&#39;</span>
<span class="nv">hidden = </span><span class="nf">(file) -&gt;</span> <span class="o">/^</span><span class="err">\</span><span class="p">.</span><span class="o">|~</span><span class="nx">$</span><span class="err">/.test file</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>The help banner that is printed when <code>coffee</code> is called without arguments.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">BANNER = </span><span class="s1">&#39;&#39;&#39;</span>
<span class="s1"> Usage: coffee [options] path/to/script.coffee -- [args]</span>
<span class="s1"> If called without options, `coffee` will run your script.</span>
<span class="s1">&#39;&#39;&#39;</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>The list of all the valid option flags that <code>coffee</code> knows how to handle.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">SWITCHES = </span><span class="p">[</span>
<span class="p">[</span><span class="s1">&#39;-b&#39;</span><span class="p">,</span> <span class="s1">&#39;--bare&#39;</span><span class="p">,</span> <span class="s1">&#39;compile without a top-level function wrapper&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-c&#39;</span><span class="p">,</span> <span class="s1">&#39;--compile&#39;</span><span class="p">,</span> <span class="s1">&#39;compile to JavaScript and save as .js files&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-e&#39;</span><span class="p">,</span> <span class="s1">&#39;--eval&#39;</span><span class="p">,</span> <span class="s1">&#39;pass a string from the command line as input&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-h&#39;</span><span class="p">,</span> <span class="s1">&#39;--help&#39;</span><span class="p">,</span> <span class="s1">&#39;display this help message&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-i&#39;</span><span class="p">,</span> <span class="s1">&#39;--interactive&#39;</span><span class="p">,</span> <span class="s1">&#39;run an interactive CoffeeScript REPL&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-j&#39;</span><span class="p">,</span> <span class="s1">&#39;--join [FILE]&#39;</span><span class="p">,</span> <span class="s1">&#39;concatenate the source CoffeeScript before compiling&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-l&#39;</span><span class="p">,</span> <span class="s1">&#39;--lint&#39;</span><span class="p">,</span> <span class="s1">&#39;pipe the compiled JavaScript through JavaScript Lint&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-n&#39;</span><span class="p">,</span> <span class="s1">&#39;--nodes&#39;</span><span class="p">,</span> <span class="s1">&#39;print out the parse tree that the parser produces&#39;</span><span class="p">]</span>
<span class="p">[</span> <span class="s1">&#39;--nodejs [ARGS]&#39;</span><span class="p">,</span> <span class="s1">&#39;pass options directly to the &quot;node&quot; binary&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-o&#39;</span><span class="p">,</span> <span class="s1">&#39;--output [DIR]&#39;</span><span class="p">,</span> <span class="s1">&#39;set the output directory for compiled JavaScript&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-p&#39;</span><span class="p">,</span> <span class="s1">&#39;--print&#39;</span><span class="p">,</span> <span class="s1">&#39;print out the compiled JavaScript&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-r&#39;</span><span class="p">,</span> <span class="s1">&#39;--require [FILE*]&#39;</span><span class="p">,</span> <span class="s1">&#39;require a library before executing your script&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-s&#39;</span><span class="p">,</span> <span class="s1">&#39;--stdio&#39;</span><span class="p">,</span> <span class="s1">&#39;listen for and compile scripts over stdio&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-t&#39;</span><span class="p">,</span> <span class="s1">&#39;--tokens&#39;</span><span class="p">,</span> <span class="s1">&#39;print out the tokens that the lexer/rewriter produce&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-v&#39;</span><span class="p">,</span> <span class="s1">&#39;--version&#39;</span><span class="p">,</span> <span class="s1">&#39;display the version number&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;-w&#39;</span><span class="p">,</span> <span class="s1">&#39;--watch&#39;</span><span class="p">,</span> <span class="s1">&#39;watch scripts for changes and rerun commands&#39;</span><span class="p">]</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Top-level objects shared by all the functions.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">opts = </span><span class="p">{}</span>
<span class="nv">sources = </span><span class="p">[]</span>
<span class="nv">sourceCode = </span><span class="p">[]</span>
<span class="nv">notSources = </span><span class="p">{}</span>
<span class="nv">watchers = </span><span class="p">{}</span>
<span class="nv">optionParser = </span><span class="kc">null</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Run <code>coffee</code> by parsing passed options and determining what action to take.
Many flags cause us to divert before compiling anything. Flags passed after
<code>--</code> will be passed verbatim to your script as arguments in <code>process.argv</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.run = </span><span class="o">-&gt;</span>
<span class="nx">parseOptions</span><span class="p">()</span>
<span class="k">return</span> <span class="nx">forkNode</span><span class="p">()</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">nodejs</span>
<span class="k">return</span> <span class="nx">usage</span><span class="p">()</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">help</span>
<span class="k">return</span> <span class="nx">version</span><span class="p">()</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">version</span>
<span class="nx">loadRequires</span><span class="p">()</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">require</span>
<span class="k">return</span> <span class="nx">require</span> <span class="s1">&#39;./repl&#39;</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">interactive</span>
<span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">watch</span> <span class="o">and</span> <span class="o">!</span><span class="nx">fs</span><span class="p">.</span><span class="nx">watch</span>
<span class="k">return</span> <span class="nx">printWarn</span> <span class="s2">&quot;The --watch feature depends on Node v0.6.0+. You are running #{process.version}.&quot;</span>
<span class="k">return</span> <span class="nx">compileStdio</span><span class="p">()</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">stdio</span>
<span class="k">return</span> <span class="nx">compileScript</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">sources</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nb">eval</span>
<span class="k">return</span> <span class="nx">require</span> <span class="s1">&#39;./repl&#39;</span> <span class="nx">unless</span> <span class="nx">sources</span><span class="p">.</span><span class="nx">length</span>
<span class="nv">literals = </span><span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">run</span> <span class="k">then</span> <span class="nx">sources</span><span class="p">.</span><span class="nx">splice</span> <span class="mi">1</span> <span class="k">else</span> <span class="p">[]</span>
<span class="nv">process.argv = </span><span class="nx">process</span><span class="p">.</span><span class="nx">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">..</span><span class="mi">1</span><span class="p">].</span><span class="nx">concat</span> <span class="nx">literals</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;coffee&#39;</span>
<span class="nv">process.execPath = </span><span class="nx">require</span><span class="p">.</span><span class="nx">main</span><span class="p">.</span><span class="nx">filename</span>
<span class="k">for</span> <span class="nx">source</span> <span class="k">in</span> <span class="nx">sources</span>
<span class="nx">compilePath</span> <span class="nx">source</span><span class="p">,</span> <span class="kc">yes</span><span class="p">,</span> <span class="nx">path</span><span class="p">.</span><span class="nx">normalize</span> <span class="nx">source</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Compile a path, which could be a script or a directory. If a directory
is passed, recursively compile all '.coffee' extension source files in it
and all subdirectories.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">compilePath = </span><span class="nf">(source, topLevel, base) -&gt;</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">stat</span> <span class="nx">source</span><span class="p">,</span> <span class="nf">(err, stats) -&gt;</span>
<span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span> <span class="o">and</span> <span class="nx">err</span><span class="p">.</span><span class="nx">code</span> <span class="o">isnt</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="k">if</span> <span class="nx">err</span><span class="o">?</span><span class="p">.</span><span class="nx">code</span> <span class="o">is</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="k">if</span> <span class="nx">topLevel</span> <span class="o">and</span> <span class="nx">source</span><span class="p">[</span><span class="o">-</span><span class="mi">7</span><span class="p">..]</span> <span class="o">isnt</span> <span class="s1">&#39;.coffee&#39;</span>
<span class="nv">source = </span><span class="nx">sources</span><span class="p">[</span><span class="nx">sources</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">source</span><span class="p">)]</span> <span class="o">=</span> <span class="s2">&quot;#{source}.coffee&quot;</span>
<span class="k">return</span> <span class="nx">compilePath</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">topLevel</span><span class="p">,</span> <span class="nx">base</span>
<span class="k">if</span> <span class="nx">topLevel</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">error</span> <span class="s2">&quot;File not found: #{source}&quot;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">exit</span> <span class="mi">1</span>
<span class="k">return</span>
<span class="k">if</span> <span class="nx">stats</span><span class="p">.</span><span class="nx">isDirectory</span><span class="p">()</span>
<span class="nx">watchDir</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">base</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">watch</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">readdir</span> <span class="nx">source</span><span class="p">,</span> <span class="nf">(err, files) -&gt;</span>
<span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span> <span class="o">and</span> <span class="nx">err</span><span class="p">.</span><span class="nx">code</span> <span class="o">isnt</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="k">return</span> <span class="k">if</span> <span class="nx">err</span><span class="o">?</span><span class="p">.</span><span class="nx">code</span> <span class="o">is</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="nv">index = </span><span class="nx">sources</span><span class="p">.</span><span class="nx">indexOf</span> <span class="nx">source</span>
<span class="nv">files = </span><span class="nx">files</span><span class="p">.</span><span class="nx">filter</span> <span class="nf">(file) -&gt;</span> <span class="o">not</span> <span class="nx">hidden</span> <span class="nx">file</span>
<span class="nx">sources</span><span class="p">[</span><span class="nx">index</span><span class="p">..</span><span class="nx">index</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">file</span> <span class="k">for</span> <span class="nx">file</span> <span class="k">in</span> <span class="nx">files</span><span class="p">)</span>
<span class="nx">sourceCode</span><span class="p">[</span><span class="nx">index</span><span class="p">..</span><span class="nx">index</span><span class="p">]</span> <span class="o">=</span> <span class="nx">files</span><span class="p">.</span><span class="nx">map</span> <span class="o">-&gt;</span> <span class="kc">null</span>
<span class="nx">files</span><span class="p">.</span><span class="nx">forEach</span> <span class="nf">(file) -&gt;</span>
<span class="nx">compilePath</span> <span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">file</span><span class="p">),</span> <span class="kc">no</span><span class="p">,</span> <span class="nx">base</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">topLevel</span> <span class="o">or</span> <span class="nx">path</span><span class="p">.</span><span class="nx">extname</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;.coffee&#39;</span>
<span class="nx">watch</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">base</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">watch</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">readFile</span> <span class="nx">source</span><span class="p">,</span> <span class="nf">(err, code) -&gt;</span>
<span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span> <span class="o">and</span> <span class="nx">err</span><span class="p">.</span><span class="nx">code</span> <span class="o">isnt</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="k">return</span> <span class="k">if</span> <span class="nx">err</span><span class="o">?</span><span class="p">.</span><span class="nx">code</span> <span class="o">is</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="nx">compileScript</span><span class="p">(</span><span class="nx">source</span><span class="p">,</span> <span class="nx">code</span><span class="p">.</span><span class="nx">toString</span><span class="p">(),</span> <span class="nx">base</span><span class="p">)</span>
<span class="k">else</span>
<span class="nx">notSources</span><span class="p">[</span><span class="nx">source</span><span class="p">]</span> <span class="o">=</span> <span class="kc">yes</span>
<span class="nx">removeSource</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">base</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Compile a single source script, containing the given code, according to the
requested options. If evaluating the script directly sets <code>__filename</code>,
<code>__dirname</code> and <code>module.filename</code> to be correct relative to the script's path.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">compileScript = </span><span class="nf">(file, input, base) -&gt;</span>
<span class="nv">o = </span><span class="nx">opts</span>
<span class="nv">options = </span><span class="nx">compileOptions</span> <span class="nx">file</span>
<span class="k">try</span>
<span class="nv">t = task = </span><span class="p">{</span><span class="nx">file</span><span class="p">,</span> <span class="nx">input</span><span class="p">,</span> <span class="nx">options</span><span class="p">}</span>
<span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">emit</span> <span class="s1">&#39;compile&#39;</span><span class="p">,</span> <span class="nx">task</span>
<span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">tokens</span> <span class="k">then</span> <span class="nx">printTokens</span> <span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">tokens</span> <span class="nx">t</span><span class="p">.</span><span class="nx">input</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">nodes</span> <span class="k">then</span> <span class="nx">printLine</span> <span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">nodes</span><span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">input</span><span class="p">).</span><span class="nx">toString</span><span class="p">().</span><span class="nx">trim</span><span class="p">()</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">run</span> <span class="k">then</span> <span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">run</span> <span class="nx">t</span><span class="p">.</span><span class="nx">input</span><span class="p">,</span> <span class="nx">t</span><span class="p">.</span><span class="nx">options</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">join</span> <span class="o">and</span> <span class="nx">t</span><span class="p">.</span><span class="nx">file</span> <span class="o">isnt</span> <span class="nx">o</span><span class="p">.</span><span class="nx">join</span>
<span class="nx">sourceCode</span><span class="p">[</span><span class="nx">sources</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">t</span><span class="p">.</span><span class="nx">file</span><span class="p">)]</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">input</span>
<span class="nx">compileJoin</span><span class="p">()</span>
<span class="k">else</span>
<span class="nv">t.output = </span><span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">compile</span> <span class="nx">t</span><span class="p">.</span><span class="nx">input</span><span class="p">,</span> <span class="nx">t</span><span class="p">.</span><span class="nx">options</span>
<span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">emit</span> <span class="s1">&#39;success&#39;</span><span class="p">,</span> <span class="nx">task</span>
<span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">print</span> <span class="k">then</span> <span class="nx">printLine</span> <span class="nx">t</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">trim</span><span class="p">()</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">compile</span> <span class="k">then</span> <span class="nx">writeJs</span> <span class="nx">t</span><span class="p">.</span><span class="nx">file</span><span class="p">,</span> <span class="nx">t</span><span class="p">.</span><span class="nx">output</span><span class="p">,</span> <span class="nx">base</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">lint</span> <span class="k">then</span> <span class="nx">lint</span> <span class="nx">t</span><span class="p">.</span><span class="nx">file</span><span class="p">,</span> <span class="nx">t</span><span class="p">.</span><span class="nx">output</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">emit</span> <span class="s1">&#39;failure&#39;</span><span class="p">,</span> <span class="nx">err</span><span class="p">,</span> <span class="nx">task</span>
<span class="k">return</span> <span class="k">if</span> <span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">listeners</span><span class="p">(</span><span class="s1">&#39;failure&#39;</span><span class="p">).</span><span class="nx">length</span>
<span class="k">return</span> <span class="nx">printLine</span> <span class="nx">err</span><span class="p">.</span><span class="nx">message</span> <span class="o">+</span> <span class="s1">&#39;\x07&#39;</span> <span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">watch</span>
<span class="nx">printWarn</span> <span class="nx">err</span> <span class="k">instanceof</span> <span class="nb">Error</span> <span class="o">and</span> <span class="nx">err</span><span class="p">.</span><span class="nx">stack</span> <span class="o">or</span> <span class="s2">&quot;ERROR: #{err}&quot;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">exit</span> <span class="mi">1</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>,
and write them back to <strong>stdout</strong>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">compileStdio = </span><span class="o">-&gt;</span>
<span class="nv">code = </span><span class="s1">&#39;&#39;</span>
<span class="nv">stdin = </span><span class="nx">process</span><span class="p">.</span><span class="nx">openStdin</span><span class="p">()</span>
<span class="nx">stdin</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nf">(buffer) -&gt;</span>
<span class="nx">code</span> <span class="o">+=</span> <span class="nx">buffer</span><span class="p">.</span><span class="nx">toString</span><span class="p">()</span> <span class="k">if</span> <span class="nx">buffer</span>
<span class="nx">stdin</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;end&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nx">compileScript</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">code</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>If all of the source files are done being read, concatenate and compile
them together.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">joinTimeout = </span><span class="kc">null</span>
<span class="nv">compileJoin = </span><span class="o">-&gt;</span>
<span class="k">return</span> <span class="nx">unless</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">join</span>
<span class="nx">unless</span> <span class="nx">sourceCode</span><span class="p">.</span><span class="nx">some</span><span class="p">(</span><span class="nf">(code) -&gt;</span> <span class="nx">code</span> <span class="o">is</span> <span class="kc">null</span><span class="p">)</span>
<span class="nx">clearTimeout</span> <span class="nx">joinTimeout</span>
<span class="nv">joinTimeout = </span><span class="nx">wait</span> <span class="mi">100</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nx">compileScript</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">join</span><span class="p">,</span> <span class="nx">sourceCode</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">),</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">join</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>Load files that are to-be-required before compilation occurs.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">loadRequires = </span><span class="o">-&gt;</span>
<span class="nv">realFilename = </span><span class="nx">module</span><span class="p">.</span><span class="nx">filename</span>
<span class="nv">module.filename = </span><span class="s1">&#39;.&#39;</span>
<span class="nx">require</span> <span class="nx">req</span> <span class="k">for</span> <span class="nx">req</span> <span class="k">in</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">require</span>
<span class="nv">module.filename = </span><span class="nx">realFilename</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>Watch a source CoffeeScript file using <code>fs.watch</code>, recompiling it every
time the file is updated. May be used in combination with other options,
such as <code>--lint</code> or <code>--print</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">watch = </span><span class="nf">(source, base) -&gt;</span>
<span class="nv">prevStats = </span><span class="kc">null</span>
<span class="nv">compileTimeout = </span><span class="kc">null</span>
<span class="nv">watchErr = </span><span class="nf">(e) -&gt;</span>
<span class="k">if</span> <span class="nx">e</span><span class="p">.</span><span class="nx">code</span> <span class="o">is</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="k">return</span> <span class="k">if</span> <span class="nx">sources</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="o">is</span> <span class="o">-</span><span class="mi">1</span>
<span class="k">try</span>
<span class="nx">rewatch</span><span class="p">()</span>
<span class="nx">compile</span><span class="p">()</span>
<span class="k">catch</span> <span class="nx">e</span>
<span class="nx">removeSource</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">base</span><span class="p">,</span> <span class="kc">yes</span>
<span class="nx">compileJoin</span><span class="p">()</span>
<span class="k">else</span> <span class="k">throw</span> <span class="nx">e</span>
<span class="nv">compile = </span><span class="o">-&gt;</span>
<span class="nx">clearTimeout</span> <span class="nx">compileTimeout</span>
<span class="nv">compileTimeout = </span><span class="nx">wait</span> <span class="mi">25</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">stat</span> <span class="nx">source</span><span class="p">,</span> <span class="nf">(err, stats) -&gt;</span>
<span class="k">return</span> <span class="nx">watchErr</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
<span class="k">return</span> <span class="nx">rewatch</span><span class="p">()</span> <span class="k">if</span> <span class="nx">prevStats</span> <span class="o">and</span> <span class="nx">stats</span><span class="p">.</span><span class="nx">size</span> <span class="o">is</span> <span class="nx">prevStats</span><span class="p">.</span><span class="nx">size</span> <span class="o">and</span>
<span class="nx">stats</span><span class="p">.</span><span class="nx">mtime</span><span class="p">.</span><span class="nx">getTime</span><span class="p">()</span> <span class="o">is</span> <span class="nx">prevStats</span><span class="p">.</span><span class="nx">mtime</span><span class="p">.</span><span class="nx">getTime</span><span class="p">()</span>
<span class="nv">prevStats = </span><span class="nx">stats</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">readFile</span> <span class="nx">source</span><span class="p">,</span> <span class="nf">(err, code) -&gt;</span>
<span class="k">return</span> <span class="nx">watchErr</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
<span class="nx">compileScript</span><span class="p">(</span><span class="nx">source</span><span class="p">,</span> <span class="nx">code</span><span class="p">.</span><span class="nx">toString</span><span class="p">(),</span> <span class="nx">base</span><span class="p">)</span>
<span class="nx">rewatch</span><span class="p">()</span>
<span class="k">try</span>
<span class="nv">watcher = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">watch</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">compile</span>
<span class="k">catch</span> <span class="nx">e</span>
<span class="nx">watchErr</span> <span class="nx">e</span>
<span class="nv">rewatch = </span><span class="o">-&gt;</span>
<span class="nx">watcher</span><span class="o">?</span><span class="p">.</span><span class="nx">close</span><span class="p">()</span>
<span class="nv">watcher = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">watch</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">compile</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>Watch a directory of files for new additions.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">watchDir = </span><span class="nf">(source, base) -&gt;</span>
<span class="nv">readdirTimeout = </span><span class="kc">null</span>
<span class="k">try</span>
<span class="nv">watcher = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">watch</span> <span class="nx">source</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nx">clearTimeout</span> <span class="nx">readdirTimeout</span>
<span class="nv">readdirTimeout = </span><span class="nx">wait</span> <span class="mi">25</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">readdir</span> <span class="nx">source</span><span class="p">,</span> <span class="nf">(err, files) -&gt;</span>
<span class="k">if</span> <span class="nx">err</span>
<span class="k">throw</span> <span class="nx">err</span> <span class="nx">unless</span> <span class="nx">err</span><span class="p">.</span><span class="nx">code</span> <span class="o">is</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="nx">watcher</span><span class="p">.</span><span class="nx">close</span><span class="p">()</span>
<span class="k">return</span> <span class="nx">unwatchDir</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">base</span>
<span class="k">for</span> <span class="nx">file</span> <span class="k">in</span> <span class="nx">files</span> <span class="k">when</span> <span class="o">not</span> <span class="nx">hidden</span><span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">notSources</span><span class="p">[</span><span class="nx">file</span><span class="p">]</span>
<span class="nv">file = </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">file</span>
<span class="k">continue</span> <span class="k">if</span> <span class="nx">sources</span><span class="p">.</span><span class="nx">some</span> <span class="nf">(s) -&gt;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">0</span>
<span class="nx">sources</span><span class="p">.</span><span class="nx">push</span> <span class="nx">file</span>
<span class="nx">sourceCode</span><span class="p">.</span><span class="nx">push</span> <span class="kc">null</span>
<span class="nx">compilePath</span> <span class="nx">file</span><span class="p">,</span> <span class="kc">no</span><span class="p">,</span> <span class="nx">base</span>
<span class="k">catch</span> <span class="nx">e</span>
<span class="k">throw</span> <span class="nx">e</span> <span class="nx">unless</span> <span class="nx">e</span><span class="p">.</span><span class="nx">code</span> <span class="o">is</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="nv">unwatchDir = </span><span class="nf">(source, base) -&gt;</span>
<span class="nv">prevSources = </span><span class="nx">sources</span><span class="p">[..]</span>
<span class="nv">toRemove = </span><span class="p">(</span><span class="nx">file</span> <span class="k">for</span> <span class="nx">file</span> <span class="k">in</span> <span class="nx">sources</span> <span class="k">when</span> <span class="nx">file</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">)</span>
<span class="nx">removeSource</span> <span class="nx">file</span><span class="p">,</span> <span class="nx">base</span><span class="p">,</span> <span class="kc">yes</span> <span class="k">for</span> <span class="nx">file</span> <span class="k">in</span> <span class="nx">toRemove</span>
<span class="k">return</span> <span class="nx">unless</span> <span class="nx">sources</span><span class="p">.</span><span class="nx">some</span> <span class="nf">(s, i) -&gt;</span> <span class="nx">prevSources</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">isnt</span> <span class="nx">s</span>
<span class="nx">compileJoin</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>Remove a file from our source list, and source code cache. Optionally remove
the compiled JS version as well.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">removeSource = </span><span class="nf">(source, base, removeJs) -&gt;</span>
<span class="nv">index = </span><span class="nx">sources</span><span class="p">.</span><span class="nx">indexOf</span> <span class="nx">source</span>
<span class="nx">sources</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">index</span><span class="p">,</span> <span class="mi">1</span>
<span class="nx">sourceCode</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">index</span><span class="p">,</span> <span class="mi">1</span>
<span class="k">if</span> <span class="nx">removeJs</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">join</span>
<span class="nv">jsPath = </span><span class="nx">outputPath</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">base</span>
<span class="nx">path</span><span class="p">.</span><span class="nx">exists</span> <span class="nx">jsPath</span><span class="p">,</span> <span class="nf">(exists) -&gt;</span>
<span class="k">if</span> <span class="nx">exists</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">unlink</span> <span class="nx">jsPath</span><span class="p">,</span> <span class="nf">(err) -&gt;</span>
<span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span> <span class="o">and</span> <span class="nx">err</span><span class="p">.</span><span class="nx">code</span> <span class="o">isnt</span> <span class="s1">&#39;ENOENT&#39;</span>
<span class="nx">timeLog</span> <span class="s2">&quot;removed #{source}&quot;</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>Get the corresponding output JavaScript path for a source file.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">outputPath = </span><span class="nf">(source, base) -&gt;</span>
<span class="nv">filename = </span><span class="nx">path</span><span class="p">.</span><span class="nx">basename</span><span class="p">(</span><span class="nx">source</span><span class="p">,</span> <span class="nx">path</span><span class="p">.</span><span class="nx">extname</span><span class="p">(</span><span class="nx">source</span><span class="p">))</span> <span class="o">+</span> <span class="s1">&#39;.js&#39;</span>
<span class="nv">srcDir = </span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span> <span class="nx">source</span>
<span class="nv">baseDir = </span><span class="k">if</span> <span class="nx">base</span> <span class="o">is</span> <span class="s1">&#39;.&#39;</span> <span class="k">then</span> <span class="nx">srcDir</span> <span class="k">else</span> <span class="nx">srcDir</span><span class="p">.</span><span class="nx">substring</span> <span class="nx">base</span><span class="p">.</span><span class="nx">length</span>
<span class="nv">dir = </span><span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">output</span> <span class="k">then</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">output</span><span class="p">,</span> <span class="nx">baseDir</span> <span class="k">else</span> <span class="nx">srcDir</span>
<span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">dir</span><span class="p">,</span> <span class="nx">filename</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>Write out a JavaScript source file with the compiled code. By default, files
are written out in <code>cwd</code> as <code>.js</code> files with the same name, but the output
directory can be customized with <code>--output</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">writeJs = </span><span class="nf">(source, js, base) -&gt;</span>
<span class="nv">jsPath = </span><span class="nx">outputPath</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">base</span>
<span class="nv">jsDir = </span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span> <span class="nx">jsPath</span>
<span class="nv">compile = </span><span class="o">-&gt;</span>
<span class="nv">js = </span><span class="s1">&#39; &#39;</span> <span class="k">if</span> <span class="nx">js</span><span class="p">.</span><span class="nx">length</span> <span class="o">&lt;=</span> <span class="mi">0</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">writeFile</span> <span class="nx">jsPath</span><span class="p">,</span> <span class="nx">js</span><span class="p">,</span> <span class="nf">(err) -&gt;</span>
<span class="k">if</span> <span class="nx">err</span>
<span class="nx">printLine</span> <span class="nx">err</span><span class="p">.</span><span class="nx">message</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">compile</span> <span class="o">and</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">watch</span>
<span class="nx">timeLog</span> <span class="s2">&quot;compiled #{source}&quot;</span>
<span class="nx">path</span><span class="p">.</span><span class="nx">exists</span> <span class="nx">jsDir</span><span class="p">,</span> <span class="nf">(exists) -&gt;</span>
<span class="k">if</span> <span class="nx">exists</span> <span class="k">then</span> <span class="nx">compile</span><span class="p">()</span> <span class="k">else</span> <span class="nx">exec</span> <span class="s2">&quot;mkdir -p #{jsDir}&quot;</span><span class="p">,</span> <span class="nx">compile</span></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>Convenience for cleaner setTimeouts.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">wait = </span><span class="nf">(milliseconds, func) -&gt;</span> <span class="nx">setTimeout</span> <span class="nx">func</span><span class="p">,</span> <span class="nx">milliseconds</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <p>When watching scripts, it's useful to log changes with the timestamp.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">timeLog = </span><span class="nf">(message) -&gt;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s2">&quot;#{(new Date).toLocaleTimeString()} - #{message}&quot;</span></pre></div> </td> </tr> <tr id="section-20"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-20">&#182;</a> </div> <p>Pipe compiled JS through JSLint (requires a working <code>jsl</code> command), printing
any errors or warnings that arise.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">lint = </span><span class="nf">(file, js) -&gt;</span>
<span class="nv">printIt = </span><span class="nf">(buffer) -&gt;</span> <span class="nx">printLine</span> <span class="nx">file</span> <span class="o">+</span> <span class="s1">&#39;:\t&#39;</span> <span class="o">+</span> <span class="nx">buffer</span><span class="p">.</span><span class="nx">toString</span><span class="p">().</span><span class="nx">trim</span><span class="p">()</span>
<span class="nv">conf = </span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../../extras/jsl.conf&#39;</span>
<span class="nv">jsl = </span><span class="nx">spawn</span> <span class="s1">&#39;jsl&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;-nologo&#39;</span><span class="p">,</span> <span class="s1">&#39;-stdin&#39;</span><span class="p">,</span> <span class="s1">&#39;-conf&#39;</span><span class="p">,</span> <span class="nx">conf</span><span class="p">]</span>
<span class="nx">jsl</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nx">printIt</span>
<span class="nx">jsl</span><span class="p">.</span><span class="nx">stderr</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nx">printIt</span>
<span class="nx">jsl</span><span class="p">.</span><span class="nx">stdin</span><span class="p">.</span><span class="nx">write</span> <span class="nx">js</span>
<span class="nx">jsl</span><span class="p">.</span><span class="nx">stdin</span><span class="p">.</span><span class="nx">end</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-21"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-21">&#182;</a> </div> <p>Pretty-print a stream of tokens.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">printTokens = </span><span class="nf">(tokens) -&gt;</span>
<span class="nv">strings = </span><span class="k">for</span> <span class="nx">token</span> <span class="k">in</span> <span class="nx">tokens</span>
<span class="p">[</span><span class="nx">tag</span><span class="p">,</span> <span class="nx">value</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nx">token</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nx">toString</span><span class="p">().</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\n/</span><span class="p">,</span> <span class="s1">&#39;\\n&#39;</span><span class="p">)]</span>
<span class="s2">&quot;[#{tag} #{value}]&quot;</span>
<span class="nx">printLine</span> <span class="nx">strings</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-22"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-22">&#182;</a> </div> <p>Use the <a href="optparse.html">OptionParser module</a> to extract all options from
<code>process.argv</code> that are specified in <code>SWITCHES</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">parseOptions = </span><span class="o">-&gt;</span>
<span class="nv">optionParser = </span><span class="k">new</span> <span class="nx">optparse</span><span class="p">.</span><span class="nx">OptionParser</span> <span class="nx">SWITCHES</span><span class="p">,</span> <span class="nx">BANNER</span>
<span class="nv">o = opts = </span><span class="nx">optionParser</span><span class="p">.</span><span class="nx">parse</span> <span class="nx">process</span><span class="p">.</span><span class="nx">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">..]</span>
<span class="nx">o</span><span class="p">.</span><span class="nx">compile</span> <span class="o">or=</span> <span class="o">!!</span><span class="nx">o</span><span class="p">.</span><span class="nx">output</span>
<span class="nv">o.run = </span><span class="o">not</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">compile</span> <span class="o">or</span> <span class="nx">o</span><span class="p">.</span><span class="nx">print</span> <span class="o">or</span> <span class="nx">o</span><span class="p">.</span><span class="nx">lint</span><span class="p">)</span>
<span class="nv">o.print = </span><span class="o">!!</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">print</span> <span class="o">or</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nb">eval</span> <span class="o">or</span> <span class="nx">o</span><span class="p">.</span><span class="nx">stdio</span> <span class="o">and</span> <span class="nx">o</span><span class="p">.</span><span class="nx">compile</span><span class="p">))</span>
<span class="nv">sources = </span><span class="nx">o</span><span class="p">.</span><span class="nx">arguments</span>
<span class="nx">sourceCode</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="kc">null</span> <span class="k">for</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">sources</span>
<span class="k">return</span></pre></div> </td> </tr> <tr id="section-23"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-23">&#182;</a> </div> <p>The compile-time options to pass to the CoffeeScript compiler.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">compileOptions = </span><span class="nf">(filename) -&gt;</span>
<span class="p">{</span><span class="nx">filename</span><span class="p">,</span> <span class="nv">bare: </span><span class="nx">opts</span><span class="p">.</span><span class="nx">bare</span><span class="p">,</span> <span class="nv">header: </span><span class="nx">opts</span><span class="p">.</span><span class="nx">compile</span><span class="p">}</span></pre></div> </td> </tr> <tr id="section-24"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-24">&#182;</a> </div> <p>Start up a new Node.js instance with the arguments in <code>--nodejs</code> passed to
the <code>node</code> binary, preserving the other options.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">forkNode = </span><span class="o">-&gt;</span>
<span class="nv">nodeArgs = </span><span class="nx">opts</span><span class="p">.</span><span class="nx">nodejs</span><span class="p">.</span><span class="nx">split</span> <span class="sr">/\s+/</span>
<span class="nv">args = </span><span class="nx">process</span><span class="p">.</span><span class="nx">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">..]</span>
<span class="nx">args</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">args</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;--nodejs&#39;</span><span class="p">),</span> <span class="mi">2</span>
<span class="nx">spawn</span> <span class="nx">process</span><span class="p">.</span><span class="nx">execPath</span><span class="p">,</span> <span class="nx">nodeArgs</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">args</span><span class="p">),</span>
<span class="nv">cwd: </span> <span class="nx">process</span><span class="p">.</span><span class="nx">cwd</span><span class="p">()</span>
<span class="nv">env: </span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span>
<span class="nv">customFds: </span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-25"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-25">&#182;</a> </div> <p>Print the <code>--help</code> usage message and exit. Deprecated switches are not
shown.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">usage = </span><span class="o">-&gt;</span>
<span class="nx">printLine</span> <span class="p">(</span><span class="k">new</span> <span class="nx">optparse</span><span class="p">.</span><span class="nx">OptionParser</span> <span class="nx">SWITCHES</span><span class="p">,</span> <span class="nx">BANNER</span><span class="p">).</span><span class="nx">help</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-26"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-26">&#182;</a> </div> <p>Print the <code>--version</code> message and exit.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">version = </span><span class="o">-&gt;</span>
<span class="nx">printLine</span> <span class="s2">&quot;CoffeeScript version #{CoffeeScript.VERSION}&quot;</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,186 +0,0 @@
/*--------------------- Layout and Typography ----------------------------*/
body {
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
font-size: 15px;
line-height: 22px;
color: #252519;
margin: 0; padding: 0;
}
a {
color: #261a3b;
}
a:visited {
color: #261a3b;
}
p {
margin: 0 0 15px 0;
}
h1, h2, h3, h4, h5, h6 {
margin: 0px 0 15px 0;
}
h1 {
margin-top: 40px;
}
#container {
position: relative;
}
#background {
position: fixed;
top: 0; left: 525px; right: 0; bottom: 0;
background: #f5f5ff;
border-left: 1px solid #e5e5ee;
z-index: -1;
}
#jump_to, #jump_page {
background: white;
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
font: 10px Arial;
text-transform: uppercase;
cursor: pointer;
text-align: right;
}
#jump_to, #jump_wrapper {
position: fixed;
right: 0; top: 0;
padding: 5px 10px;
}
#jump_wrapper {
padding: 0;
display: none;
}
#jump_to:hover #jump_wrapper {
display: block;
}
#jump_page {
padding: 5px 0 3px;
margin: 0 0 25px 25px;
}
#jump_page .source {
display: block;
padding: 5px 10px;
text-decoration: none;
border-top: 1px solid #eee;
}
#jump_page .source:hover {
background: #f5f5ff;
}
#jump_page .source:first-child {
}
table td {
border: 0;
outline: 0;
}
td.docs, th.docs {
max-width: 450px;
min-width: 450px;
min-height: 5px;
padding: 10px 25px 1px 50px;
overflow-x: hidden;
vertical-align: top;
text-align: left;
}
.docs pre {
margin: 15px 0 15px;
padding-left: 15px;
}
.docs p tt, .docs p code {
background: #f8f8ff;
border: 1px solid #dedede;
font-size: 12px;
padding: 0 0.2em;
}
.pilwrap {
position: relative;
}
.pilcrow {
font: 12px Arial;
text-decoration: none;
color: #454545;
position: absolute;
top: 3px; left: -20px;
padding: 1px 2px;
opacity: 0;
-webkit-transition: opacity 0.2s linear;
}
td.docs:hover .pilcrow {
opacity: 1;
}
td.code, th.code {
padding: 14px 15px 16px 25px;
width: 100%;
vertical-align: top;
background: #f5f5ff;
border-left: 1px solid #e5e5ee;
}
pre, tt, code {
font-size: 12px; line-height: 18px;
font-family: Monaco, Consolas, "Lucida Console", monospace;
margin: 0; padding: 0;
}
/*---------------------- Syntax Highlighting -----------------------------*/
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
body .hll { background-color: #ffffcc }
body .c { color: #408080; font-style: italic } /* Comment */
body .err { border: 1px solid #FF0000 } /* Error */
body .k { color: #954121 } /* Keyword */
body .o { color: #666666 } /* Operator */
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
body .cp { color: #BC7A00 } /* Comment.Preproc */
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
body .cs { color: #408080; font-style: italic } /* Comment.Special */
body .gd { color: #A00000 } /* Generic.Deleted */
body .ge { font-style: italic } /* Generic.Emph */
body .gr { color: #FF0000 } /* Generic.Error */
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
body .gi { color: #00A000 } /* Generic.Inserted */
body .go { color: #808080 } /* Generic.Output */
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
body .gs { font-weight: bold } /* Generic.Strong */
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
body .gt { color: #0040D0 } /* Generic.Traceback */
body .kc { color: #954121 } /* Keyword.Constant */
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
body .kp { color: #954121 } /* Keyword.Pseudo */
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
body .kt { color: #B00040 } /* Keyword.Type */
body .m { color: #666666 } /* Literal.Number */
body .s { color: #219161 } /* Literal.String */
body .na { color: #7D9029 } /* Name.Attribute */
body .nb { color: #954121 } /* Name.Builtin */
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
body .no { color: #880000 } /* Name.Constant */
body .nd { color: #AA22FF } /* Name.Decorator */
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
body .nf { color: #0000FF } /* Name.Function */
body .nl { color: #A0A000 } /* Name.Label */
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
body .nv { color: #19469D } /* Name.Variable */
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
body .w { color: #bbbbbb } /* Text.Whitespace */
body .mf { color: #666666 } /* Literal.Number.Float */
body .mh { color: #666666 } /* Literal.Number.Hex */
body .mi { color: #666666 } /* Literal.Number.Integer */
body .mo { color: #666666 } /* Literal.Number.Oct */
body .sb { color: #219161 } /* Literal.String.Backtick */
body .sc { color: #219161 } /* Literal.String.Char */
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
body .s2 { color: #219161 } /* Literal.String.Double */
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
body .sh { color: #219161 } /* Literal.String.Heredoc */
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
body .sx { color: #954121 } /* Literal.String.Other */
body .sr { color: #BB6688 } /* Literal.String.Regex */
body .s1 { color: #219161 } /* Literal.String.Single */
body .ss { color: #19469D } /* Literal.String.Symbol */
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
body .vc { color: #19469D } /* Name.Variable.Class */
body .vg { color: #19469D } /* Name.Variable.Global */
body .vi { color: #19469D } /* Name.Variable.Instance */
body .il { color: #666666 } /* Literal.Number.Integer.Long */

View File

@@ -1,407 +0,0 @@
<!DOCTYPE html> <html> <head> <title>grammar.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> grammar.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>The CoffeeScript parser is generated by <a href="http://github.com/zaach/jison">Jison</a>
from this grammar file. Jison is a bottom-up parser generator, similar in
style to <a href="http://www.gnu.org/software/bison">Bison</a>, implemented in JavaScript.
It can recognize <a href="http://en.wikipedia.org/wiki/LR_grammar">LALR(1), LR(0), SLR(1), and LR(1)</a>
type grammars. To create the Jison parser, we list the pattern to match
on the left-hand side, and the action to take (usually the creation of syntax
tree nodes) on the right. As the parser runs, it
shifts tokens from our token stream, from left to right, and
<a href="http://en.wikipedia.org/wiki/Bottom-up_parsing">attempts to match</a>
the token sequence against the rules below. When a match can be made, it
reduces into the <a href="http://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols">nonterminal</a>
(the enclosing name at the top), and we proceed from there.</p>
<p>If you run the <code>cake build:parser</code> command, Jison constructs a parse table
from our rules and saves it into <code>lib/parser.js</code>.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>The only dependency is on the <strong>Jison.Parser</strong>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">{</span><span class="nx">Parser</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;jison&#39;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h2>Jison DSL</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Since we're going to be wrapped in a function by Jison in any case, if our
action immediately returns a value, we can optimize by removing the function
wrapper and just returning the value directly.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">unwrap = </span><span class="sr">/^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Our handy DSL for Jison grammar generation, thanks to
<a href="http://github.com/creationix">Tim Caswell</a>. For every rule in the grammar,
we pass the pattern-defining string, the action to run, and extra options,
optionally. If no action is specified, we simply pass the value of the
previous nonterminal.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">o = </span><span class="nf">(patternString, action, options) -&gt;</span>
<span class="nv">patternString = </span><span class="nx">patternString</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\s{2,}/g</span><span class="p">,</span> <span class="s1">&#39; &#39;</span>
<span class="k">return</span> <span class="p">[</span><span class="nx">patternString</span><span class="p">,</span> <span class="s1">&#39;$$ = $1;&#39;</span><span class="p">,</span> <span class="nx">options</span><span class="p">]</span> <span class="nx">unless</span> <span class="nx">action</span>
<span class="nv">action = </span><span class="k">if</span> <span class="nv">match = </span><span class="nx">unwrap</span><span class="p">.</span><span class="nx">exec</span> <span class="nx">action</span> <span class="k">then</span> <span class="nx">match</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">else</span> <span class="s2">&quot;(#{action}())&quot;</span>
<span class="nv">action = </span><span class="nx">action</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\bnew /g</span><span class="p">,</span> <span class="s1">&#39;$&amp;yy.&#39;</span>
<span class="nv">action = </span><span class="nx">action</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\b(?:Block\.wrap|extend)\b/g</span><span class="p">,</span> <span class="s1">&#39;yy.$&amp;&#39;</span>
<span class="p">[</span><span class="nx">patternString</span><span class="p">,</span> <span class="s2">&quot;$$ = #{action};&quot;</span><span class="p">,</span> <span class="nx">options</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h2>Grammatical Rules</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>In all of the rules that follow, you'll see the name of the nonterminal as
the key to a list of alternative matches. With each match's action, the
dollar-sign variables are provided by Jison as references to the value of
their numeric position, so in this rule:</p>
<pre><code>"Expression UNLESS Expression"
</code></pre>
<p><code>$1</code> would be the value of the first <code>Expression</code>, <code>$2</code> would be the token
for the <code>UNLESS</code> terminal, and <code>$3</code> would be the value of the second
<code>Expression</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">grammar =</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>The <strong>Root</strong> is the top-level node in the syntax tree. Since we parse bottom-up,
all parsing must end here.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Root: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Block</span>
<span class="nx">o</span> <span class="s1">&#39;Body&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Block TERMINATOR&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Any list of statements and expressions, separated by line breaks or semicolons.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Body: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Line&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">Block</span><span class="p">.</span><span class="nx">wrap</span> <span class="p">[</span><span class="nx">$1</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;Body TERMINATOR Line&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">push</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Body TERMINATOR&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Block and statements, which make up a line in a body.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Line: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Expression&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Statement&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Pure statements which cannot be expressions.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Statement: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Return&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Comment&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;STATEMENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>All the different types of expressions in our language. The basic unit of
CoffeeScript is the <strong>Expression</strong> -- everything that can be an expression
is one. Blocks serve as the building blocks of many other rules, making
them somewhat circular.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Expression: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Value&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Invocation&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Code&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Operation&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Assign&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;If&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Try&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;While&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;For&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Switch&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Class&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Throw&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>An indented block of expressions. Note that the <a href="rewriter.html">Rewriter</a>
will convert some postfix forms into blocks for us, by adjusting the
token stream.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Block: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;INDENT OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Block</span>
<span class="nx">o</span> <span class="s1">&#39;INDENT Body OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$2</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>A literal identifier, a variable name or property.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Identifier: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;IDENTIFIER&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>Alphanumerics are separated from the other <strong>Literal</strong> matchers because
they can also serve as keys in object literals.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">AlphaNumeric: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;NUMBER&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;STRING&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>All of our immediate values. Generally these can be passed straight
through and printed to JavaScript.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Literal: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;AlphaNumeric&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;JS&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;REGEX&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;DEBUGGER&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;UNDEFINED&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Undefined</span>
<span class="nx">o</span> <span class="s1">&#39;NULL&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Null</span>
<span class="nx">o</span> <span class="s1">&#39;BOOL&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Bool</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>Assignment of a variable, property, or index to a value.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Assign: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Assignable = Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Assign</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Assignable = TERMINATOR Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Assign</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;Assignable = INDENT Expression OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Assign</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$4</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>Assignment when it happens within an object literal. The difference from
the ordinary <strong>Assign</strong> is that these allow numbers and strings as keys.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">AssignObj: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;ObjAssignable&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;ObjAssignable : Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Assign</span> <span class="k">new</span> <span class="nx">Value</span><span class="p">(</span><span class="nx">$1</span><span class="p">),</span> <span class="nx">$3</span><span class="p">,</span> <span class="s1">&#39;object&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;ObjAssignable :</span>
<span class="s1"> INDENT Expression OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Assign</span> <span class="k">new</span> <span class="nx">Value</span><span class="p">(</span><span class="nx">$1</span><span class="p">),</span> <span class="nx">$4</span><span class="p">,</span> <span class="s1">&#39;object&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Comment&#39;</span>
<span class="p">]</span>
<span class="nv">ObjAssignable: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Identifier&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;AlphaNumeric&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;ThisProperty&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <p>A return statement from a function body.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Return: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;RETURN Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Return</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;RETURN&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Return</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-20"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-20">&#182;</a> </div> <p>A block comment.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Comment: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;HERECOMMENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Comment</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-21"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-21">&#182;</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> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Code: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;PARAM_START ParamList PARAM_END FuncGlyph Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Code</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$5</span><span class="p">,</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;FuncGlyph Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Code</span> <span class="p">[],</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-22"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-22">&#182;</a> </div> <p>CoffeeScript has two different symbols for functions. <code>-&gt;</code> is for ordinary
functions, and <code>=&gt;</code> is for functions bound to the current value of <em>this</em>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">FuncGlyph: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="s1">&#39;func&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;=&gt;&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="s1">&#39;boundfunc&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-23"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-23">&#182;</a> </div> <p>An optional, trailing comma.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">OptComma: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;,&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-24"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-24">&#182;</a> </div> <p>The list of parameters that a function accepts can be of any length.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ParamList: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[]</span>
<span class="nx">o</span> <span class="s1">&#39;Param&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="nx">$1</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;ParamList , Param&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;ParamList OptComma TERMINATOR Param&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;ParamList OptComma INDENT ParamList OptComma OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$4</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-25"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-25">&#182;</a> </div> <p>A single parameter in a function definition can be ordinary, or a splat
that hoovers up the remaining arguments.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Param: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;ParamVar&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Param</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;ParamVar ...&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Param</span> <span class="nx">$1</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">on</span>
<span class="nx">o</span> <span class="s1">&#39;ParamVar = Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Param</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-26"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-26">&#182;</a> </div> <p>Function Parameters</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ParamVar: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Identifier&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;ThisProperty&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Array&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Object&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-27"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-27">&#182;</a> </div> <p>A splat that occurs outside of a parameter list.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Splat: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Expression ...&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Splat</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-28"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-28">&#182;</a> </div> <p>Variables and properties that can be assigned to.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">SimpleAssignable: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Identifier&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;Value Accessor&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">add</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;Invocation Accessor&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span><span class="p">,</span> <span class="p">[].</span><span class="nx">concat</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;ThisProperty&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-29"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-29">&#182;</a> </div> <p>Everything that can be assigned to.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Assignable: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;SimpleAssignable&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Array&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;Object&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-30"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-30">&#182;</a> </div> <p>The types of things that can be treated as values -- assigned to, invoked
as functions, indexed into, named as a class, etc.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Value: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Assignable&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Literal&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;Parenthetical&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;Range&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;This&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-31"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-31">&#182;</a> </div> <p>The general group of accessors into an object, by property, by prototype
or by array index or slice.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Accessor: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;. Identifier&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Access</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;?. Identifier&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Access</span> <span class="nx">$2</span><span class="p">,</span> <span class="s1">&#39;soak&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;:: Identifier&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[(</span><span class="k">new</span> <span class="nx">Access</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="s1">&#39;prototype&#39;</span><span class="p">),</span> <span class="k">new</span> <span class="nx">Access</span> <span class="nx">$2</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;::&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Access</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="s1">&#39;prototype&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Index&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-32"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-32">&#182;</a> </div> <p>Indexing into an object or array using bracket notation.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Index: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;INDEX_START IndexValue INDEX_END&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;INDEX_SOAK Index&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">extend</span> <span class="nx">$2</span><span class="p">,</span> <span class="nv">soak : </span><span class="kc">yes</span>
<span class="p">]</span>
<span class="nv">IndexValue: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Index</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;Slice&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Slice</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-33"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-33">&#182;</a> </div> <p>In CoffeeScript, an object literal is simply a list of assignments.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nb">Object</span><span class="o">:</span> <span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;{ AssignList OptComma }&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Obj</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">generated</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-34"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-34">&#182;</a> </div> <p>Assignment of properties within an object literal can be separated by
comma, as in JavaScript, or simply by newline.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">AssignList: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[]</span>
<span class="nx">o</span> <span class="s1">&#39;AssignObj&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="nx">$1</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;AssignList , AssignObj&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;AssignList OptComma TERMINATOR AssignObj&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;AssignList OptComma INDENT AssignList OptComma OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$4</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-35"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-35">&#182;</a> </div> <p>Class definitions have optional bodies of prototype property assignments,
and optional references to the superclass.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Class: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;CLASS&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Class</span>
<span class="nx">o</span> <span class="s1">&#39;CLASS Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Class</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;CLASS EXTENDS Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Class</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;CLASS EXTENDS Expression Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Class</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$3</span><span class="p">,</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;CLASS SimpleAssignable&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Class</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;CLASS SimpleAssignable Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Class</span> <span class="nx">$2</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;CLASS SimpleAssignable EXTENDS Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Class</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;CLASS SimpleAssignable EXTENDS Expression Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Class</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$4</span><span class="p">,</span> <span class="nx">$5</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-36"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-36">&#182;</a> </div> <p>Ordinary function invocation, or a chained series of calls.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Invocation: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Value OptFuncExist Arguments&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Call</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;Invocation OptFuncExist Arguments&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Call</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;SUPER&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Call</span> <span class="s1">&#39;super&#39;</span><span class="p">,</span> <span class="p">[</span><span class="k">new</span> <span class="nx">Splat</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="s1">&#39;arguments&#39;</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;SUPER Arguments&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Call</span> <span class="s1">&#39;super&#39;</span><span class="p">,</span> <span class="nx">$2</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-37"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-37">&#182;</a> </div> <p>An optional existence check on a function.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">OptFuncExist: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="kc">no</span>
<span class="nx">o</span> <span class="s1">&#39;FUNC_EXIST&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="kc">yes</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-38"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-38">&#182;</a> </div> <p>The list of arguments to a function call.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Arguments: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;CALL_START CALL_END&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[]</span>
<span class="nx">o</span> <span class="s1">&#39;CALL_START ArgList OptComma CALL_END&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$2</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-39"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-39">&#182;</a> </div> <p>A reference to the <em>this</em> current object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">This: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;THIS&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="s1">&#39;this&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;@&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="k">new</span> <span class="nx">Literal</span> <span class="s1">&#39;this&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-40"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-40">&#182;</a> </div> <p>A reference to a property on <em>this</em>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ThisProperty: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;@ Identifier&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="k">new</span> <span class="nx">Literal</span><span class="p">(</span><span class="s1">&#39;this&#39;</span><span class="p">),</span> <span class="p">[</span><span class="k">new</span> <span class="nx">Access</span><span class="p">(</span><span class="nx">$2</span><span class="p">)],</span> <span class="s1">&#39;this&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-41"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-41">&#182;</a> </div> <p>The array literal.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nb">Array</span><span class="o">:</span> <span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;[ ]&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Arr</span> <span class="p">[]</span>
<span class="nx">o</span> <span class="s1">&#39;[ ArgList OptComma ]&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Arr</span> <span class="nx">$2</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-42"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-42">&#182;</a> </div> <p>Inclusive and exclusive range dots.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">RangeDots: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;..&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="s1">&#39;inclusive&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;...&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="s1">&#39;exclusive&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-43"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-43">&#182;</a> </div> <p>The CoffeeScript range literal.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Range: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;[ Expression RangeDots Expression ]&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Range</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$4</span><span class="p">,</span> <span class="nx">$3</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-44"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-44">&#182;</a> </div> <p>Array slice literals.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Slice: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Expression RangeDots Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Range</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;Expression RangeDots&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Range</span> <span class="nx">$1</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;RangeDots Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Range</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;RangeDots&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Range</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-45"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-45">&#182;</a> </div> <p>The <strong>ArgList</strong> is both the list of objects passed into a function call,
as well as the contents of an array literal
(i.e. comma-separated expressions). Newlines work as well.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ArgList: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Arg&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="nx">$1</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;ArgList , Arg&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;ArgList OptComma TERMINATOR Arg&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;INDENT ArgList OptComma OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;ArgList OptComma INDENT ArgList OptComma OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$4</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-46"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-46">&#182;</a> </div> <p>Valid arguments are Blocks or Splats.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Arg: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Expression&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Splat&#39;</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-47"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-47">&#182;</a> </div> <p>Just simple, comma-separated, required arguments (no fancy syntax). We need
this to be separate from the <strong>ArgList</strong> for use in <strong>Switch</strong> blocks, where
having the newlines wouldn't make sense.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">SimpleArgs: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Expression&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;SimpleArgs , Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[].</span><span class="nx">concat</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-48"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-48">&#182;</a> </div> <p>The variants of <em>try/catch/finally</em> exception handling blocks.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Try: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;TRY Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Try</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;TRY Block Catch&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Try</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$3</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nx">$3</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;TRY Block FINALLY Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Try</span> <span class="nx">$2</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;TRY Block Catch FINALLY Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Try</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$3</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nx">$3</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="nx">$5</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-49"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-49">&#182;</a> </div> <p>A catch clause names its error and runs a block of code.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Catch: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;CATCH Identifier Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="nx">$2</span><span class="p">,</span> <span class="nx">$3</span><span class="p">]</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-50"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-50">&#182;</a> </div> <p>Throw an exception object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Throw: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;THROW Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Throw</span> <span class="nx">$2</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-51"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-51">&#182;</a> </div> <p>Parenthetical expressions. Note that the <strong>Parenthetical</strong> is a <strong>Value</strong>,
not an <strong>Expression</strong>, so if you need to use an expression in a place
where only values are accepted, wrapping it in parentheses will always do
the trick.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Parenthetical: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;( Body )&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Parens</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;( INDENT Body OUTDENT )&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Parens</span> <span class="nx">$3</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-52"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-52">&#182;</a> </div> <p>The condition portion of a while loop.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">WhileSource: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;WHILE Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">While</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;WHILE Expression WHEN Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">While</span> <span class="nx">$2</span><span class="p">,</span> <span class="nv">guard: </span><span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;UNTIL Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">While</span> <span class="nx">$2</span><span class="p">,</span> <span class="nv">invert: </span><span class="kc">true</span>
<span class="nx">o</span> <span class="s1">&#39;UNTIL Expression WHEN Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">While</span> <span class="nx">$2</span><span class="p">,</span> <span class="nv">invert: </span><span class="kc">true</span><span class="p">,</span> <span class="nv">guard: </span><span class="nx">$4</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-53"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-53">&#182;</a> </div> <p>The while loop can either be normal, with a block of expressions to execute,
or postfix, with a single expression. There is no do..while.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">While: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;WhileSource Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">addBody</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;Statement WhileSource&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$2</span><span class="p">.</span><span class="nx">addBody</span> <span class="nx">Block</span><span class="p">.</span><span class="nx">wrap</span> <span class="p">[</span><span class="nx">$1</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;Expression WhileSource&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$2</span><span class="p">.</span><span class="nx">addBody</span> <span class="nx">Block</span><span class="p">.</span><span class="nx">wrap</span> <span class="p">[</span><span class="nx">$1</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;Loop&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span>
<span class="p">]</span>
<span class="nv">Loop: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;LOOP Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">While</span><span class="p">(</span><span class="k">new</span> <span class="nx">Literal</span> <span class="s1">&#39;true&#39;</span><span class="p">).</span><span class="nx">addBody</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;LOOP Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">While</span><span class="p">(</span><span class="k">new</span> <span class="nx">Literal</span> <span class="s1">&#39;true&#39;</span><span class="p">).</span><span class="nx">addBody</span> <span class="nx">Block</span><span class="p">.</span><span class="nx">wrap</span> <span class="p">[</span><span class="nx">$2</span><span class="p">]</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-54"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-54">&#182;</a> </div> <p>Array, object, and range comprehensions, at the most generic level.
Comprehensions can either be normal, with a block of expressions to execute,
or postfix, with a single expression.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">For: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Statement ForBody&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">For</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;Expression ForBody&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">For</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;ForBody Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">For</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span>
<span class="p">]</span>
<span class="nv">ForBody: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;FOR Range&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">source: </span><span class="k">new</span> <span class="nx">Value</span><span class="p">(</span><span class="nx">$2</span><span class="p">)</span>
<span class="nx">o</span> <span class="s1">&#39;ForStart ForSource&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">$2.own = </span><span class="nx">$1</span><span class="p">.</span><span class="nx">own</span><span class="p">;</span> <span class="nv">$2.name = </span><span class="nx">$1</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span> <span class="nv">$2.index = </span><span class="nx">$1</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span> <span class="nx">$2</span>
<span class="p">]</span>
<span class="nv">ForStart: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;FOR ForVariables&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;FOR OWN ForVariables&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">$3.own = </span><span class="kc">yes</span><span class="p">;</span> <span class="nx">$3</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-55"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-55">&#182;</a> </div> <p>An array of all accepted values for a variable inside the loop.
This enables support for pattern matching.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ForValue: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;Identifier&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;ThisProperty&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Array&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;Object&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Value</span> <span class="nx">$1</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-56"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-56">&#182;</a> </div> <p>An array or range comprehension has variables for the current element
and (optional) reference to the current index. Or, <em>key, value</em>, in the case
of object comprehensions.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ForVariables: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;ForValue&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="nx">$1</span><span class="p">]</span>
<span class="nx">o</span> <span class="s1">&#39;ForValue , ForValue&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span><span class="p">]</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-57"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-57">&#182;</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
in fixed-size increments.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ForSource: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;FORIN Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">source: </span><span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;FOROF Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">source: </span><span class="nx">$2</span><span class="p">,</span> <span class="nv">object: </span><span class="kc">yes</span>
<span class="nx">o</span> <span class="s1">&#39;FORIN Expression WHEN Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">source: </span><span class="nx">$2</span><span class="p">,</span> <span class="nv">guard: </span><span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;FOROF Expression WHEN Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">source: </span><span class="nx">$2</span><span class="p">,</span> <span class="nv">guard: </span><span class="nx">$4</span><span class="p">,</span> <span class="nv">object: </span><span class="kc">yes</span>
<span class="nx">o</span> <span class="s1">&#39;FORIN Expression BY Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">source: </span><span class="nx">$2</span><span class="p">,</span> <span class="nv">step: </span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;FORIN Expression WHEN Expression BY Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">source: </span><span class="nx">$2</span><span class="p">,</span> <span class="nv">guard: </span><span class="nx">$4</span><span class="p">,</span> <span class="nv">step: </span><span class="nx">$6</span>
<span class="nx">o</span> <span class="s1">&#39;FORIN Expression BY Expression WHEN Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nv">source: </span><span class="nx">$2</span><span class="p">,</span> <span class="nv">step: </span> <span class="nx">$4</span><span class="p">,</span> <span class="nv">guard: </span><span class="nx">$6</span>
<span class="p">]</span>
<span class="nv">Switch: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;SWITCH Expression INDENT Whens OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Switch</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$4</span>
<span class="nx">o</span> <span class="s1">&#39;SWITCH Expression INDENT Whens ELSE Block OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Switch</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$4</span><span class="p">,</span> <span class="nx">$6</span>
<span class="nx">o</span> <span class="s1">&#39;SWITCH INDENT Whens OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Switch</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;SWITCH INDENT Whens ELSE Block OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Switch</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">$3</span><span class="p">,</span> <span class="nx">$5</span>
<span class="p">]</span>
<span class="nv">Whens: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;When&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;Whens When&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">$2</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-58"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-58">&#182;</a> </div> <p>An individual <strong>When</strong> clause, with action.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">When: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;LEADING_WHEN SimpleArgs Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[[</span><span class="nx">$2</span><span class="p">,</span> <span class="nx">$3</span><span class="p">]]</span>
<span class="nx">o</span> <span class="s1">&#39;LEADING_WHEN SimpleArgs Block TERMINATOR&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="p">[[</span><span class="nx">$2</span><span class="p">,</span> <span class="nx">$3</span><span class="p">]]</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-59"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-59">&#182;</a> </div> <p>The most basic form of <em>if</em> is a condition and an action. The following
if-related rules are broken up along these lines in order to avoid
ambiguity.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">IfBlock: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;IF Expression Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">If</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$3</span><span class="p">,</span> <span class="nv">type: </span><span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;IfBlock ELSE IF Expression Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">addElse</span> <span class="k">new</span> <span class="nx">If</span> <span class="nx">$4</span><span class="p">,</span> <span class="nx">$5</span><span class="p">,</span> <span class="nv">type: </span><span class="nx">$3</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-60"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-60">&#182;</a> </div> <p>The full complement of <em>if</em> expressions, including postfix one-liner
<em>if</em> and <em>unless</em>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">If: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;IfBlock&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;IfBlock ELSE Block&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="nx">$1</span><span class="p">.</span><span class="nx">addElse</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Statement POST_IF Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">If</span> <span class="nx">$3</span><span class="p">,</span> <span class="nx">Block</span><span class="p">.</span><span class="nx">wrap</span><span class="p">([</span><span class="nx">$1</span><span class="p">]),</span> <span class="nv">type: </span><span class="nx">$2</span><span class="p">,</span> <span class="nv">statement: </span><span class="kc">true</span>
<span class="nx">o</span> <span class="s1">&#39;Expression POST_IF Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">If</span> <span class="nx">$3</span><span class="p">,</span> <span class="nx">Block</span><span class="p">.</span><span class="nx">wrap</span><span class="p">([</span><span class="nx">$1</span><span class="p">]),</span> <span class="nv">type: </span><span class="nx">$2</span><span class="p">,</span> <span class="nv">statement: </span><span class="kc">true</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-61"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-61">&#182;</a> </div> <p>Arithmetic and logical operators, working on one or more operands.
Here they are grouped by order of precedence. The actual precedence rules
are defined at the bottom of the page. It would be shorter if we could
combine most of these rules into a single generic <em>Operand OpSymbol Operand</em>
-type rule, but in order to make the precedence binding possible, separate
rules are necessary.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">Operation: </span><span class="p">[</span>
<span class="nx">o</span> <span class="s1">&#39;UNARY Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="nx">$1</span> <span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;- Expression&#39;</span><span class="p">,</span> <span class="p">(</span><span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="s1">&#39;-&#39;</span><span class="p">,</span> <span class="nx">$2</span><span class="p">),</span> <span class="nv">prec: </span><span class="s1">&#39;UNARY&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;+ Expression&#39;</span><span class="p">,</span> <span class="p">(</span><span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="s1">&#39;+&#39;</span><span class="p">,</span> <span class="nx">$2</span><span class="p">),</span> <span class="nv">prec: </span><span class="s1">&#39;UNARY&#39;</span>
<span class="nx">o</span> <span class="s1">&#39;-- SimpleAssignable&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;++ SimpleAssignable&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="s1">&#39;++&#39;</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;SimpleAssignable --&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">true</span>
<span class="nx">o</span> <span class="s1">&#39;SimpleAssignable ++&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="s1">&#39;++&#39;</span><span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="kc">true</span></pre></div> </td> </tr> <tr id="section-62"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-62">&#182;</a> </div> <p><a href="http://jashkenas.github.com/coffee-script/#existence">The existential operator</a>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">o</span> <span class="s1">&#39;Expression ?&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Existence</span> <span class="nx">$1</span>
<span class="nx">o</span> <span class="s1">&#39;Expression + Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="s1">&#39;+&#39;</span> <span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Expression - Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="s1">&#39;-&#39;</span> <span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Expression MATH Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Expression SHIFT Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Expression COMPARE Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Expression LOGIC Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Op</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;Expression RELATION Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="k">if</span> <span class="nx">$2</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;!&#39;</span>
<span class="k">new</span> <span class="nx">Op</span><span class="p">(</span><span class="nx">$2</span><span class="p">[</span><span class="mi">1</span><span class="p">..],</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span><span class="p">).</span><span class="nx">invert</span><span class="p">()</span>
<span class="k">else</span>
<span class="k">new</span> <span class="nx">Op</span> <span class="nx">$2</span><span class="p">,</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="nx">o</span> <span class="s1">&#39;SimpleAssignable COMPOUND_ASSIGN</span>
<span class="s1"> Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Assign</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;SimpleAssignable COMPOUND_ASSIGN</span>
<span class="s1"> INDENT Expression OUTDENT&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Assign</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$4</span><span class="p">,</span> <span class="nx">$2</span>
<span class="nx">o</span> <span class="s1">&#39;SimpleAssignable EXTENDS Expression&#39;</span><span class="p">,</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">Extends</span> <span class="nx">$1</span><span class="p">,</span> <span class="nx">$3</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-63"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-63">&#182;</a> </div> <h2>Precedence</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-64"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-64">&#182;</a> </div> <p>Operators at the top of this list have higher precedence than the ones lower
down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:</p>
<pre><code>2 + (3 * 4)
</code></pre>
<p>And not:</p>
<pre><code>(2 + 3) * 4
</code></pre> </td> <td class="code"> <div class="highlight"><pre><span class="nv">operators = </span><span class="p">[</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">,</span> <span class="s1">&#39;?.&#39;</span><span class="p">,</span> <span class="s1">&#39;::&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;CALL_START&#39;</span><span class="p">,</span> <span class="s1">&#39;CALL_END&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;nonassoc&#39;</span><span class="p">,</span> <span class="s1">&#39;++&#39;</span><span class="p">,</span> <span class="s1">&#39;--&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;?&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;right&#39;</span><span class="p">,</span> <span class="s1">&#39;UNARY&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;MATH&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;+&#39;</span><span class="p">,</span> <span class="s1">&#39;-&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;SHIFT&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;RELATION&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;COMPARE&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;left&#39;</span><span class="p">,</span> <span class="s1">&#39;LOGIC&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;nonassoc&#39;</span><span class="p">,</span> <span class="s1">&#39;INDENT&#39;</span><span class="p">,</span> <span class="s1">&#39;OUTDENT&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;right&#39;</span><span class="p">,</span> <span class="s1">&#39;=&#39;</span><span class="p">,</span> <span class="s1">&#39;:&#39;</span><span class="p">,</span> <span class="s1">&#39;COMPOUND_ASSIGN&#39;</span><span class="p">,</span> <span class="s1">&#39;RETURN&#39;</span><span class="p">,</span> <span class="s1">&#39;THROW&#39;</span><span class="p">,</span> <span class="s1">&#39;EXTENDS&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;right&#39;</span><span class="p">,</span> <span class="s1">&#39;FORIN&#39;</span><span class="p">,</span> <span class="s1">&#39;FOROF&#39;</span><span class="p">,</span> <span class="s1">&#39;BY&#39;</span><span class="p">,</span> <span class="s1">&#39;WHEN&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;right&#39;</span><span class="p">,</span> <span class="s1">&#39;IF&#39;</span><span class="p">,</span> <span class="s1">&#39;ELSE&#39;</span><span class="p">,</span> <span class="s1">&#39;FOR&#39;</span><span class="p">,</span> <span class="s1">&#39;WHILE&#39;</span><span class="p">,</span> <span class="s1">&#39;UNTIL&#39;</span><span class="p">,</span> <span class="s1">&#39;LOOP&#39;</span><span class="p">,</span> <span class="s1">&#39;SUPER&#39;</span><span class="p">,</span> <span class="s1">&#39;CLASS&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;right&#39;</span><span class="p">,</span> <span class="s1">&#39;POST_IF&#39;</span><span class="p">]</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-65"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-65">&#182;</a> </div> <h2>Wrapping Up</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-66"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-66">&#182;</a> </div> <p>Finally, now that we have our <strong>grammar</strong> and our <strong>operators</strong>, we can create
our <strong>Jison.Parser</strong>. We do this by processing all of our rules, recording all
terminals (every symbol which does not appear as the name of a rule above)
as "tokens".</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">tokens = </span><span class="p">[]</span>
<span class="k">for</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">alternatives</span> <span class="k">of</span> <span class="nx">grammar</span>
<span class="nx">grammar</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="k">for</span> <span class="nx">alt</span> <span class="k">in</span> <span class="nx">alternatives</span>
<span class="k">for</span> <span class="nx">token</span> <span class="k">in</span> <span class="nx">alt</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">split</span> <span class="s1">&#39; &#39;</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">push</span> <span class="nx">token</span> <span class="nx">unless</span> <span class="nx">grammar</span><span class="p">[</span><span class="nx">token</span><span class="p">]</span>
<span class="nx">alt</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;return #{alt[1]}&quot;</span> <span class="k">if</span> <span class="nx">name</span> <span class="o">is</span> <span class="s1">&#39;Root&#39;</span>
<span class="nx">alt</span></pre></div> </td> </tr> <tr id="section-67"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-67">&#182;</a> </div> <p>Initialize the <strong>Parser</strong> with our list of terminal <strong>tokens</strong>, our <strong>grammar</strong>
rules, and the name of the root. Reverse the operators because Jison orders
precedence from low to high, and we have it high to low
(as in <a href="http://dinosaur.compilertools.net/yacc/index.html">Yacc</a>).</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.parser = </span><span class="k">new</span> <span class="nx">Parser</span>
<span class="nv">tokens : </span><span class="nx">tokens</span><span class="p">.</span><span class="nx">join</span> <span class="s1">&#39; &#39;</span>
<span class="nv">bnf : </span><span class="nx">grammar</span>
<span class="nv">operators : </span><span class="nx">operators</span><span class="p">.</span><span class="nx">reverse</span><span class="p">()</span>
<span class="nv">startSymbol : </span><span class="s1">&#39;Root&#39;</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,31 +0,0 @@
<!DOCTYPE html> <html> <head> <title>helpers.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> helpers.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>This file contains the common helper functions that we'd like to share among
the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten
arrays, count characters, that sort of thing.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Peek at the beginning of a given string to see if it matches a sequence.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.starts = </span><span class="nf">(string, literal, start) -&gt;</span>
<span class="nx">literal</span> <span class="o">is</span> <span class="nx">string</span><span class="p">.</span><span class="nx">substr</span> <span class="nx">start</span><span class="p">,</span> <span class="nx">literal</span><span class="p">.</span><span class="nx">length</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Peek at the end of a given string to see if it matches a sequence.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.ends = </span><span class="nf">(string, literal, back) -&gt;</span>
<span class="nv">len = </span><span class="nx">literal</span><span class="p">.</span><span class="nx">length</span>
<span class="nx">literal</span> <span class="o">is</span> <span class="nx">string</span><span class="p">.</span><span class="nx">substr</span> <span class="nx">string</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="nx">len</span> <span class="o">-</span> <span class="p">(</span><span class="nx">back</span> <span class="o">or</span> <span class="mi">0</span><span class="p">),</span> <span class="nx">len</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Trim out all falsy values from an array.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.compact = </span><span class="nf">(array) -&gt;</span>
<span class="nx">item</span> <span class="k">for</span> <span class="nx">item</span> <span class="k">in</span> <span class="nx">array</span> <span class="k">when</span> <span class="nx">item</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Count the number of occurrences of a string in a string.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.count = </span><span class="nf">(string, substr) -&gt;</span>
<span class="nv">num = pos = </span><span class="mi">0</span>
<span class="k">return</span> <span class="mi">1</span><span class="o">/</span><span class="mi">0</span> <span class="nx">unless</span> <span class="nx">substr</span><span class="p">.</span><span class="nx">length</span>
<span class="nx">num</span><span class="o">++</span> <span class="k">while</span> <span class="nv">pos = </span><span class="mi">1</span> <span class="o">+</span> <span class="nx">string</span><span class="p">.</span><span class="nx">indexOf</span> <span class="nx">substr</span><span class="p">,</span> <span class="nx">pos</span>
<span class="nx">num</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Merge objects, returning a fresh copy with attributes from both sides.
Used every time <code>Base#compile</code> is called, to allow properties in the
options hash to propagate down the tree without polluting other branches.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.merge = </span><span class="nf">(options, overrides) -&gt;</span>
<span class="nx">extend</span> <span class="p">(</span><span class="nx">extend</span> <span class="p">{},</span> <span class="nx">options</span><span class="p">),</span> <span class="nx">overrides</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Extend a source object with the properties of another object (shallow copy).</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">extend = exports.extend = </span><span class="nf">(object, properties) -&gt;</span>
<span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span> <span class="k">of</span> <span class="nx">properties</span>
<span class="nx">object</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">val</span>
<span class="nx">object</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Return a flattened version of an array.
Handy for getting a list of <code>children</code> from the nodes.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.flatten = flatten = </span><span class="nf">(array) -&gt;</span>
<span class="nv">flattened = </span><span class="p">[]</span>
<span class="k">for</span> <span class="nx">element</span> <span class="k">in</span> <span class="nx">array</span>
<span class="k">if</span> <span class="nx">element</span> <span class="k">instanceof</span> <span class="nb">Array</span>
<span class="nv">flattened = </span><span class="nx">flattened</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">flatten</span> <span class="nx">element</span>
<span class="k">else</span>
<span class="nx">flattened</span><span class="p">.</span><span class="nx">push</span> <span class="nx">element</span>
<span class="nx">flattened</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Delete a key from an object, returning the value. Useful when a node is
looking for a particular method in an options hash.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.del = </span><span class="nf">(obj, key) -&gt;</span>
<span class="nv">val = </span> <span class="nx">obj</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span>
<span class="k">delete</span> <span class="nx">obj</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span>
<span class="nx">val</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Gets the last item of an array(-like) object.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.last = </span><span class="nf">(array, back) -&gt;</span> <span class="nx">array</span><span class="p">[</span><span class="nx">array</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="p">(</span><span class="nx">back</span> <span class="o">or</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,3 +0,0 @@
<!DOCTYPE html> <html> <head> <title>index.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> index.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>Loader for CoffeeScript as a Node.js library.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">val</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span> <span class="k">of</span> <span class="nx">require</span> <span class="s1">&#39;./coffee-script&#39;</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,87 +0,0 @@
<!DOCTYPE html> <html> <head> <title>optparse.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> optparse.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
Use it like so:</p>
<pre><code>parser = new OptionParser switches, helpBanner
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> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.OptionParser = </span><span class="k">class</span> <span class="nx">OptionParser</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Initialize with a list of valid options, in the form:</p>
<pre><code>[short-flag, long-flag, description]
</code></pre>
<p>Along with an an optional banner for the usage help.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">constructor: </span><span class="nf">(rules, @banner) -&gt;</span>
<span class="vi">@rules = </span><span class="nx">buildRules</span> <span class="nx">rules</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Parse the list of arguments, populating an <code>options</code> object with all of the
specified options, and return it. Options after the first non-option
argument are treated as arguments. <code>options.arguments</code> will be an array
containing the remaining arguments. This is a simpler API than many option
parsers that allow you to attach callback actions for every flag. Instead,
you're responsible for interpreting the options object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">parse: </span><span class="nf">(args) -&gt;</span>
<span class="nv">options = arguments: </span><span class="p">[]</span>
<span class="nv">skippingArgument = </span><span class="kc">no</span>
<span class="nv">originalArgs = </span><span class="nx">args</span>
<span class="nv">args = </span><span class="nx">normalizeArguments</span> <span class="nx">args</span>
<span class="k">for</span> <span class="nx">arg</span><span class="p">,</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">args</span>
<span class="k">if</span> <span class="nx">skippingArgument</span>
<span class="nv">skippingArgument = </span><span class="kc">no</span>
<span class="k">continue</span>
<span class="k">if</span> <span class="nx">arg</span> <span class="o">is</span> <span class="s1">&#39;--&#39;</span>
<span class="nv">pos = </span><span class="nx">originalArgs</span><span class="p">.</span><span class="nx">indexOf</span> <span class="s1">&#39;--&#39;</span>
<span class="nv">options.arguments = </span><span class="nx">options</span><span class="p">.</span><span class="nx">arguments</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">originalArgs</span><span class="p">[(</span><span class="nx">pos</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)..]</span>
<span class="k">break</span>
<span class="nv">isOption = </span><span class="o">!!</span><span class="p">(</span><span class="nx">arg</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">LONG_FLAG</span><span class="p">)</span> <span class="o">or</span> <span class="nx">arg</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">SHORT_FLAG</span><span class="p">))</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>the CS option parser is a little odd; options after the first
non-option argument are treated as non-option arguments themselves</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">seenNonOptionArg = </span><span class="nx">options</span><span class="p">.</span><span class="nx">arguments</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span>
<span class="nx">unless</span> <span class="nx">seenNonOptionArg</span>
<span class="nv">matchedRule = </span><span class="kc">no</span>
<span class="k">for</span> <span class="nx">rule</span> <span class="k">in</span> <span class="nx">@rules</span>
<span class="k">if</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">shortFlag</span> <span class="o">is</span> <span class="nx">arg</span> <span class="o">or</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">longFlag</span> <span class="o">is</span> <span class="nx">arg</span>
<span class="nv">value = </span><span class="kc">true</span>
<span class="k">if</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">hasArgument</span>
<span class="nv">skippingArgument = </span><span class="kc">yes</span>
<span class="nv">value = </span><span class="nx">args</span><span class="p">[</span><span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span>
<span class="nx">options</span><span class="p">[</span><span class="nx">rule</span><span class="p">.</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="k">if</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">isList</span> <span class="k">then</span> <span class="p">(</span><span class="nx">options</span><span class="p">[</span><span class="nx">rule</span><span class="p">.</span><span class="nx">name</span><span class="p">]</span> <span class="o">or</span> <span class="p">[]).</span><span class="nx">concat</span> <span class="nx">value</span> <span class="k">else</span> <span class="nx">value</span>
<span class="nv">matchedRule = </span><span class="kc">yes</span>
<span class="k">break</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s2">&quot;unrecognized option: #{arg}&quot;</span> <span class="k">if</span> <span class="nx">isOption</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">matchedRule</span>
<span class="k">if</span> <span class="nx">seenNonOptionArg</span> <span class="o">or</span> <span class="o">not</span> <span class="nx">isOption</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">arguments</span><span class="p">.</span><span class="nx">push</span> <span class="nx">arg</span>
<span class="nx">options</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Return the help text for this <strong>OptionParser</strong>, listing and describing all
of the valid options, for <code>--help</code> and such.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">help: </span><span class="o">-&gt;</span>
<span class="nv">lines = </span><span class="p">[]</span>
<span class="nx">lines</span><span class="p">.</span><span class="nx">unshift</span> <span class="s2">&quot;#{@banner}\n&quot;</span> <span class="k">if</span> <span class="nx">@banner</span>
<span class="k">for</span> <span class="nx">rule</span> <span class="k">in</span> <span class="nx">@rules</span>
<span class="nv">spaces = </span><span class="mi">15</span> <span class="o">-</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">longFlag</span><span class="p">.</span><span class="nx">length</span>
<span class="nv">spaces = </span><span class="k">if</span> <span class="nx">spaces</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="k">then</span> <span class="nb">Array</span><span class="p">(</span><span class="nx">spaces</span> <span class="o">+</span> <span class="mi">1</span><span class="p">).</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
<span class="nv">letPart = </span><span class="k">if</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">shortFlag</span> <span class="k">then</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">shortFlag</span> <span class="o">+</span> <span class="s1">&#39;, &#39;</span> <span class="k">else</span> <span class="s1">&#39; &#39;</span>
<span class="nx">lines</span><span class="p">.</span><span class="nx">push</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nx">letPart</span> <span class="o">+</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">longFlag</span> <span class="o">+</span> <span class="nx">spaces</span> <span class="o">+</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">description</span>
<span class="s2">&quot;\n#{ lines.join(&#39;\n&#39;) }\n&quot;</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h2>Helpers</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Regex matchers for option flags.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">LONG_FLAG = </span><span class="sr">/^(--\w[\w\-]*)/</span>
<span class="nv">SHORT_FLAG = </span><span class="sr">/^(-\w)$/</span>
<span class="nv">MULTI_FLAG = </span><span class="sr">/^-(\w{2,})/</span>
<span class="nv">OPTIONAL = </span><span class="sr">/\[(\w+(\*?))\]/</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Build and return the list of option rules. If the optional <em>short-flag</em> is
unspecified, leave it out by padding with <code>null</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">buildRules = </span><span class="nf">(rules) -&gt;</span>
<span class="k">for</span> <span class="nx">tuple</span> <span class="k">in</span> <span class="nx">rules</span>
<span class="nx">tuple</span><span class="p">.</span><span class="nx">unshift</span> <span class="kc">null</span> <span class="k">if</span> <span class="nx">tuple</span><span class="p">.</span><span class="nx">length</span> <span class="o">&lt;</span> <span class="mi">3</span>
<span class="nx">buildRule</span> <span class="nx">tuple</span><span class="p">...</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Build a rule from a <code>-o</code> short flag, a <code>--output [DIR]</code> long flag, and the
description of what the option does.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">buildRule = </span><span class="nf">(shortFlag, longFlag, description, options = {}) -&gt;</span>
<span class="nv">match = </span><span class="nx">longFlag</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">OPTIONAL</span><span class="p">)</span>
<span class="nv">longFlag = </span><span class="nx">longFlag</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">LONG_FLAG</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="p">{</span>
<span class="nv">name: </span> <span class="nx">longFlag</span><span class="p">.</span><span class="nx">substr</span> <span class="mi">2</span>
<span class="nv">shortFlag: </span> <span class="nx">shortFlag</span>
<span class="nv">longFlag: </span> <span class="nx">longFlag</span>
<span class="nv">description: </span> <span class="nx">description</span>
<span class="nv">hasArgument: </span> <span class="o">!!</span><span class="p">(</span><span class="nx">match</span> <span class="o">and</span> <span class="nx">match</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
<span class="nv">isList: </span> <span class="o">!!</span><span class="p">(</span><span class="nx">match</span> <span class="o">and</span> <span class="nx">match</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Normalize arguments by expanding merged flags into multiple flags. This allows
you to have <code>-wl</code> be the same as <code>--watch --lint</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">normalizeArguments = </span><span class="nf">(args) -&gt;</span>
<span class="nv">args = </span><span class="nx">args</span><span class="p">[..]</span>
<span class="nv">result = </span><span class="p">[]</span>
<span class="k">for</span> <span class="nx">arg</span> <span class="k">in</span> <span class="nx">args</span>
<span class="k">if</span> <span class="nv">match = </span><span class="nx">arg</span><span class="p">.</span><span class="nx">match</span> <span class="nx">MULTI_FLAG</span>
<span class="nx">result</span><span class="p">.</span><span class="nx">push</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span> <span class="nx">l</span> <span class="k">for</span> <span class="nx">l</span> <span class="k">in</span> <span class="nx">match</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nx">split</span> <span class="s1">&#39;&#39;</span>
<span class="k">else</span>
<span class="nx">result</span><span class="p">.</span><span class="nx">push</span> <span class="nx">arg</span>
<span class="nx">result</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,138 +0,0 @@
<!DOCTYPE html> <html> <head> <title>repl.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> repl.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>A very simple Read-Eval-Print-Loop. Compiles one line at a time to JavaScript
and evaluates it. Good for simple tests, or poking around the <strong>Node.js</strong> API.
Using it looks like this:</p>
<pre><code>coffee&gt; console.log "#{num} bottles of beer" for num in [99..1]
</code></pre> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Start by opening up <code>stdin</code> and <code>stdout</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">stdin = </span><span class="nx">process</span><span class="p">.</span><span class="nx">openStdin</span><span class="p">()</span>
<span class="nv">stdout = </span><span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Require the <strong>coffee-script</strong> module to get access to the compiler.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">CoffeeScript = </span><span class="nx">require</span> <span class="s1">&#39;./coffee-script&#39;</span>
<span class="nv">readline = </span><span class="nx">require</span> <span class="s1">&#39;readline&#39;</span>
<span class="p">{</span><span class="nx">inspect</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;util&#39;</span>
<span class="p">{</span><span class="nx">Script</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;vm&#39;</span>
<span class="nv">Module = </span><span class="nx">require</span> <span class="s1">&#39;module&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>REPL Setup</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Config</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">REPL_PROMPT = </span><span class="s1">&#39;coffee&gt; &#39;</span>
<span class="nv">REPL_PROMPT_MULTILINE = </span><span class="s1">&#39;------&gt; &#39;</span>
<span class="nv">REPL_PROMPT_CONTINUATION = </span><span class="s1">&#39;......&gt; &#39;</span>
<span class="nv">enableColours = </span><span class="kc">no</span>
<span class="nx">unless</span> <span class="nx">process</span><span class="p">.</span><span class="nx">platform</span> <span class="o">is</span> <span class="s1">&#39;win32&#39;</span>
<span class="nv">enableColours = </span><span class="o">not</span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">NODE_DISABLE_COLORS</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Log an error.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">error = </span><span class="nf">(err) -&gt;</span>
<span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span> <span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">stack</span> <span class="o">or</span> <span class="nx">err</span><span class="p">.</span><span class="nx">toString</span><span class="p">())</span> <span class="o">+</span> <span class="s1">&#39;\n&#39;</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h1>Autocompletion</h1> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Regexes to match complete-able bits of text.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">ACCESSOR = </span><span class="sr">/\s*([\w\.]+)(?:\.(\w*))$/</span>
<span class="nv">SIMPLEVAR = </span><span class="sr">/(\w+)$/i</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Returns a list of completions, and the completed text.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">autocomplete = </span><span class="nf">(text) -&gt;</span>
<span class="nx">completeAttribute</span><span class="p">(</span><span class="nx">text</span><span class="p">)</span> <span class="o">or</span> <span class="nx">completeVariable</span><span class="p">(</span><span class="nx">text</span><span class="p">)</span> <span class="o">or</span> <span class="p">[[],</span> <span class="nx">text</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Attempt to autocomplete a chained dotted attribute: <code>one.two.three</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">completeAttribute = </span><span class="nf">(text) -&gt;</span>
<span class="k">if</span> <span class="nv">match = </span><span class="nx">text</span><span class="p">.</span><span class="nx">match</span> <span class="nx">ACCESSOR</span>
<span class="p">[</span><span class="nx">all</span><span class="p">,</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">prefix</span><span class="p">]</span> <span class="o">=</span> <span class="nx">match</span>
<span class="k">try</span>
<span class="nv">val = </span><span class="nx">Script</span><span class="p">.</span><span class="nx">runInThisContext</span> <span class="nx">obj</span>
<span class="k">catch</span> <span class="nx">error</span>
<span class="k">return</span>
<span class="nv">val = </span><span class="nb">Object</span> <span class="nx">val</span>
<span class="nv">possibilities = </span><span class="nb">Object</span><span class="p">.</span><span class="nx">getOwnPropertyNames</span> <span class="nx">val</span>
<span class="k">for</span> <span class="nx">key</span> <span class="k">of</span> <span class="nx">val</span> <span class="k">when</span> <span class="o">~</span><span class="nx">possibilities</span><span class="p">.</span><span class="nx">indexOf</span> <span class="nx">val</span>
<span class="nx">possibilities</span><span class="p">.</span><span class="nx">push</span> <span class="nx">key</span>
<span class="nv">completions = </span><span class="nx">getCompletions</span> <span class="nx">prefix</span><span class="p">,</span> <span class="nx">possibilities</span>
<span class="p">[</span><span class="nx">completions</span><span class="p">,</span> <span class="nx">prefix</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Attempt to autocomplete an in-scope free variable: <code>one</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">completeVariable = </span><span class="nf">(text) -&gt;</span>
<span class="nv">free = </span><span class="nx">text</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="nx">SIMPLEVAR</span><span class="p">)</span><span class="o">?</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="nv">free = </span><span class="s2">&quot;&quot;</span> <span class="k">if</span> <span class="nx">text</span> <span class="o">is</span> <span class="s2">&quot;&quot;</span>
<span class="k">if</span> <span class="nx">free</span><span class="o">?</span>
<span class="nv">vars = </span><span class="nx">Script</span><span class="p">.</span><span class="nx">runInThisContext</span> <span class="s1">&#39;Object.getOwnPropertyNames(Object(this))&#39;</span>
<span class="nv">keywords = </span><span class="p">(</span><span class="nx">r</span> <span class="k">for</span> <span class="nx">r</span> <span class="k">in</span> <span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">RESERVED</span> <span class="k">when</span> <span class="nx">r</span><span class="p">[..</span><span class="mi">1</span><span class="p">]</span> <span class="o">isnt</span> <span class="s1">&#39;__&#39;</span><span class="p">)</span>
<span class="nv">possibilities = </span><span class="nx">vars</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">keywords</span>
<span class="nv">completions = </span><span class="nx">getCompletions</span> <span class="nx">free</span><span class="p">,</span> <span class="nx">possibilities</span>
<span class="p">[</span><span class="nx">completions</span><span class="p">,</span> <span class="nx">free</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>Return elements of candidates for which <code>prefix</code> is a prefix.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">getCompletions = </span><span class="nf">(prefix, candidates) -&gt;</span>
<span class="p">(</span><span class="nx">el</span> <span class="k">for</span> <span class="nx">el</span> <span class="k">in</span> <span class="nx">candidates</span> <span class="k">when</span> <span class="nx">el</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">prefix</span><span class="p">)</span> <span class="o">is</span> <span class="mi">0</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>Make sure that uncaught exceptions don't kill the REPL.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">process</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;uncaughtException&#39;</span><span class="p">,</span> <span class="nx">error</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>The current backlog of multi-line code.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">backlog = </span><span class="s1">&#39;&#39;</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>The main REPL function. <strong>run</strong> is called every time a line of code is entered.
Attempt to evaluate the command. If there's an exception, print it out instead
of exiting.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">run = </span><span class="nf">(buffer) -&gt;</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>remove single-line comments</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">buffer = </span><span class="nx">buffer</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/</span><span class="p">,</span> <span class="s2">&quot;$1$2$3&quot;</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>remove trailing newlines</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">buffer = </span><span class="nx">buffer</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/[\r\n]+$/</span><span class="p">,</span> <span class="s2">&quot;&quot;</span>
<span class="k">if</span> <span class="nx">multilineMode</span>
<span class="nx">backlog</span> <span class="o">+=</span> <span class="s2">&quot;#{buffer}\n&quot;</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="nx">REPL_PROMPT_CONTINUATION</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">()</span>
<span class="k">return</span>
<span class="k">if</span> <span class="o">!</span><span class="nx">buffer</span><span class="p">.</span><span class="nx">toString</span><span class="p">().</span><span class="nx">trim</span><span class="p">()</span> <span class="o">and</span> <span class="o">!</span><span class="nx">backlog</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">()</span>
<span class="k">return</span>
<span class="nv">code = </span><span class="nx">backlog</span> <span class="o">+=</span> <span class="nx">buffer</span>
<span class="k">if</span> <span class="nx">code</span><span class="p">[</span><span class="nx">code</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;\\&#39;</span>
<span class="nv">backlog = </span><span class="s2">&quot;#{backlog[...-1]}\n&quot;</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="nx">REPL_PROMPT_CONTINUATION</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">()</span>
<span class="k">return</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="nx">REPL_PROMPT</span>
<span class="nv">backlog = </span><span class="s1">&#39;&#39;</span>
<span class="k">try</span>
<span class="nv">_ = </span><span class="nx">global</span><span class="p">.</span><span class="nx">_</span>
<span class="nv">returnValue = </span><span class="nx">CoffeeScript</span><span class="p">.</span><span class="nb">eval</span> <span class="s2">&quot;_=(#{code}\n)&quot;</span><span class="p">,</span> <span class="p">{</span>
<span class="nv">filename: </span><span class="s1">&#39;repl&#39;</span>
<span class="nv">modulename: </span><span class="s1">&#39;repl&#39;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="nx">returnValue</span> <span class="o">is</span> <span class="kc">undefined</span>
<span class="nv">global._ = </span><span class="nx">_</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">write</span> <span class="s2">&quot;#{inspect returnValue, no, 2, enableColours}\n&quot;</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="nx">error</span> <span class="nx">err</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">()</span>
<span class="k">if</span> <span class="nx">stdin</span><span class="p">.</span><span class="nx">readable</span></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>handle piped input</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">pipedInput = </span><span class="s1">&#39;&#39;</span>
<span class="nv">repl =</span>
<span class="nv">prompt: </span><span class="o">-&gt;</span> <span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span> <span class="nx">@_prompt</span>
<span class="nv">setPrompt: </span><span class="nf">(p) -&gt;</span> <span class="vi">@_prompt = </span><span class="nx">p</span>
<span class="nv">input: </span><span class="nx">stdin</span>
<span class="nv">output: </span><span class="nx">stdout</span>
<span class="kc">on</span><span class="o">:</span> <span class="o">-&gt;</span>
<span class="nx">stdin</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nf">(chunk) -&gt;</span>
<span class="nx">pipedInput</span> <span class="o">+=</span> <span class="nx">chunk</span>
<span class="k">return</span> <span class="nx">unless</span> <span class="sr">/\n/</span><span class="p">.</span><span class="nx">test</span> <span class="nx">pipedInput</span>
<span class="nv">lines = </span><span class="nx">pipedInput</span><span class="p">.</span><span class="nx">split</span> <span class="s2">&quot;\n&quot;</span>
<span class="nv">pipedInput = </span><span class="nx">lines</span><span class="p">[</span><span class="nx">lines</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
<span class="k">for</span> <span class="nx">line</span> <span class="k">in</span> <span class="nx">lines</span><span class="p">[...</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">when</span> <span class="nx">line</span>
<span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span> <span class="s2">&quot;#{line}\n&quot;</span>
<span class="nx">run</span> <span class="nx">line</span>
<span class="k">return</span>
<span class="nx">stdin</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;end&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="k">for</span> <span class="nx">line</span> <span class="k">in</span> <span class="nx">pipedInput</span><span class="p">.</span><span class="nx">trim</span><span class="p">().</span><span class="nx">split</span> <span class="s2">&quot;\n&quot;</span> <span class="k">when</span> <span class="nx">line</span>
<span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span> <span class="s2">&quot;#{line}\n&quot;</span>
<span class="nx">run</span> <span class="nx">line</span>
<span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span> <span class="s1">&#39;\n&#39;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">exit</span> <span class="mi">0</span>
<span class="k">else</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <p>Create the REPL by listening to <strong>stdin</strong>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="nx">readline</span><span class="p">.</span><span class="nx">createInterface</span><span class="p">.</span><span class="nx">length</span> <span class="o">&lt;</span> <span class="mi">3</span>
<span class="nv">repl = </span><span class="nx">readline</span><span class="p">.</span><span class="nx">createInterface</span> <span class="nx">stdin</span><span class="p">,</span> <span class="nx">autocomplete</span>
<span class="nx">stdin</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nf">(buffer) -&gt;</span> <span class="nx">repl</span><span class="p">.</span><span class="nx">write</span> <span class="nx">buffer</span>
<span class="k">else</span>
<span class="nv">repl = </span><span class="nx">readline</span><span class="p">.</span><span class="nx">createInterface</span> <span class="nx">stdin</span><span class="p">,</span> <span class="nx">stdout</span><span class="p">,</span> <span class="nx">autocomplete</span>
<span class="nv">multilineMode = </span><span class="kc">off</span></pre></div> </td> </tr> <tr id="section-20"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-20">&#182;</a> </div> <p>Handle multi-line mode switch</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">repl</span><span class="p">.</span><span class="nx">input</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;keypress&#39;</span><span class="p">,</span> <span class="nf">(char, key) -&gt;</span></pre></div> </td> </tr> <tr id="section-21"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-21">&#182;</a> </div> <p>test for Ctrl-v</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="nx">unless</span> <span class="nx">key</span> <span class="o">and</span> <span class="nx">key</span><span class="p">.</span><span class="nx">ctrl</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">key</span><span class="p">.</span><span class="nx">meta</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">key</span><span class="p">.</span><span class="nx">shift</span> <span class="o">and</span> <span class="nx">key</span><span class="p">.</span><span class="nx">name</span> <span class="o">is</span> <span class="s1">&#39;v&#39;</span>
<span class="nv">cursorPos = </span><span class="nx">repl</span><span class="p">.</span><span class="nx">cursor</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">cursorTo</span> <span class="mi">0</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">clearLine</span> <span class="mi">1</span>
<span class="nv">multilineMode = </span><span class="o">not</span> <span class="nx">multilineMode</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">_line</span><span class="p">()</span> <span class="k">if</span> <span class="o">not</span> <span class="nx">multilineMode</span> <span class="o">and</span> <span class="nx">backlog</span>
<span class="nv">backlog = </span><span class="s1">&#39;&#39;</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="p">(</span><span class="nv">newPrompt = </span><span class="k">if</span> <span class="nx">multilineMode</span> <span class="k">then</span> <span class="nx">REPL_PROMPT_MULTILINE</span> <span class="k">else</span> <span class="nx">REPL_PROMPT</span><span class="p">)</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">()</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">cursorTo</span> <span class="nx">newPrompt</span><span class="p">.</span><span class="nx">length</span> <span class="o">+</span> <span class="p">(</span><span class="nv">repl.cursor = </span><span class="nx">cursorPos</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-22"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-22">&#182;</a> </div> <p>Handle Ctrl-d press at end of last line in multiline mode</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">repl</span><span class="p">.</span><span class="nx">input</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;keypress&#39;</span><span class="p">,</span> <span class="nf">(char, key) -&gt;</span>
<span class="k">return</span> <span class="nx">unless</span> <span class="nx">multilineMode</span> <span class="o">and</span> <span class="nx">repl</span><span class="p">.</span><span class="nx">line</span></pre></div> </td> </tr> <tr id="section-23"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-23">&#182;</a> </div> <p>test for Ctrl-d</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="nx">unless</span> <span class="nx">key</span> <span class="o">and</span> <span class="nx">key</span><span class="p">.</span><span class="nx">ctrl</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">key</span><span class="p">.</span><span class="nx">meta</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">key</span><span class="p">.</span><span class="nx">shift</span> <span class="o">and</span> <span class="nx">key</span><span class="p">.</span><span class="nx">name</span> <span class="o">is</span> <span class="s1">&#39;d&#39;</span>
<span class="nv">multilineMode = </span><span class="kc">off</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">_line</span><span class="p">()</span>
<span class="nx">repl</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;attemptClose&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="k">if</span> <span class="nx">multilineMode</span>
<span class="nv">multilineMode = </span><span class="kc">off</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">cursorTo</span> <span class="mi">0</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">clearLine</span> <span class="mi">1</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">_onLine</span> <span class="nx">repl</span><span class="p">.</span><span class="nx">line</span>
<span class="k">return</span>
<span class="k">if</span> <span class="nx">backlog</span>
<span class="nv">backlog = </span><span class="s1">&#39;&#39;</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">write</span> <span class="s1">&#39;\n&#39;</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="nx">REPL_PROMPT</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">()</span>
<span class="k">else</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">close</span><span class="p">()</span>
<span class="nx">repl</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;close&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">write</span> <span class="s1">&#39;\n&#39;</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">input</span><span class="p">.</span><span class="nx">destroy</span><span class="p">()</span>
<span class="nx">repl</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;line&#39;</span><span class="p">,</span> <span class="nx">run</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="nx">REPL_PROMPT</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">()</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,243 +0,0 @@
<!DOCTYPE html> <html> <head> <title>rewriter.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> rewriter.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>The CoffeeScript language has a good deal of optional syntax, implicit syntax,
and shorthand syntax. This can greatly complicate a grammar and bloat
the resulting parse table. Instead of making the parser handle it all, we take
a series of passes over the token stream, using this <strong>Rewriter</strong> to convert
shorthand into the unambiguous long form, add implicit indentation and
parentheses, and generally clean things up.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>The <strong>Rewriter</strong> class is used by the <a href="lexer.html">Lexer</a>, directly against
its internal array of tokens.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Rewriter</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Helpful snippet for debugging:
console.log (t[0] + '/' + t[1] for t in @tokens).join ' '</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Rewrite the token stream in multiple passes, one logical filter at
a time. This could certainly be changed into a single pass through the
stream, with a big ol' efficient switch, but it's much nicer to work with
like this. The order of these passes matters -- indentation must be
corrected before implicit parentheses can be wrapped around blocks of code.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">rewrite: </span><span class="nf">(@tokens) -&gt;</span>
<span class="nx">@removeLeadingNewlines</span><span class="p">()</span>
<span class="nx">@removeMidExpressionNewlines</span><span class="p">()</span>
<span class="nx">@closeOpenCalls</span><span class="p">()</span>
<span class="nx">@closeOpenIndexes</span><span class="p">()</span>
<span class="nx">@addImplicitIndentation</span><span class="p">()</span>
<span class="nx">@tagPostfixConditionals</span><span class="p">()</span>
<span class="nx">@addImplicitBraces</span><span class="p">()</span>
<span class="nx">@addImplicitParentheses</span><span class="p">()</span>
<span class="nx">@tokens</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Rewrite the token stream, looking one token ahead and behind.
Allow the return value of the block to tell us how many tokens to move
forwards (or backwards) in the stream, to make sure we don't miss anything
as tokens are inserted and removed, and the stream changes length under
our feet.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">scanTokens: </span><span class="nf">(block) -&gt;</span>
<span class="p">{</span><span class="nx">tokens</span><span class="p">}</span> <span class="o">=</span> <span class="k">this</span>
<span class="nv">i = </span><span class="mi">0</span>
<span class="nx">i</span> <span class="o">+=</span> <span class="nx">block</span><span class="p">.</span><span class="nx">call</span> <span class="k">this</span><span class="p">,</span> <span class="nx">token</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">tokens</span> <span class="k">while</span> <span class="nv">token = </span><span class="nx">tokens</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span>
<span class="kc">true</span>
<span class="nv">detectEnd: </span><span class="nf">(i, condition, action) -&gt;</span>
<span class="p">{</span><span class="nx">tokens</span><span class="p">}</span> <span class="o">=</span> <span class="k">this</span>
<span class="nv">levels = </span><span class="mi">0</span>
<span class="k">while</span> <span class="nv">token = </span><span class="nx">tokens</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span>
<span class="k">return</span> <span class="nx">action</span><span class="p">.</span><span class="nx">call</span> <span class="k">this</span><span class="p">,</span> <span class="nx">token</span><span class="p">,</span> <span class="nx">i</span> <span class="k">if</span> <span class="nx">levels</span> <span class="o">is</span> <span class="mi">0</span> <span class="o">and</span> <span class="nx">condition</span><span class="p">.</span><span class="nx">call</span> <span class="k">this</span><span class="p">,</span> <span class="nx">token</span><span class="p">,</span> <span class="nx">i</span>
<span class="k">return</span> <span class="nx">action</span><span class="p">.</span><span class="nx">call</span> <span class="k">this</span><span class="p">,</span> <span class="nx">token</span><span class="p">,</span> <span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span> <span class="k">if</span> <span class="o">not</span> <span class="nx">token</span> <span class="o">or</span> <span class="nx">levels</span> <span class="o">&lt;</span> <span class="mi">0</span>
<span class="k">if</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">in</span> <span class="nx">EXPRESSION_START</span>
<span class="nx">levels</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">in</span> <span class="nx">EXPRESSION_END</span>
<span class="nx">levels</span> <span class="o">-=</span> <span class="mi">1</span>
<span class="nx">i</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Leading newlines would introduce an ambiguity in the grammar, so we
dispatch them here.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">removeLeadingNewlines: </span><span class="o">-&gt;</span>
<span class="k">break</span> <span class="k">for</span> <span class="p">[</span><span class="nx">tag</span><span class="p">],</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">@tokens</span> <span class="k">when</span> <span class="nx">tag</span> <span class="o">isnt</span> <span class="s1">&#39;TERMINATOR&#39;</span>
<span class="nx">@tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">i</span> <span class="k">if</span> <span class="nx">i</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Some blocks occur in the middle of expressions -- when we're expecting
this, remove their trailing newlines.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">removeMidExpressionNewlines: </span><span class="o">-&gt;</span>
<span class="nx">@scanTokens</span> <span class="nf">(token, i, tokens) -&gt;</span>
<span class="k">return</span> <span class="mi">1</span> <span class="nx">unless</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;TERMINATOR&#39;</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="k">in</span> <span class="nx">EXPRESSION_CLOSE</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span><span class="p">,</span> <span class="mi">1</span>
<span class="mi">0</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>The lexer has tagged the opening parenthesis of a method call. Match it with
its paired close. We have the mis-nested outdent case included here for
calls that close on the same line, just before their outdent.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">closeOpenCalls: </span><span class="o">-&gt;</span>
<span class="nv">condition = </span><span class="nf">(token, i) -&gt;</span>
<span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;)&#39;</span><span class="p">,</span> <span class="s1">&#39;CALL_END&#39;</span><span class="p">]</span> <span class="o">or</span>
<span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;OUTDENT&#39;</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;)&#39;</span>
<span class="nv">action = </span><span class="nf">(token, i) -&gt;</span>
<span class="nx">@tokens</span><span class="p">[</span><span class="k">if</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;OUTDENT&#39;</span> <span class="k">then</span> <span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span> <span class="k">else</span> <span class="nx">i</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;CALL_END&#39;</span>
<span class="nx">@scanTokens</span> <span class="nf">(token, i) -&gt;</span>
<span class="nx">@detectEnd</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">condition</span><span class="p">,</span> <span class="nx">action</span> <span class="k">if</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;CALL_START&#39;</span>
<span class="mi">1</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>The lexer has tagged the opening parenthesis of an indexing operation call.
Match it with its paired close.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">closeOpenIndexes: </span><span class="o">-&gt;</span>
<span class="nv">condition = </span><span class="nf">(token, i) -&gt;</span>
<span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;]&#39;</span><span class="p">,</span> <span class="s1">&#39;INDEX_END&#39;</span><span class="p">]</span>
<span class="nv">action = </span><span class="nf">(token, i) -&gt;</span>
<span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;INDEX_END&#39;</span>
<span class="nx">@scanTokens</span> <span class="nf">(token, i) -&gt;</span>
<span class="nx">@detectEnd</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">condition</span><span class="p">,</span> <span class="nx">action</span> <span class="k">if</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;INDEX_START&#39;</span>
<span class="mi">1</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Object literals may be written with implicit braces, for simple cases.
Insert the missing braces here, so that the parser doesn't have to.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">addImplicitBraces: </span><span class="o">-&gt;</span>
<span class="nv">stack = </span><span class="p">[]</span>
<span class="nv">start = </span><span class="kc">null</span>
<span class="nv">startsLine = </span><span class="kc">null</span>
<span class="nv">sameLine = </span><span class="kc">yes</span>
<span class="nv">startIndent = </span><span class="mi">0</span>
<span class="nv">startIndex = </span><span class="mi">0</span>
<span class="nv">condition = </span><span class="nf">(token, i) -&gt;</span>
<span class="p">[</span><span class="nx">one</span><span class="p">,</span> <span class="nx">two</span><span class="p">,</span> <span class="nx">three</span><span class="p">]</span> <span class="o">=</span> <span class="nx">@tokens</span><span class="p">[</span><span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">..</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">3</span><span class="p">]</span>
<span class="k">return</span> <span class="kc">no</span> <span class="k">if</span> <span class="s1">&#39;HERECOMMENT&#39;</span> <span class="o">is</span> <span class="nx">one</span><span class="o">?</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="p">[</span><span class="nx">tag</span><span class="p">]</span> <span class="o">=</span> <span class="nx">token</span>
<span class="nv">sameLine = </span><span class="kc">no</span> <span class="k">if</span> <span class="nx">tag</span> <span class="k">in</span> <span class="nx">LINEBREAKS</span>
<span class="k">return</span> <span class="p">(</span>
<span class="p">(</span><span class="nx">tag</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;TERMINATOR&#39;</span><span class="p">,</span> <span class="s1">&#39;OUTDENT&#39;</span><span class="p">]</span> <span class="o">or</span>
<span class="p">(</span><span class="nx">tag</span> <span class="k">in</span> <span class="nx">IMPLICIT_END</span> <span class="o">and</span> <span class="nx">sameLine</span> <span class="o">and</span> <span class="o">not</span> <span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="nx">startIndex</span> <span class="o">is</span> <span class="mi">1</span><span class="p">)))</span> <span class="o">and</span>
<span class="p">((</span><span class="o">!</span><span class="nx">startsLine</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">isnt</span> <span class="s1">&#39;,&#39;</span><span class="p">)</span> <span class="o">or</span>
<span class="o">not</span> <span class="p">(</span><span class="nx">two</span><span class="o">?</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;:&#39;</span> <span class="o">or</span> <span class="nx">one</span><span class="o">?</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;@&#39;</span> <span class="o">and</span> <span class="nx">three</span><span class="o">?</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;:&#39;</span><span class="p">)))</span> <span class="o">or</span>
<span class="p">(</span><span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;,&#39;</span> <span class="o">and</span> <span class="nx">one</span> <span class="o">and</span>
<span class="nx">one</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">not</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;IDENTIFIER&#39;</span><span class="p">,</span> <span class="s1">&#39;NUMBER&#39;</span><span class="p">,</span> <span class="s1">&#39;STRING&#39;</span><span class="p">,</span> <span class="s1">&#39;@&#39;</span><span class="p">,</span> <span class="s1">&#39;TERMINATOR&#39;</span><span class="p">,</span> <span class="s1">&#39;OUTDENT&#39;</span><span class="p">]</span>
<span class="p">)</span>
<span class="nv">action = </span><span class="nf">(token, i) -&gt;</span>
<span class="nv">tok = </span><span class="nx">@generate</span> <span class="s1">&#39;}&#39;</span><span class="p">,</span> <span class="s1">&#39;}&#39;</span><span class="p">,</span> <span class="nx">token</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="nx">@tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">tok</span>
<span class="nx">@scanTokens</span> <span class="nf">(token, i, tokens) -&gt;</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">tag = </span><span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">in</span> <span class="nx">EXPRESSION_START</span>
<span class="nx">stack</span><span class="p">.</span><span class="nx">push</span> <span class="p">[(</span><span class="k">if</span> <span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;INDENT&#39;</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;{&#39;</span> <span class="k">then</span> <span class="s1">&#39;{&#39;</span> <span class="k">else</span> <span class="nx">tag</span><span class="p">),</span> <span class="nx">i</span><span class="p">]</span>
<span class="k">return</span> <span class="mi">1</span>
<span class="k">if</span> <span class="nx">tag</span> <span class="k">in</span> <span class="nx">EXPRESSION_END</span>
<span class="nv">start = </span><span class="nx">stack</span><span class="p">.</span><span class="nx">pop</span><span class="p">()</span>
<span class="k">return</span> <span class="mi">1</span>
<span class="k">return</span> <span class="mi">1</span> <span class="nx">unless</span> <span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;:&#39;</span> <span class="o">and</span>
<span class="p">((</span><span class="nv">ago = </span><span class="nx">@tag</span> <span class="nx">i</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;:&#39;</span> <span class="o">or</span> <span class="nx">stack</span><span class="p">[</span><span class="nx">stack</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span><span class="o">?</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">isnt</span> <span class="s1">&#39;{&#39;</span><span class="p">)</span>
<span class="nv">sameLine = </span><span class="kc">yes</span>
<span class="nv">startIndex = </span><span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span>
<span class="nx">stack</span><span class="p">.</span><span class="nx">push</span> <span class="p">[</span><span class="s1">&#39;{&#39;</span><span class="p">]</span>
<span class="nv">idx = </span> <span class="k">if</span> <span class="nx">ago</span> <span class="o">is</span> <span class="s1">&#39;@&#39;</span> <span class="k">then</span> <span class="nx">i</span> <span class="o">-</span> <span class="mi">2</span> <span class="k">else</span> <span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span>
<span class="nx">idx</span> <span class="o">-=</span> <span class="mi">2</span> <span class="k">while</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">idx</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;HERECOMMENT&#39;</span>
<span class="nv">prevTag = </span><span class="nx">@tag</span><span class="p">(</span><span class="nx">idx</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="nv">startsLine = </span><span class="o">not</span> <span class="nx">prevTag</span> <span class="o">or</span> <span class="p">(</span><span class="nx">prevTag</span> <span class="k">in</span> <span class="nx">LINEBREAKS</span><span class="p">)</span>
<span class="nv">value = </span><span class="k">new</span> <span class="nb">String</span><span class="p">(</span><span class="s1">&#39;{&#39;</span><span class="p">)</span>
<span class="nv">value.generated = </span><span class="kc">yes</span>
<span class="nv">tok = </span><span class="nx">@generate</span> <span class="s1">&#39;{&#39;</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">token</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">idx</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">tok</span>
<span class="nx">@detectEnd</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">condition</span><span class="p">,</span> <span class="nx">action</span>
<span class="mi">2</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Methods may be optionally called without parentheses, for simple cases.
Insert the implicit parentheses here, so that the parser doesn't have to
deal with them.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">addImplicitParentheses: </span><span class="o">-&gt;</span>
<span class="nv">noCall = seenSingle = seenControl = </span><span class="kc">no</span>
<span class="nv">condition = </span><span class="nf">(token, i) -&gt;</span>
<span class="p">[</span><span class="nx">tag</span><span class="p">]</span> <span class="o">=</span> <span class="nx">token</span>
<span class="k">return</span> <span class="kc">yes</span> <span class="k">if</span> <span class="o">not</span> <span class="nx">seenSingle</span> <span class="o">and</span> <span class="nx">token</span><span class="p">.</span><span class="nx">fromThen</span>
<span class="nv">seenSingle = </span><span class="kc">yes</span> <span class="k">if</span> <span class="nx">tag</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;IF&#39;</span><span class="p">,</span> <span class="s1">&#39;ELSE&#39;</span><span class="p">,</span> <span class="s1">&#39;CATCH&#39;</span><span class="p">,</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;=&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;CLASS&#39;</span><span class="p">]</span>
<span class="nv">seenControl = </span><span class="kc">yes</span> <span class="k">if</span> <span class="nx">tag</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;IF&#39;</span><span class="p">,</span> <span class="s1">&#39;ELSE&#39;</span><span class="p">,</span> <span class="s1">&#39;SWITCH&#39;</span><span class="p">,</span> <span class="s1">&#39;TRY&#39;</span><span class="p">,</span> <span class="s1">&#39;=&#39;</span><span class="p">]</span>
<span class="k">return</span> <span class="kc">yes</span> <span class="k">if</span> <span class="nx">tag</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;.&#39;</span><span class="p">,</span> <span class="s1">&#39;?.&#39;</span><span class="p">,</span> <span class="s1">&#39;::&#39;</span><span class="p">]</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;OUTDENT&#39;</span>
<span class="o">not</span> <span class="nx">token</span><span class="p">.</span><span class="nx">generated</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">isnt</span> <span class="s1">&#39;,&#39;</span> <span class="o">and</span> <span class="p">(</span><span class="nx">tag</span> <span class="k">in</span> <span class="nx">IMPLICIT_END</span> <span class="o">or</span>
<span class="p">(</span><span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;INDENT&#39;</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">seenControl</span><span class="p">))</span> <span class="o">and</span>
<span class="p">(</span><span class="nx">tag</span> <span class="o">isnt</span> <span class="s1">&#39;INDENT&#39;</span> <span class="o">or</span>
<span class="p">(</span><span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">not</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;CLASS&#39;</span><span class="p">,</span> <span class="s1">&#39;EXTENDS&#39;</span><span class="p">]</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">not</span> <span class="k">in</span> <span class="nx">IMPLICIT_BLOCK</span> <span class="o">and</span>
<span class="o">not</span> <span class="p">((</span><span class="nv">post = </span><span class="nx">@tokens</span><span class="p">[</span><span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> <span class="o">and</span> <span class="nx">post</span><span class="p">.</span><span class="nx">generated</span> <span class="o">and</span> <span class="nx">post</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;{&#39;</span><span class="p">)))</span>
<span class="nv">action = </span><span class="nf">(token, i) -&gt;</span>
<span class="nx">@tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">@generate</span> <span class="s1">&#39;CALL_END&#39;</span><span class="p">,</span> <span class="s1">&#39;)&#39;</span><span class="p">,</span> <span class="nx">token</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="nx">@scanTokens</span> <span class="nf">(token, i, tokens) -&gt;</span>
<span class="nv">tag = </span><span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="nv">noCall = </span><span class="kc">yes</span> <span class="k">if</span> <span class="nx">tag</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;CLASS&#39;</span><span class="p">,</span> <span class="s1">&#39;IF&#39;</span><span class="p">,</span> <span class="s1">&#39;FOR&#39;</span><span class="p">,</span> <span class="s1">&#39;WHILE&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="nx">prev</span><span class="p">,</span> <span class="nx">current</span><span class="p">,</span> <span class="nx">next</span><span class="p">]</span> <span class="o">=</span> <span class="nx">tokens</span><span class="p">[</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span> <span class="p">..</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span>
<span class="nv">callObject = </span><span class="o">not</span> <span class="nx">noCall</span> <span class="o">and</span> <span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;INDENT&#39;</span> <span class="o">and</span>
<span class="nx">next</span> <span class="o">and</span> <span class="nx">next</span><span class="p">.</span><span class="nx">generated</span> <span class="o">and</span> <span class="nx">next</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;{&#39;</span> <span class="o">and</span>
<span class="nx">prev</span> <span class="o">and</span> <span class="nx">prev</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">in</span> <span class="nx">IMPLICIT_FUNC</span>
<span class="nv">seenSingle = </span><span class="kc">no</span>
<span class="nv">seenControl = </span><span class="kc">no</span>
<span class="nv">noCall = </span><span class="kc">no</span> <span class="k">if</span> <span class="nx">tag</span> <span class="k">in</span> <span class="nx">LINEBREAKS</span>
<span class="nv">token.call = </span><span class="kc">yes</span> <span class="k">if</span> <span class="nx">prev</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">prev</span><span class="p">.</span><span class="nx">spaced</span> <span class="o">and</span> <span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;?&#39;</span>
<span class="k">return</span> <span class="mi">1</span> <span class="k">if</span> <span class="nx">token</span><span class="p">.</span><span class="nx">fromThen</span>
<span class="k">return</span> <span class="mi">1</span> <span class="nx">unless</span> <span class="nx">callObject</span> <span class="o">or</span>
<span class="nx">prev</span><span class="o">?</span><span class="p">.</span><span class="nx">spaced</span> <span class="o">and</span> <span class="p">(</span><span class="nx">prev</span><span class="p">.</span><span class="nx">call</span> <span class="o">or</span> <span class="nx">prev</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">in</span> <span class="nx">IMPLICIT_FUNC</span><span class="p">)</span> <span class="o">and</span>
<span class="p">(</span><span class="nx">tag</span> <span class="k">in</span> <span class="nx">IMPLICIT_CALL</span> <span class="o">or</span> <span class="o">not</span> <span class="p">(</span><span class="nx">token</span><span class="p">.</span><span class="nx">spaced</span> <span class="o">or</span> <span class="nx">token</span><span class="p">.</span><span class="nx">newLine</span><span class="p">)</span> <span class="o">and</span> <span class="nx">tag</span> <span class="k">in</span> <span class="nx">IMPLICIT_UNSPACED_CALL</span><span class="p">)</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">@generate</span> <span class="s1">&#39;CALL_START&#39;</span><span class="p">,</span> <span class="s1">&#39;(&#39;</span><span class="p">,</span> <span class="nx">token</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="nx">@detectEnd</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">condition</span><span class="p">,</span> <span class="nx">action</span>
<span class="nx">prev</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;FUNC_EXIST&#39;</span> <span class="k">if</span> <span class="nx">prev</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;?&#39;</span>
<span class="mi">2</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>Because our grammar is LALR(1), it can't handle some single-line
expressions that lack ending delimiters. The <strong>Rewriter</strong> adds the implicit
blocks, so it doesn't need to. ')' can close a single-line block,
but we need to make sure it's balanced.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">addImplicitIndentation: </span><span class="o">-&gt;</span>
<span class="nv">starter = indent = outdent = </span><span class="kc">null</span>
<span class="nv">condition = </span><span class="nf">(token, i) -&gt;</span>
<span class="nx">token</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">isnt</span> <span class="s1">&#39;;&#39;</span> <span class="o">and</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">in</span> <span class="nx">SINGLE_CLOSERS</span> <span class="o">and</span>
<span class="o">not</span> <span class="p">(</span><span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;ELSE&#39;</span> <span class="o">and</span> <span class="nx">starter</span> <span class="o">not</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;IF&#39;</span><span class="p">,</span> <span class="s1">&#39;THEN&#39;</span><span class="p">])</span>
<span class="nv">action = </span><span class="nf">(token, i) -&gt;</span>
<span class="nx">@tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="p">(</span><span class="k">if</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;,&#39;</span> <span class="k">then</span> <span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span> <span class="k">else</span> <span class="nx">i</span><span class="p">),</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">outdent</span>
<span class="nx">@scanTokens</span> <span class="nf">(token, i, tokens) -&gt;</span>
<span class="p">[</span><span class="nx">tag</span><span class="p">]</span> <span class="o">=</span> <span class="nx">token</span>
<span class="k">if</span> <span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;TERMINATOR&#39;</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;THEN&#39;</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span><span class="p">,</span> <span class="mi">1</span>
<span class="k">return</span> <span class="mi">0</span>
<span class="k">if</span> <span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;ELSE&#39;</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">isnt</span> <span class="s1">&#39;OUTDENT&#39;</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">@indentation</span><span class="p">(</span><span class="nx">token</span><span class="p">)...</span>
<span class="k">return</span> <span class="mi">2</span>
<span class="k">if</span> <span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;CATCH&#39;</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;OUTDENT&#39;</span><span class="p">,</span> <span class="s1">&#39;TERMINATOR&#39;</span><span class="p">,</span> <span class="s1">&#39;FINALLY&#39;</span><span class="p">]</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">@indentation</span><span class="p">(</span><span class="nx">token</span><span class="p">)...</span>
<span class="k">return</span> <span class="mi">4</span>
<span class="k">if</span> <span class="nx">tag</span> <span class="k">in</span> <span class="nx">SINGLE_LINERS</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">isnt</span> <span class="s1">&#39;INDENT&#39;</span> <span class="o">and</span>
<span class="o">not</span> <span class="p">(</span><span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;ELSE&#39;</span> <span class="o">and</span> <span class="nx">@tag</span><span class="p">(</span><span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;IF&#39;</span><span class="p">)</span>
<span class="nv">starter = </span><span class="nx">tag</span>
<span class="p">[</span><span class="nx">indent</span><span class="p">,</span> <span class="nx">outdent</span><span class="p">]</span> <span class="o">=</span> <span class="nx">@indentation</span> <span class="nx">token</span><span class="p">,</span> <span class="kc">yes</span>
<span class="nv">indent.fromThen = </span><span class="kc">true</span> <span class="k">if</span> <span class="nx">starter</span> <span class="o">is</span> <span class="s1">&#39;THEN&#39;</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">indent</span>
<span class="nx">@detectEnd</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">condition</span><span class="p">,</span> <span class="nx">action</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">i</span><span class="p">,</span> <span class="mi">1</span> <span class="k">if</span> <span class="nx">tag</span> <span class="o">is</span> <span class="s1">&#39;THEN&#39;</span>
<span class="k">return</span> <span class="mi">1</span>
<span class="k">return</span> <span class="mi">1</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>Tag postfix conditionals as such, so that we can parse them with a
different precedence.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">tagPostfixConditionals: </span><span class="o">-&gt;</span>
<span class="nv">original = </span><span class="kc">null</span>
<span class="nv">condition = </span><span class="nf">(token, i) -&gt;</span>
<span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;TERMINATOR&#39;</span><span class="p">,</span> <span class="s1">&#39;INDENT&#39;</span><span class="p">]</span>
<span class="nv">action = </span><span class="nf">(token, i) -&gt;</span>
<span class="k">if</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">isnt</span> <span class="s1">&#39;INDENT&#39;</span> <span class="o">or</span> <span class="p">(</span><span class="nx">token</span><span class="p">.</span><span class="nx">generated</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">token</span><span class="p">.</span><span class="nx">fromThen</span><span class="p">)</span>
<span class="nx">original</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;POST_&#39;</span> <span class="o">+</span> <span class="nx">original</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="nx">@scanTokens</span> <span class="nf">(token, i) -&gt;</span>
<span class="k">return</span> <span class="mi">1</span> <span class="nx">unless</span> <span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;IF&#39;</span>
<span class="nv">original = </span><span class="nx">token</span>
<span class="nx">@detectEnd</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">condition</span><span class="p">,</span> <span class="nx">action</span>
<span class="mi">1</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>Generate the indentation tokens, based on another token on the same line.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">indentation: </span><span class="nf">(token, implicit = no) -&gt;</span>
<span class="nv">indent = </span><span class="p">[</span><span class="s1">&#39;INDENT&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">token</span><span class="p">[</span><span class="mi">2</span><span class="p">]]</span>
<span class="nv">outdent = </span><span class="p">[</span><span class="s1">&#39;OUTDENT&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">token</span><span class="p">[</span><span class="mi">2</span><span class="p">]]</span>
<span class="nv">indent.generated = outdent.generated = </span><span class="kc">yes</span> <span class="k">if</span> <span class="nx">implicit</span>
<span class="p">[</span><span class="nx">indent</span><span class="p">,</span> <span class="nx">outdent</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>Create a generated token: one that exists due to a use of implicit syntax.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">generate: </span><span class="nf">(tag, value, line) -&gt;</span>
<span class="nv">tok = </span><span class="p">[</span><span class="nx">tag</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">line</span><span class="p">]</span>
<span class="nv">tok.generated = </span><span class="kc">yes</span>
<span class="nx">tok</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>Look up a tag by token index.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">tag: </span><span class="nf">(i) -&gt;</span> <span class="nx">@tokens</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="o">?</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <h2>Constants</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>List of the token pairs that must be balanced.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">BALANCED_PAIRS = </span><span class="p">[</span>
<span class="p">[</span><span class="s1">&#39;(&#39;</span><span class="p">,</span> <span class="s1">&#39;)&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;[&#39;</span><span class="p">,</span> <span class="s1">&#39;]&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;{&#39;</span><span class="p">,</span> <span class="s1">&#39;}&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;INDENT&#39;</span><span class="p">,</span> <span class="s1">&#39;OUTDENT&#39;</span><span class="p">],</span>
<span class="p">[</span><span class="s1">&#39;CALL_START&#39;</span><span class="p">,</span> <span class="s1">&#39;CALL_END&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;PARAM_START&#39;</span><span class="p">,</span> <span class="s1">&#39;PARAM_END&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s1">&#39;INDEX_START&#39;</span><span class="p">,</span> <span class="s1">&#39;INDEX_END&#39;</span><span class="p">]</span>
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <p>The inverse mappings of <code>BALANCED_PAIRS</code> we're trying to fix up, so we can
look things up from either end.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.INVERSES = INVERSES = </span><span class="p">{}</span></pre></div> </td> </tr> <tr id="section-20"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-20">&#182;</a> </div> <p>The tokens that signal the start/end of a balanced pair.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">EXPRESSION_START = </span><span class="p">[]</span>
<span class="nv">EXPRESSION_END = </span><span class="p">[]</span>
<span class="k">for</span> <span class="p">[</span><span class="nx">left</span><span class="p">,</span> <span class="nx">rite</span><span class="p">]</span> <span class="k">in</span> <span class="nx">BALANCED_PAIRS</span>
<span class="nx">EXPRESSION_START</span><span class="p">.</span><span class="nx">push</span> <span class="nx">INVERSES</span><span class="p">[</span><span class="nx">rite</span><span class="p">]</span> <span class="o">=</span> <span class="nx">left</span>
<span class="nx">EXPRESSION_END</span> <span class="p">.</span><span class="nx">push</span> <span class="nx">INVERSES</span><span class="p">[</span><span class="nx">left</span><span class="p">]</span> <span class="o">=</span> <span class="nx">rite</span></pre></div> </td> </tr> <tr id="section-21"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-21">&#182;</a> </div> <p>Tokens that indicate the close of a clause of an expression.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">EXPRESSION_CLOSE = </span><span class="p">[</span><span class="s1">&#39;CATCH&#39;</span><span class="p">,</span> <span class="s1">&#39;WHEN&#39;</span><span class="p">,</span> <span class="s1">&#39;ELSE&#39;</span><span class="p">,</span> <span class="s1">&#39;FINALLY&#39;</span><span class="p">].</span><span class="nx">concat</span> <span class="nx">EXPRESSION_END</span></pre></div> </td> </tr> <tr id="section-22"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-22">&#182;</a> </div> <p>Tokens that, if followed by an <code>IMPLICIT_CALL</code>, indicate a function invocation.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">IMPLICIT_FUNC = </span><span class="p">[</span><span class="s1">&#39;IDENTIFIER&#39;</span><span class="p">,</span> <span class="s1">&#39;SUPER&#39;</span><span class="p">,</span> <span class="s1">&#39;)&#39;</span><span class="p">,</span> <span class="s1">&#39;CALL_END&#39;</span><span class="p">,</span> <span class="s1">&#39;]&#39;</span><span class="p">,</span> <span class="s1">&#39;INDEX_END&#39;</span><span class="p">,</span> <span class="s1">&#39;@&#39;</span><span class="p">,</span> <span class="s1">&#39;THIS&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-23"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-23">&#182;</a> </div> <p>If preceded by an <code>IMPLICIT_FUNC</code>, indicates a function invocation.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">IMPLICIT_CALL = </span><span class="p">[</span>
<span class="s1">&#39;IDENTIFIER&#39;</span><span class="p">,</span> <span class="s1">&#39;NUMBER&#39;</span><span class="p">,</span> <span class="s1">&#39;STRING&#39;</span><span class="p">,</span> <span class="s1">&#39;JS&#39;</span><span class="p">,</span> <span class="s1">&#39;REGEX&#39;</span><span class="p">,</span> <span class="s1">&#39;NEW&#39;</span><span class="p">,</span> <span class="s1">&#39;PARAM_START&#39;</span><span class="p">,</span> <span class="s1">&#39;CLASS&#39;</span>
<span class="s1">&#39;IF&#39;</span><span class="p">,</span> <span class="s1">&#39;TRY&#39;</span><span class="p">,</span> <span class="s1">&#39;SWITCH&#39;</span><span class="p">,</span> <span class="s1">&#39;THIS&#39;</span><span class="p">,</span> <span class="s1">&#39;BOOL&#39;</span><span class="p">,</span> <span class="s1">&#39;NULL&#39;</span><span class="p">,</span> <span class="s1">&#39;UNDEFINED&#39;</span><span class="p">,</span> <span class="s1">&#39;UNARY&#39;</span><span class="p">,</span> <span class="s1">&#39;SUPER&#39;</span>
<span class="s1">&#39;@&#39;</span><span class="p">,</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;=&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;[&#39;</span><span class="p">,</span> <span class="s1">&#39;(&#39;</span><span class="p">,</span> <span class="s1">&#39;{&#39;</span><span class="p">,</span> <span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="s1">&#39;++&#39;</span>
<span class="p">]</span>
<span class="nv">IMPLICIT_UNSPACED_CALL = </span><span class="p">[</span><span class="s1">&#39;+&#39;</span><span class="p">,</span> <span class="s1">&#39;-&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-24"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-24">&#182;</a> </div> <p>Tokens indicating that the implicit call must enclose a block of expressions.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">IMPLICIT_BLOCK = </span><span class="p">[</span><span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;=&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;{&#39;</span><span class="p">,</span> <span class="s1">&#39;[&#39;</span><span class="p">,</span> <span class="s1">&#39;,&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-25"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-25">&#182;</a> </div> <p>Tokens that always mark the end of an implicit call for single-liners.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">IMPLICIT_END = </span><span class="p">[</span><span class="s1">&#39;POST_IF&#39;</span><span class="p">,</span> <span class="s1">&#39;FOR&#39;</span><span class="p">,</span> <span class="s1">&#39;WHILE&#39;</span><span class="p">,</span> <span class="s1">&#39;UNTIL&#39;</span><span class="p">,</span> <span class="s1">&#39;WHEN&#39;</span><span class="p">,</span> <span class="s1">&#39;BY&#39;</span><span class="p">,</span> <span class="s1">&#39;LOOP&#39;</span><span class="p">,</span> <span class="s1">&#39;TERMINATOR&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-26"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-26">&#182;</a> </div> <p>Single-line flavors of block expressions that have unclosed endings.
The grammar can't disambiguate them, so we insert the implicit indentation.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">SINGLE_LINERS = </span><span class="p">[</span><span class="s1">&#39;ELSE&#39;</span><span class="p">,</span> <span class="s1">&#39;-&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;=&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;TRY&#39;</span><span class="p">,</span> <span class="s1">&#39;FINALLY&#39;</span><span class="p">,</span> <span class="s1">&#39;THEN&#39;</span><span class="p">]</span>
<span class="nv">SINGLE_CLOSERS = </span><span class="p">[</span><span class="s1">&#39;TERMINATOR&#39;</span><span class="p">,</span> <span class="s1">&#39;CATCH&#39;</span><span class="p">,</span> <span class="s1">&#39;FINALLY&#39;</span><span class="p">,</span> <span class="s1">&#39;ELSE&#39;</span><span class="p">,</span> <span class="s1">&#39;OUTDENT&#39;</span><span class="p">,</span> <span class="s1">&#39;LEADING_WHEN&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-27"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-27">&#182;</a> </div> <p>Tokens that end a line.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">LINEBREAKS = </span><span class="p">[</span><span class="s1">&#39;TERMINATOR&#39;</span><span class="p">,</span> <span class="s1">&#39;INDENT&#39;</span><span class="p">,</span> <span class="s1">&#39;OUTDENT&#39;</span><span class="p">]</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

View File

@@ -1,58 +0,0 @@
<!DOCTYPE html> <html> <head> <title>scope.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="browser.html"> browser.coffee </a> <a class="source" href="cake.html"> cake.coffee </a> <a class="source" href="coffee-script.html"> coffee-script.coffee </a> <a class="source" href="command.html"> command.coffee </a> <a class="source" href="grammar.html"> grammar.coffee </a> <a class="source" href="helpers.html"> helpers.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="lexer.html"> lexer.coffee </a> <a class="source" href="nodes.html"> nodes.coffee </a> <a class="source" href="optparse.html"> optparse.coffee </a> <a class="source" href="repl.html"> repl.coffee </a> <a class="source" href="rewriter.html"> rewriter.coffee </a> <a class="source" href="scope.html"> scope.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> scope.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>The <strong>Scope</strong> class regulates lexical scoping within CoffeeScript. As you
generate code, you create a tree of scopes in the same shape as the nested
function bodies. Each scope knows about the variables declared within it,
and has a reference to its parent enclosing scope. In this way, we know which
variables are new and need to be declared with <code>var</code>, and which are shared
with the outside.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Import the helpers we plan to use.</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">{</span><span class="nx">extend</span><span class="p">,</span> <span class="nx">last</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;./helpers&#39;</span>
<span class="nv">exports.Scope = </span><span class="k">class</span> <span class="nx">Scope</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>The top-level <strong>Scope</strong> object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="vi">@root: </span><span class="kc">null</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the <strong>Block</strong> node it belongs to, which is
where it should declare its variables, and a reference to the function that
it wraps.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">constructor: </span><span class="nf">(@parent, @expressions, @method) -&gt;</span>
<span class="vi">@variables = </span><span class="p">[{</span><span class="nv">name: </span><span class="s1">&#39;arguments&#39;</span><span class="p">,</span> <span class="nv">type: </span><span class="s1">&#39;arguments&#39;</span><span class="p">}]</span>
<span class="vi">@positions = </span><span class="p">{}</span>
<span class="nv">Scope.root = </span><span class="k">this</span> <span class="nx">unless</span> <span class="nx">@parent</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Adds a new variable or overrides an existing one.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">add: </span><span class="nf">(name, type, immediate) -&gt;</span>
<span class="k">return</span> <span class="nx">@parent</span><span class="p">.</span><span class="nx">add</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">immediate</span> <span class="k">if</span> <span class="nx">@shared</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">immediate</span>
<span class="k">if</span> <span class="nb">Object</span><span class="o">::</span><span class="nx">hasOwnProperty</span><span class="p">.</span><span class="nx">call</span> <span class="nx">@positions</span><span class="p">,</span> <span class="nx">name</span>
<span class="nx">@variables</span><span class="p">[</span><span class="nx">@positions</span><span class="p">[</span><span class="nx">name</span><span class="p">]].</span><span class="nv">type = </span><span class="nx">type</span>
<span class="k">else</span>
<span class="nx">@positions</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">@variables</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span><span class="nx">name</span><span class="p">,</span> <span class="nx">type</span><span class="p">})</span> <span class="o">-</span> <span class="mi">1</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>When <code>super</code> is called, we need to find the name of the current method we're
in, so that we know how to invoke the same method of the parent class. This
can get complicated if super is being called from an inner function.
<code>namedMethod</code> will walk up the scope tree until it either finds the first
function object that has a name filled in, or bottoms out.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">namedMethod: </span><span class="o">-&gt;</span>
<span class="k">return</span> <span class="nx">@method</span> <span class="k">if</span> <span class="nx">@method</span><span class="p">.</span><span class="nx">name</span> <span class="o">or</span> <span class="o">!</span><span class="nx">@parent</span>
<span class="nx">@parent</span><span class="p">.</span><span class="nx">namedMethod</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Look up a variable name in lexical scope, and declare it if it does not
already exist.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">find: </span><span class="nf">(name) -&gt;</span>
<span class="k">return</span> <span class="kc">yes</span> <span class="k">if</span> <span class="nx">@check</span> <span class="nx">name</span>
<span class="nx">@add</span> <span class="nx">name</span><span class="p">,</span> <span class="s1">&#39;var&#39;</span>
<span class="kc">no</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Reserve a variable name as originating from a function parameter for this
scope. No <code>var</code> required for internal references.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">parameter: </span><span class="nf">(name) -&gt;</span>
<span class="k">return</span> <span class="k">if</span> <span class="nx">@shared</span> <span class="o">and</span> <span class="nx">@parent</span><span class="p">.</span><span class="nx">check</span> <span class="nx">name</span><span class="p">,</span> <span class="kc">yes</span>
<span class="nx">@add</span> <span class="nx">name</span><span class="p">,</span> <span class="s1">&#39;param&#39;</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Just check to see if a variable has already been declared, without reserving,
walks up to the root scope.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">check: </span><span class="nf">(name) -&gt;</span>
<span class="o">!!</span><span class="p">(</span><span class="nx">@type</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="o">or</span> <span class="nx">@parent</span><span class="o">?</span><span class="p">.</span><span class="nx">check</span><span class="p">(</span><span class="nx">name</span><span class="p">))</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Generate a temporary variable name at the given index.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">temporary: </span><span class="nf">(name, index) -&gt;</span>
<span class="k">if</span> <span class="nx">name</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">1</span>
<span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="nx">name</span> <span class="o">+</span> <span class="k">if</span> <span class="nx">index</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="k">then</span> <span class="nx">index</span> <span class="o">-</span> <span class="mi">1</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
<span class="k">else</span>
<span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="p">(</span><span class="nx">index</span> <span class="o">+</span> <span class="nb">parseInt</span> <span class="nx">name</span><span class="p">,</span> <span class="mi">36</span><span class="p">).</span><span class="nx">toString</span><span class="p">(</span><span class="mi">36</span><span class="p">).</span><span class="nx">replace</span> <span class="sr">/\d/g</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Gets the type of a variable.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">type: </span><span class="nf">(name) -&gt;</span>
<span class="k">return</span> <span class="nx">v</span><span class="p">.</span><span class="nx">type</span> <span class="k">for</span> <span class="nx">v</span> <span class="k">in</span> <span class="nx">@variables</span> <span class="k">when</span> <span class="nx">v</span><span class="p">.</span><span class="nx">name</span> <span class="o">is</span> <span class="nx">name</span>
<span class="kc">null</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>If we need to store an intermediate result, find an available name for a
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">freeVariable: </span><span class="nf">(name, reserve=true) -&gt;</span>
<span class="nv">index = </span><span class="mi">0</span>
<span class="nx">index</span><span class="o">++</span> <span class="k">while</span> <span class="nx">@check</span><span class="p">((</span><span class="nv">temp = </span><span class="nx">@temporary</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">index</span><span class="p">))</span>
<span class="nx">@add</span> <span class="nx">temp</span><span class="p">,</span> <span class="s1">&#39;var&#39;</span><span class="p">,</span> <span class="kc">yes</span> <span class="k">if</span> <span class="nx">reserve</span>
<span class="nx">temp</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>Ensure that an assignment is made at the top of this scope
(or at the top-level scope, if requested).</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">assign: </span><span class="nf">(name, value) -&gt;</span>
<span class="nx">@add</span> <span class="nx">name</span><span class="p">,</span> <span class="p">{</span><span class="nx">value</span><span class="p">,</span> <span class="nv">assigned: </span><span class="kc">yes</span><span class="p">},</span> <span class="kc">yes</span>
<span class="vi">@hasAssignments = </span><span class="kc">yes</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>Does this scope have any declared variables?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">hasDeclarations: </span><span class="o">-&gt;</span>
<span class="o">!!</span><span class="nx">@declaredVariables</span><span class="p">().</span><span class="nx">length</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>Return the list of variables first declared in this scope.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">declaredVariables: </span><span class="o">-&gt;</span>
<span class="nv">realVars = </span><span class="p">[]</span>
<span class="nv">tempVars = </span><span class="p">[]</span>
<span class="k">for</span> <span class="nx">v</span> <span class="k">in</span> <span class="nx">@variables</span> <span class="k">when</span> <span class="nx">v</span><span class="p">.</span><span class="nx">type</span> <span class="o">is</span> <span class="s1">&#39;var&#39;</span>
<span class="p">(</span><span class="k">if</span> <span class="nx">v</span><span class="p">.</span><span class="nx">name</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;_&#39;</span> <span class="k">then</span> <span class="nx">tempVars</span> <span class="k">else</span> <span class="nx">realVars</span><span class="p">).</span><span class="nx">push</span> <span class="nx">v</span><span class="p">.</span><span class="nx">name</span>
<span class="nx">realVars</span><span class="p">.</span><span class="nx">sort</span><span class="p">().</span><span class="nx">concat</span> <span class="nx">tempVars</span><span class="p">.</span><span class="nx">sort</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>Return the list of assignments that are supposed to be made at the top
of this scope.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">assignedVariables: </span><span class="o">-&gt;</span>
<span class="s2">&quot;#{v.name} = #{v.type.value}&quot;</span> <span class="k">for</span> <span class="nx">v</span> <span class="k">in</span> <span class="nx">@variables</span> <span class="k">when</span> <span class="nx">v</span><span class="p">.</span><span class="nx">type</span><span class="p">.</span><span class="nx">assigned</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
###
SkinnyMochaHalfCaffScript Compiler v1.0
Released under the MIT License
###

View File

@@ -6,4 +6,4 @@ task 'build:parser', 'rebuild the Jison parser', (options) ->
require 'jison'
code = require('./lib/grammar').parser.generate()
dir = options.output or 'lib'
fs.writeFile "#{dir}/parser.js", code
fs.writeFile "#{dir}/parser.js", code

View File

@@ -0,0 +1,6 @@
$ 'body'
.click (e) ->
$ '.box'
.fadeIn 'fast'
.addClass '.active'
.css 'background', 'white'

View File

@@ -19,7 +19,3 @@ tom = new Horse "Tommy the Palomino"
sam.move()
tom.move()

View File

@@ -1,5 +1,3 @@
cholesterol = 127
healthy = 200 > cholesterol > 60

View File

@@ -7,6 +7,3 @@ else
showIt()
date = if friday then sue else jill

View File

@@ -0,0 +1,5 @@
class Person
constructor: (options) ->
{@name, @age, @height = 'average'} = options
tim = new Person name: 'Tim', age: 4

View File

@@ -1,8 +1,2 @@
fill = (container, liquid = "coffee") ->
"Filling the #{container} with #{liquid}..."

View File

@@ -1,4 +1,4 @@
for filename in list
do (filename) ->
fs.readFile filename, (err, contents) ->
compile filename, contents.toString()
compile filename, contents.toString()

View File

@@ -1,6 +1,3 @@
hi = `function() {
return [document.title, "Hello JavaScript"].join(": ");
}`

View File

@@ -0,0 +1,5 @@
```
function time() {
return `The time is ${new Date().toLocaleTimeString()}`;
}
```

View File

@@ -0,0 +1,3 @@
markdown = `function () {
return \`In Markdown, write code like \\\`this\\\`\`;
}`

View File

@@ -4,10 +4,3 @@ speed = 0
speed ?= 15
footprints = yeti ? "bear"

View File

@@ -0,0 +1,4 @@
text = "Every literary critic believes he will
outwit history and have the last word"
[first, ..., last] = text.split " "

View File

@@ -6,4 +6,4 @@ grade = (student) ->
else
"C"
eldest = if 24 > 21 then "Liz" else "Ike"
eldest = if 24 > 21 then "Liz" else "Ike"

View File

@@ -0,0 +1,3 @@
# The first ten global properties.
globals = (name for name of window)[0...10]

View File

@@ -4,4 +4,3 @@ alert(
catch error
"And the error is ... #{error}"
)

View File

@@ -0,0 +1,6 @@
Account = (customer, cart) ->
@customer = customer
@cart = cart
$('.shopping_cart').on 'click', (event) =>
@customer.purchase @cart

View File

@@ -0,0 +1,13 @@
fibonacci = ->
[previous, current] = [1, 1]
loop
[previous, current] = [current, previous + current]
yield current
return
getFibonacciNumbers = (length) ->
results = [1]
for n from fibonacci()
results.push n
break if results.length is length
results

View File

@@ -0,0 +1,8 @@
perfectSquares = ->
num = 0
loop
num += 1
yield num * num
return
window.ps or= perfectSquares()

View File

@@ -3,4 +3,3 @@ html = """
cup of coffeescript
</strong>
"""

Some files were not shown because too many files have changed in this diff Show More