Compare commits

...

2206 Commits
0.6.0 ... 1.6.2

Author SHA1 Message Date
Jeremy Ashkenas
3527af89fa new new docs 2013-03-13 11:48:23 +08:00
Jeremy Ashkenas
b32e3c0dfb fixing gray for github pages 2013-03-11 23:33:43 +08:00
Jeremy Ashkenas
956f432a68 fixing viewport 2013-03-11 22:21:22 +08:00
Jeremy Ashkenas
65d39c50f1 new docs, mo docs, shiny docs 2013-03-11 22:03:03 +08:00
Jeremy Ashkenas
55f60506b9 Fixes #2783 -- leftover comments 2013-03-06 07:14:37 +13: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
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
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
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
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
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
Jason Walton
541ab8334d Compile to an array of CodeFragments instead of to a giant string. 2013-02-26 13:34:27 -05: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
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
Michael Ficarra
8b0dd9d224 Merge pull request #2719 from epidemian/minor-embellishments
Minor embellishments
2013-02-25 10:35:25 -08: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
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
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
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
79492aab36 CoffeeScript 1.3.3 2012-05-15 12:35:40 -04:00
Jeremy Ashkenas
e3454ed7fb Fixes #2331 -- bound 'super' regression 2012-05-15 12:30:51 -04:00
Michael Ficarra
8dcbe54e55 Fixes broken autocompletion from 8bc6001d27
8bc6001d27 removed autocompletions of
non-enumerable own-properties in trying to add enumerable prototype
properties to the autocompletions. This commit adds them back and unions
them with the enumerable prototype properties.
2012-05-15 02:25:28 -04:00
Michael Ficarra
dac24a3d8a small refactoring of 66c751be11 2012-05-14 21:07:54 -04:00
Michael Ficarra
5c8eef2ab5 package.json: changing license URL to new github raw URL format 2012-05-14 17:50:04 -04:00
Michael Ficarra
66c751be11 fixed REPL to allow streamed input from stdin 2012-05-14 15:55:51 -04:00
Jeremy Ashkenas
b4af24b7e2 Merge branch 'master' into gh-pages 2012-05-14 14:45:35 -04:00
Jeremy Ashkenas
7792a3a6e3 CoffeeScript 1.3.2 2012-05-14 14:45:20 -04:00
Michael Ficarra
e57a5de33e added bugs to package.json
satyr/coco@d15ca300ca
2012-05-14 12:35:50 -04:00
Michael Ficarra
ed705403ad Merge pull request #2299 from geraldalewis/2213-no-method-is-array
Wraps up #2211 -- addresses invocations within destructured params
2012-05-12 17:30:48 -07:00
Colin Ross
fa899ab810 Fix typo in test name 2012-05-12 06:34:12 +01:00
Jeremy Ashkenas
3fc0e6be90 adding a rel=canonical 2012-05-10 17:42:40 -04:00
Jeremy Ashkenas
fdcd99dfef adding a rel=canonical 2012-05-10 17:42:27 -04:00
Michael Ficarra
d5ddd0f783 removing redundant cases in lexer; thanks @satyr 2012-05-08 16:42:09 -04:00
Michael Ficarra
848d10594b reverting premature start of solution to #2306 2012-05-08 16:22:26 -04:00
Michael Ficarra
caf3da2f66 lexer/parser: split out null and undefined from BOOL token
also made explicit AST nodes `Bool`, `Null`, and `Undefined`
2012-05-08 16:14:28 -04:00
Gerald Lewis
f1b286469a Wraps up #2211 -- addresses invocations within destructured params 2012-05-02 18:03:32 -04:00
Jeremy Ashkenas
46065199cd Fixes #2287 -- tweak extends to make jshint easier 2012-04-25 17:33:21 -04:00
Jeremy Ashkenas
879fe3976d Fixes #2197 -- uncached double existential 2012-04-25 15:04:15 -04:00
Jeremy Ashkenas
c1309e12f7 Fixes #2209 -- document heredocs as 'block strings' 2012-04-25 14:37:05 -04:00
Jeremy Ashkenas
6bcc798a76 Fixes #2207 -- unambiguous immediate implicit closes don't close implicit objects 2012-04-25 14:14:00 -04:00
Maxwell Krohn
3e95d7f2d0 Reapply the removed patch from bugfix_1183 in PR 2252. Include a test
case to show it's required.

What's going on: inside of Coffee-generated closures, calling `super()`
is implicitly making use of `this` (or explicitly doing so if you look
at the output code), so we have to pass `this` through closures as if
`@` is being accessed within the closure.  So, just add one more
condition to the list in `Closure::literalThis`
2012-04-24 21:48:18 -04:00
Jeremy Ashkenas
c3159e48c8 Merge pull request #2219 from matt-hickford/build-windows-alternative
build on Windows - fix spawn command by calling node explicitly
2012-04-24 14:59:30 -07:00
Jeremy Ashkenas
34be878257 Fixes #1183, Refactors #2252, super calls in inner functions 2012-04-24 17:23:37 -04:00
Jeremy Ashkenas
87257ea6b3 Fixes #2258 -- allow parameter lists in the vertical style. 2012-04-24 16:56:39 -04:00
Jeremy Ashkenas
8bc6001d27 Fixes #2280 -- add enumerable prototypal properties to autocompletion. 2012-04-24 16:26:07 -04:00
Jeremy Ashkenas
e433098eb2 Adding a test for #2273 2012-04-24 15:39:22 -04:00
Jeremy Ashkenas
afdcdcfd54 Fixes #2273, reverts #643 -- no special variable treatment for loop variables. 2012-04-24 15:37:26 -04:00
Jeremy Ashkenas
4fc9a345bb Fixes #2274 -- allow @variables as loop variables 2012-04-24 12:21:47 -04:00
Jeremy Ashkenas
9d4dc094a1 adding a link to the high-rez logo 2012-04-24 12:12:32 -04:00
Jeremy Ashkenas
c06487c13b Merge branch 'master' of github.com:jashkenas/coffee-script 2012-04-24 12:12:12 -04:00
Jeremy Ashkenas
7a80661ad5 adding a link to the high-rez logo 2012-04-24 12:12:09 -04:00
Jeremy Ashkenas
2fb527a63f Merge pull request #2277 from geraldalewis/2213-dup-destructured-params
Destructured assignment params incorrectly identified as duplicates.
2012-04-24 08:48:06 -07:00
Gerald Lewis
99394e1011 Fixes issue where destructured assignment params were incorrectly identified as duplicates. 2012-04-23 20:41:56 -04:00
Trevor Burnham
3b1a566117 Hidden files no longer queued for --join (fixes #2263) 2012-04-23 13:59:42 -04:00
Trevor Burnham
d58da49cee Intermediate version bump to 1.3.2-pre 2012-04-23 13:34:04 -04:00
Jeremy Ashkenas
0fada5109a Merge pull request #2213 from geraldalewis/2211-destructed-splats
Issue #2211 -- splats in destructured parameters
2012-04-23 09:00:22 -07:00
Michael Ficarra
46ff7705ee corrections for octal escape sequences; allows "\0" alone; see #1547
Relevant sections of the spec:
* http://es5.github.com/#C
* http://es5.github.com/#B.1.2
* http://es5.github.com/#x7.8.4
2012-04-20 18:29:40 -04:00
Michael Ficarra
eabcb2c8b0 Merge pull request #2261 from josher19/patch-2 2012-04-12 22:17:13 -07:00
josher19
ea60dfa44d See issue #2620 2012-04-13 12:54:36 +08:00
Michael Ficarra
53a82da3f3 fixes #2255: global leak with splatted @-params 2012-04-12 23:46:28 -04:00
Maxwell Krohn
b03bea14fa Code and commentary diverged in that short time. Fix. 2012-04-11 19:35:14 -04:00
Maxwell Krohn
2f13fae6f0 restore proper error messages 2012-04-11 19:32:40 -04:00
Maxwell Krohn
a92af02ae8 Add some commentary. 2012-04-11 19:17:55 -04:00
Michael Ficarra
4043124135 tests for fix to #2052, f3a1f46679 2012-04-11 18:35:51 -04:00
Maxwell Krohn
7b66e22bc6 now it works for all of #1183. This should do it. 2012-04-11 18:22:52 -04:00
Maxwell Krohn
5542e00b80 sart work on a bugfix, but we're not covering the exact case in issue #1183 2012-04-11 18:05:33 -04:00
Michael Ficarra
f3a1f46679 fixes #2052: don't manually assign constructors' name property
I'm not sure how we would test this, so... no tests.
2012-04-11 12:14:44 -04:00
Michael Ficarra
08673261b1 comments in the REPL should have no output, not undefined 2012-04-11 11:43:31 -04:00
Jeremy Ashkenas
60c9b94656 CoffeeScript 1.3.1 (quick bugfix for compound assignment to a global variable 2012-04-10 17:26:23 -04:00
Jeremy Ashkenas
f0e17fc20f fixing compound assignments to global variables. oof. 2012-04-10 17:07:38 -04:00
Jeremy Ashkenas
de511e0348 resolving merge 2012-04-10 14:58:59 -04:00
Jeremy Ashkenas
ed8d94f69c CoffeeScript 1.3.0 2012-04-10 14:57:45 -04:00
Jeremy Ashkenas
1b3af684cb Merge pull request #2070 from clutchski/slice-docs
Documenting default slice indexes.
2012-04-10 07:56:44 -07:00
Michael Ficarra
53fe10e4ad REPL once again permits indented expressions 2012-04-05 21:33:15 -04:00
Michael Ficarra
b4e1e54cf7 fixes #2239: REPL didn't accept expressions that were just comments 2012-04-05 18:10:05 -04:00
Michael Ficarra
22db7ae85a Octal and binary literals are more appropriately converted to hex 2012-03-27 21:31:48 -04:00
Michael Ficarra
6a88ce7d1e fixes #2224: various issues related to number lexing
This was... embarrassing. I'm just really glad we didn't cut a release
before this got fixed.
2012-03-27 21:31:20 -04:00
Matt Hickford
7e32c32057 build on Windows - fix spawn command by calling node explicitly 2012-03-25 11:17:46 +01:00
Gerald Lewis
c5737764b5 Issue #2211 -- splats in destructured parameters 2012-03-23 13:20:15 -04:00
Michael Ficarra
ddd6e9a48b abb11c80d1 didn't consider objects with [[Call]] 2012-03-10 11:54:31 -05:00
Michael Ficarra
d6fbfa55b6 number literal error messages: more consistent, removed pluralisation 2012-03-08 14:44:47 -05:00
Michael Ficarra
abb11c80d1 splatted constructors returning null should produce the new instance 2012-03-07 18:19:53 -05:00
Trevor Burnham
ef0cb46b9b Following symlinks when setting module.paths (fixes #2175) 2012-03-05 15:00:20 -05:00
Trevor Burnham
209a0f5a79 Rebuilding browser lib 2012-03-03 13:52:43 -05:00
Michael Ficarra
44e1ccec7e eval's options argument should default to {}, even in the browser 2012-03-02 22:51:38 -05:00
Jeremy Ashkenas
7c1f4b38f4 start with 1, then 2 for reused vars. 2012-02-29 23:46:03 -05:00
Jeremy Ashkenas
b9cfb5a7d8 Fixes #2155 -- existential assignment to a closure 2012-02-29 23:41:57 -05:00
Jeremy Ashkenas
1c8411f628 merging in early error for compound assignment to undeclared variables. 2012-02-28 10:42:11 -05:00
Trevor Burnham
de9970412a Making bare the default for eval in the browser (fixes #2148) 2012-02-27 12:13:46 -05:00
Jeremy Ashkenas
a0e3a8b420 Merge pull request #2117 from AdleyEskridge/master
Improve documentation section about heregexes
2012-02-26 09:10:20 -08:00
Jeremy Ashkenas
bc2ca1ef73 building missed commit change. 2012-02-26 11:48:33 -05:00
Jeremy Ashkenas
9a955859fd link typo 2012-02-23 22:05:41 -05:00
Jeremy Ashkenas
ecfe49adca Merge branch 'master' of github.com:jashkenas/coffee-script 2012-02-23 22:05:39 -05:00
Jeremy Ashkenas
7a75b2b8d0 link typo 2012-02-23 22:05:00 -05:00
Michael Ficarra
127653b7d4 fixes #1537: ignore hidden files/directories in watched directories 2012-02-22 12:19:30 -05:00
Jeremy Ashkenas
b7f2681007 Merge pull request #2121 from jashkenas/issue2120
add --help indicator for passing arguments to scripts run with `coffee`
2012-02-14 11:19:43 -08:00
Michael Ficarra
12d6461bbe added help indicator for passing arguments to scripts run with coffee 2012-02-14 12:25:14 -05:00
Michael Ficarra
28a1101b91 merging/improving @rolftimmermans fix/tests for #2007 2012-02-13 19:47:21 -05:00
Michael Ficarra
8248601b72 Merge branch 'object_literals_in_compr' of https://github.com/rolftimmermans/coffee-script into rolftimmermans-object_literals_in_compr
Conflicts:
	test/objects.coffee
2012-02-13 19:41:47 -05:00
Adley Eskridge
2e78508016 Improve section on heregexes
Currently, the only mention of heregexes' support for interpolation is
in the change log. This feature is useful enough to warrant a mention in
the heregex section itself.

I also felt that the heregex section was a bit less clear than it could
be, so I slightly reworded it.
2012-02-12 10:58:53 -06:00
Michael Ficarra
d9120b8365 Merge pull request #2116 from fawek/illegal-parameter-name-error-message
Fix a confusing error message for '(arguments) ->'
2012-02-12 08:46:05 -08:00
Jakub Wieczorek
eb8e20c3ef Fix a confusing error message for '(arguments) ->' 2012-02-12 15:38:42 +01:00
Ken Gregson
cb0003d894 Issue #2105 refined
Fix updated as suggested by michaelficarra
2012-02-05 19:40:29 -05:00
Ken Gregson
7becf808c7 Issue #2105
Make REPL continuation work better. Check for trailing "\" fails when
run function is called with buffer terminated by newline. Chomp'ing
buffer to remove newline fixes this issue.
2012-02-05 19:12:33 -05:00
Michael Ficarra
13f8348568 Merge pull request #2102 from Nitrodist/master
Fix inherited spelling in documentation
2012-02-03 17:32:14 -08:00
Mark Campbell
d6e2ae292e Fix inherited spelling in documentation 2012-02-03 19:07:48 -06:00
Michael Ficarra
e42f96b76d Merge pull request #2101 from clutchski/style-fixes
Style fixes
2012-02-03 16:40:23 -08:00
clutchski
40a9196c7f Removing tab indentation. 2012-02-03 19:33:03 -05:00
clutchski
0ca255b7b8 Whitespace clean-up. 2012-02-03 19:31:26 -05:00
clutchski
8ade4f1077 Indentation fix. 2012-02-03 19:08:45 -05:00
clutchski
d74c909930 Documenting default slice indexes. 2012-01-26 15:57:27 -05:00
Michael Ficarra
c0dac45fe1 OptionParser and related tests needed a cleanup
The object returned from OptionParser::parse no longer has a `literals`
property. It was pretty arbitrary, anyway.
2012-01-25 19:47:03 -05:00
Michael Ficarra
eb5c4057a1 Merge branch 'uppercase_radix_prefixes' of git://github.com/geraldalewis/coffee-script 2012-01-21 11:40:20 -05:00
Gerald Lewis
a080bd40fb Issue #2060 cleanup 2012-01-21 11:21:03 -05:00
Jeremy Ashkenas
b7b92eddbd Merge pull request #2062 from clutchski/lint-fixes
Lint fixes
2012-01-20 19:47:46 -08:00
Jeremy Ashkenas
e0ec397046 Merge pull request #2061 from geraldalewis/uppercase_radix_prefixes
Issue #2060 Disallow uppercase radix prefixes and exponential notation
2012-01-20 19:47:09 -08:00
Gerald Lewis
34e517de09 Issue #2060 Disallow uppercase radix prefixes and exponential notation 2012-01-20 17:23:50 -05:00
clutchski
f40ba672db Fixing indentation, trailing whitespace. 2012-01-20 15:18:50 -05:00
Jeremy Ashkenas
8ac440fd52 Merge pull request #2057 from geraldalewis/2054_{arguments}
Issue #2054 "{arguments}"
2012-01-19 17:49:52 -08:00
Gerald Lewis
c3a8a4f81f Issue #2054 "{arguments}"
Fixes error message: SyntaxError: variable name may not be "true"

Permits assigning to "arguments" and "eval" properties in
object literals.
2012-01-19 11:33:43 -05:00
Michael Ficarra
7c56da26f6 fixes #2055: destructuring assignment with new 2012-01-18 23:12:50 -05:00
Michael Ficarra
97cd2dbc41 committing compiled command.js 2012-01-18 23:12:08 -05:00
Jeremy Ashkenas
8affc297fc Merge pull request #2049 from jawj/6d69812046942ae8faacdfb7d715b5bb5e51855c
Hex-escaped bell char for error on --watched compilation
2012-01-17 09:10:38 -08:00
George MacKerron
6d69812046 Oops -- changed bell char from still-octal to hex 2012-01-17 16:50:56 +00:00
Jeremy Ashkenas
de8d16f5e7 Merge pull request #2048 from jawj/beep-on-compile-error
Changed octal to decimal for escaped bell character
2012-01-17 08:40:16 -08:00
George MacKerron
b4712c6a93 Changed octal to decimal for escaped bell character 2012-01-17 16:34:09 +00:00
Jeremy Ashkenas
3fc4f10248 Merge pull request #1953 from jawj/beep-on-compile-error
Added --beep option to command, to warn user on compilation failure with --watch
2012-01-17 07:12:36 -08:00
George MacKerron
ec55335092 Beep on all --watched compile errors 2012-01-17 15:11:06 +00:00
George MacKerron
af51300887 Made --beep the standard watch behaviour, and debounced it 2012-01-17 11:37:47 +00:00
Michael Ficarra
233cd27d70 rebuilding REPL with newest CS compiler 2012-01-16 19:22:31 -05:00
Michael Ficarra
c1f7db8275 typo 2012-01-16 19:20:24 -05:00
Michael Ficarra
0bf488ea49 fixes #2001: spoof a REPL readline interface to handle piped REPL input 2012-01-16 19:20:24 -05:00
Gerald Lewis
bf8e0aa1ea Issue #1547 'use strict' style tweaks, cleanup, and compiled output 2012-01-16 17:35:21 -05:00
Gerald Lewis
4372138fdd Issue #1547 'use strict' Python-style octal literal notation 0o777
Allows octals in the form '0o777' and '0O777'

Case insensitive

Disallows decimals prefixed with '0'
2012-01-16 17:22:19 -05:00
Gerald Lewis
8b179fb391 Issue #1547 'use strict' eval and arguments use restricted 2012-01-16 17:20:55 -05:00
Gerald Lewis
0b7cfba94a Issue #1547 'use strict' future reserved keywords as identifiers prohibited 2012-01-16 17:20:11 -05:00
Gerald Lewis
f43ec97e30 Issue #1547 'use strict' delete operands restricted 2012-01-16 17:20:02 -05:00
Gerald Lewis
7521068ba3 Issue #1547 'use strict' duplicate formal parameter are prohibited
updated error message (thanks @davidchambers)

code style fixes
2012-01-16 17:19:14 -05:00
Gerald Lewis
a2ef66f197 Issue #1547 'use strict' duplicate property definitions in obj literals prohibited 2012-01-16 17:18:53 -05:00
Gerald Lewis
3a694d7dfa Issue #1547 'use strict' octal escape sequences prohibited
RegExp updated (thanks @michaelficarra)
and hex escapes for colors in Cakefile

tests updated (thanks @satyr)

error message conforms to existing Lexer SyntaxErrors
2012-01-16 17:18:13 -05:00
Gerald Lewis
cad108eca0 Issue #1547 'use strict' octal literals prohibited 2012-01-16 17:18:02 -05:00
Gerald Lewis
66eb186a74 Issue #1547 'use strict' tests 2012-01-16 17:17:48 -05:00
Michael Ficarra
6e1e77d46d Merging #2033; fixes #1534 2012-01-16 15:55:59 -05:00
Michael Ficarra
e207c983c1 cleaned up trailing whitespace; merging @geraldalewis's #2033 2012-01-16 15:50:09 -05:00
Michael Ficarra
9a23511965 adding test for #2037; should've included it in the first place 2012-01-16 15:38:00 -05:00
Michael Ficarra
df7ab264ab fixes #2037: line terminators are incorrectly added after herecomments
thanks @geraldalewis for finding the relevant line and making this fix
way too easy for me
2012-01-16 15:38:00 -05:00
Michael Ficarra
9e1d418d7a CoffeeScript.run should be able to safely omit options 2012-01-16 15:38:00 -05:00
Gerald Lewis
ee9311c025 #1534 class then "use strict": modified strict error condition 2012-01-16 14:09:06 -05:00
Gerald Lewis
2ec4c38433 #1534 class then "use strict": multiple directives support 2012-01-14 15:07:32 -05:00
Michael Ficarra
b6310d0365 adding test for #2037; should've included it in the first place 2012-01-14 11:32:09 -05:00
Michael Ficarra
77670b0f3e fixes #2037: line terminators are incorrectly added after herecomments
thanks @geraldalewis for finding the relevant line and making this fix
way too easy for me
2012-01-14 10:40:15 -05:00
Gerald Lewis
fd1fa7d551 #1534 class then "use strict": herecomments fix 2012-01-13 13:59:24 -05:00
Michael Ficarra
0c5726d3ab CoffeeScript.run should be able to safely omit options 2012-01-12 19:25:51 -05:00
Gerald Lewis
5816de39ba #1534 class then "use strict" compiled output 2012-01-12 18:35:04 -05:00
Gerald Lewis
80677a9d2b #1534 class then "use strict" tests 2012-01-12 18:34:50 -05:00
Gerald Lewis
8d952c245f #1534 class then "use strict" 2012-01-12 18:34:34 -05:00
Michael Ficarra
6d33a2e1a0 allowing capital B in binary literals; see #2021; thanks @BrendanEich 2012-01-12 13:21:29 -05:00
Michael Ficarra
ff05575b78 fixes #1973: redefining Array/Object constructors shouldn't break helpers 2012-01-10 17:01:27 -05:00
Trevor Burnham
16e297ab61 Adding test to ensure that header is disabled by default 2012-01-10 14:03:48 -05:00
Trevor Burnham
447ce82721 Merge pull request #1793 from TrevorBurnham/header
Adding header to generated JS (#1778)
2012-01-10 11:01:16 -08:00
Trevor Burnham
86e4d79ffb Early return from CoffeeScript.compile when header not enabled 2012-01-10 14:00:29 -05:00
Trevor Burnham
11342ef97b Rebuilding -> our JS files now include the generated header 2012-01-10 12:55:41 -05:00
Trevor Burnham
48c17e2c3d Adding header to files compiled with command.coffee 2012-01-10 12:54:48 -05:00
Trevor Burnham
36a69864e3 Adding support for a header with version number to CoffeeScript.compile (#1778) 2012-01-10 12:54:21 -05:00
Rolf Timmermans
64b0e50609 Fix error that prevented object literals from being properly returned from comprehensions. 2012-01-09 09:08:58 +01:00
Jeremy Ashkenas
806df9bc1e Merge pull request #2011 from zzen/patch-1
Cake::printTasks broken in node v0.4
2012-01-05 10:43:35 -08:00
Jakub Nešetřil
f98c613ecc Fixed cake::printTasks to be backward compatible with node v0.4 2012-01-05 19:40:13 +01:00
Michael Ficarra
642fcbbbfe Last commit accidentally broke autocompletion. Fixed. 2012-01-03 18:21:26 -05:00
Michael Ficarra
58bb6725e4 fixes #1979: add multiline support to the REPL; press Ctrl-v to activate 2012-01-03 14:56:17 -05:00
Jeremy Banks
3484ca5e64 Merge remote-tracking branch 'jashkenas/master' into fix-conditional-assignment
Conflicts:
	test/assignment.coffee
2012-01-03 03:09:46 -05:00
Jeremy Ashkenas
0b1b7c36d2 removing out of date Windows instructions -- nothing extra needed now. 2011-12-30 09:07:26 -05:00
Jeremy Ashkenas
8eb04cd80b removing out of date Windows instructions -- nothing extra needed now. 2011-12-30 09:07:10 -05:00
Jeremy Ashkenas
8dfec65034 Fixes #1980 2011-12-27 16:54:14 -08:00
Jeremy Ashkenas
4a0e8139ea Merge pull request #1970 from michaelficarra/issue1966
fixes #1966: external constructors should produce their return value
2011-12-27 09:33:56 -08:00
Michael Ficarra
c8059a752f fixes #1976: minor REPL tab completion bug fixes 2011-12-27 00:45:29 -05:00
Jeremy Ashkenas
62a331a3dc Fixes #1961, Fixes #1974, compound assignments to an implicit object. 2011-12-26 09:45:48 -08:00
Michael Ficarra
90e0ce97e4 unnecessary 2011-12-24 15:44:51 -05:00
Trevor Burnham
3b3c069c3b Moving rewatch to end of function for scoping (thanks, satyr) 2011-12-24 11:00:09 -08:00
Michael Ficarra
46b34d4b43 whitespace cleanup 2011-12-24 07:04:34 -05:00
Michael Ficarra
080ed2e8dd fixes #1966: external constructors should produce their return value 2011-12-24 06:51:14 -05:00
Michael Ficarra
0c4cb309b0 getting rid of excessive spaces after Class.name = "Class" assignment 2011-12-24 06:49:21 -05:00
Michael Ficarra
8d5f800e2f literals need newlines after them 2011-12-24 06:46:09 -05:00
Michael Ficarra
e2a205ab22 making use of slicing syntax 2011-12-24 06:04:05 -05:00
Trevor Burnham
21a499c726 Merge branch 'rewatch2' 2011-12-22 12:02:52 -08:00
Trevor Burnham
e5f3750de2 Removing rewatchTimer (see discussion at #1964) 2011-12-22 12:02:25 -08:00
Jeremy Ashkenas
4944fba3f7 Merge pull request #1964 from TrevorBurnham/rewatch2
Rewatch files on change event (redo)
2011-12-22 11:43:22 -08:00
Trevor Burnham
65d21766b7 Rewatching files more liberally and consistently 2011-12-22 11:30:12 -08:00
Trevor Burnham
2a0521fba6 Freeing compilation from 250ms delay 2011-12-22 11:03:39 -08:00
Trevor Burnham
97cd7cc1c9 Rewatching on every file event, be it change or rename 2011-12-22 10:58:30 -08:00
Trevor Burnham
d3f60599e8 Removing duplicate watchErr declaration (my bad) 2011-12-22 10:50:10 -08:00
Jeremy Ashkenas
8728706237 Merge pull request #1959 from jashkenas/issue1910
fixes #1910: loop index should be mutable within a loop iteration and immutable between loop iterations
2011-12-21 11:42:04 -08:00
Michael Ficarra
c6c527e830 appeasing Jeremy: switching prefix increments out for postfix equivalent 2011-12-21 14:37:38 -05:00
Michael Ficarra
fc0a169a9a fixes #1910: loop index should be mutable within a loop iteration and immutable between loop iterations 2011-12-21 14:06:34 -05:00
Jeremy Ashkenas
5b7366583d Merge pull request #1956 from Gregg/master
Seperated Books and Screencasts and added Code School course
2011-12-20 20:03:16 -08:00
Gregg Pollack
01e03ae2d8 Seperated Books and Screencasts and added Code School course 2011-12-20 22:51:39 -05:00
Jeremy Ashkenas
8a1deee8d8 Merge pull request #1955 from clutchski/implicit-slice
Allowing both end-points of slices to be implicit.
2011-12-20 17:29:30 -08:00
clutchski
2e06316e31 Allowing both end-points of slices to be implicit. 2011-12-20 19:21:26 -05:00
George MacKerron
6870af36b7 Added --beep option to command, to warn user on compilation failure with --watch 2011-12-20 15:27:02 +00:00
Trevor Burnham
0f1dbffa40 Adding test case: do (x = y) -> overrides existing x value 2011-12-19 11:33:52 -05:00
Trevor Burnham
cfb9cb6fe9 Exiting when users try to use --watch and fs.watch is undefined 2011-12-19 11:23:27 -05:00
Jeremy Ashkenas
9de0d886eb bringing back an ol' line of docco. 2011-12-18 23:01:20 -05:00
Jeremy Ashkenas
5c24b80367 Amending new do test. 2011-12-18 21:24:29 -05:00
Jeremy Ashkenas
a477880edc Fixes #960 -- 'do' is now more efficient and permissive about undefined values. 2011-12-18 20:53:30 -05:00
Jeremy Ashkenas
00f5f54b77 removing unused DO from grammar 2011-12-18 20:32:09 -05:00
Jeremy Ashkenas
1018c51359 Fixes #494: Forcing named classes in CoffeeScript (named functions) ... even in IE. 2011-12-18 20:00:09 -05:00
Jeremy Ashkenas
8d8c345216 removing unused @name 2011-12-18 19:37:11 -05:00
Jeremy Ashkenas
dd25ac03e4 fixing the borked previous merge 2011-12-18 18:53:34 -05:00
Jeremy Ashkenas
3ff194dd61 merging in Matt's generated tag for coffeelint. 2011-12-18 18:44:56 -05:00
Jeremy Ashkenas
215979c9e0 bumping to 1.2.1-pre 2011-12-18 15:31:17 -05:00
Jeremy Ashkenas
6d3acdcd2f Merge branch 'master' into gh-pages 2011-12-18 15:29:29 -05:00
Jeremy Ashkenas
9abe614ea8 CoffeeScript 1.2.0 2011-12-18 15:29:02 -05:00
Jeremy Ashkenas
36c171d78e style in command watch 2011-12-18 15:27:08 -05:00
Jeremy Ashkenas
c75c4421a7 merged 2011-12-18 15:23:42 -05:00
Trevor Burnham
55998f7481 Fixing bug that was causing directory deletes to be ignored 2011-12-18 15:21:50 -05:00
Trevor Burnham
d5acd7f338 Fixing bug that was causing file deletes to be ignored, debouncing compileJoin 2011-12-18 15:19:08 -05:00
Trevor Burnham
d3cc05bdfc Preventing compileJoins when directory events do not affect source files 2011-12-18 14:42:16 -05:00
Trevor Burnham
07ccd91022 More ENOENT-catching 2011-12-18 14:39:19 -05:00
Trevor Burnham
edd0b661f3 Avoiding duplicate compileJoins on directory deletion 2011-12-18 14:35:32 -05:00
Jeremy Ashkenas
4b0fabd7cb pushing this waypoint... 2011-12-18 14:26:23 -05:00
Jeremy Ashkenas
55e794dbe5 Merge branch 'issue1941' of git://github.com/TrevorBurnham/coffee-script 2011-12-18 14:21:35 -05:00
Trevor Burnham
988dedd08d Removing remaining ENOENT throws 2011-12-18 14:15:33 -05:00
Jeremy Ashkenas
f66564273c Merge pull request #1944 from TrevorBurnham/issue1941
Misc fixes for --watch
2011-12-18 11:13:22 -08:00
Trevor Burnham
dfc602159e Limiting watched file compilation to once every 25ms 2011-12-18 14:05:18 -05:00
Trevor Burnham
9fde794858 Handling all ENOENTs potentially thrown by fs.watch (hopefully) 2011-12-18 14:01:13 -05:00
Trevor Burnham
ed1ddbce50 Preventing fs.stat from throwing ENOENT errors 2011-12-18 13:50:04 -05:00
Jeremy Ashkenas
cda95afd3e tweaking documentation 2011-12-18 13:41:33 -05:00
Jeremy Ashkenas
0e40feb9af prepping for 1.2.0 2011-12-18 13:21:00 -05:00
Jeremy Ashkenas
846306f85e Fixes #1771: Fixing the indexOf shim. 2011-12-18 13:02:27 -05:00
Jeremy Ashkenas
a0aa090f2c Fixes #1859 -- postfix if preceding an unparenthesized single-line function body 2011-12-18 12:55:21 -05:00
Jeremy Ashkenas
460b5d6edb Got --watch with directory watching and addition / removal of inner subdirectories working... 2011-12-18 12:26:04 -05:00
Jeremy Ashkenas
b9805f3f80 More work on watching / joining ... Fixes #1941, fixes #365. Watched files may now be added and removed, including with --join 2011-12-18 11:27:02 -05:00
Jeremy Ashkenas
0069c4901f reverting the closure wrapper removal again. 2011-12-18 10:35:42 -05:00
Jeremy Ashkenas
93b118bfa2 Revert "reverting to 26a28abcb5 behaviour"
This reverts commit 38b6a43e26.
2011-12-18 10:27:32 -05:00
Jeremy Ashkenas
7c6bc95a84 Correcting and cleaning up --join ... now it works in conjunction with --watch 2011-12-18 10:27:22 -05:00
Jeremy Ashkenas
ee8a1a3b68 style fixes to command.coffee 2011-12-18 09:17:01 -05:00
Jeremy Ashkenas
5bca978444 Fixes #1853 -- fs.watch trouble. 2011-12-18 09:05:42 -05:00
clutchski
347409e354 Code review tweaks. 2011-12-17 19:18:24 -05:00
clutchski
c284f3f226 Mark implicit parens generated. 2011-12-17 18:45:48 -05:00
clutchski
cdd3c13ce9 Marking indentation tokens generated with helper. 2011-12-17 18:40:50 -05:00
clutchski
f6dbaa7c31 Adding generated token helper function. 2011-12-17 18:25:51 -05:00
clutchski
a4553c970c Delete trailing whitespace. 2011-12-17 18:04:50 -05:00
Michael Ficarra
38b6a43e26 reverting to 26a28abcb5 behaviour
This is only slightly problematic for the most pathological of cases
where a prelude is followed by a set of statements, none of which
generate top-level variables or attempt to return. In these cases, the
non-prelude statements will be indented. See related discussion at
e4b3e838e2.
2011-12-15 22:11:42 -05:00
Jeremy Ashkenas
121009dec4 Fixes #1813 2011-12-15 16:03:01 -05:00
Jeremy Ashkenas
510fb59e29 Fixes #1871, allows single-line implicit ends to close implicit objects. 2011-12-15 15:43:38 -05:00
Jeremy Ashkenas
e4b3e838e2 removing the closure-wrapping-removal optimization, because it was incorrectly formatting the code it optimized. 2011-12-15 15:21:58 -05:00
Jeremy Ashkenas
4b70a16cf9 refactoring rewriter to make the methods read consistently. 2011-12-15 13:33:47 -05:00
Jeremy Ashkenas
af0ee70ea3 Fixes #1903 2011-12-15 12:29:03 -05:00
Jeremy Ashkenas
ad39150565 Fixing crappy JS AMD code. 2011-12-15 11:21:38 -05:00
Jeremy Ashkenas
686ef9e7f4 Fixes #1838 2011-12-14 18:31:20 -05:00
Jeremy Ashkenas
fac615108c Fixes #1861 2011-12-14 12:44:27 -05:00
Jeremy Ashkenas
ddfe89d916 cleaning up super assignment. 2011-12-14 12:38:19 -05:00
Jeremy Ashkenas
b0948f81dd Fixes #1876 2011-12-14 12:17:21 -05:00
Jeremy Ashkenas
00f9e244f2 Fixes #1922 2011-12-14 11:32:40 -05:00
Jeremy Ashkenas
eb55f2d8f4 style 2011-12-14 11:26:25 -05:00
Jeremy Ashkenas
b50315d8a0 Adding a more comprehensive test case for the previous commit. 2011-12-14 11:06:01 -05:00
Jeremy Ashkenas
85286b8ca5 Fixes #1842 2011-12-14 11:02:10 -05:00
Jeremy Ashkenas
74944da211 fixing extra newline in the prelude 2011-12-14 10:41:17 -05:00
Jeremy Ashkenas
c9a0a33fa2 reverting 63ab88 2011-12-14 10:39:20 -05:00
Jeremy Ashkenas
b12be3188f tweaking dev dependencies 2011-12-14 10:37:05 -05:00
Michael Ficarra
26a28abcb5 fixes #1509: compile initial comments/literals outside of safety wrapper 2011-12-12 02:49:21 -05:00
Michael Ficarra
5f1314cd66 Merge pull request #1927 from clutchski/traverse-children
Documentation fix: s/traverse/traverseChildren/
2011-12-11 22:03:23 -08:00
clutchski
0ad9d4bf16 Documentation fix: s/traverse/traverseChildren/ 2011-12-12 00:57:17 -05:00
Michael Ficarra
621e5648e3 fixed #1858 for real now 2011-12-10 22:40:08 -05:00
Michael Ficarra
f0728fcf8f fixes #1858: top-level returns should force safety wrapper 2011-12-10 22:06:38 -05:00
Michael Ficarra
63ab886e9f removed excessive spacing 2011-12-10 21:19:59 -05:00
Michael Ficarra
7b4f1b165d fixes #1924: CoffeeScript.compile shouldn't modify options object 2011-12-10 21:00:28 -05:00
Michael Ficarra
8855eede5f Merge pull request #1697 from showell/doc-usage
split out Usage section
2011-12-07 08:38:00 -08:00
Michael Ficarra
69d49e137a more correct jison requirement 2011-12-07 11:13:51 -05:00
Jeremy Ashkenas
94e17e0d88 Merge pull request #1916 from ded/patch-1
jison 0.2.11 requires node v0.4 - v0.5
2011-12-06 15:41:34 -08:00
Dustin Diaz
5debc3c903 jison 0.2.11 requires node v0.4 - v0.5, which in turns makes coffee-script incompatible with node v0.6 2011-12-06 15:03:02 -08:00
Michael Ficarra
0ce332edca fixes #1911: remove spacing around initial skipped comments/JS 2011-12-04 16:43:26 -05:00
Jeremy Ashkenas
b122406683 huh. 2011-11-25 08:49:51 -05:00
Jeremy Ashkenas
35dc56d785 making debugger an expression. 2011-11-25 08:35:20 -05:00
Jeremy Ashkenas
6cb13f4c44 Merge pull request #1892 from marijnh/master
Two tiny fixes
2011-11-25 05:01:56 -08:00
Marijn Haverbeke
26d5c99570 Fix bug in lexer's reserved word error message 2011-11-25 12:46:40 +01:00
Marijn Haverbeke
24836ccf6d Stop treating debugger statements as jumps
Since in most debuggers you can continue past them.

No tests added, since I wasn't sure how to test code with `debugger`
in it.
2011-11-25 12:46:39 +01:00
Jeremy Ashkenas
7d22a011ab amending the previous test 2011-11-24 09:58:04 -05:00
Jeremy Ashkenas
e9e5ae119f adding a test case for throw-as-an-expression. 2011-11-24 09:57:34 -05:00
Jeremy Ashkenas
2c92904109 Reverting conclusion of #1001 -- Throw should be able to be used as part of an expression. 2011-11-24 09:36:16 -05:00
Jeremy Ashkenas
2fb6d0beb9 Revert "Closes #1001. Throw cannot be directly used as an expression with parens, but can appear as a statement in an expression."
This reverts commit 96b22a16eb.
2011-11-24 09:33:45 -05:00
Jeremy Ashkenas
b9c17cab3c Merge pull request #1888 from joliss/fat-arrow-doc
Document fat arrow in class definitions.
2011-11-23 09:18:00 -08:00
Jo Liss
d2c3b79617 Document fat arrow in class definitions.
This pleasently surprised but also confused me when it worked. Now it's
documented. No example (yet), alas, but better than nothing.

Originally added in/around 07e66dd2.
2011-11-23 18:15:50 +01:00
Jeremy Ashkenas
03b8222c9e Merge pull request #1887 from joliss/index-doc
Use "index" for index variable in for loop
2011-11-23 07:33:10 -08:00
Jo Liss
57e109ff11 Use "index" for index variable in for loop
This confused me every time I Ctrl+F'ed the home page for "index" and only got
this cryptic statement:

"Comprehensions replace (and compile into) for loops, with optional guard clauses
and the value of the current array index."

Now I can see how the index is used in the code.
2011-11-23 16:25:21 +01:00
Michael Ficarra
30614c5721 I'd rather have a long line than an orphan. 2011-11-18 15:17:26 -05:00
Jeremy Ashkenas
55521a2f4c Merge pull request #1868 from geraldalewis/1840_invocation_prototype_prop_access
#1840 Invocation Prototype Prop Access
2011-11-14 09:59:58 -08:00
Gerald Lewis
8762e37e58 Merge branch '1840' into 1840_invocation_prototype_prop_access 2011-11-14 11:43:30 -05:00
Gerald Lewis
fba69f5651 tests for 1840 2011-11-14 11:37:16 -05:00
Gerald Lewis
bde1c6282e rebuilt jison parser for 1840 2011-11-14 11:36:58 -05:00
Gerald Lewis
a24451b6d3 fixes #1840: invocations followed by prototype property access now correctly compile 2011-11-14 11:35:54 -05:00
Michael Ficarra
d0b8cded6b 1e25c9da306f38ddf7bd3c63ed7c9540b75384e0#commitcomment-719177 2011-11-14 11:18:45 -05:00
Jeremy Ashkenas
1e25c9da30 Merge pull request #1851 from michaelficarra/issue1844
fixes #1844: bound functions in nested comprehensions causing empty var statements
2011-11-14 07:49:51 -08:00
Trevor Burnham
fe78e65b16 Merging pull req #1826 2011-11-13 20:42:02 -05:00
Trevor Burnham
9e1d1f57f0 Merge pull request #1866 from TrevorBurnham/issue1862
Interface enhancements for cake (#1862)
2011-11-13 17:32:53 -08:00
Trevor Burnham
73acfa18a3 Just showing the error thrown by OptionParser rather than parsing it 2011-11-13 16:20:51 -05:00
Trevor Burnham
266d97f8f5 On second thought, just saying 'run cake' on error rather than listing all options 2011-11-13 15:28:56 -05:00
Trevor Burnham
a70753e6d3 Prefacing task list with the relative Cakefile path 2011-11-13 15:13:05 -05:00
Trevor Burnham
97dbb7bb49 Showing task list on error 2011-11-13 15:12:12 -05:00
Trevor Burnham
79945ad473 Using console.error for errors instead of console.log 2011-11-13 15:11:26 -05:00
Trevor Burnham
1d7a3b4d0f Adding 'No such option' output to parallel 'No such task' (fixes #1862) 2011-11-13 14:53:41 -05:00
satyr
5bf8b422f8 nodes: added missing jump-guard in While::makeReturn, fixing #1850 2011-11-11 06:56:49 +09:00
Trevor Burnham
9633816d7a Warning when fs.watch is unavailable, rather than throwing errors 2011-11-10 15:11:27 +01:00
Trevor Burnham
cc8708493e Forgot to build on previous commit 2011-11-10 15:04:33 +01:00
Trevor Burnham
51b25fb3d8 Bumping version to 1.1.4-pre 2011-11-10 14:54:46 +01:00
Trevor Burnham
b41a69da2d Merge pull request #1847 from TrevorBurnham/rewatch
Re-fs.watching files on rename event (fixes #1803)
2011-11-10 05:49:38 -08:00
Trevor Burnham
1ce92d1aeb Ignoring exception thrown when trying to re-watch a file after rename 2011-11-10 14:44:48 +01:00
Michael Ficarra
496978abdd tiny cleanup in /src/scope.coffee 2011-11-10 03:34:58 -05:00
Michael Ficarra
424bb17224 cleaning up tab calculation in last commit 2011-11-10 03:14:41 -05:00
Michael Ficarra
6d6a5f609a fixes #1844: bound functions in nested comprehensions
causing empty var statements
2011-11-10 03:08:38 -05:00
Michael Ficarra
a296957771 fixes #1848: line number reported as NaN in interpolation parse errors 2011-11-10 01:09:43 -05:00
Michael Ficarra
fbe84e376c forgot to build 11544f2717 2011-11-10 01:09:21 -05:00
Trevor Burnham
d30aa6d621 Ensuring that fs.watch duplication does not occur 2011-11-09 19:54:43 +01:00
Trevor Burnham
966063db0c "Re-fs.watching files on rename event"
See discussion at #1803, #1846, and at
https://github.com/joyent/node/issues/2062
2011-11-09 19:49:14 +01:00
Jeremy Ashkenas
13717e2e65 Merge branch 'master' into gh-pages 2011-11-09 12:53:27 -05:00
Jeremy Ashkenas
7aaaac42bc Merge pull request #1845 from joliss/master
update link
2011-11-09 09:51:25 -08:00
Jo Liss
65930224ee update link 2011-11-09 18:41:09 +01:00
Jeremy Ashkenas
97d1eedd5a Merge pull request #1839 from michaelficarra/issue1832
fixes #1832: speed up `CoffeeScript.eval` in browser script
2011-11-08 19:26:37 -08:00
Michael Ficarra
11544f2717 fixes #1832: speed up CoffeeScript.eval in browser script 2011-11-08 19:56:00 -05:00
Jeremy Ashkenas
590bd3dec9 Merge branch 'master' into gh-pages 2011-11-08 18:13:07 -05:00
Jeremy Ashkenas
74501f643c whoops. 2011-11-08 18:12:58 -05:00
Jeremy Ashkenas
cebfe394ad change_log -> changelog 2011-11-08 18:11:33 -05:00
Jeremy Ashkenas
2e037dcb93 updating gh-pages 2011-11-08 18:08:19 -05:00
Jeremy Ashkenas
3e41659095 CoffeeScript 1.1.3 2011-11-08 18:01:45 -05:00
Jeremy Ashkenas
d592d2c9cb Fixes #1803 -- use fs.watch instead of fs.watchFile ... more of a PITA, but hey. 2011-11-08 16:13:45 -05:00
Jeremy Ashkenas
78491b3a58 fixing relative path to jsl.conf 2011-11-08 16:04:10 -05:00
Jeremy Ashkenas
426f51db21 removing another process.binding() private snafu 2011-11-08 15:58:48 -05:00
Sam Day
8a41ee95c7 Adding updated extras/coffee-script.js 2011-11-06 11:18:18 +10:00
Michael Ficarra
5ae4e06770 cake test: change eq to use egal semantics, paralleling arrayEq 2011-11-05 11:14:09 -04:00
Michael Ficarra
683b3afbc1 cake test: count number of complete tests that pass, not assertions 2011-11-05 11:12:50 -04:00
Michael Ficarra
1c86aee7a4 joyent/node#1914: REPL no longer hides undefined results 2011-11-05 10:35:27 -04:00
Michael Ficarra
11f048c368 compiling @jashkenas' last commit: f0043468a0 2011-11-05 10:34:44 -04:00
Jeremy Ashkenas
f0043468a0 removing process.ARGV from command.coffee, as it is gone in 0.6.0 2011-11-05 07:46:58 -04:00
Sam Day
3564f51fb5 Added AMD support. 2011-11-05 20:44:19 +10:00
Jeremy Ashkenas
df641261d6 trying with just the .org 2011-10-31 22:54:32 -04:00
Jeremy Ashkenas
f3486499ac adding a CNAME file for github pages. 2011-10-31 20:52:31 -04:00
Jeremy Ashkenas
a6081caf50 Merge pull request #1807 from TrevorBurnham/console_io
fixes #1798: using process.stderr in command.coffee
2011-10-27 08:42:17 -07:00
Trevor Burnham
c77f7737a5 Using process.stderr in command.coffee (fixes #1798) 2011-10-27 11:23:03 -04:00
Jeremy Ashkenas
91cb433b66 Revert "Merge branch 'console_io' of git://github.com/TrevorBurnham/coffee-script"
This reverts commit 2cb42b502c, reversing
changes made to 64bd4b3f74.
2011-10-24 16:19:15 -04:00
Jeremy Ashkenas
2cb42b502c Merge branch 'console_io' of git://github.com/TrevorBurnham/coffee-script 2011-10-24 14:56:20 -04:00
Jeremy Ashkenas
64bd4b3f74 rebuilding lexer.js 2011-10-24 14:51:41 -04:00
Trevor Burnham
41f2d2f789 Using console.log and console.error in command.coffee (fixes #1798) 2011-10-24 14:39:55 -04:00
Jeremy Ashkenas
913171f708 Merge pull request #1787 from revence27/binary
Binary notation integers (0b100 as 4).
2011-10-24 07:07:36 -07:00
Trevor Burnham
3f4daaf2ad Whoops, mergefail; corrected 2011-10-23 22:45:32 -04:00
Trevor Burnham
cf32ba0149 Merge pull request #1661 from TrevorBurnham/master
Allow user-added globals on the REPL (fixes #1654)
2011-10-23 19:34:07 -07:00
Trevor Burnham
6bec372684 Merging current master 2011-10-23 22:23:29 -04:00
Revence Kalibwani
620d8ce9ed Cleaner style. 2011-10-22 10:40:26 +03:00
Revence Kalibwani
bf8062ce7f Unindent. :-o 2011-10-21 22:49:47 +03:00
Revence Kalibwani
350e50600d Neater numberToken function. 2011-10-21 22:33:03 +03:00
Revence Kalibwani
938abae4b5 One test; viz., for binary literal. 2011-10-21 22:27:08 +03:00
Revence Kalibwani
264f881a81 Binary notation integers (0b100 as 4). 2011-10-21 21:44:56 +03:00
Michael Ficarra
d359764fba fixes #1774: generate safety wrapper only when necessary. awesome. 2011-10-17 16:12:09 -04:00
Jeremy Ashkenas
4a937ec3b8 Merge pull request #1757 from disnet/nocolor
Add flag to surpress color in cake output
2011-10-10 08:45:27 -07:00
Tim Disney
0ded5b3ff3 removing old changes 2011-10-06 21:39:24 -07:00
Tim Disney
c20a8ff53d using NODE_DISABLE_COLORS instead of flag 2011-10-06 18:43:53 -07:00
Tim Disney
2f38ed5e69 adding flag to surpress color in cake output 2011-10-06 16:17:36 -07:00
Michael Ficarra
054fe34434 fixes #1754: support filenames starting with - by using -- arg 2011-10-06 14:51:27 -04:00
Michael Ficarra
e686e3f6e9 fixes #1752: passing POSIX-style arguments to scripts through the CLI 2011-10-06 04:11:41 -04:00
Jeremy Banks
a768f167cf Improved tests for #1627. 2011-10-04 22:26:50 -04:00
Michael Ficarra
cf996d2c4a quick fix to part of new issue in #1099:
`not in []` unconditionally compiled to `false`
2011-10-03 06:43:00 -04:00
Michael Ficarra
9fef66ffcf empty regular expressions with flags still need to be compiled to /(?:)/ 2011-10-03 03:49:59 -04:00
Michael Ficarra
1627922060 unless is useful outside of single-line statements 2011-10-02 21:03:36 -03:00
Jeremy Ashkenas
981db17b8f Adopting coco-style efficient bound functions for the common case ... but not for class/prototypes. 2011-09-25 21:44:23 -04:00
Jeremy Banks
03a8340a85 Add tests for conditional assignment of variable in parent scope. 2011-09-23 00:45:33 -04:00
Jeremy Banks
036197fac3 Prohibiting conditional assignment of undefined variables for #1627. 2011-09-23 00:45:33 -04:00
Michael Ficarra
52dd348289 fixes #1724 for heregexen
TODO: DRY up that regex handling code so we don't have a duplicate test/error
2011-09-22 04:39:13 -04:00
Michael Ficarra
f4c1b20ec2 fixes #1724: regular expressions beginning with *
also normalised capitalisation in a few error messages
2011-09-22 04:09:58 -04:00
Michael Ficarra
08762a101c fixes #1723: operator precedence in unbounded splice compilation 2011-09-22 02:14:07 -04:00
Michael Ficarra
3b5c889040 fixes #1722: operator precedence in unbounded slice compilation 2011-09-21 18:56:20 -04:00
Jeremy Ashkenas
0171204e50 Merge pull request #1719 from jeremybanks/master
Upgrade jQuery in documentation from v1.4.2 to v1.6.4
2011-09-20 21:42:36 -07:00
Jeremy Banks
dd82b15b78 Upgrade jQuery in documentation from 1.4.2 to 1.6.4. 2011-09-21 00:27:32 -04:00
Jeremy Ashkenas
3d91b10927 Fixes #1714 2011-09-20 23:21:46 -05:00
Jeremy Ashkenas
65b3bf0d4c merging in the try coffeescript linking patch from Jeremy Banks, and regen-ing source. The newline patch makes a *huge* difference on the documentation page. 2011-09-20 22:42:19 -05:00
Jeremy Ashkenas
4c0b2372c7 Merge branch 'master' of https://github.com/jeremybanks/coffee-script 2011-09-20 22:33:35 -05:00
Jeremy Ashkenas
54110c98d9 Issue #1714 ... broken 'in' after raw range 'for' 2011-09-20 22:28:07 -05:00
Michael Ficarra
a2c593bc2c too many newlines after errors in the REPL 2011-09-19 02:18:42 -04:00
Jeremy Banks
de0122dc17 Moving [Link] button's inline style to stylesheet. 2011-09-18 21:53:08 -04:00
Jeremy Banks
2c43a9d209 Pulled Try CoffeeScript fragment prefix into a variable, other minor improvements. 2011-09-18 21:43:10 -04:00
Jeremy Ashkenas
6da70168a6 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-09-18 20:16:14 -05:00
Jeremy Ashkenas
0199515cef experimental change -- comments wanted. writing out helper functions and assignments as a single line, to minimize clutter. 2011-09-18 17:29:01 -05:00
Jeremy Ashkenas
37705e712b removing the extra newline that block comments take 2011-09-18 17:19:09 -05:00
Jeremy Ashkenas
d2b0404188 big whitespace / readability change. join top level block with extra newlines, and class definitions as well. 2011-09-18 17:16:39 -05:00
Jeremy Banks
80f9a20bfd Adds [Link] button to Try CoffeeScript interface. 2011-09-18 17:56:09 -04:00
Michael Ficarra
94a9551ffa fixes #1699 2011-09-18 00:52:30 -03:00
Jeremy Ashkenas
4419f7ca0f Issue #1703, - --x 2011-09-17 22:21:47 -04:00
Jeremy Ashkenas
19f77cfff5 Unified error handling in the lexer. 2011-09-17 21:39:24 -04:00
satyr
3cdee749c6 rewriter: followed up d03d288 2011-09-17 09:18:14 +09:00
satyr
d03d288a98 fixed #1299: overhauled token pairings 2011-09-17 08:26:04 +09:00
Steve Howell
b8d60a9cf1 split out Usage section 2011-09-12 22:58:08 -07:00
Jeremy Ashkenas
c5dbb1c933 Issue #1687. Keeping a reference to __originalDirname in Cake tasks, after Node's __dirname 2011-09-11 23:41:50 -04:00
Jeremy Ashkenas
85342f1e31 Issue #1682, futher refinements to command-line help. 2011-09-11 22:43:28 -04:00
Jeremy Ashkenas
c1f9ae8208 style tweaks for #1687 2011-09-11 22:25:27 -04:00
Jeremy Ashkenas
bd1672621c Merge pull request #1687 from fortes/1686_cakefile_parent_dirs
Check parent directories for Cakefiles
2011-09-11 19:17:20 -07:00
Michael Ficarra
2d6cda7f32 sorting options in coffee --help 2011-09-11 22:04:44 -04:00
Jeremy Ashkenas
2c8690ee39 Merge pull request #1691 from willbailey/master
I didn't see an example of how to do this and thought it might be helpful for others.
2011-09-11 18:11:14 -07:00
Filipe Fortes
6c98480a1e Remove extra call to path.exists when finding Cakefile 2011-09-11 20:50:27 -04:00
Will Bailey
98cc7eb149 [docs] examples of using guards and indices in array comprehensions 2011-09-11 12:43:39 -07:00
Filipe Fortes
6278930aef Check parent directories for Cakefiles. Closes #1686 2011-09-10 20:46:25 -04:00
Jeremy Ashkenas
0b57b3136c Edited src/command.coffee via GitHub 2011-09-09 23:44:34 -03:00
Michael Ficarra
46b7a2d17c Merge branch '1643_splatted_access' of https://github.com/geraldalewis/coffee-script 2011-09-09 22:07:58 -04:00
Trevor Burnham
588af1f6af Merge pull request #1673 from codelahoma/watch-help
clarify --watch option in "coffee -h" output
2011-09-09 18:50:13 -07:00
Gerald Lewis
34f99c4a79 #1643: Bugfix in heredoc in test for 1643 2011-09-09 21:30:00 -04:00
Jeremy Ashkenas
a0d4242da4 Merge pull request #1666 from geraldalewis/1643_splatted_access
#1643 splatted access
2011-09-09 16:17:24 -07:00
Gerald Lewis
447c3639e7 #1643: compiled JS 2011-09-09 19:03:40 -04:00
Gerald Lewis
f0e276c63a #1643: Remove superfluous assignable check from destructured Splats 2011-09-09 19:03:12 -04:00
Gerald Lewis
7d4e693d20 #1643: Updated tests 2011-09-09 18:59:35 -04:00
Gerald Lewis
03372c9b29 #1643: Tag subpatterns in Assign#compilePatternMatch to prevent appending reference to RHS 2011-09-09 18:58:59 -04:00
Gerald Lewis
6d0ba4b3bd #1643: Clean up Assign#compile and Assign#compilePatternMatch 2011-09-09 18:57:57 -04:00
Gerald Lewis
6622f015ab #1643: Add unwrap method to Splat 2011-09-09 18:55:08 -04:00
Rod Knowlton
d6ec5e40cc tiny edit 2011-09-09 15:24:56 -05:00
Rod Knowlton
c44b80b6b6 build to update lib 2011-09-08 20:02:12 -05:00
Rod Knowlton
9db814f70d change phrasing of watch help text 2011-09-08 18:04:59 -05:00
Rod Knowlton
d7f9054108 change phrasing of watch help text 2011-09-08 18:02:23 -05:00
Rod Knowlton
2df9204104 change phrasing of watch help text 2011-09-08 17:59:39 -05:00
Michael Ficarra
b02ac3a733 removed a gratuitous comma 2011-09-08 02:06:58 -03:00
Rod Knowlton
ed4f7046d3 clarify --watch option in "coffee -h" output 2011-09-07 20:19:14 -05:00
satyr
ad1bc1e0b8 closes #1669; loop results are now collected in the same way as auto-returns are generated 2011-09-07 12:13:23 +09:00
Trevor Burnham
70a5402509 Merge pull request #1625 from codelahoma/gh-pages
Clarify `--watch` option on homepage.
2011-09-06 13:31:34 -07:00
satyr
2ea51b02cc fixed #1102; lexer: cleaned up unfinished 2011-09-07 02:56:14 +09:00
Jeremy Ashkenas
036fc561a2 Merge pull request #1662 from geraldalewis/1195_trailing_semicolons
#1195 Ignore trailing semicolons
2011-09-06 06:15:13 -07:00
Jeremy Ashkenas
a8185407fa Merge pull request #1663 from TrevorBurnham/node_version
Bump node dependency from 0.2.5 to 0.4.0
2011-09-05 12:48:49 -07:00
Trevor Burnham
1cc85aad64 Adding tests for CoffeeScript.eval 2011-09-04 13:57:09 -04:00
Trevor Burnham
067cd4b4fe Allowing eval with a sandbox, but defaulting to global context 2011-09-04 13:53:44 -04:00
Trevor Burnham
6d68b1f5ad Bumping node dependency from 0.2.5 to 0.4.0 2011-09-04 13:32:57 -04:00
Trevor Burnham
e8b3e2f248 Restoring the ability to CoffeeScript.eval code in a sandbox 2011-09-04 12:38:59 -04:00
Trevor Burnham
d5aad39b3f Bumping node dependency to 0.4.0 (see discussion at #1661) 2011-09-04 12:27:38 -04:00
Trevor Burnham
cce9ac28c9 Taking an axe to the sandbox (see discussion at #1661) 2011-09-04 12:26:39 -04:00
Gerald Lewis
49e3a91d67 tests for #1195: lex out semicolons before newlines and at end of program 2011-09-04 12:18:38 -04:00
Gerald Lewis
76b6a1771b fixes #1195: lex out semicolons before newlines and at end of program 2011-09-04 12:18:22 -04:00
Michael Ficarra
c88cb5c8b5 Another attempt to fix #1580... still haven't come up with a good way to
test it, though. Hopefully the third time is... the one that works.
2011-09-04 12:16:04 -04:00
Trevor Burnham
efd503f84a Reloading globals after every REPL command (actually fixes #1654) 2011-09-04 10:05:26 -04:00
Trevor Burnham
7ba52ae729 Blacklisting certain globals from REPL rather than whitelisting (fixes #1654) 2011-09-04 09:54:13 -04:00
Gerald Lewis
8ebda7ac02 tests for #1643: splatted accesses in destructuring assignments no longer create obj.key var declarations 2011-09-01 14:47:30 -04:00
Gerald Lewis
43a8b46203 fixes #1643: splatted accesses in destructuring assignments no longer create obj.key var declarations 2011-09-01 14:47:10 -04:00
Jeremy Ashkenas
d1af5163eb Merge pull request #1647 from dget/patch-1
Adding a link to the change log to the current version on the webpage
2011-08-31 15:23:39 -07:00
dget
ee6eccbfe1 Adding a link to the change log to the current version, to make it easier to see what's changed. 2011-08-31 16:10:06 -03:00
Jeremy Ashkenas
d37cfc69d9 Merge pull request #1641 from geraldalewis/1591_splats_in_destructuring
1591 Splatted Expressions in Destructuring Assignment Must Be Assignable
2011-08-30 08:23:26 -07:00
Gerald Lewis
3a6c8c92b3 tests for #1591: splatted expressions in destructuring assignment must be assignable 2011-08-30 11:12:39 -04:00
Gerald Lewis
e17b67e6f2 fixes #1591: splatted expressions in destructuring assignment must be assignable 2011-08-30 11:12:25 -04:00
Jeremy Ashkenas
c0e0ede09f Merge pull request #1636 from mineo/patch-1
alert(html) in the heredoc example
2011-08-29 20:35:23 -07:00
Wieland Hoffmann
a4425471fd alert(html) in the heredoc example 2011-08-30 10:42:34 +03:00
Michael Ficarra
b4e2240ede fixes #1633: error output when using coffee -e 2011-08-27 13:21:03 -04:00
Michael Ficarra
539b872e02 compiled src/coffee-script.coffee 2011-08-27 13:20:29 -04:00
Michael Ficarra
2ff6c4c3fc fixes #1630: in should check indices of the right operand when it can
pass a `hasOwnProperty` check for them
2011-08-26 15:44:00 -04:00
Rod Knowlton
f2c0ea7fa4 Clarify --watch option on homepage. 2011-08-22 22:47:00 -05:00
Jeremy Ashkenas
8686e31271 Merge pull request #1624 from johnyanarella/master
--join fails silently with no resulting output file
2011-08-22 10:39:47 -07:00
John Yanarella
0bf0f6d721 Resolved an issue that could occur while compiling with the --join option which would cause the compiler to silently fail with no resulting output file.
While recursively traversing a source directory, if a directory was encountered containing either no .coffee files (ex. an .svn metadata directory) or where the last file processed in that directory was not a .coffee file, compileJoin() might never be called.

This issue was originally introduced by a (well-needed) optimization in commit dc272a680b.

In join mode, anytime the 'unprocessed' count is decremented, the remaining file count should be evaluated to determine if it is time to run compileJoin().  Previously, compileJoin() would only ever be called in one of the four possible terminating branches of this recursive asynchronous operation.
2011-08-22 13:32:54 -04:00
Michael Ficarra
3ef0c1c88a reverting stylistic change from parent commit 2011-08-16 10:53:08 -03:00
Michael Ficarra
5b115ddb74 (probably) expressing Jeremy's intentions
edited via Github, so no changes to /lib/coffee-script.js
2011-08-16 08:53:15 -03:00
Jeremy Ashkenas
604e39b413 Merge pull request #1605 from geraldalewis/1513_obj_front_ops
#1513 Top level bare obj literals with unary and exist ops
2011-08-15 08:55:24 -07:00
Gerald Lewis
f3253f4f5c tests for #1513 2011-08-15 11:06:53 -04:00
Gerald Lewis
2fb2ddb9b4 fixes #1513 -- top level bare obj literals now wrapped in parens for unary and exists operations 2011-08-15 11:06:36 -04:00
Jeremy Ashkenas
7e4d6198d4 #1568, new super in a function body. 2011-08-14 17:24:19 -04:00
Jeremy Ashkenas
8c31f2ee44 Adding a test for #1595 2011-08-14 17:08:12 -04:00
Jeremy Ashkenas
9a026e51bd Issue #1595, reusing a variable in a catch leads to missing declaration. 2011-08-14 17:04:54 -04:00
Jeremy Ashkenas
50982b668b Issue #1598 -- enabling super() calls in static functions in class bodies. 2011-08-14 16:51:59 -04:00
Jeremy Ashkenas
c6c988ae28 Revert "Ensure test failures get fully outputted."
This reverts commit 41b8b3256d.
2011-08-14 16:39:38 -04:00
Jeremy Ashkenas
306d84828d Merge branch 'super' of https://github.com/aseemk/coffee-script 2011-08-14 16:39:12 -04:00
Jeremy Ashkenas
216ad777de clarifying Cake on the homepage. 2011-08-14 16:24:42 -04:00
Jeremy Ashkenas
4710e744dc clarifying Cake on the homepage. 2011-08-14 16:24:26 -04:00
Aseem Kishore
0b3029dd3f Add test for static super calls.
Tests jashkenas/coffee-script#1598. Fails currently as expected.
2011-08-12 15:10:19 -07:00
Aseem Kishore
41b8b3256d Ensure test failures get fully outputted.
Node's console.log() is non-blocking, so I was seeing test failure output get
cut off since it was happening on process exit. No more!
2011-08-12 14:56:33 -07:00
Jeremy Ashkenas
42f2bd926b Merge pull request #1590 from geraldalewis/proto_access
#1234 Protoype Access in :: Operator
2011-08-12 11:21:46 -07:00
Gerald Lewis
197d07cc85 revised tests for #1234 thanks to @michaelficarra 2011-08-12 14:11:44 -04:00
Gerald Lewis
c9fd0659c2 revised patch for #1234; consolidated Value#push and Value#concat into Value#add; removed unnecessary INDEX_PROTO 2011-08-12 13:38:34 -04:00
Michael Ficarra
fa2fbf0c60 minor enhancements to tests for #1005 2011-08-11 02:17:48 -04:00
Michael Ficarra
c3fe29455b finishing up fix for #1009: class @do; it's a little bit ugly, but it
makes sense to do it this way
2011-08-11 01:52:10 -04:00
Michael Ficarra
df5aca9348 fixes #1005: invalid identifiers allowed on LHS of destructuring
assignment
2011-08-11 01:11:33 -04:00
Gerald Lewis
ab0b36a53f test for #1234 2011-08-10 22:01:47 -04:00
Gerald Lewis
29a44b84d5 fixes #1234 ... :: now creates an intermediary "prototype" Access node before any additional property accesses 2011-08-10 22:01:47 -04:00
Michael Ficarra
e5b77b180a fixes #580 by deleteing the compiler from require.cache and requireing it again 2011-08-10 21:26:16 -04:00
Michael Ficarra
fc1cdfc913 Merge pull request #1584 from MichaelBlume/grammar_path
fix path to grammar file
2011-08-08 22:43:08 -07:00
Mike Blume
8c5027abb9 fix the output path too 2011-08-08 22:37:48 -07:00
Mike Blume
333daf33a3 fix path to grammar file 2011-08-08 22:34:09 -07:00
Michael Ficarra
064f2b5787 README: corrected compilation instruction; added execution instruction 2011-08-09 00:23:55 -03:00
Michael Ficarra
13ac72239a repl: allowing tab completion of an empty line and masking __X
reserved helpers from tab completion; fixes #1583
2011-08-08 18:26:50 -04:00
Michael Ficarra
818216374c Merge branch 'restructuring' of github.com:jashkenas/coffee-script 2011-08-08 13:21:58 -04:00
Michael Ficarra
5a9cf5722f conditional compilation update as per discussion in
a5ba0c27ae
2011-08-08 12:55:22 -04:00
Michael Ficarra
a5ba0c27ae breaking long lines created by 803a7d06e3 2011-08-08 12:27:53 -04:00
Jeremy Ashkenas
f6d3953bc6 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-08-08 10:04:31 -04:00
Jeremy Ashkenas
c9a5135e23 Merge branch 'gh-pages' 2011-08-08 10:04:09 -04:00
Jeremy Ashkenas
ab326aea4c removing errant line from changelog 2011-08-08 10:03:41 -04:00
Michael Ficarra
7cf5988099 allowing classes to extend expressions; fixes #1482 2011-08-07 05:02:01 -04:00
Michael Ficarra
35a30fbd6d cleaned up block comment output; fixes #1186 2011-08-07 03:51:51 -04:00
Michael Ficarra
6608a7aa98 fixes #1100: precedence in or-test compilation of in 2011-08-07 03:43:41 -04:00
Michael Ficarra
803a7d06e3 output formatting cleanup; fixes #1254: improve when compilation; also
causes single-line, single-statement conditional bodies to sit next to
their conditions
2011-08-07 02:59:37 -04:00
Michael Ficarra
be4685589a fixes #1009: classes with reserved words as determined names 2011-08-07 01:48:27 -04:00
Michael Ficarra
bf7d62affb avoiding require.paths poison pill from newer node releases in
`CoffeeScript.eval`
2011-08-06 18:12:55 -04:00
Michael Ficarra
718b73a0ba removed some unnecessary assignment; related: #1491 2011-08-06 13:31:14 -04:00
Michael Ficarra
c2a43f70f2 moved src/coffee-script/*.coffee to src as per discussion in #1246 2011-08-05 18:39:55 -04:00
Michael Ficarra
c222da9dd6 Merge branch 'restructure' of https://github.com/gfxmonk/coffee-script into restructuring
Conflicts:
	Cakefile
2011-08-05 17:47:54 -04:00
Jeremy Ashkenas
55e366f29c Merge pull request #1571 from MichaelBlume/fix-ternary
shorten one of the ternaries
2011-08-04 21:02:16 -07:00
Jeremy Ashkenas
4e71aad124 Merge pull request #1573 from geraldalewis/1464_bound_static_methods
1464 bound static methods
2011-08-04 21:00:46 -07:00
Jeremy Ashkenas
a03f2fe937 Jison goes to 11 2011-08-04 23:59:46 -04:00
Jeremy Ashkenas
5710992156 Merge pull request #1576 from sstephenson/dev-dependencies
Add uglify-js and jison as development dependencies
2011-08-04 20:58:40 -07:00
Jeremy Ashkenas
0ed9be4665 rebuilding the browser js with a new Jison-generated parser. 2011-08-04 23:57:40 -04:00
Sam Stephenson
d665c3a75f Add uglify-js and jison as development dependencies 2011-08-04 22:55:53 -05:00
Jeremy Ashkenas
48f3c70013 bumping version to 1.1.3-pre for Trevor's sake ;) 2011-08-04 23:52:27 -04:00
Jeremy Ashkenas
8a4ec8f562 Adding books + screencasts to the homepage 2011-08-04 23:45:38 -04:00
Jeremy Ashkenas
1a652a9736 CoffeeScript 1.1.2 2011-08-04 23:17:23 -04:00
Mike Blume
15fed8d17f fix another long ternary in the lib 2011-08-04 19:58:27 -07:00
Mike Blume
396f9b3a12 eliminate unnecessary assignment
there's no need to assign this entire if statement to condpart
when condpart is assigned at every endpoint
2011-08-04 19:58:27 -07:00
Michael Ficarra
1f69200d06 Merge pull request #1542 from MichaelBlume/master
Check for existence of this.context. Avoid build error.
2011-08-04 13:23:33 -07:00
Gerald Lewis
0e0d625adb test for #1464 ... bound class methods now keep context 2011-08-04 13:54:26 -04:00
Gerald Lewis
638dbbecbc fixes issue #1464 ... bound class methods now keep context 2011-08-04 13:54:26 -04:00
Michael Ficarra
9f89a83c27 formatting and rewording a test 2011-08-01 17:28:52 -04:00
Mike Blume
178af9de56 check existence of this.context. Avoid build error
https://github.com/jashkenas/coffee-script/issues/1541

with thanks to analyst74 whose bug report made the fix trivial =)
2011-07-31 18:45:30 +00:00
Michael Ficarra
e7854bec09 changed uses of the slice method to CS slices in nodes.coffee 2011-07-31 13:25:57 -04:00
satyr
9b9612e09c fixed #1322; block comments no longer get out of implicitly called implicit objects 2011-07-27 18:49:48 +09:00
Michael Ficarra
d2d02bf91d Cakefile: build:full exits unsuccessfully when tests or builds fail;
test failures now print full stack trace
2011-07-18 17:47:31 -04:00
Jeremy Ashkenas
860c5030d2 Merge pull request #1527 from breckinloggins/fix_1446
Fix for issue #1446: Compiler fails with unrelated exception on file permissions problems
2011-07-18 12:38:23 -07:00
Breckin Loggins
2d54fea90c Fix for issue #1446: Compiler crashes on permissions error instead of giving meaningful error message 2011-07-18 14:29:45 -05:00
Breckin Loggins
5ee0254ce5 Merge branch 'master' of git://github.com/jashkenas/coffee-script 2011-07-18 14:21:09 -05:00
Jeremy Ashkenas
37019dab1c Merge pull request #1522 from breckinloggins/fix_1470
Issue #1470: Command line compiler now assumes ".coffee" extension if left off of file names
2011-07-18 06:12:44 -07:00
Breckin Loggins
2b31f28f8f Replacing heredoc in test with simple string 2011-07-17 15:50:42 -05:00
Michael Ficarra
8931e31991 improving test for #1492 2011-07-17 16:43:50 -04:00
Jeremy Ashkenas
813efbe1d3 Merge pull request #1517 from breckinloggins/master
Patch for issue #1492 (consecutive semicolons in compiled output)
2011-07-17 13:31:32 -07:00
Jeremy Ashkenas
7790df0df6 Merge pull request #1518 from taku0/fix_pluckDirectCall
Removed a garbage code in `pluckDirectCall`.
2011-07-17 09:21:29 -07:00
Jeremy Ashkenas
c2b32df22b Merge pull request #1460 from yyyc514/fix_print_with_join
compileJoin should happen once after all files are read
2011-07-17 09:11:32 -07:00
Breckin Loggins
479a2e0383 Using string interpolation when adding extension 2011-07-16 14:44:26 -05:00
Breckin Loggins
471cf1d51a Issue #1470: Cleaning up logic on extension detection 2011-07-16 14:42:45 -05:00
taku0
ecdaad2fd6 Removed a garbage code in pluckDirectCall.
`args` are removed at 094b876a38.
2011-07-17 02:31:50 +09:00
Breckin Loggins
3e20622bd5 Test implementation of issue #1470. Assuming '.coffee' extension if file not found 2011-07-16 10:44:37 -05:00
Breckin Loggins
8a4a28bd33 Fixing issue #1492: Consecutive semicolons in compiled output in some situations 2011-07-16 09:34:46 -05:00
Jeremy Ashkenas
8fe59ed888 Fixing funkiness introduced in #1498. 2011-07-12 13:13:46 -04:00
Jeremy Ashkenas
1927213174 Merge pull request #1498 from breckinloggins/master
Some typo corrections and minor documentation edits
2011-07-12 09:07:48 -07:00
Michael Ficarra
cb8e147212 arranged and formatted nonContextGlobals list in REPL 2011-07-11 13:08:47 -04:00
Michael Ficarra
07baed89ed Added globals to the REPL that are (for a reason currently unknown to
me) not provided by `vm.Script.createContext`
2011-07-11 12:55:29 -04:00
Michael Ficarra
af1cf3400e fixes tab completion in the REPL 2011-07-10 14:26:31 -04:00
breckinloggins
eb53670676 Changing sentance structure in a grammar rule explanation 2011-07-09 18:33:19 -05:00
breckinloggins
709dc73c27 Removing 'the' from the CoffeeScript Compiler for Windows link 2011-07-09 11:52:02 -05:00
breckinloggins
14e09d2ca8 One more minor correction to main documentation 2011-07-09 10:03:04 -05:00
breckinloggins
0353b0ddd3 Small typo fixes in several files. Completed some missing documentation in nodes.coffee 2011-07-09 09:58:17 -05:00
breckinloggins
f2ba08f77f Minor edits to the main documentation. Added a reference to @alisey's CoffeeScript Compiler for Windows. 2011-07-08 22:22:28 -05:00
Michael Ficarra
1d7d8cb4d2 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-07-06 22:16:30 -04:00
Michael Ficarra
6e9cfd8a33 allow Ctrl-C to escape an unwanted continuation prompt 2011-07-06 22:15:35 -04:00
Michael Ficarra
2a9fd34a03 Made line continuations in the REPL much, much nicer and moved all of
the REPL-specific code out of CoffeeScript.eval and into the REPL
function (thanks for the suggestion, @TrevorBurnham)
2011-07-06 22:15:35 -04:00
Jeremy Ashkenas
b1111c96ca fixes issue #1490 ... jsl.conf is incorrectly npmignored. 2011-07-06 22:15:35 -04:00
Michael Ficarra
55383155e5 More accurately emulating node's REPL behaviour with regard to _
assignment. Also addresses `i for i in [1..3]` regression introduced by
fff4c9c672 and noticed by @satyr
2011-07-06 22:15:35 -04:00
Michael Ficarra
bb1502a9d7 output a newline before exiting REPL 2011-07-06 22:15:35 -04:00
Michael Ficarra
40ee30ecde Fixes #1035, #1425, and #1444: (another) overhaul of REPL and
CoffeeScript.eval. Instead of writing about all the changes and why I
made those decisions, I'll just answer any questions in the commit
comments, so add a commit comment if you want to question anything.
Thanks to @TrevorBurnham and @satyr for their help/contributions. Also,
closes #1487. And still no REPL tests...
2011-07-06 22:15:35 -04:00
Jeremy Ashkenas
4ff00359b6 fixes #1478, documentation. 2011-07-06 22:15:35 -04:00
Michael Ficarra
f433fa4187 improved test for #1436 2011-07-06 22:15:35 -04:00
Michael Ficarra
594ead00e8 improved tests for #1416, fixed accidental scope leak in test for #1420 2011-07-06 22:15:35 -04:00
Timothy Jones
5adf3b8865 Fixes #1461. Existential assignment now correctly reports if it is a statement. 2011-07-06 22:15:35 -04:00
Timothy Jones
4fc52cd08e Fixes #1467. Catch now introduces its parameter to scope. 2011-07-06 22:15:35 -04:00
Jann Horn
4af47f0c26 second part of fixing #1416 2011-07-06 22:15:35 -04:00
Jann Horn
9d3510a1e4 added another test for #1416 2011-07-06 22:15:35 -04:00
Jann Horn
18f6ad9583 fixes #1416: don't omit one 'new' when compiling 'new new' 2011-07-06 22:15:35 -04:00
Jann Horn
4c70ea5e09 test for #1416: don't omit one 'new' when compiling 'new new' 2011-07-06 22:15:35 -04:00
Jann Horn
d32c060e05 fixed #1436 2011-07-06 22:15:35 -04:00
Jann Horn
caa3d1ab5d added a test for #1436, for etc. should work as normal property names 2011-07-06 22:15:34 -04:00
Michael Ficarra
d3e809da38 subliminally promoting the use of interpolation in the documentation 2011-07-06 22:15:34 -04:00
Jeremy Ashkenas
5ab892d009 Merge pull request #1426 from jashkenas/documentationInterpolations
promote the use of interpolation in the documentation
2011-07-06 17:52:32 -07:00
Michael Ficarra
54dbc0fdf8 allow Ctrl-C to escape an unwanted continuation prompt 2011-07-06 17:00:13 -04:00
Michael Ficarra
003f91d43d Made line continuations in the REPL much, much nicer and moved all of
the REPL-specific code out of CoffeeScript.eval and into the REPL
function (thanks for the suggestion, @TrevorBurnham)
2011-07-06 16:36:07 -04:00
Jeremy Ashkenas
83806a4d77 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-07-06 16:06:47 -04:00
Jeremy Ashkenas
c4324f1db2 fixes issue #1490 ... jsl.conf is incorrectly npmignored. 2011-07-06 16:06:17 -04:00
Michael Ficarra
b9c3e0e640 More accurately emulating node's REPL behaviour with regard to _
assignment. Also addresses `i for i in [1..3]` regression introduced by
fff4c9c672 and noticed by @satyr
2011-07-06 13:06:18 -04:00
Michael Ficarra
60e51a238d output a newline before exiting REPL 2011-07-06 13:05:07 -04:00
Michael Ficarra
fff4c9c672 Fixes #1035, #1425, and #1444: (another) overhaul of REPL and
CoffeeScript.eval. Instead of writing about all the changes and why I
made those decisions, I'll just answer any questions in the commit
comments, so add a commit comment if you want to question anything.
Thanks to @TrevorBurnham and @satyr for their help/contributions. Also,
closes #1487. And still no REPL tests...
2011-07-06 03:54:36 -04:00
gfxmonk
ab17f41652 Moved src/*.coffee under src/coffee-script/ so that lib can be added to $NODE_PATH and only expose the top-level coffee-script namespace. Fixes #1246 2011-07-05 21:58:04 +10:00
Jeremy Ashkenas
18ab569b2d Merge branch 'master' of github.com:jashkenas/coffee-script 2011-07-01 08:30:38 -04:00
Jeremy Ashkenas
2951d34dc0 fixes #1478, documentation. 2011-07-01 08:30:12 -04:00
Michael Ficarra
0cc5379caa improved test for #1436 2011-06-30 12:15:00 -04:00
Michael Ficarra
f6fcfa831c Merge branch 'bugfix-1436' of git://github.com/thejh/coffee-script into thejh_1448 2011-06-30 11:53:24 -04:00
Michael Ficarra
c93fc3ec76 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-06-30 11:46:32 -04:00
Michael Ficarra
7b5f012f79 improved tests for #1416, fixed accidental scope leak in test for #1420 2011-06-30 11:35:29 -04:00
Timothy Jones
22cee5d2d6 Fixes #1461. Existential assignment now correctly reports if it is a statement. 2011-06-29 18:54:23 -04:00
Timothy Jones
0f18dff464 Fixes #1467. Catch now introduces its parameter to scope. 2011-06-29 18:54:23 -04:00
Timothy Jones
e38aeefb5c Fixes #1461. Existential assignment now correctly reports if it is a statement. 2011-06-26 03:08:38 +12:00
Timothy Jones
baa983ac33 Fixes #1467. Catch now introduces its parameter to scope. 2011-06-26 02:34:52 +12:00
Josh Goebel
cd65c66cf9 combine conditions 2011-06-23 06:54:06 -04:00
Josh Goebel
dc272a680b compileJoin should happen once after all files are read 2011-06-23 04:42:12 -04:00
ngn
6f64fc266d added one more test for #1150 2011-06-22 19:42:07 +03:00
Jann Horn
73af3b17b1 second part of fixing #1416 2011-06-21 16:42:53 +02:00
Jann Horn
8b2884e40f added another test for #1416 2011-06-21 16:42:20 +02:00
Jann Horn
f0c22f390d fixes #1416: don't omit one 'new' when compiling 'new new' 2011-06-20 18:38:29 +02:00
Jann Horn
11f2cd4515 test for #1416: don't omit one 'new' when compiling 'new new' 2011-06-20 18:38:07 +02:00
ngn
5ce7984a2b Another attempt to fix #1150
Here's how the algorithm in balancedString() was modified.  When we
encounter a slash in an interpolation, we:

    * try to find a heregex right after it; if found---skip it.  Three
      slashes always terminate a heregex, no matter if there is an open
      "#{" before them or not, so we don't have to bother about
      sub-interpolations inside the heregex.

    * try to find a regex right after it; if found---skip it.  Simple
      regexen can't contain interpolations.

    * otherwise, assume that the slash means division and carry on.
2011-06-19 20:05:38 +03:00
Jann Horn
9699059226 fixed #1436 2011-06-19 10:49:41 +02:00
Jann Horn
9941c3f045 added a test for #1436, for etc. should work as normal property names 2011-06-19 10:49:19 +02:00
Michael Ficarra
25e7eeac8f Revert "Merge https://github.com/ngn/coffee-script"
This reverts commit 277e82bd03, reversing
changes made to 0f523de212.
2011-06-17 11:53:48 -04:00
Michael Ficarra
277e82bd03 Merge https://github.com/ngn/coffee-script 2011-06-17 11:32:08 -04:00
Michael Ficarra
a1f1afe3ed fixes #1442: javascript literals should increase line count when they
contain newlines
2011-06-17 11:26:39 -04:00
ngn
0f523de212 Fix for #1150: String interpolation regression 2011-06-15 20:34:12 +03:00
Michael Ficarra
47f12c453a subliminally promoting the use of interpolation in the documentation 2011-06-08 19:38:12 -04:00
Michael Ficarra
dfcff3f0fc adding regression test for #1420; also cleaned up a little trailing
whitespace in the function invocation tests
2011-06-07 04:10:40 -04:00
Michael Ficarra
522f2ee3b3 fixes #1420: (fn() ->) by causing the Lexer::tagParameters method to
give up looking for a parameter list when it saw a `CALL_START` token.
2011-06-07 03:58:36 -04:00
Michael Ficarra
8ce1fdb5bb enhancement for fix to #1409: when compiling as an array, ranges can't
have been given steps (would be a SyntaxError) ... yet
2011-06-02 09:28:13 -04:00
Michael Ficarra
a0efdac8ce removed trailing whitespace in source files 2011-06-02 02:00:47 -04:00
Michael Ficarra
22bc54f974 fixes #1409: creating large ranges outside of a function body 2011-06-02 01:50:31 -04:00
Michael Ficarra
e240621a72 test for #1409 2011-06-02 01:49:28 -04:00
Michael Ficarra
35c2a72ad2 REPL blank line fix 2011-06-02 01:34:55 -04:00
Michael Ficarra
10ec1a659f fixes #1398: comments in the REPL 2011-05-28 22:39:27 -04:00
Jeremy Ashkenas
1fb34e42a6 Revert "fixed condext during construction of bound functions; now using native"
This reverts commit 8d6e33c2cf.
2011-05-28 18:58:48 -04:00
Jeremy Ashkenas
7082000e66 Revert "switched to canonical two-space indentation in __bind helper"
This reverts commit 6a40807330.
2011-05-28 18:58:38 -04:00
Jeremy Ashkenas
79fff367c2 Revert "__bind helper: caching ctor"
This reverts commit 9cbf2a82ec.
2011-05-28 18:58:28 -04:00
Michael Ficarra
9cbf2a82ec __bind helper: caching ctor 2011-05-27 18:41:31 -04:00
Michael Ficarra
6a40807330 switched to canonical two-space indentation in __bind helper 2011-05-27 18:18:22 -04:00
Michael Ficarra
8d6e33c2cf fixed condext during construction of bound functions; now using native
Function::bind when it is available. related: #1363
2011-05-27 18:03:57 -04:00
Michael Ficarra
085874d5f3 hopefully the last enhancement for my #1380 fix 2011-05-25 12:57:45 -04:00
Michael Ficarra
94fb7e32ea removing accidentally-committed console.log 2011-05-25 04:22:03 -04:00
Michael Ficarra
042f7ec791 enhancement for #1380 fix 2011-05-25 04:10:50 -04:00
Michael Ficarra
e4f47a05f6 merging @TrevorBurnham's pull request #1314, enhancing CS.eval; closes #1314 2011-05-25 03:53:51 -04:00
Michael Ficarra
bbf37e5229 Merge pull request #1388 from johnyanarella/master
'coffee' silently fails with no output when the --join option is specified and the source files specified include directories
2011-05-25 00:47:05 -07:00
Michael Ficarra
454aa8433b fixes #1390: persistence of non-enumerable global properties in the REPL 2011-05-25 03:43:10 -04:00
Michael Ficarra
bbf1c6a8df fixes #1380: super with reserved names 2011-05-25 03:22:26 -04:00
Michael Ficarra
8e5eff5e1e test for #1380 2011-05-25 03:22:06 -04:00
Michael Ficarra
e64fa71185 fixes #1372: bound class methods with reserved names 2011-05-24 16:49:45 -04:00
Michael Ficarra
c8845643e5 fixes #1385: property access on parenthesized number literals 2011-05-24 16:27:07 -04:00
John Yanarella
371ff5e726 Fixed silently failing command line --join functionality when directories are specified for compilation. 2011-05-24 15:01:35 -04:00
Michael Ficarra
19520d8d35 merging in @fjakobs's heregex line number fix; closes #1374 2011-05-19 13:59:58 -04:00
Fabian Jakobs
abb11a7c0e fix line numbers after heregexps 2011-05-16 19:56:29 +02:00
Michael Ficarra
2ac74356bd cleaned up and optimized fix for #1354 (d91ccd4003) 2011-05-15 21:46:35 -04:00
Jeremy Ashkenas
004f13f0fc Merge pull request #1346 from adam-f/fixedsplatscope
Fixed improper scoping of siblings to the splat argument.
2011-05-15 17:13:50 -07:00
Adam Freidin
395a97ef07 removing unimportant changes for easy pull. 2011-05-15 17:11:02 -07:00
Jeremy Ashkenas
01b0cfc8ab Merge pull request #1324 from TrevorBurnham/node-modules
Use `require.main` instead of loop to get main module
2011-05-15 17:04:40 -07:00
Jeremy Ashkenas
f3758e4af0 Fixes #1328 2011-05-15 19:59:52 -04:00
Jeremy Ashkenas
2563324ed8 merging #1353 2011-05-15 18:56:11 -04:00
Jeremy Ashkenas
d91ccd4003 Issue #1354, 'in' with splatted arrays. 2011-05-15 18:50:04 -04:00
Jeremy Ashkenas
15ddb8e2ea simplifying some string interpolation in Range#compileNode 2011-05-15 17:07:59 -04:00
Jeremy Ashkenas
c056c93e19 Issue #1356 ... range comprehension optimization when a step is present. 2011-05-15 17:05:05 -04:00
Jeremy Ashkenas
9e32a5bfa1 fixing implicit invocations against inline try/catch. 2011-05-15 15:04:29 -04:00
Jeremy Ashkenas
cd5c41f351 Issue #1364, implicit calls against control structures. 2011-05-15 10:41:41 -04:00
Jeremy Ashkenas
b780d707ab fixing over whitespace-ing from the previous commit. 2011-05-15 10:16:46 -04:00
Jeremy Ashkenas
84ae563368 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-05-15 10:08:55 -04:00
Jeremy Ashkenas
dddc7c6edb Issue #1368, block comment formatting. 2011-05-15 10:08:31 -04:00
Gerald Lewis
bd8d82809b Updated tests for #1216 and pull #1348 2011-05-11 09:11:41 -04:00
Gerald Lewis
51b7142805 Fix for #1216 and pull #1348; preserves original semantics while prettying the compiled output 2011-05-11 09:10:58 -04:00
Michael Ficarra
6c9ef76b95 fixed behavioural change accidentally introduced by #1348, thanks @satyr 2011-05-11 00:08:24 -04:00
Michael Ficarra
a024ec5b27 reverting tests from @geraldalewis's fix for #1216 2011-05-10 23:23:31 -04:00
Gerald Lewis
2212e959ac Fix for #1216 ?= compilation 2011-05-10 19:33:30 -04:00
Jeremy Ashkenas
d4d027159f rebuilding browser/source 2011-05-10 10:04:25 -04:00
Jeremy Ashkenas
a8a581acae Never return from a constructor. 2011-05-10 10:03:22 -04:00
Jeremy Ashkenas
9e4fa02cdb CoffeeScript 1.1.1 2011-05-10 09:27:19 -04:00
Jeremy Ashkenas
6d6e07604e Fixing external constructors / order of execution for once and for all ... knock on wood. 2011-05-10 09:24:20 -04:00
Adam Freidin
dc499089e9 fixed name of simple destructuring test. 2011-05-08 15:00:27 -07:00
Michael Ficarra
f4b8e19c7f adding another failing test case related to #1182 2011-05-08 17:16:45 -04:00
Adam Freidin
1809c0e675 fixed 2nd scoping problem
x = 10
([x]) -> # used to not declare var x

this is one fix, the other way to fix
it is to remove the entire if ... olen is 1 ....
block... not sure if that's a good idea or not.
2011-05-08 04:59:44 -07:00
Adam Freidin
d11d69958f Removed extra index variable left from code thrash 2011-05-08 04:32:47 -07:00
Adam Freidin
6d2733405d Fixed splat sibling variable scope leak. 2011-05-07 20:46:08 -07:00
Adam Freidin
2dc2d162bc variadic arguments breaking out of scope (test) 2011-05-07 16:55:27 -07:00
Michael Ficarra
56b2b02637 some cleanup, renaming temporary variable from _by to _step 2011-05-06 23:10:46 -04:00
Michael Ficarra
d031c26229 Merge git://github.com/geraldalewis/coffee-script into geraldalewis_issue1326 2011-05-06 22:53:26 -04:00
Michael Ficarra
4046fcf971 adding failing test case for #1182 execution order bug mentioned by
@satyr
2011-05-06 09:48:12 -04:00
Michael Ficarra
7a4fd2ec01 slightly improved fix for #1182 and #1313 2011-05-06 09:47:40 -04:00
Michael Ficarra
73731ba155 Merge branch 'issue1313' 2011-05-06 01:10:27 -04:00
Michael Ficarra
8781a148db issues #1313 and #1182: better class compilation in presence of
externally defined constructors and inheritence via `extends`. Thanks to
@stephank for the suggested approach.
2011-05-06 01:00:35 -04:00
Gerald Lewis
0e978a0d99 Merge branch 'issue_1326' 2011-05-04 13:14:46 -04:00
Gerald Lewis
ac46ede170 Fix for #1326 by value is uncached 2011-05-04 13:12:05 -04:00
Satoshi Murakami
ad669fc23a command: JSLint => JavaScript Lint 2011-05-04 10:04:17 -07:00
Trevor Burnham
b9d3bc5b44 x = {} if x -> x and= {}, per Michael's suggestion
https://github.com/jashkenas/coffee-script/pull/1324/files#r25463
2011-05-03 17:06:34 -04:00
Trevor Burnham
fa2ed81485 Renaming root to mainModule in run method 2011-05-03 15:53:10 -04:00
Trevor Burnham
ea4a723379 Simpler method of getting the root module 2011-05-03 15:47:39 -04:00
Jeremy Ashkenas
71bcdb91c8 fixing changelog -- it was a regression from an earlier commit, not a true fix. 2011-05-01 14:29:48 -04:00
Jeremy Ashkenas
08294dc4d6 s/process.mainModule/require.main 2011-05-01 13:45:47 -04:00
Jeremy Ashkenas
09712603c4 coffee-script 1.1.0 2011-05-01 12:08:15 -04:00
Jeremy Ashkenas
2fb7ccc8f0 Revert "Fix for #1304 ... but disallows an alternative syntax."
This reverts commit 31bfe50831.
2011-05-01 10:43:50 -04:00
Jeremy Ashkenas
31bfe50831 Fix for #1304 ... but disallows an alternative syntax. 2011-05-01 10:16:04 -04:00
Jeremy Ashkenas
9aa3b5b78c showing line number information for failed tests. 2011-05-01 10:11:56 -04:00
Jeremy Ashkenas
7480f55e53 making end implicit tokens generated 2011-05-01 10:03:50 -04:00
Jeremy Ashkenas
5fd82e829b fixing test.html 2011-05-01 08:28:00 -04:00
Jeremy Ashkenas
43ebec1812 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-05-01 08:12:27 -04:00
Michael Ficarra
5cdf02f840 Merge pull request #1309 from TrevorBurnham/sandbox.
Fixing unavailability of `global` properties on REPL
2011-04-30 23:26:25 -07:00
Trevor Burnham
824e081005 Fixing unavailability of global properties on REPL 2011-05-01 01:45:14 -04:00
Trevor Burnham
fc992ba380 Using process.mainModule.filename instead of passing __filename 2011-04-30 23:01:36 -04:00
Trevor Burnham
264070bfc7 Making process.execPath point to coffee when running .coffee files
Related: #1303 set `process.argv[0]` to `coffee`. This makes
`process.execPath` consistent with that change.
2011-04-30 19:45:32 -04:00
Jeremy Ashkenas
a91509ba72 reintroducing a variant of kit's in-order script loading fix. 2011-04-30 13:48:54 -04:00
Jeremy Ashkenas
0dfe2429bc reverted @kitgoncharov's commits that broke the browser runner. 2011-04-30 13:33:28 -04:00
Jeremy Ashkenas
f1ad2e1fae Revert "Fix a typo in browser.coffee."
This reverts commit 6793eb383c.
2011-04-30 13:32:26 -04:00
Jeremy Ashkenas
c51679810a fixing unfoldSoak performance my memoizing. #1033 2011-04-30 13:13:09 -04:00
Jeremy Ashkenas
468ad1a2d5 Updating README and website with -g instructions. 2011-04-30 11:10:37 -04:00
Jeremy Ashkenas
bf8fbc2c0e Fixing process.argv[0] ... #1303 2011-04-30 10:59:55 -04:00
Jeremy Ashkenas
0ed8ae28e7 merging #1303 ... setting process.argv[0] to coffee for coffee's run. 2011-04-30 10:39:28 -04:00
Jeremy Ashkenas
f76ad8912c Merge pull request #1305 from benatkin/patch-1.
Updated for npm 1.0: the -g option installs to the global npm bin directory
2011-04-30 07:36:43 -07:00
Jeremy Ashkenas
83e7d442fb slightly less sketchy fix for #1106. 2011-04-30 10:35:56 -04:00
Jeremy Ashkenas
76252659fd Merge pull request #1300 from michaelficarra/issue1106.
fixes issue #1106
2011-04-30 07:29:41 -07:00
Ben Atkin
19036348a5 Updated for npm 1.0: the -g option installs to the global npm bin directory.
Without -g, the bin is in node-modules/.bin/coffee.
2011-04-29 19:57:18 -07:00
Michael Ficarra
7efea4bb23 removed "globals" option of CoffeeScript.compile and enhanced fix from
previous commits
2011-04-29 15:53:30 -04:00
Michael Ficarra
63ce244359 Better fixes for problem mentioned in last 3 commits. Also adds _
special value (as in node's REPL) that always holds return value of last
executed expression. Finally, fixes #1109
2011-04-29 13:59:59 -04:00
Michael Ficarra
0bdf9538d0 Recently discussed problem has been understood. Adding relevant values
to the global scope upon `eval` in REPL.

See bcf1e178a1 (commitcomment-362493)
2011-04-29 09:29:25 -04:00
Michael Ficarra
b88e23892f Fixes broken require from last commit. We're not actually sure yet
*why* `require` and only `require` was affected. All other globals that
I tried were unaffected: `console`, `parseInt`, `process`, `global`,
`Array`, `Object`, `Buffer`, `setTimeout`, ...
2011-04-29 09:18:47 -04:00
Michael Ficarra
bcf1e178a1 Fixes error in REPL where any variable defined in
`src/coffee-script.coffee` is shared with the REPL scope. Example: try
`lexer` or `@VERSION` pre-commit.
2011-04-29 02:32:16 -04:00
Trevor Burnham
fe889b8428 Setting process.argv[0] to 'coffee' in the REPL (aesthetic) 2011-04-28 18:35:42 -04:00
Trevor Burnham
cde7498c8e Setting process.argv[0] to 'coffee' in 'coffee foo.coffee'
See #1301 et al.
2011-04-28 18:27:40 -04:00
Jeremy Ashkenas
a27feb4157 Making the naming of the --join'd coffeescript mandatory. Issue #1076. 2011-04-27 23:06:58 -04:00
Jeremy Ashkenas
a93c835557 Issue #1006, infinite loop in addImplicitParentheses. 2011-04-27 22:49:42 -04:00
Michael Ficarra
5cd5821c18 #1106 test case: making sure __proto__ exists in case v8 ever removes it 2011-04-27 18:57:22 -07:00
Jeremy Ashkenas
3912e29eb7 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-04-27 21:56:31 -04:00
Jeremy Ashkenas
0bad04d374 Issue #1182 -- subclasses with external constructor functions. 2011-04-27 21:56:08 -04:00
Michael Ficarra
50c3a64553 fixes #1106; __proto__ compilation 2011-04-27 21:39:30 -04:00
Michael Ficarra
cd8492dd7b test for #1106 2011-04-27 21:36:29 -04:00
Jeremy Ashkenas
79e160a46b Edited documentation/index.html.erb via GitHub 2011-04-27 06:51:05 -07:00
Timothy Jones
761b3b3646 Merged pull request #1298 from pjaspers/patch-1.
Typo error, s/synax/syntax
2011-04-27 03:18:32 -07:00
Piet Jaspers
937f027f3c Typo error, s/synax/syntax 2011-04-27 00:57:37 -07:00
Jeremy Ashkenas
da14538299 Issue #1272 documentation 2011-04-26 21:47:48 -04:00
Jeremy Ashkenas
02fbf766ad removing erroneous tabs from nodes.coffee. 2011-04-26 21:23:51 -04:00
Jeremy Ashkenas
b13bef7f45 #1256, documentation typo 2011-04-26 20:46:07 -04:00
Jeremy Ashkenas
5e1aadba80 expanding on the sentence that talks about standalone extends ... Issue #1258 2011-04-26 20:42:24 -04:00
Jeremy Ashkenas
44e0bbf342 Issue #1262, print filename in error messages for require module scripts. 2011-04-26 20:35:30 -04:00
Jeremy Ashkenas
a7ed3379df merging in kit's in-order execution patch. 2011-04-23 13:40:40 -04:00
Jeremy Ashkenas
19849e66d4 renaming wordy test titles. 2011-04-23 13:35:15 -04:00
Jeremy Ashkenas
e9dac2fddc Fixes #1280, regex and compound division mixup. 2011-04-23 13:33:35 -04:00
Jeremy Ashkenas
e61fe48b4d Issue #1294, throw the error for a bad symlink reference when compiling a file. 2011-04-23 13:21:58 -04:00
Jeremy Ashkenas
7e8b52ad70 be more consistent about === 2011-04-20 23:43:41 -04:00
Jeremy Ashkenas
d5a5f9572e be consistent about triple-equals-equality. 2011-04-20 23:24:59 -04:00
Jeremy Ashkenas
fe4f7f8b0f Merge branch 'gh-pages' of https://github.com/willmoffat/coffee-script 2011-04-20 23:16:27 -04:00
Jeremy Ashkenas
4e3f80749f merging issue #1127 2011-04-20 23:12:05 -04:00
Jeremy Ashkenas
ff8c340330 Merge branch 'keyboard' of https://github.com/willmoffat/coffee-script 2011-04-20 23:10:48 -04:00
Jeremy Ashkenas
039109ed56 Removing resources section from the homepage, in favor of linking to the Wiki. #1137 2011-04-20 23:08:21 -04:00
Jeremy Ashkenas
f3f34e9ef5 Fixes #1188, scope for self-referencing functions. 2011-04-20 22:16:56 -04:00
Jeremy Ashkenas
2f39102026 merging fix for #1124 2011-04-18 20:44:27 -04:00
Kit Goncharov
6793eb383c Fix a typo in browser.coffee. 2011-04-11 13:50:27 -06:00
Kit Goncharov
2caceda8c4 Enforce script execution order in browser.coffee. 2011-04-11 13:38:38 -06:00
Jeremy Ashkenas
238dc3a5b6 merging in #1268 ... michaelficarra's colored REPL. 2011-04-09 17:42:03 -07:00
Jeremy Ashkenas
390ff30690 Merge branch 'stable' 2011-04-09 17:39:55 -07:00
Jeremy Ashkenas
e1cf187cfe Merge branch 'bugfix-1157' of https://github.com/thejh/coffee-script into stable 2011-04-09 16:11:21 -07:00
Jeremy Ashkenas
8c01df7828 Merge branch 'stable' 2011-04-09 16:02:10 -07:00
Jeremy Ashkenas
ff8faa4cd7 Merge branch 'stable' of github.com:jashkenas/coffee-script into stable 2011-04-09 16:01:20 -07:00
Jeremy Ashkenas
b9aa64fd25 merging in Josh's patch for Node 0.4.x module lookup changes. 2011-04-09 16:00:57 -07:00
Jeremy Ashkenas
8dfd53620c Merge branch 'module-loading' of https://github.com/josh/coffee-script into stable 2011-04-09 16:00:17 -07:00
Michael Ficarra
0090aee0e5 full revert of 4ce374be25 2011-04-09 10:48:14 -04:00
Michael Ficarra
230dea1243 fixes #1274: {}=a() and []=a() compile to false instead of a() 2011-04-09 09:54:45 -04:00
Michael Ficarra
3453bfa513 regression tests for #1274 2011-04-09 09:53:04 -04:00
Michael Ficarra
d0f047dfe7 improved fix for #1266 2011-04-07 19:40:45 -04:00
Michael Ficarra
8e7c454de0 disabling colours for win32 and in presence of NODE_DISABLE_COLORS
environment variable
2011-04-05 20:51:28 -04:00
Michael Ficarra
68c75c7eb1 pretty node-like output in the REPL 2011-04-05 20:40:54 -04:00
Michael Ficarra
31ae260282 unnecessarily strict {in,}equality in existence checks 2011-03-29 17:25:09 -04:00
Jann Horn
8b443b94ea added a test 2011-03-28 23:16:49 +02:00
Jann Horn
6ec9c844e4 fixes #1124 (and uglifies generated JS) 2011-03-28 23:12:27 +02:00
Jeremy Ashkenas
3d3b03e1e4 Merge branch 'stable' of github.com:jashkenas/coffee-script into stable 2011-03-28 08:37:15 -04:00
Jeremy Ashkenas
4d194cb50c rebuilt parser with Jison 0.2.4 2011-03-28 08:36:42 -04:00
Michael Ficarra
b0d2bf4afe Merge branch 'improvedRangeCompilation' of github.com:michaelficarra/coffee-script into michaelficarra-improvedRangeCompilation 2011-03-28 00:51:42 -04:00
Michael Ficarra
8f73bc3b4c Merge branch 'bugfix-1108' of https://github.com/thejh/coffee-script into thejh-bugfix-1108 2011-03-27 23:54:46 -04:00
Michael Ficarra
90495b614f Merge branch 'thejh-bugfix-1099' into stable 2011-03-27 23:47:01 -04:00
Michael Ficarra
f03bcc24ad enhanced tests for #1099 fix 2011-03-27 23:42:49 -04:00
Jann Horn
6646155712 fixes #1157: when compiling multiple scripts, compile them if at least one of them isn't empty 2011-03-27 23:30:55 +02:00
Jann Horn
9d72208d9e added a test (issue #1099) 2011-03-27 21:35:29 +02:00
Jann Horn
e84e703211 fixes bug mentioned by @satyr in #1108
"[v] = a ? b" must compile to
v = (typeof a != "undefined" && a !== null ? a : b)[0];
and not to:
v = typeof a != "undefined" && a !== null ? a : b[0];
2011-03-27 21:22:09 +02:00
Jann Horn
0497c0742f fixes #1099: instead of nothing, compile to false
"if a in []"
2011-03-27 19:46:44 +02:00
Joshua Peek
573e2b0012 Assign module.paths for node_module loading 2011-03-25 15:36:48 -05:00
Michael Ficarra
c4b72fcc79 improved range compilation 2011-03-23 13:49:15 -04:00
Jeremy Ashkenas
a2d7716331 Adding CoffeeScript.mode 2011-03-20 17:40:20 -04:00
Will Moffat
67b5ebdb76 Bind not required for evalJS. 2011-03-19 16:03:53 -07:00
Will Moffat
4c2ce2b45b Merge branch 'master' of https://github.com/jashkenas/coffee-script into keyboard 2011-03-19 15:28:50 -07:00
Jeremy Ashkenas
3b2bade2f2 Use the newer Node.js binding for 'vm'. 2011-03-16 05:47:58 -05:00
Jeremy Ashkenas
cdeb28a793 missing space. 2011-03-16 05:45:17 -05:00
Jeremy Ashkenas
61918a1efa merging stable 2011-03-12 07:41:58 -06:00
Jeremy Ashkenas
963adb5230 merging jcoglan's splat declaration patch. 2011-03-12 07:41:14 -06:00
Jeremy Ashkenas
8f8a1ecf18 Merge branch 'master' of github.com:jashkenas/coffee-script 2011-03-12 07:38:34 -06:00
James Coglan
b9343b458f Fix scoping of splat parameters in argument lists. 2011-03-12 11:46:07 +00:00
Jeremy Ashkenas
ac85fa2fc3 merged stable 2011-03-11 22:44:18 -05:00
Jeremy Ashkenas
b7855857b5 stop trimming all trailing whitespace. 2011-03-11 22:39:32 -05:00
Jeremy Ashkenas
d957c4373b test-ified function_invocation 2011-03-11 22:18:22 -05:00
Jeremy Ashkenas
f485d8f548 test-ified control_flow 2011-03-11 22:09:33 -05:00
Jeremy Ashkenas
b994e235f3 test-ified comprehensions.coffee 2011-03-11 22:05:52 -05:00
Jeremy Ashkenas
2b1aea80ed testified compilation.coffee, removed empty command.coffee 2011-03-11 21:59:17 -05:00
Jeremy Ashkenas
53d8083343 removing empty test file for cake.coffee 2011-03-11 21:55:43 -05:00
Jeremy Ashkenas
d30c125ab7 continuing with the ol' refactorTests 2011-03-11 21:55:26 -05:00
Jeremy Ashkenas
9e2c75b548 removing over-hash-comment 2011-03-11 21:41:12 -05:00
Michael Ficarra
aa54b23713 fixes #1168: leading floating point suppresses newline (thanks, satyr) 2011-02-27 02:11:35 -05:00
Michael Ficarra
dc8e955c4f test for #1168 2011-02-27 02:11:12 -05:00
Timothy Jones
96b22a16eb Closes #1001. Throw cannot be directly used as an expression with parens, but can appear as a statement in an expression. 2011-02-23 15:50:28 +13:00
Timothy Jones
5fbbfbcbe3 Closes #1082. Puts back use of function calls in parameter lists. 2011-02-23 13:20:01 +13:00
Jeremy Ashkenas
faf98dacf6 stricter array splat tests. 2011-02-18 07:15:40 -05:00
Jeremy Ashkenas
86b47a528a adding an array splat test. 2011-02-17 21:56:28 -05:00
Jeremy Ashkenas
cf6c21a0d2 merging in aeosynth's tweaks to package.json 2011-02-17 21:21:31 -05:00
James Campos
b1d900210a add repository to package.json 2011-02-10 18:17:53 -08:00
James Campos
963fc4cebc add homepage to package.json 2011-02-10 17:54:00 -08:00
Will Moffat
80adaa700c Console keyboard shortcuts
Cmd/Ctrl-Enter to run code
Escape to dismiss console
2011-02-10 08:40:53 -08:00
Will Moffat
dfead460ca Disable spellcheck in the code editor.
Firefox highlights all the camelCase variable names in the examples and even WebKit highligts words like 'bitlist'.
2011-02-09 15:52:35 -08:00
Jeremy Ashkenas
6f21f8a402 merging stable 2011-02-01 22:02:57 -05:00
Trevor Burnham
abfc99308d Setting process.argv[1] to equal the filename of the script being run (issue 1087) 2011-02-01 21:41:20 -05:00
Jeremy Ashkenas
955c87ef30 Bumping version to 1.0.2-pre 2011-02-01 21:32:58 -05:00
Jeremy Ashkenas
b4df62bec1 #1085, adding CoffeeScript.mode to the docs. 2011-02-01 21:31:54 -05:00
Jeremy Ashkenas
14d2fa3895 #1085, adding CoffeeScript.mode to the docs. 2011-02-01 21:30:33 -05:00
Jeremy Ashkenas
005c5309c4 Merging in stable at 1.0.1 2011-01-31 23:34:34 -05:00
Jeremy Ashkenas
c44d9ae923 CoffeeScript 1.0.1 2011-01-31 22:39:12 -05:00
Jeremy Ashkenas
a487259e8e Backporting the REPL fix for Node 0.3.7 and Coffee 1.0-stable 2011-01-31 22:27:56 -05:00
Jeremy Ashkenas
37308e6760 Issue #1071, parenthesizing undefined literals when accessed. 2011-01-30 21:16:39 -05:00
Jeremy Ashkenas
4ce374be25 Issue #870 ... placeholders in destructuring assignment. 2011-01-30 20:49:02 -05:00
Jeremy Ashkenas
8b8e8a94ff Issue #997 ... Maloptimized break suppression. 2011-01-30 20:28:11 -05:00
Jeremy Ashkenas
3c9fdde24b resolved merge 2011-01-30 19:40:59 -05:00
Jeremy Ashkenas
578a46fbda Issue #875 -- console.log in the REPL 2011-01-30 19:32:07 -05:00
Jeremy Ashkenas
6fb2088d5f changed 'when' example. 2011-01-30 19:25:36 -05:00
Jeremy Ashkenas
49d9eb687d documenting 'when', a bit. 2011-01-30 17:10:50 -05:00
Jeremy Ashkenas
654c933e30 fixing version number to 1.1.0-pre ... to make it installable with npm. 2011-01-30 17:00:07 -05:00
Timothy Jones
83a86aacb5 Closes #1068. Don't know why CALL_START was in that file. 2011-01-24 19:57:31 +13:00
Timothy Jones
f231809e22 Swapping == with <, just in case. 2011-01-23 00:54:43 +13:00
Timothy Jones
2c8e0a6914 Merge branch 'readline0.3.6' of https://github.com/agnoster/coffee-script into agnoster 2011-01-23 00:43:18 +13:00
Isaac Wolkerstorfer
496816acff Add backwards compatibility for older readline
Check the readline.createInterface for arity. If it is 3,
assume the newer interface requiring separate stdin and stdout.
Otherwise, use the older calling style.
2011-01-22 12:30:22 +01:00
Isaac Wolkerstorfer
78b52f5716 Replace stdio with stdin/stdout pair for readline
On Node.js v0.3.6, the readline interface expects (in, out, complete).
This change makes the coffee-script repl conform to that expectation.
2011-01-22 11:40:25 +01:00
Timothy Jones
2ca108820f Closes #973. New is more careful around the do construct. 2011-01-22 23:26:38 +13:00
Timothy Jones
dc6bd715b2 Closes #970. Statements that use new are wrapped in parens to avoid the closure being used. 2011-01-22 23:12:39 +13:00
Timothy Jones
18a1e01d64 Closes #971. Existensial slices now supported. 2011-01-22 19:56:14 +13:00
Timothy Jones
15e1078d01 I suppose there's no reason to ever call a prototype like a function. 2011-01-22 19:34:30 +13:00
Timothy Jones
06b0c7e928 Closes #1064. Dot accesses force the next token to be an identifier. 2011-01-22 19:29:07 +13:00
Jeremy Ashkenas
3924c2f2bd First draft of fixing shorthand objects mixed with regulars within arrays. 2011-01-19 22:36:30 -05:00
Jeremy Ashkenas
7625d900d3 toTimeString -> toLocaleTimeString 2011-01-19 22:17:53 -05:00
Jeremy Ashkenas
53dc1f2055 Merging in donjones' implicit object fix, hooray. 2011-01-18 23:46:55 -05:00
Jeremy Ashkenas
e706fa4a58 Merge branch 'master' of https://github.com/donjones/coffee-script 2011-01-18 23:38:22 -05:00
Jeremy Ashkenas
65e81e4034 Merge branch '1.0-stable' 2011-01-18 23:29:44 -05:00
Jeremy Ashkenas
1f2f55bea3 merging in chetan51's Node 0.2.5 compatibility patch. Homebrew timestamps. 2011-01-18 23:28:37 -05:00
Jeremy Ashkenas
4b78790096 Making #1050 a syntax error. 2011-01-18 23:10:09 -05:00
Jonas Dohse
236e129e7a Tests for call parameters after implicit objects 2011-01-19 00:32:59 +01:00
Jonas Dohse
d200619774 Check for invalid implicit values 2011-01-18 23:31:50 +01:00
Chetan Surpur
f35ea486a7 Removed dependency on the util module in the coffee source files 2011-01-18 10:19:00 -08:00
Chetan Surpur
a48cd7cb1d Removed dependency on util to extend support to node v0.2.5 2011-01-18 09:45:58 -08:00
Jonas Dohse
d0f13223bc No assignment shortcut in implicit braces
Let

    f a: b, c

compile to

    f({
      a: b
    }, c);
2011-01-18 15:42:59 +01:00
Jeremy Ashkenas
7ae284f432 Allowing an environment variable of MINIFY=false to disable minification of the build:browser cake task. 2011-01-15 15:20:01 -05:00
Jeremy Ashkenas
df872b8223 Merge branch '1.0-stable' 2011-01-15 15:15:33 -05:00
Jeremy Ashkenas
150a8a12a0 A bit more explanation of what's actually going on with build:browser 2011-01-15 15:12:47 -05:00
Jeremy Ashkenas
d8823ed45e Implemented continuable lines in the REPL. Use a trailing slash. Multiline functions are now possible. 2011-01-15 15:06:51 -05:00
Jeremy Ashkenas
9a63b3147f First implementation of autocomplete. 2011-01-15 14:53:07 -05:00
Jeremy Ashkenas
3f586ff4ab Merge branch 'master' into 1.1-pre 2011-01-15 14:50:44 -05:00
Jeremy Ashkenas
c4d4cfe9dc Merge branch 'master' of https://github.com/ryszard/coffee-script into 1.1-pre 2011-01-15 14:50:41 -05:00
Jeremy Ashkenas
08cd112585 trailing comment. 2011-01-15 14:20:45 -05:00
Jeremy Ashkenas
566087b518 Expressions -> Block 2011-01-15 14:19:35 -05:00
Jeremy Ashkenas
f4a7cca075 Issue #1038 ... optimize away trailing return / and return undefined 2011-01-15 14:14:11 -05:00
Jeremy Ashkenas
d9d50fdf54 Leave out the 'Available Options' bit. 2011-01-15 11:04:50 -05:00
Jeremy Ashkenas
4c18ddf549 Fixing issue #1046. 2011-01-15 10:57:50 -05:00
Jeremy Ashkenas
7c7b9a4be1 Merging in 1035 fix. fileName -> filename ... a bit of refactoring. 2011-01-15 10:46:53 -05:00
Jeremy Ashkenas
9faedbf516 bump version to 1.1-pre 2011-01-15 10:28:26 -05:00
Trevor Burnham
ba45dedbd5 Decoupling --require flag processing from file compilation
This change allows files to be `--require`d before entering the REPL. It's also
an opimization, since files are `--require`d only once, rather than being
required again every time a file is compiled.

A secondary change is that `module.filename` is temporarily modified. This is
somewhat less aesthetically appealing than the old approach of using
fs.realpathSync, but it allows you to run `coffee -r ./foo` rather than having
to write `coffee -r ./foo.coffee`, since Node does not accept absolute paths
without a file extension.
2011-01-13 14:50:00 -05:00
Trevor Burnham
7815138386 Fixing require './foo' under --eval and REPL; issue 1035 2011-01-13 14:20:11 -05:00
Jeremy Ashkenas
47e4f4dae1 Merge branch 'issue1011' of http://github.com/michaelficarra/coffee-script 2011-01-10 23:25:28 -05:00
Jeremy Ashkenas
9b3197c6e8 #1026 2011-01-10 23:19:31 -05:00
Jeremy Ashkenas
44355f8eef Issue #1024. 2011-01-10 23:09:21 -05:00
Jeremy Ashkenas
45058dfa79 Adding jEdit highlighter. 2011-01-10 22:03:52 -05:00
Jeremy Ashkenas
83f9cb88cf Issue #1027 ... leading indentation. 2011-01-10 21:58:35 -05:00
Jeremy Ashkenas
c851ed9d60 Removing Roast (deleted) 2011-01-10 21:07:19 -05:00
Michael Ficarra
5f19f65ef2 obeying coffeescript convention of a single space after every comma 2011-01-07 03:20:48 -05:00
Michael Ficarra
8ca8cd046f mismatched issue number in test case for #1012 2011-01-06 23:55:50 -05:00
Michael Ficarra
6832dda2fa improving/minimizing the provided test cases for #1014 2011-01-06 23:47:03 -05:00
Gerald Lewis
782bc6c03a fix for issue 1014 - arguments object in ranged array - apply(this,arguments) instead of call(this) 2011-01-06 21:51:04 -05:00
Michael Ficarra
b158f1cbe6 fix for #1011 2011-01-06 12:38:54 -05:00
Michael Ficarra
944a114400 tests for #1011 2011-01-06 12:38:40 -05:00
Jeremy Ashkenas
5a7120e163 merging in refactorTests. 2011-01-05 21:52:53 -05:00
Michael Ficarra
1f58232e87 adding tests for trailing commas and semicolons 2011-01-03 12:20:35 -05:00
Michael Ficarra
0d3827989d removed global ?= window hack by actually giving tests a global
reference to global
2011-01-03 11:50:54 -05:00
Michael Ficarra
07ff3020cf Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests 2011-01-03 04:46:58 -05:00
Michael Ficarra
af4748d92b Fixing browser test suite for new filenames after reorganization.
Also added `global ?= window` where necessary. Firefox seems to be
complaining about an unexpected lambda still, though.
2011-01-03 04:37:29 -05:00
Michael Ficarra
240a0b9c93 made sure all files were properly commented 2011-01-03 04:28:47 -05:00
Michael Ficarra
6421c865f5 finished reorganizing test suite 2011-01-03 04:17:00 -05:00
Jeremy Ashkenas
06de5c7ffe joliss, vertical-align top 2011-01-02 21:43:53 -05:00
Michael Ficarra
ccae9ea6a8 final waypoint; remaining files to be sorted:
* _test_existence.coffee
  * _test_pattern_matching.coffee
2011-01-01 23:35:05 -05:00
Michael Ficarra
8692a5fd06 Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests 2010-12-30 22:52:16 -05:00
Michael Ficarra
dcbe62b9b9 test reorganization waypoint 3 2010-12-30 22:48:31 -05:00
Jeremy Ashkenas
9bed99482a Consistently using == instead of === in conjunction with typeof. 2010-12-30 21:15:50 -05:00
Michael Ficarra
fb201976b8 test reorganization waypoint #2 2010-12-29 14:06:57 -05:00
Ryszard Szopa
bb745a8036 Basic REPL autocomplete.
It sort of works, but the tests could are incomplete.
2010-12-29 12:59:23 +01:00
Michael Ficarra
a330eda4b6 Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests 2010-12-29 00:51:26 -05:00
Michael Ficarra
dcfdd144d8 test reorganization waypoint 2010-12-29 00:48:54 -05:00
Michael Ficarra
0fd3ed593c adding new (empty) classifications for tests 2010-12-28 23:33:13 -05:00
Jeremy Ashkenas
83d424f2f4 Issue #985. 2010-12-28 17:46:54 -08:00
Jeremy Ashkenas
c16c90c00a Issue #986 ... Unicode identifiers. 2010-12-28 17:42:20 -08:00
Michael Ficarra
8087a5914c coffee-script/test$ for file in .; do git mv "$file" "_$file"; done 2010-12-28 18:07:15 -05:00
Jeremy Ashkenas
03eccd4958 New favicon.ico 2010-12-27 10:12:42 -08:00
Jeremy Ashkenas
6d3f272551 ln -sfn ... part of Issue #971 2010-12-26 17:34:26 -08:00
Jeremy Ashkenas
7ffb7c19fd Issue #980 ... improperly truncated --help. 2010-12-26 17:15:55 -08:00
Jeremy Ashkenas
f545f18c2d Bumping to version 1.0.1-pre 2010-12-26 16:28:18 -08:00
Jeremy Ashkenas
33d2577fb5 CoffeeScript 1.0.0 2010-12-24 11:02:10 -08:00
Jeremy Ashkenas
3be22bd43b Documenting and testing 'do' 2010-12-24 09:22:27 -08:00
Jeremy Ashkenas
094b876a38 Scoped comprehensions are back out, Do is back in. 2010-12-24 08:59:30 -08:00
Jeremy Ashkenas
97f8e9ce1c reserving __bind and __indexOf 2010-12-23 22:24:14 -08:00
Jeremy Ashkenas
385be63126 disallowing --watch and --join together for the time being. 2010-12-23 22:22:34 -08:00
Jeremy Ashkenas
7710528f01 Adding a test for the previous commit. 2010-12-23 17:58:22 -08:00
Jeremy Ashkenas
c25462d924 Fixing for a in b() -> ... 2010-12-23 17:57:29 -08:00
Jeremy Ashkenas
9b45d240bb splice literals should evaluate to their right hand side, like any other type of assignment. 2010-12-23 14:46:34 -08:00
Jeremy Ashkenas
8bd27db727 Fixing issue #965 -- first character of '.' prefixed folder. 2010-12-23 14:34:50 -08:00
Jeremy Ashkenas
83a7985a97 more work on site, down to arrays and objects. 2010-12-23 14:26:10 -08:00
Jeremy Ashkenas
2d54a45a80 splicing to the end of a one-time expression. 2010-12-23 14:02:46 -08:00
Jeremy Ashkenas
813a5f1e1f documentation waypoint 2010-12-23 13:44:12 -08:00
Jeremy Ashkenas
c7d7757dbd Fixing the asKey setting in Obj. 2010-12-23 13:38:20 -08:00
Jeremy Ashkenas
d7b6996bcf Documentation tweaks, up to Language Reference. 2010-12-23 13:30:35 -08:00
Jeremy Ashkenas
61705e4d22 Issue #964. Super should trigger an implicit call. 2010-12-23 12:57:27 -08:00
Jeremy Ashkenas
6a1730956e slightly less parentheticals. 2010-12-23 12:41:42 -08:00
Jeremy Ashkenas
df8a6529ac tagging more nodes as keys. 2010-12-23 12:14:47 -08:00
Jeremy Ashkenas
97a29f9c50 fixing mentionsArgs for accesses. 2010-12-23 12:00:23 -08:00
Jeremy Ashkenas
9395d58669 Remove seenFor in favor of a safe scanLineBack. 2010-12-23 11:22:01 -08:00
Jeremy Ashkenas
f9a0bbbc20 safer paren-wrapping for closures. 2010-12-23 10:50:52 -08:00
Jeremy Ashkenas
ccfd369a77 Fixing class extends this in a non-class context. 2010-12-23 10:22:52 -08:00
Jeremy Ashkenas
2ec1c3b56c reinstating makeReturn for statement literals. 2010-12-23 10:09:05 -08:00
Jeremy Ashkenas
dbeb626f32 switch with debugger in a case should still break, afterwards. 2010-12-23 09:38:57 -08:00
Jeremy Ashkenas
8fd78d3819 Fixing literals that should be statements, and adding failed compilation tests. 2010-12-23 09:33:12 -08:00
Jeremy Ashkenas
b56b08387d Comprehensions over break and continue 2010-12-23 08:50:34 -08:00
Jeremy Ashkenas
34b16699fa Merge branch 'refactorTests' of http://github.com/michaelficarra/coffee-script 2010-12-23 08:16:42 -08:00
Jeremy Ashkenas
75dfa5af7e forgot to inherit For::jumps from While::jumps 2010-12-23 08:14:00 -08:00
Jeremy Ashkenas
e983032762 more docs... scoped loops, --join. 2010-12-22 22:43:13 -08:00
Jeremy Ashkenas
f5c5709cd9 trailing file, uncompiled. 2010-12-22 21:46:06 -08:00
Jeremy Ashkenas
fb874e1d65 fixing test_literals 2010-12-22 21:32:48 -08:00
Jeremy Ashkenas
6495508194 First draft of --join. 2010-12-22 21:26:15 -08:00
Jeremy Ashkenas
482626b9b8 Fixing issue #924 ... static methods of nested classes. 2010-12-22 19:01:32 -08:00
Jeremy Ashkenas
9f01040d46 fixing arrayEq and arrayEqual in test.html 2010-12-22 18:34:36 -08:00
Jeremy Ashkenas
cdf298bafb Updating test.html 2010-12-22 17:10:21 -08:00
Jeremy Ashkenas
a2f9f9320b Adding a comprehension/jump test. 2010-12-22 09:44:59 -08:00
Jeremy Ashkenas
0a48f613ec Removed the last bits of pureStatements 2010-12-22 12:23:08 -05:00
Jeremy Ashkenas
19f2d69be8 removing containsPureStatement 2010-12-22 12:10:52 -05:00
Jeremy Ashkenas
241de27c75 waypoint 2010-12-22 12:09:05 -05:00
Jeremy Ashkenas
df8dafc5ca starting to move over isPureStatement to Coco style jumps() 2010-12-22 12:00:46 -05:00
Jeremy Ashkenas
d01b7ac682 last logo tweak (I promise) 2010-12-22 10:24:12 -05:00
Jeremy Ashkenas
3161723c8b change logo 2010-12-22 06:25:30 -05:00
Michael Ficarra
a907811b22 just finishing up ranges_slices_and_splices.coffee 2010-12-22 01:39:58 -05:00
Jeremy Ashkenas
f1d298450d intro. 2010-12-21 22:34:53 -05:00
Jeremy Ashkenas
53eb66e5c4 trying to shorten the table of contents. 2010-12-21 22:24:24 -05:00
Jeremy Ashkenas
907f576010 sprucing up the error messages. 2010-12-21 22:02:53 -05:00
Jeremy Ashkenas
f24c2146e0 blackening the logo. 2010-12-21 21:53:49 -05:00
Jeremy Ashkenas
c342b58a87 The load button now includes the snippet from the 'run' button, at the end (homepage) 2010-12-21 21:51:39 -05:00
Jeremy Ashkenas
be8feb7ee8 Accurate positioning of the repl_bridge, hopefully. 2010-12-21 21:35:43 -05:00
Jeremy Ashkenas
b32eb2bfc1 new logo, credit to rampall. 2010-12-21 21:28:31 -05:00
Jeremy Ashkenas
4375a03f38 Fiddling with For#compileNode. 2010-12-21 21:03:52 -05:00
Jeremy Ashkenas
ad9b7d700a Fiddling with For#compileNode. 2010-12-21 20:59:58 -05:00
Jeremy Ashkenas
460272291f Some Try CoffeeScript tweaks ... scrolling left-hand, opt-out load buttons, correct cursor. 2010-12-21 20:43:13 -05:00
Jeremy Ashkenas
f567dafe62 being stricter about body-less scoped loops. 2010-12-21 20:28:48 -05:00
Jeremy Ashkenas
3c86c57765 some cleanups for hasPure 2010-12-21 20:01:30 -05:00
Jeremy Ashkenas
dc2f77e019 Allowing the fat arrow to be used in scoped loops. 2010-12-21 19:14:53 -05:00
Jeremy Ashkenas
80693d8338 Updating documentation for has own key, value 2010-12-21 18:57:23 -05:00
Jeremy Ashkenas
72e5c4300c Removing 'do', in favor of a trailing -> 2010-12-21 18:54:36 -05:00
Jeremy Ashkenas
6e7168b3e9 first re-implementation of 'do' 2010-12-21 16:12:30 -05:00
Jeremy Ashkenas
31892e1d68 Issue #959 (and countless others) Removing the loop-block-scoped magic for once and for all. 2010-12-21 15:45:46 -05:00
Jeremy Ashkenas
aa3099ce09 Adding notes about Ubuntu and Windows installation. 2010-12-21 14:25:28 -05:00
Jeremy Ashkenas
c6b90b9068 Congo -> coffee-mongo 2010-12-21 12:08:04 -05:00
Jeremy Ashkenas
47fe5c201c more existential. 2010-12-21 00:48:54 -05:00
Jeremy Ashkenas
f7d19f5a3a drying up compileSplice 2010-12-21 00:46:31 -05:00
Jeremy Ashkenas
d42f7daef7 Issue #943 -- splices with expressions. 2010-12-20 23:41:58 -05:00
Jeremy Ashkenas
53363e6b80 Issue #958. Removing UNLESS tokens to make them just inverted IFs. 2010-12-20 22:50:49 -05:00
Jeremy Ashkenas
7ba0573702 More tweaks to Slice#compileNode 2010-12-20 08:13:07 -05:00
Jeremy Ashkenas
777a99fe07 tweaks to Slice#compileNode 2010-12-19 20:19:50 -05:00
Jeremy Ashkenas
3b392b2dd9 rebuilt parser with Jison 0.2.0 2010-12-19 20:04:49 -05:00
Jeremy Ashkenas
6009929a3b Merge branch 'master' of https://github.com/grayrest/coffee-script 2010-12-18 18:28:16 -05:00
Jeremy Ashkenas
c1c9de4546 utils -> util (again) 2010-12-18 17:44:28 -05:00
Karl Guertin
c08ae001a6 Add additional test cases for implicit object calls 2010-12-18 16:06:07 -05:00
Joshua Peek
6c2c4d4428 Exclude docs, examples, and tests from npm package 2010-12-18 14:27:31 -06:00
Karl Guertin
e692e7cd9e Take out object call rewriter condition 2010-12-18 15:27:19 -05:00
Michael Ficarra
f0a62e83c8 Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests 2010-12-18 15:05:39 -05:00
Michael Ficarra
a01225db39 moving global identity function back into just the files in which it is
used
2010-12-18 15:04:47 -05:00
Jeremy Ashkenas
b36f6b67e6 removing start from balancedString. 2010-12-18 14:48:44 -05:00
Michael Ficarra
782de8743f updated comment for arrayEqual function, mentioning that it tests for
functional equivalence
2010-12-18 14:48:43 -05:00
Michael Ficarra
c42ac967ea changed arrayEqual to arrayEq, added global identity function id 2010-12-18 14:45:32 -05:00
Jeremy Ashkenas
e379fcf2cf unterminated -> missing. 2010-12-18 14:40:22 -05:00
Jeremy Ashkenas
89678fca47 unterminated -> missing. 2010-12-18 14:38:55 -05:00
Michael Ficarra
e378f79d2b moving splats.coffee back to test_splats.coffee while it's in development 2010-12-18 14:24:40 -05:00
Jeremy Ashkenas
fba165408c #923 ... correct interpolation. 2010-12-18 13:20:14 -05:00
Jeremy Ashkenas
dd168373a1 1.0.0-pre, that is. 2010-12-18 12:14:40 -05:00
Michael Ficarra
076e60378a begun working on refactoring test_splats.coffee 2010-12-18 11:57:27 -05:00
Jeremy Ashkenas
526af777d4 Adding 'by' to the documentation. 2010-12-18 11:54:40 -05:00
Jeremy Ashkenas
f121558668 Starting to use development versions. This one is '1.0-pre' 2010-12-18 10:53:08 -05:00
Jeremy Ashkenas
640ba7d69e Issue #948. A plucked direct call should not have shared scope. (kinda defeats the whole point.) 2010-12-18 10:41:44 -05:00
Jeremy Ashkenas
bc4498e018 Issue #910. Adding support for a --nodejs flag to forward arguments. 2010-12-18 09:29:04 -05:00
Michael Ficarra
805d03125b added --node flag for passing options through directly to node 2010-12-17 02:39:39 -05:00
Michael Ficarra
7499f0811b bugfix for previous fix to #930 and added (almost) all tests to
ranges_slices_and_splices.coffee
2010-12-16 20:21:29 -05:00
Michael Ficarra
37e0566957 Merge branch 'master' of git://github.com/jashkenas/coffee-script into refactorTests 2010-12-16 12:41:55 -05:00
Michael Ficarra
1fbaff9f81 using 9e9 over 1/0 for compatibility 2010-12-16 12:18:53 -05:00
Jeremy Ashkenas
c3943d21d0 Pulling out a lastNonComment method. 2010-12-16 11:35:51 -05:00
Jeremy Ashkenas
a7158ec69c fixing trailing herecomments with 'break' 2010-12-16 08:23:34 -05:00
Michael Ficarra
f66906d54d finished converting tests to newer, cleaner format in
test_ranges_slices_and_splices.coffee, just need to add some new ones
2010-12-16 05:14:57 -05:00
Michael Ficarra
85afef9981 crap, forgot to remove a piece of temporary code 2010-12-16 04:43:32 -05:00
Michael Ficarra
bd463a038c overhaul of last fix for #930, much better this time 2010-12-16 04:39:17 -05:00
Michael Ficarra
eeb1a284a8 Fixing #930 so I can work on testing ranges, slices, and splices.
Regression tests for this will come with the other refactored slicing
tests in a future commit.
2010-12-16 03:25:54 -05:00
Michael Ficarra
b38cc75f17 refactored test_if.coffee, renamed to conditionals.coffee 2010-12-16 01:06:40 -05:00
Michael Ficarra
dd11528160 changed occurrences of deepEqual to new, self-defined arrayEqual for
recursively walking arrays and testing if their values are equal
2010-12-16 00:12:11 -05:00
Michael Ficarra
912d6f442a Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests 2010-12-15 23:57:15 -05:00
Jeremy Ashkenas
346621ed21 Fix for #926 2010-12-15 23:38:27 -05:00
Jeremy Ashkenas
941f5a8ecb tagged -> stable 2010-12-15 23:20:32 -05:00
Jeremy Ashkenas
76e11e6f64 Fixing #934 (at least partially). 2010-12-15 22:59:28 -05:00
Jeremy Ashkenas
3c558ebbee pulling jQuery in locally, rebuilding docs with variable scope patch 2010-12-15 21:11:43 -05:00
Michael Ficarra
eba7b16ccf Merge branch 'master' of git://github.com/jashkenas/coffee-script into refactorTests
Conflicts:
	test/importing.coffee
2010-12-14 03:23:44 -05:00
Jeremy Ashkenas
466cd43277 Pulling in variable declarations closer to inner scope (after Coco). 2010-12-13 21:24:32 -05:00
Michael Ficarra
47acbefa57 forgot to rename test_helpers.coffee to helpers.coffee 2010-12-13 06:34:42 -05:00
Michael Ficarra
d9cf34ab8c Refactored test_helpers.coffee. Added now-needed deepEqual to browser
test page; warning: was unable to test it, so it might be completely
broken!
2010-12-13 06:28:17 -05:00
Michael Ficarra
9dc7d2a081 CoffeeScript.helpers.count now handles empty strings properly instead of
going into an infinite loop
2010-12-13 05:51:57 -05:00
Michael Ficarra
438708ea15 using deepEqual where I would have like to before, if I had known about
it
2010-12-13 05:03:11 -05:00
Michael Ficarra
835840e8da minor enhancements to test/exception_handling.coffee 2010-12-13 01:27:22 -05:00
Michael Ficarra
d13e0762d3 fixed error introduced when testingBrowser global was added to
cakefile and test/importing.coffee. `testingBrowser` did not exist when
running the test suite through cake:test.
2010-12-13 00:27:41 -05:00
Michael Ficarra
ae8f6a6db5 Merge branch 'master' of git://github.com/jashkenas/coffee-script into refactorTests 2010-12-12 23:28:14 -05:00
Michael Ficarra
608c5fd516 Merge branch 'master' of github.com:michaelficarra/coffee-script into refactorTests 2010-12-12 23:28:04 -05:00
Jeremy Ashkenas
b5bd58b2b6 fixing some site bugs. 2010-12-12 21:53:17 -05:00
Jeremy Ashkenas
9785fd0333 Bumping site. 2010-12-12 21:41:04 -05:00
Michael Ficarra
b02a1ee037 just fixing a single test in test_functions.coffee for now, so I don't
forget my suggested fix
2010-12-12 18:35:41 -05:00
Michael Ficarra
5de43fca4e added try-catch around script eval so that errors that are NOT inside
`test` calls (or syntax errors) are caught, and the test suite can
continue on
2010-12-12 18:34:44 -05:00
Jeremy Ashkenas
46fdbd629d prettifying coffeescript.org, part 3. Next up, Try CoffeeScript 2010-12-12 15:02:27 -05:00
Jeremy Ashkenas
2f4902a478 prettifying coffeescript.org, part 2 2010-12-12 14:34:33 -05:00
Jeremy Ashkenas
7e58c5009e first round of prettifications to coffeescript.org 2010-12-12 14:11:33 -05:00
Jeremy Ashkenas
39009dcfb9 Fixing Issue #916. Overoptimization leading to empty var; 2010-12-12 12:16:27 -05:00
Michael Ficarra
a19ea4b662 refactored test_regexps.coffee 2010-12-12 05:04:48 -05:00
Michael Ficarra
63bc12d3f1 refactored test_importing.coffee 2010-12-12 01:13:02 -05:00
Jeremy Ashkenas
b9c2236885 Merging in MichaelFicarra's refactorTests branch. 2010-12-11 20:30:48 -05:00
Jeremy Ashkenas
450ae723cb Merge branch 'refactorTests' of http://github.com/michaelficarra/coffee-script 2010-12-11 19:47:35 -05:00
Jeremy Ashkenas
2ac5ee4062 Adding an existential infix operator example. 2010-12-11 19:44:11 -05:00
Michael Ficarra
0d436b5f11 updated comments.coffee to make use of new micro-framework 2010-12-11 15:51:48 -05:00
Michael Ficarra
ca6983139e Merge branch 'master' of git://github.com/jashkenas/coffee-script into refactorTests 2010-12-11 15:02:37 -05:00
Jeremy Ashkenas
9f56c92497 Issue #853. Normalizing values of ARGV and argv with Node.js 2010-12-11 13:50:59 -05:00
Michael Ficarra
113cecc4f0 updated all completed test files except comments.coffee to the new
testing mini-framework
2010-12-10 00:23:37 -05:00
Michael Ficarra
7ac1176120 a little extra enhancement to cake test 2010-12-10 00:16:25 -05:00
Michael Ficarra
09c23a564d majorly enhanced test output 2010-12-09 23:59:50 -05:00
Michael Ficarra
a969d3ff1d Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests 2010-12-09 22:49:58 -05:00
Jeremy Ashkenas
b6324d0007 Fixing issue #902 ... collected comprehension when no comprehension is necessary. 2010-12-09 22:16:32 -05:00
Jeremy Ashkenas
ba27b4be69 Fixing Issue #904. Destructuring parameters need to reserve their variable names as if they were true parameters. 2010-12-09 21:34:52 -05:00
Jeremy Ashkenas
7c3ef56332 LEVEL_PAREN -> LEVEL_LIST 2010-12-09 21:12:24 -05:00
Jeremy Ashkenas
7b9286b2c2 Issue #905. Fixing soaked-value-as-a-comprehension-subject ... incorrect LEVEL_TOP. 2010-12-09 21:03:41 -05:00
Michael Ficarra
50d2b4e0b5 Merge branch 'master' of git://github.com/jashkenas/coffee-script into refactorTests 2010-12-08 01:29:40 -05:00
Michael Ficarra
f1988a9e20 refactored test_try_catch.coffee 2010-12-08 01:27:29 -05:00
Jeremy Ashkenas
a24a3c565e Merge branch 'fixSplices' of http://github.com/michaelficarra/coffee-script 2010-12-07 22:24:17 -05:00
Jeremy Ashkenas
20d87297b2 merging in 909 2010-12-07 22:16:27 -05:00
Michael Ficarra
049df99afc consistency: eq(expected,actual), formatting, etc. 2010-12-07 22:04:16 -05:00
Michael Ficarra
6dcdf4ff45 refactored test_comments.coffee 2010-12-07 21:01:58 -05:00
Michael Ficarra
00fd33b635 fixes (temporarily) issue #908; line 1232 of src/nodes.coffee still
needs a rewrite though
2010-12-07 19:44:47 -05:00
Michael Ficarra
f2dc526fc8 Fixing compileSplice broken by c7a9801d because " + 1" is now evaluated
as NaN by node. Removed that implicit cast entirely.
2010-12-07 14:27:44 -05:00
Michael Ficarra
e5491198f6 Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests
Conflicts:
	lib/coffee-script.js
2010-12-07 12:27:03 -05:00
Jeremy Ashkenas
4cab45c759 mention dynakey removal in the changelog 2010-12-07 11:08:16 -05:00
Jeremy Ashkenas
fa53a4c057 CoffeeScript 0.9.6 2010-12-07 00:21:34 -05:00
Jeremy Ashkenas
edd0c5af5a no-op. 2010-12-06 23:39:06 -05:00
Jeremy Ashkenas
2fb269a938 refactoring Scope. 2010-12-06 23:32:32 -05:00
Jeremy Ashkenas
3eac6aeb99 rebuilding browser coffee-script.js ... all tests pass. 2010-12-06 23:21:55 -05:00
Jeremy Ashkenas
ec64646fee Issue #901 ... allow constructor functions to maintain their position in the class body. 2010-12-06 01:01:57 -05:00
Michael Ficarra
5371268f8f Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests 2010-12-05 22:31:28 -05:00
Jeremy Ashkenas
2decb30d4e Issue #897 ... fixed leaking direct-call-plucked comprehension variables, due to shared scope. 2010-12-05 21:18:30 -05:00
Jeremy Ashkenas
c0bbc609be Fixing direct construction splats. 2010-12-05 20:44:32 -05:00
Jeremy Ashkenas
f6be426aa0 utils -> util. 2010-12-05 17:51:52 -05:00
Jeremy Ashkenas
17b5c8ac6f Issue #887 and #893. Adding timestamps to --watch --compile. 2010-12-05 16:06:13 -05:00
Jeremy Ashkenas
b18d0d75fd adding newlines after error stacktrace in REPL. 2010-12-05 15:46:04 -05:00
Jeremy Ashkenas
77e13e459b Fixing the repl so that errors print properly, and async exceptions are logged instead of killing the session. 2010-12-05 15:40:49 -05:00
Jeremy Ashkenas
06647bdd0a Adding warning about accidentally-comprehended-functions. Issue #896. 2010-12-05 15:29:28 -05:00
Jeremy Ashkenas
24183d9a39 Issue #894: Strange interaction between class instantiation and splats 2010-12-05 15:08:41 -05:00
Michael Ficarra
1e080cc258 Merge branch 'master' of github.com:michaelficarra/coffee-script into refactorTests 2010-12-05 13:37:34 -05:00
Michael Ficarra
dc5854689b fix for bug introduced in 63cbb643 2010-12-05 13:10:14 -05:00
Michael Ficarra
ed70b9d4d0 test for bug introduced in 63cbb643
discussion: 63cbb64341 (commitcomment-209643)
2010-12-05 13:08:14 -05:00
Jeremy Ashkenas
c7a9801db7 simplifying generated output for common-case splices. 2010-12-04 15:06:21 -05:00
Jeremy Ashkenas
85521f88b2 typo 2010-12-04 12:55:46 -05:00
Jeremy Ashkenas
75ca0f23ac redocumenting slices/splices ... issue #833 2010-12-04 12:52:51 -05:00
Michael Ficarra
eba73f6844 refactored test_break.coffee 2010-12-04 01:44:08 -05:00
Michael Ficarra
cf45da33f6 refactored test_assignment.coffee 2010-12-03 18:21:09 -05:00
Michael Ficarra
fb7498a8ec made reserved words available as CoffeeScript.RESERVED 2010-12-03 18:07:36 -05:00
Michael Ficarra
574f9afa3d using nonces more where applicable, also added tests for default
arguments
2010-12-03 17:10:36 -05:00
Michael Ficarra
3751ac1784 refactored test_arguments.coffee 2010-12-03 16:24:22 -05:00
Michael Ficarra
af759dcf42 test_operations: removed the top-level closures that symbolized
sections
2010-12-03 14:49:21 -05:00
Michael Ficarra
47426c28e1 test_operations: using eq instead of ok wherever possible, as per
satyr's suggestion
2010-12-03 14:43:45 -05:00
Michael Ficarra
49f7775d2d refactored test_operations.coffee 2010-12-03 13:01:13 -05:00
Jeremy Ashkenas
67c20c0715 style tweaks to previous patch. 2010-12-03 01:23:54 -05:00
Michael Ficarra
c50cb65019 Chained comparisons now properly apply DeMorgan's Laws. I couldn't
believe there wasn't a test to remind me to toggle the
{dis,con}junctions. Added that test.
2010-12-03 00:07:30 -05:00
Michael Ficarra
23b4d2fd1d Finally got !== and === back to inverting again (instead of wrapping in
`!()`)

Also, removed the `@inverted` kludge. It was gross to begin with, but I
didn't know the proper way to do it.
2010-12-02 23:03:21 -05:00
Michael Ficarra
dd18703b50 Issue #891: cannot safely invert < and > to >= and <= (or the
other way around). Proper fix this time.
2010-12-02 20:55:19 -05:00
Michael Ficarra
b1ba298ffc Reverted previous change to what was believed to be an errant test case.
Also added a test for NaN safety
2010-12-02 20:54:15 -05:00
Michael Ficarra
992324b425 fix for #891: incorrect inversion of chained comparisons 2010-12-02 12:55:53 -05:00
Michael Ficarra
56e10f9bce added test for #891: incorrect inversion of chained comparisons; fixed a
faulty test case in test/test_switch.coffee
2010-12-02 12:55:28 -05:00
Jeremy Ashkenas
69664a1bb3 Adding precedence change note to changelog 2010-12-01 14:17:10 -05:00
Jeremy Ashkenas
1f5727fe9d Coco 38aa762: rewriter: made addImplicitBraces consume multiple leading comments 2010-11-28 17:54:00 -08:00
Jeremy Ashkenas
b52a1ed60a disallow index mentions for range loops. 2010-11-28 15:54:39 -08:00
Jeremy Ashkenas
c3f1820ebc Issue #856. Invert 2010-11-28 15:33:43 -08:00
Jeremy Ashkenas
4afa6a2887 Issue #860. Nested classes. 2010-11-28 14:56:07 -08:00
Jeremy Ashkenas
1254efaddb Issue #878. Namespaced classes should not leak their function name. 2010-11-28 10:08:49 -08:00
Jeremy Ashkenas
adeace8f62 Merge branch 'issue/875' of git://github.com/StanAngeloff/coffee-script 2010-11-28 09:55:54 -08:00
Jeremy Ashkenas
4447180d5a Removing dynamic keys from objects. 2010-11-28 09:42:43 -08:00
Jeremy Ashkenas
41beccbe3c reverting Scope#temporary simplification. 2010-11-28 09:28:46 -08:00
Jeremy Ashkenas
a4958e76c1 whitespace 2010-11-28 09:27:06 -08:00
Stan Angeloff
a9e264dd84 console.{log,warn} → print{Line,Warn} 2010-11-28 16:04:52 +02:00
Jeremy Ashkenas
51988dba09 Removing unused garbage collection from Scope. 2010-11-27 18:04:40 -08:00
Jeremy Ashkenas
39c4c23200 nested shared scopes don't clobber variables. 2010-11-27 17:52:52 -08:00
Michael Ficarra
63cbb64341 fixes #855; fix partially inspired by satyr/coco 3e37cf32 2010-11-26 02:08:25 -05:00
Michael Ficarra
c0cb0c35e2 adding tests for #855 2010-11-26 02:06:10 -05:00
Jeremy Ashkenas
9db6d6f4ef Updating rake task to pull version number and date. 2010-11-21 22:33:27 -05:00
Jeremy Ashkenas
57bd6bc2cd Adding the coffee-script-source gem publisher to the Rakefile. 2010-11-21 21:42:15 -05:00
Jeremy Ashkenas
e5deb2b3c3 CoffeeScript 0.9.5 2010-11-21 21:21:07 -05:00
Jeremy Ashkenas
fc64fa49ac Switching default arguments to use an if instead of an and, more documentation. 2010-11-21 21:12:59 -05:00
Jeremy Ashkenas
5dfd36af6a removing some extra parens. 2010-11-21 19:59:22 -05:00
Jeremy Ashkenas
1778177195 continuing to document the homepage for 0.9.5 ... removing an optimization for local variables within loops. 2010-11-21 19:53:31 -05:00
Jeremy Ashkenas
ac9d36e444 adding Lucida Sans Unicode back in. 2010-11-21 12:59:21 -05:00
Jeremy Ashkenas
fcda00c3d8 tweaking coffeescript.org styles 2010-11-21 12:51:03 -05:00
Jeremy Ashkenas
28d5db3bca preparing documentation for 0.9.5 2010-11-21 12:38:27 -05:00
Jeremy Ashkenas
8fcd67e82f Updating examples for 0.9.5 2010-11-21 11:41:24 -05:00
Jeremy Ashkenas
710290ad1d Revert "Coco 5622aef: grammar: POST_IF now has the same precedence as FOR/WHILE, making work as expected"
This reverts commit aa262ecf0e.
2010-11-20 21:09:13 -05:00
Jeremy Ashkenas
aa262ecf0e Coco 5622aef: grammar: POST_IF now has the same precedence as FOR/WHILE, making work as expected 2010-11-20 20:59:38 -05:00
Jeremy Ashkenas
338e6d7f72 Coco 9a917bb: nodes: removed NUMBER 2010-11-20 20:51:43 -05:00
Jeremy Ashkenas
4ef9470466 Coco 16dcb4a: parenthesized expressions can now be indented 2010-11-20 20:47:43 -05:00
Jeremy Ashkenas
0e4d589d80 Coco ce2d08a: removed _argN temporaries for readability/consistency 2010-11-20 20:39:35 -05:00
Jeremy Ashkenas
835244f92d slight reformats to cake bench 2010-11-20 20:28:45 -05:00
Jeremy Ashkenas
2f498162b0 Coco f10291f: parens can now take a sequence of expressions: a = (b; c) 2010-11-20 20:22:05 -05:00
Jeremy Ashkenas
93cf3bd922 Coco ecd6aa4: Accessor -> Access 2010-11-20 20:09:36 -05:00
Jeremy Ashkenas
d3ae3525b8 reordering __extends. Issue #848 2010-11-20 19:17:09 -05:00
Jeremy Ashkenas
c8a2a78319 Issue #843. If a for-body ends in a pure-statement, no need to try and return results. 2010-11-20 19:12:39 -05:00
Jeremy Ashkenas
1f12642af2 Slice and Splice tests are back on master. 2010-11-20 18:49:17 -05:00
Jeremy Ashkenas
9111c2e702 All tests passing again. 2010-11-20 18:38:56 -05:00
Jeremy Ashkenas
0e388fd21c making empty loops compile newlineless 2010-11-20 18:37:19 -05:00
Jeremy Ashkenas
41c6364f6c removing an accidental double-method 2010-11-20 18:21:31 -05:00
Jeremy Ashkenas
12134d2043 Using pluckDirectCalls again 2010-11-20 18:14:05 -05:00
Jeremy Ashkenas
83c41c69be CoffeeScript lints cleanly again. 2010-11-20 17:46:44 -05:00
Jeremy Ashkenas
31f4214b5d first draft of range literals back... 2010-11-20 17:40:46 -05:00
Jeremy Ashkenas
9f708ad0c8 Merge branch 'master' of https://github.com/andrewschaaf/coffee-script 2010-11-20 14:32:19 -05:00
Jeremy Ashkenas
a2760c6ca3 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-11-20 14:22:44 -05:00
Jeremy Ashkenas
98a362136b rebuilding source docs with new version of Docco. 2010-11-20 14:22:28 -05:00
satyr
bcbf9f7dfd "cake bench" now shows total time spent 2010-11-18 21:33:56 +09:00
satyr
1a9a48c5f2 rewrote "cake bench" to time per parsing stage 2010-11-18 01:34:23 +09:00
satyr
32bd1dfd53 rewrote "cake bench" to see more consistent results 2010-11-17 23:53:39 +09:00
Andrew Schaaf
77cf992224 "sudo npm" -> "npm". npm calls "sudo npm"ing "HOLY COW NOT RECOMMENDED!!" 2010-11-16 14:44:24 -05:00
Jeremy Ashkenas
0c11267045 coco fd028a0: closes #13; leading comments/literals are now placed before variable declarations 2010-11-16 00:11:52 -05:00
Jeremy Ashkenas
ee6f24b48a coco c6cf38a: lexer: refactored @balancedString 2010-11-15 23:59:52 -05:00
Jeremy Ashkenas
eb959b3879 coco: cc71308 (partial) break continue debugger -> STATEMENT 2010-11-14 15:15:13 -05:00
Jeremy Ashkenas
f31798bbb4 coco 31ad9f0: nodes: made Op::invert more accurate 2010-11-14 15:07:43 -05:00
Jeremy Ashkenas
a1aaa4495c fixing Lexer#ASSIGNED 2010-11-14 15:00:20 -05:00
Jeremy Ashkenas
be17b8215c constructor: prefix is back for classes. punto. 2010-11-14 14:21:55 -05:00
Jeremy Ashkenas
15bdcf79e6 coco 63d607f: made deep destructuring compile nicer 2010-11-14 09:47:06 -05:00
Jeremy Ashkenas
09aa9e2a04 coco 19474b4: nodes: removed Base::collectChildren 2010-11-14 09:44:40 -05:00
Jeremy Ashkenas
c98fa8168b making levels start at one. 2010-11-13 21:08:42 -05:00
Jeremy Ashkenas
32a9c2ce49 moving up constructor definitions. 2010-11-13 21:05:59 -05:00
Jeremy Ashkenas
c7cd72c682 coco 02ee77c: nodes: fixed parenthesization in Op::compileNode 2010-11-13 18:27:05 -05:00
Jeremy Ashkenas
144b66c4da coco 2419207: coffee#840: fixed post-for precedence 2010-11-13 18:23:46 -05:00
Jeremy Ashkenas
7c7eccf1f2 removing an unused rule in Root. 2010-11-13 18:13:09 -05:00
Jeremy Ashkenas
5de73f6c25 coco 7222551: crushed __bind 2010-11-13 18:08:02 -05:00
Jeremy Ashkenas
6f47364392 done refactoring Class for now... 2010-11-13 18:02:50 -05:00
Jeremy Ashkenas
9a5546c8e9 further refactors to Class 2010-11-13 17:05:54 -05:00
Jeremy Ashkenas
f1972ff336 waypoint: part way through refactoring Class 2010-11-13 16:53:55 -05:00
Jeremy Ashkenas
cb6793f56b adding back '@static: value' syntax for classes 2010-11-13 15:52:30 -05:00
Jeremy Ashkenas
2aedbc2e42 Back to naked constructors. 2010-11-13 15:22:18 -05:00
Jeremy Ashkenas
f0b73dc9f5 Building with latest version of Jison. 2010-11-13 15:10:12 -05:00
Jeremy Ashkenas
354708dbc2 Putting 'constructor' back. Improving constructor definitions. 2010-11-13 12:17:09 -05:00
Jeremy Ashkenas
3059db8515 Merge branch 'master' into executable 2010-11-13 11:28:22 -05:00
Jason Davies
498e8124f6 Fix spelling 2010-11-13 10:37:55 +00:00
Jeremy Ashkenas
18afd2d84f merging in master 2010-11-12 20:18:52 -05:00
Jeremy Ashkenas
6d3e9df89f coco c39edf: braceless objects can now have trailing herecomments 2010-11-12 20:16:08 -05:00
Jeremy Ashkenas
d08cb20376 removing extended in favor of static method inheritance. 2010-11-12 00:20:08 -05:00
Jeremy Ashkenas
c778ef1004 merge 2010-11-12 00:07:32 -05:00
Jeremy Ashkenas
50c2226dd3 first draft of metaprogramming in class defn's. 2010-11-12 00:05:30 -05:00
satyr
9fa973debe dynakeys: work again on JScript 2010-11-11 23:10:32 -05:00
Jeremy Ashkenas
07e66dd2b4 Added back instance-bound functions to classes ... all tests pass again. 2010-11-11 23:04:58 -05:00
Jeremy Ashkenas
4d8434d1b6 a little further with the tests 2010-11-11 22:02:53 -05:00
Jeremy Ashkenas
ce4bf4aca5 a little further with the tests 2010-11-11 22:02:06 -05:00
Jeremy Ashkenas
21111755cf resolving merge 2010-11-11 21:55:20 -05:00
Jeremy Ashkenas
7fda0cd7d9 first draft of coco's executable class bodies ... cleanups and tests to follow. 2010-11-11 21:48:08 -05:00
satyr
a2d33112b8 dynakeys: work again on JScript 2010-11-11 16:17:56 +09:00
Jeremy Ashkenas
2c7f6d8bfe switching to UglifyJS for browser version of CoffeeScript. 2010-11-10 23:06:26 -05:00
Jeremy Ashkenas
5ec7e885f1 coco 8a8cc53: meta-heregex 2010-11-10 22:43:06 -05:00
Jeremy Ashkenas
3338cd073d better slash-w. 2010-11-10 22:41:14 -05:00
Jeremy Ashkenas
9a71bb17fd Adding IDENTIFIER and STRING to NOT_SPACED_REGEX 2010-11-09 22:46:37 -05:00
Jeremy Ashkenas
841463da8e Hewing closer to JS' syntactic resynchronization for regexp lexing. 2010-11-09 22:39:15 -05:00
Jeremy Ashkenas
71db1fc142 making REGEXP a bit stricter. 2010-11-09 22:22:02 -05:00
Jeremy Ashkenas
bc0cc34420 coco 03a9ac0: made tab characters consistent. 2010-11-09 08:25:48 -05:00
Jeremy Ashkenas
611174b0af Revert "coco b8039b9: merged @closeOpenCalls and @closeOpenIndexes into @closeOpenPairs"
This reverts commit a151ceccc6.
2010-11-09 08:20:09 -05:00
Jeremy Ashkenas
9c76c3ef8e Merge branch 'master' of github.com:jashkenas/coffee-script 2010-11-09 08:06:59 -05:00
Jeremy Ashkenas
8f8c4b44f1 it's attr, not css. 2010-11-09 08:06:54 -05:00
satyr
3ae818860b fixed a bug where postfix ? was incorrectly unwrapping its operand 2010-11-09 16:27:21 +09:00
Jeremy Ashkenas
188ad03c17 coco b615379: optimized @ensureBalance 2010-11-09 00:36:13 -05:00
Jeremy Ashkenas
a151ceccc6 coco b8039b9: merged @closeOpenCalls and @closeOpenIndexes into @closeOpenPairs 2010-11-09 00:31:11 -05:00
Jeremy Ashkenas
cb81f86434 coco 98271e6: made 'extends' chainable 2010-11-09 00:26:31 -05:00
Jeremy Ashkenas
d7f1193f22 coco 607fded: reinforced Op::INVERSIONS 2010-11-09 00:21:42 -05:00
Jeremy Ashkenas
9017b1ad3d _result -> _results 2010-11-09 00:17:08 -05:00
Jeremy Ashkenas
14f86043cf coco e8563db: tiny optimizations 2010-11-08 23:48:38 -05:00
Jeremy Ashkenas
042af51751 combination of satyr's three comment patches ... comments are now statements, not expressions... 2010-11-08 23:39:21 -05:00
Federico Builes
936abc381b Remove trailing whitespace from README. 2010-11-08 23:25:15 -05:00
Jeremy Ashkenas
e882af9f8d coco b82de20: removed Base::idt 2010-11-08 23:20:11 -05:00
Jeremy Ashkenas
9c5eca9131 coco dc8945c: less ternaries, more returns-from-ifs. More readable. 2010-11-08 23:07:51 -05:00
Jeremy Ashkenas
919596aba4 coco a503190 ... made postfix invertible 2010-11-08 22:47:13 -05:00
Jeremy Ashkenas
eb3a32e853 fixing coffee -s ... (jannehietamaki) 2010-11-08 21:58:13 -05:00
Janne Hietamäki
3af34d61d3 Do not pass invalid filename 'stdio' to compileScript when compiling from stdin because it breaks fs.realpathSync at run.
It would be nice to have a test for this but wasn't sure if there is a way to test stdin from cake.
2010-11-06 15:21:45 +02:00
Jeremy Ashkenas
bc8022f49f lexer refactors 2010-11-05 00:04:52 -04:00
Jeremy Ashkenas
4eee750d4c removing unused utilities.js 2010-11-04 23:15:58 -04:00
Jeremy Ashkenas
f6a8d4c074 round 2, light refactors. 2010-11-04 23:05:04 -04:00
Jeremy Ashkenas
bb05e07e4e light refactors + tweaks 2010-11-04 22:53:07 -04:00
Jeremy Ashkenas
8d30feaf88 Fixing jsl.conf to lint cleanly again (don't mind our void 0s) 2010-11-04 22:39:50 -04:00
Jeremy Ashkenas
76685e6e51 first draft of safe range comprehensions, upwards and downwards. 2010-11-04 21:53:23 -04:00
Jeremy Ashkenas
09b243e689 loosening the restrictions on functions that can be lifted out -- more tests. 2010-11-03 22:51:17 -04:00
Jeremy Ashkenas
a8b36b231c Adding back in the closed-comprehensions tests. 2010-11-03 22:29:05 -04:00
Jeremy Ashkenas
d5f639fc50 fixing unsafe unwrapAll in previous commit. 2010-11-03 22:11:38 -04:00
Jeremy Ashkenas
9fc3f8593e First draft at loop block scoping again ... works for functions that mention 'this' 2010-11-03 22:05:24 -04:00
Jeremy Ashkenas
58cac0ca39 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-11-03 21:40:11 -04:00
Jeremy Ashkenas
304a120429 satyr 4e39e2e -- efficient closures in loops -- pulling them out. 2010-11-03 21:39:54 -04:00
satyr
c418bca461 nodes: filled in missing LEVEL_* in In::compile*Test 2010-11-02 23:28:18 +09:00
satyr
0441d4a5d1 rewriter: no longer tries to include dynamic keys into braceless objects 2010-11-02 23:22:41 +09:00
Jeremy Ashkenas
5eb255a649 modified satyr: allowed temporary variables to share names with ones on upper scopes 2010-11-02 00:31:42 -04:00
Jeremy Ashkenas
605f362ab6 BY now closes implicit calls. 2010-11-02 00:25:04 -04:00
Jeremy Ashkenas
a257f5993a tweak to parser.lexer 2010-11-02 00:05:06 -04:00
Jeremy Ashkenas
987aaa0e19 modified satyr -- when now closes implicit calls. 2010-11-02 00:00:26 -04:00
Jeremy Ashkenas
b0e7c3e3e7 modified satyr -- made temp vars be declared later. 2010-11-01 23:58:03 -04:00
Jeremy Ashkenas
5aa21c363d satyr 1612b04 ... enabled break/continue in comprehensions. 2010-11-01 23:53:49 -04:00
Jeremy Ashkenas
6aaa2eb4d0 safer splats with __slice where necessary. 2010-11-01 23:41:05 -04:00
Jeremy Ashkenas
6163215bbe More indentation, less one-liners. 2010-11-01 23:29:54 -04:00
Jeremy Ashkenas
4788f842c0 satyr commit b2cf91 ... no more @tags 2010-11-01 23:25:28 -04:00
Jeremy Ashkenas
b94c15bdcc not-or to is-and ... positive side. 2010-11-01 23:11:25 -04:00
Jeremy Ashkenas
ebbe0babdb reverting ?= optimization, for the repl's sake. 2010-11-01 22:32:04 -04:00
Jeremy Ashkenas
187cda0c39 Using default arguments in one more spot. 2010-11-01 22:07:34 -04:00
Jeremy Ashkenas
f13e363a87 Now that ?= is optimized, reverting the expansion. 2010-11-01 22:04:22 -04:00
Jeremy Ashkenas
83e6955dce Optimizing default arguments and existential assignment. 2010-11-01 22:01:52 -04:00
Jeremy Ashkenas
749e056618 reindenting grammar.coffee to the shared column, as much as possible. 2010-11-01 21:37:42 -04:00
Jeremy Ashkenas
c17efcf422 merging satyr/defarg 2010-11-01 21:33:07 -04:00
Jeremy Ashkenas
3ede624759 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-11-01 20:57:45 -04:00
Jeremy Ashkenas
67f1e04f3b merging in Trevor's --no-wrap deprecation 2010-11-01 20:57:43 -04:00
Jeremy Ashkenas
a4be3bceec Merge branch 'master' of git://github.com/TrevorBurnham/coffee-script 2010-11-01 20:53:49 -04:00
satyr
56391df345 dynakeys: optimized and fixed a bug in caching 2010-11-02 02:51:46 +09:00
satyr
4f4032c053 fixed a bug that compound assignments were declaring variables 2010-11-01 10:42:42 +09:00
Jeremy Ashkenas
195ca70278 tweaks to eval-fix 2010-10-30 17:35:54 -04:00
Trevor Burnham
776b1b723e Fixing --eval; see issue 820 2010-10-28 22:18:11 -04:00
Trevor Burnham
baef719908 Accepting --no-wrap, with a warning 2010-10-28 12:22:33 -04:00
Jeremy Ashkenas
6d8126e498 Removing the last Jison hack. (Jison 0.1.25) 2010-10-28 01:39:35 -04:00
Jeremy Ashkenas
6b4e437c93 CoffeeScript now compiled 'undefined' as 'void 0' 2010-10-27 22:50:20 -04:00
Jeremy Ashkenas
853d28860a Issue #801 -- Empty catch statements immediately preceding outdents. 2010-10-27 22:21:47 -04:00
Jeremy Ashkenas
62a1824400 Removing one of the Jison patches, no longer needed with 0.1.24 2010-10-27 22:14:00 -04:00
Jeremy Ashkenas
b3a4ce4e98 merging in parity checks. 2010-10-27 22:07:21 -04:00
Jeremy Ashkenas
42812a8dc0 Merge branch 'master' of http://github.com/michaelficarra/coffee-script 2010-10-27 22:06:55 -04:00
Jeremy Ashkenas
6e9cb27e46 Patching Jison (again) to fix 'Unexpected 1' -> 'Unexpected EOF' 2010-10-27 22:04:32 -04:00
satyr
1aba75e3e8 destructuring within arguments is now allowed as in SpiderMonkey 2010-10-27 05:23:35 +09:00
Michael Ficarra
0f577e0c94 good practice for parity checks 2010-10-26 11:35:23 -04:00
Jeremy Ashkenas
7170536021 Revert "aligned up some ifelses using leading then"
This reverts commit b84063bc3f.
2010-10-26 08:42:31 -04:00
satyr
1cb6464948 optimized splatting assignment 2010-10-26 20:51:02 +09:00
satyr
e36746d367 made [a..., b...] = c throw syntax error 2010-10-26 19:32:59 +09:00
satyr
371282fe7a defarg: (options = {}) where possible 2010-10-26 19:14:03 +09:00
satyr
96f74f9da8 grammar: refactored Param 2010-10-26 19:08:01 +09:00
satyr
4eeab947dd defarg: removed Splat::compileParam in favor of using the normal array destructuring against arguments 2010-10-26 18:57:32 +09:00
satyr
e7cc4e4faf implemented default arguments 2010-10-26 13:34:56 +09:00
satyr
ecd4722b7c removed a redundancy in splatted assignment 2010-10-26 13:33:03 +09:00
satyr
5a92b339a4 lexer: removed unused UNARY tokens 2010-10-26 09:29:13 +09:00
satyr
cb5642945a test: merged "expressions" into "chaining" and "returns" 2010-10-26 09:08:16 +09:00
satyr
b84063bc3f aligned up some ifelses using leading then 2010-10-26 06:02:38 +09:00
satyr
426d71cb4f leading then is now valid 2010-10-26 05:36:32 +09:00
satyr
b2be475f93 tidied up formatting I broke at ad79e142 2010-10-26 04:57:20 +09:00
satyr
ad79e142ca refactored operator parsing 2010-10-26 03:58:11 +09:00
satyr
0d6d221568 dynakeys: {(x), y} now compiles correctly 2010-10-26 01:40:07 +09:00
satyr
863f3f6b47 rewriter: (a): (b): (c) is now allowed 2010-10-26 00:56:03 +09:00
satyr
ff82c59903 rewriter: a: b: c is now valid 2010-10-26 00:38:28 +09:00
satyr
27cdafb2d0 nodes: @soakNode -> @soak 2010-10-25 22:31:52 +09:00
satyr
2aa093b65c removed extra lines from the compilation of trailing then with if/switch 2010-10-25 22:19:02 +09:00
satyr
1e984e78ca grammar: improved formatting consistency, using single quotes unless interpolated and wrapping lines that are too long 2010-10-25 21:37:08 +09:00
Jeremy Ashkenas
520d6a9d93 Comments are statements also, not just pure statements. 2010-10-24 21:53:48 -04:00
Jeremy Ashkenas
00220a9f2c replacing mistakenly-deleted nodes.coffee 2010-10-24 21:52:18 -04:00
Jeremy Ashkenas
6faff7c344 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-24 21:50:37 -04:00
Jeremy Ashkenas
0e5dd3d557 First draft of recompiling examples for 0.9.9 2010-10-24 21:50:34 -04:00
Timothy Jones
2ddae698bb Using a typeof check in scope. 2010-10-25 14:42:37 +13:00
Jeremy Ashkenas
99c06b5cda All examples now compile and lint cleanly. 2010-10-24 21:37:27 -04:00
Jeremy Ashkenas
343c0fdef7 top-level examples now compile and lint cleanly. 2010-10-24 21:34:40 -04:00
Jeremy Ashkenas
017e3a156e Removing breaks from the last switch case, and just disabling the lint warning instead. 2010-10-24 21:30:26 -04:00
Jeremy Ashkenas
12b217c8ec Adding break to default switch clauses to pass lint. 2010-10-24 21:26:24 -04:00
Jeremy Ashkenas
6a9c4380f3 Fixing scope.coffee -- we can't use a JS object as a hash that has to contain the word 'hasOwnProperty' 2010-10-24 21:23:32 -04:00
Jeremy Ashkenas
a75368e2e8 Fixing the REPL. 2010-10-24 21:15:20 -04:00
Jeremy Ashkenas
13f6b037e2 Working towards new versions of the examples. 2010-10-24 21:11:15 -04:00
Jeremy Ashkenas
c2da8c2d54 Removing extraneous semicolon, adding back in final break -- src now lints cleanly. 2010-10-24 20:51:55 -04:00
Jeremy Ashkenas
5b16d4790c Removing/Reverting do -> 2010-10-24 20:34:50 -04:00
satyr
101a044219 nodes: reformatted 2010-10-25 08:55:42 +09:00
satyr
7bfb2e3a78 nodes: removed Value.wrap 2010-10-25 08:13:58 +09:00
satyr
ab2050dc59 nodes: added Base::unwrapAll 2010-10-25 08:00:12 +09:00
satyr
98d22f9510 assigning to bizarre things like [a()] = b now causes syntax error 2010-10-25 07:33:41 +09:00
satyr
e146b539f5 optimized switch compilation 2010-10-25 06:20:45 +09:00
Jeremy Ashkenas
d1094e11a0 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-24 15:50:22 -04:00
Jeremy Ashkenas
02e94cdb1c removing forgotten print's 2010-10-24 15:50:18 -04:00
satyr
c8d994a97d invalid destructuring assignments like {0} = x now causes syntax error 2010-10-25 04:46:28 +09:00
Jeremy Ashkenas
e007f69c71 Adding xqjs, CUP, and Congo to the resources section. 2010-10-24 14:29:47 -04:00
Jeremy Ashkenas
08527075b7 Expanding __filename and __dirname when running with the coffee command -- Issue #771 2010-10-24 14:19:47 -04:00
Jeremy Ashkenas
6347849cd0 Switching parenthesized side in comprehensions. 2010-10-24 14:11:09 -04:00
Jeremy Ashkenas
b32a75858a further reduce predecence levels. 2010-10-24 14:04:06 -04:00
Jeremy Ashkenas
d6d46697d0 Issue #795 -- clean up low precedence levels 2010-10-24 14:02:59 -04:00
Jeremy Ashkenas
3a64e6a711 Removing -> and => from precendece-having operators. 2010-10-24 13:55:47 -04:00
Jeremy Ashkenas
ca90af4fa5 Removing duplicate 'UNLESS' 2010-10-24 13:54:29 -04:00
Jeremy Ashkenas
e822b2d43b Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-24 13:38:03 -04:00
Jeremy Ashkenas
3a16677ebf typo 2010-10-24 13:38:00 -04:00
satyr
d60aa9a80c removed extra lines from trailing then compilations 2010-10-25 01:58:00 +09:00
Jeremy Ashkenas
26a115adcf Removing the mixed-in sys/util module. Switching from 'puts' to console.log 2010-10-24 12:48:42 -04:00
satyr
aed0e8790e nodes: continue while .. over while .. then 2010-10-25 01:05:37 +09:00
Jeremy Ashkenas
cecae0f965 ObjectLiteral -> Obj, ArrayLiteral -> Arr 2010-10-24 11:35:47 -04:00
Jeremy Ashkenas
55bf6450e7 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-24 11:32:29 -04:00
Jeremy Ashkenas
95be4a61ec Merging in dynakeys 2010-10-24 11:32:23 -04:00
satyr
abef3f59be rebuilt parser and rewrote the asserts wrapping loop in Cakefile using do => 2010-10-25 00:14:58 +09:00
Timothy Jones
9619fa66eb Altered bound functions with do to just use call(this) rather than binding. 2010-10-25 00:18:54 +13:00
Timothy Jones
d096f69c78 Implemented rescoping with the do keyword. 2010-10-25 00:02:39 +13:00
Timothy Jones
f52ef98cee Removing unnecessary parens and removing the sudo recommendation for npm in the readme. 2010-10-24 23:45:47 +13:00
satyr
a458c4a905 dynakeys: can now do destructuring assignments 2010-10-24 17:56:34 +09:00
satyr
85c8a6780a dynakeys: can now be braceless 2010-10-24 15:39:11 +09:00
Timothy Jones
99deb8c670 Wrapping only the last line of comprehensions, allowing pure statements anywhere in between. 2010-10-24 18:36:23 +13:00
satyr
331036f86d 786: implemented dynamic object keys 2010-10-24 14:20:20 +09:00
Timothy Jones
291f377d40 Correcting version regex. 2010-10-24 15:05:11 +13:00
Michael Ficarra
4d4e758bf3 node 0.3 compliance 2010-10-23 21:48:58 -04:00
satyr
bfc236fca3 grammar: removed a remnant of Slice 2010-10-24 05:35:35 +09:00
satyr
b648b392b6 removed an extra garbage 2010-10-24 04:16:49 +09:00
satyr
89516e6ee1 added/fixed/tweaked a few tests and merged test_compound_assignment into test_assignment 2010-10-24 04:09:13 +09:00
satyr
0c3093f331 quit using __temp__ as placeholder name for anon class 2010-10-24 03:43:06 +09:00
satyr
ebdcfb5227 merged == and != into COMPARE 2010-10-24 03:30:16 +09:00
Timothy Jones
fc332bcfbd Easing leniency on pure statements. 2010-10-24 06:53:10 +13:00
Jeremy Ashkenas
e96cdbf67c resolving merge conflict. 2010-10-23 11:11:49 -04:00
Jeremy Ashkenas
2287b06aeb Reverting LEVEL object. 2010-10-23 11:10:28 -04:00
satyr
1335aee54b 783: corrected chained comparison precedence 2010-10-24 00:01:30 +09:00
Jeremy Ashkenas
6058910b49 Making the LEVEL constants a bit more readable. 2010-10-23 10:34:22 -04:00
Timothy Jones
b60afdb619 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-24 02:17:44 +13:00
Timothy Jones
3834e7bc33 Revert "Passing the arguments object directly when generating a closure."
This reverts commit 7b887f065d.
2010-10-24 02:15:01 +13:00
satyr
0942071517 fixed a regression that for-in was failing to cache the source value 2010-10-23 22:04:58 +09:00
Timothy Jones
7b887f065d Passing the arguments object directly when generating a closure. 2010-10-24 01:20:16 +13:00
Timothy Jones
e6fb3bcffb Spacing only + and - and only in a row. 2010-10-24 00:13:48 +13:00
Timothy Jones
9448a477d2 Spacing multiple operators. 2010-10-24 00:01:26 +13:00
satyr
2bc2c4717e nodes: refactored and removed the notion of o.top in favor of LVL_TOP 2010-10-23 19:18:04 +09:00
satyr
b82f495ec7 nodes: introduced a notion of levels that streamlines parenthesizations 2010-10-23 19:17:56 +09:00
satyr
1130f4fef5 refactored and added a test for a8da321 2010-10-23 03:00:09 +09:00
satyr
a8da321883 fixed a bug where multiple trailing comments prevented returnification 2010-10-23 02:30:38 +09:00
satyr
32e63cd130 nodes: removed some redundancies and unused methods 2010-10-23 01:47:28 +09:00
satyr
3df28a8a6a reverted "lexer: simplified tokenizers' responsibility" with magic numbers removed
This reverts commit 10442239f1.
2010-10-22 23:50:44 +09:00
Jeremy Ashkenas
10442239f1 Revert "lexer: simplified tokenizers' responsibility"
This reverts commit a9e95fa43b.
2010-10-22 08:13:40 -04:00
satyr
a9e95fa43b lexer: simplified tokenizers' responsibility 2010-10-22 14:56:51 +09:00
Jeremy Ashkenas
c92fd79f35 normalizing loop declarations towards common JS practice. 2010-10-21 21:51:06 -04:00
Jeremy Ashkenas
0342b0a89f merging the range-killer to master 2010-10-21 21:27:45 -04:00
satyr
341de42692 removed extra parens around simple values 2010-10-22 09:35:15 +09:00
Timothy Jones
f43ee4075d Removing empty parens from the grammar. 2010-10-22 11:29:03 +13:00
satyr
79148d2940 refactored loop variable caching 2010-10-22 02:07:00 +09:00
satyr
bd10c2f828 implemented for-from-to and removed dotted ranges 2010-10-21 23:06:50 +09:00
satyr
2f7c076a50 fixed a bug where in malfunctioned in commaed lists 2010-10-21 22:13:59 +09:00
Timothy Jones
880c5c8083 Fixing destructor in magicked for. Also making destructors in range loops syntax errors. 2010-10-22 00:34:51 +13:00
Jeremy Ashkenas
7596e3a157 putting back arguments. 2010-10-21 00:07:21 -04:00
satyr
cb9683a7fd fixed/removed broken/redundant tests 2010-10-21 12:45:50 +09:00
Jeremy Ashkenas
0d4d7e0880 indentation 2010-10-20 23:16:46 -04:00
Jeremy Ashkenas
bb080130b9 tweaks to scope 2010-10-20 23:09:06 -04:00
Timothy Jones
f229f791a9 Proper testing, this time. 2010-10-21 14:37:58 +13:00
Timothy Jones
e694b41a94 Operators now respect new lines as being spaced. 2010-10-21 14:27:25 +13:00
satyr
31746ce692 made In node invertible 2010-10-21 09:19:52 +09:00
satyr
53fbfc7d15 removed extra parens from in/return compilations 2010-10-21 07:19:08 +09:00
satyr
78835073db removed extra parens from array/index compilations 2010-10-21 06:07:58 +09:00
satyr
c11ca94870 removed extra parens from soak compilations 2010-10-21 04:51:11 +09:00
satyr
c1dc74fc8b removed extra parens from compilations with assignments or conditional operators 2010-10-21 02:29:06 +09:00
satyr
e2a6f292a2 nodes: refactored to reduce parens 2010-10-20 19:53:41 +09:00
satyr
b0a4b7ab85 scope: refactored 2010-10-20 17:13:43 +09:00
Timothy Jones
8d6b909b93 Removing the utterly pointless splice in scope for the much more reasonable assignment. 2010-10-20 19:51:53 +13:00
Jeremy Ashkenas
303be86291 resolving merge conflict. 2010-10-19 23:31:19 -04:00
Jeremy Ashkenas
113d7ce98f let's try to merge these indexOf patches. 2010-10-19 23:27:15 -04:00
satyr
2c84f3ed1f removed helpers.{indexOf,include} in favor of in operator 2010-10-20 12:20:10 +09:00
Jeremy Ashkenas
c1d24944dc inArray -> indexOf ... 2010-10-19 23:06:51 -04:00
Jeremy Ashkenas
35b6a70724 going back to the Closure Compiler. 2010-10-19 21:59:13 -04:00
Jeremy Ashkenas
54d9b283fa Merge branch 'master' of http://github.com/stephank/coffee-script 2010-10-19 21:52:39 -04:00
satyr
90a13bd791 compound assignments are now represented as Assign nodes (rather than Op) and have the same precedence as = 2010-10-20 09:50:42 +09:00
Timothy Jones
15cfe8ebf1 Restoring garbage collection. 2010-10-20 12:58:59 +13:00
Timothy Jones
8c4a48d9d0 Adjusting refactor to better emulate map. 2010-10-20 12:51:34 +13:00
Timothy Jones
8fff6e9baf Refactoring scope to use an array instead of an object, to make the IE bugfix significantly tidier. 2010-10-20 12:36:50 +13:00
Timothy Jones
7342058e64 Comment fix. 2010-10-20 12:05:34 +13:00
Timothy Jones
083fc61dfb Fixing IE DontEnum bug in Scope. Ignoring everywhere else. 2010-10-20 12:02:38 +13:00
Timothy Jones
502d444ebd Reversing evaluation order of __inArray to reflect the ordering of the in operator. 2010-10-20 09:52:11 +13:00
Timothy Jones
c3582d4058 One character fix, for the sake of consistency. 2010-10-20 08:57:23 +13:00
Timothy Jones
37d9204ad9 Tidying inArray utility. 2010-10-20 08:47:34 +13:00
Timothy Jones
a3500e807a Avoids unnecessary temporary in comprehensions with pure statements in them. 2010-10-20 07:57:40 +13:00
Timothy Jones
1442262376 Merge branch 'master' of http://github.com/TrevorBurnham/coffee-script into trevor 2010-10-20 07:43:07 +13:00
Trevor Burnham
33ac70aec3 Whitespace fix for unstepPart (thanks, Tesco) 2010-10-19 14:24:38 -04:00
Trevor Burnham
5005cb606f Fixing inconsistencies for index variables
See the tests added to test_comprehensions.coffee. Previously, after
`for i in [1..3]`, i was 4. Also, index variables were never set to
any value in comprehensions containing both a closure and a break or
return.
2010-10-19 14:09:16 -04:00
Stéphan Kochen
c458346593 In compileScripts, run base through path.join.
Allows `path.join` to do some processing on the base path
that was also happening on the full path.
Fixes: `coffee -o ./ ./`
Still broken: `coffee -o . .`
2010-10-19 18:36:27 +02:00
Timothy Jones
c64e8d4b53 Added the __inArray helper to clean up code and speed up searches. 2010-10-20 05:34:03 +13:00
Stéphan Kochen
e5dfa19ec9 Report errors when writing files in coffee. 2010-10-19 18:30:29 +02:00
Timothy Jones
0e395569ee Fixing #761. p -1 now translates to p(-1), not p - 1. Same with +. 2010-10-20 04:52:07 +13:00
Timothy Jones
262d796356 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-20 04:11:25 +13:00
Timothy Jones
cf5a086263 Removing accidental superfluous temp variables. 2010-10-20 04:07:10 +13:00
Timothy Jones
d14ba6ac53 Fixed comprehension magic's scoping. 2010-10-20 03:59:01 +13:00
Timothy Jones
7b1902183c Just catch alls for inner scoping now. 2010-10-20 03:53:38 +13:00
Timothy Jones
cb6be74851 Fixing for magic scoping issues. Small steps at a time. 2010-10-20 02:51:52 +13:00
Jeremy Ashkenas
9e03c66529 Merge branch 'master' of git://github.com/Tesco/coffee-script 2010-10-19 09:13:41 -04:00
Jeremy Ashkenas
f6b190bb5a Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-19 09:13:21 -04:00
Jeremy Ashkenas
3f89fea65a fixing resig link 2010-10-19 09:13:09 -04:00
Timothy Jones
c8b9c5a54e Fixing #774. Strict equality operator, which wasn't supported in the grammar anyway, is removed from the lexer. 2010-10-19 20:56:55 +13:00
Timothy Jones
fd268a0479 Fixed #763. SimpleAssignables are now the only possible recepients of ++, -- and compound assignments. 2010-10-19 20:48:39 +13:00
Timothy Jones
648d6432eb Fixing #700. Block comment for constructor now appears above the constructor declaration. 2010-10-19 20:39:58 +13:00
Timothy Jones
df46fb8c68 Fixing #600. JS statements that must be expressions but contain pure statements cause syntax errors. 2010-10-19 20:02:21 +13:00
Timothy Jones
d9cd75c426 Fixing #773. Statements cannot be wrapped in parens (as in JS). 2010-10-19 19:32:23 +13:00
satyr
87560d943c lexer: made REGEX more efficient 2010-10-18 07:43:29 +09:00
satyr
8d0a0e8ab1 nodes: Value.unfoldSoak -> If.unfoldSoak 2010-10-17 13:53:02 +09:00
satyr
55794d9534 nodes: soaking Call now converts to If using the same logic as soaking Accessor 2010-10-17 13:19:51 +09:00
Jeremy Ashkenas
84dcd6fe2f Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-14 17:17:42 -04:00
satyr
88cc1ee35d 765: -b/--bare <- --no-wrap 2010-10-14 04:09:56 +09:00
Michael Ficarra
6e89ad3401 test case for #768 2010-10-13 12:12:24 -04:00
Michael Ficarra
1ea38d2f93 fixing #768, preserving execution order of in arguments when compiled
to an `or`.
2010-10-13 12:10:36 -04:00
satyr
1d4d7e96fa quit using sp?licing ranges 2010-10-13 05:47:45 +09:00
satyr
67eb966a75 stripped a line from __extends 2010-10-13 04:57:11 +09:00
Daniel J. Pritchett
ceef24834c spelling tweak to index.html 2010-10-12 14:54:02 -05:00
satyr
cb2a7f0820 simplified splatting new compilation 2010-10-12 21:48:25 +09:00
satyr
8f29574b16 764: made boolean/number/regex indexable 2010-10-12 19:30:10 +09:00
satyr
c0ec479e60 browser: exposed require for debugging 2010-10-12 17:10:39 +09:00
satyr
54101a1c9b lexer: reorganized JS_KEYWORDS 2010-10-12 16:25:33 +09:00
satyr
43613498db Merge branch '542' 2010-10-12 11:29:33 +09:00
satyr
ac841ca4e9 nodes: object literals are now parenthesized based on @tags.front (which indicates if the node leads an expression statement), fixing #542 2010-10-12 11:26:55 +09:00
satyr
95d86758ee test.html: string_interpolation -> strings 2010-10-12 10:34:31 +09:00
satyr
ed79715841 stripped out strings/regexes from test_literals; test_string_interpolation is now test_string 2010-10-12 09:35:59 +09:00
satyr
b01d7db409 merged test_blocks into test_functions 2010-10-12 08:54:36 +09:00
satyr
e5fe145f80 destructuring assignment no longer uses a temporary variable for simple LHS 2010-10-12 07:58:11 +09:00
Jeremy Ashkenas
2642fde0f8 merging in the browser test suite. 2010-10-11 18:22:01 -04:00
satyr
f682bf642f followup to #717; made new => actually work 2010-10-12 07:02:04 +09:00
satyr
5ed69a5a58 added test.html that runs most of test/*.coffee in browsers 2010-10-12 06:53:20 +09:00
Jeremy Ashkenas
a4b6b2464c merging in sstephenson's test:browser 2010-10-11 16:55:17 -04:00
Jeremy Ashkenas
4f89245570 NEXT_ELLPSIS.test 2010-10-11 16:34:16 -04:00
Sam Stephenson
5236bb279d Remove the window hack in test:browser. 2010-10-11 12:27:05 -05:00
Sam Stephenson
967fec2ae5 Merge branch 'master' into newline-splat
Conflicts:
	lib/lexer.js
	lib/parser.js
	src/lexer.coffee
2010-10-11 12:12:13 -05:00
Jeremy Ashkenas
d7052d09ff tweaking compileWithDeclarations 2010-10-11 12:27:57 -04:00
Jeremy Ashkenas
acc06d772a Back four commits ... Fixing named function expressions -> function declarations for IE. (grumble grumble) 2010-10-11 12:13:01 -04:00
Sam Stephenson
f360fba47f Add test:browser task for running the test suite against the merged browser script. 2010-10-11 09:42:13 -05:00
Jeremy Ashkenas
de0b93381c switching to YUI compressor for the time being... ticket #575 2010-10-11 08:40:15 -04:00
Jeremy Ashkenas
42d39d59dd rebuilding browser.js 2010-10-11 08:13:59 -04:00
Jeremy Ashkenas
bfed78a996 rebuilding lexer 2010-10-11 08:06:27 -04:00
satyr
9c55bd59a1 fixed a bug where while condition was compiling as statement 2010-10-11 20:29:08 +09:00
satyr
e89d7a7756 lexer: fixed a regression where assignmentError wasn't fired 2010-10-11 19:10:30 +09:00
satyr
41cd0c272b grouped TRUE/FALSE/NULL into BOOL 2010-10-11 17:05:50 +09:00
satyr
6506f6d99e grammar: removed extra arrays 2010-10-11 16:06:29 +09:00
satyr
fffa01933d fixed misdentation in a?.b = c 2010-10-11 12:31:54 +09:00
satyr
acafb1b53a nodes: no longer uses helpers.indexOf 2010-10-11 09:40:41 +09:00
satyr
c437f0b14b made until less parenful as well 2010-10-11 07:29:38 +09:00
Sam Stephenson
20a07c174c Fixing splats after newlines - #754. 2010-10-10 11:34:22 -05:00
Sam Stephenson
6e6165796c noWrap: true -> wrap: false 2010-10-10 11:55:01 -04:00
Jeremy Ashkenas
f6ca5d814c Issue #748 -- trailing reserved idenitifer. 2010-10-10 11:42:25 -04:00
Jeremy Ashkenas
45ed62931b #749 -- adding CoffeeApp mention 2010-10-10 11:33:03 -04:00
Jeremy Ashkenas
9c54291d04 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-10 11:29:29 -04:00
Jeremy Ashkenas
e8d592cdc6 Fixing issue #751 ... implicit number arguments within implicit object literals. 2010-10-10 11:29:14 -04:00
satyr
24a0015148 lexer: made REGEX more accurate 2010-10-10 07:32:49 +09:00
satyr
b0e34edf99 soak accesses no longer consume corresponding operators 2010-10-10 07:10:20 +09:00
satyr
c5f922c5db coffee-script: tokens/nodes can now take options as well 2010-10-09 04:27:05 +09:00
satyr
ebdd57a2fe rewriter: detectEnd no longer passes undefined as token, fixing #750 2010-10-09 04:00:07 +09:00
Jeremy Ashkenas
b21057d166 fixing issue #745 ... precedence of huh operator. 2010-10-07 22:22:33 -04:00
satyr
4f486bc444 removed YES/NO/ON/OFF from rewriter/parser 2010-10-08 00:56:01 +09:00
satyr
9447796d8e made unless less parenfull 2010-10-07 20:05:22 +09:00
satyr
c7157ca90c quit caching v in for all k of v 2010-10-07 15:31:40 +09:00
satyr
250ec12646 Parenthetical -> Parens 2010-10-07 12:59:36 +09:00
satyr
2d9cff3af6 nodes: removed literal helper 2010-10-07 12:41:09 +09:00
satyr
95bc4c5eeb reenabled stricter caching on For compilation as well as reduced a line from it 2010-10-07 12:31:05 +09:00
Jeremy Ashkenas
30a18fdaeb Removed the silly 'Node' suffix from everything. 2010-10-06 22:44:32 -04:00
Jeremy Ashkenas
13774cf48a empty returns no longer return null 2010-10-06 22:24:52 -04:00
Jeremy Ashkenas
69d2048ccc Re-enabling garbage collection of tempvars, only at function boundaries. 2010-10-06 21:19:05 -04:00
Jeremy Ashkenas
d4dac214ab optimizing comprehensions source references 2010-10-06 21:13:11 -04:00
Jeremy Ashkenas
5605ba32e3 merge conflict 2010-10-06 20:54:48 -04:00
Jeremy Ashkenas
59d6e59f97 Fixing Issue 730 -- and removing garbage collection of tempvars (which was totally unsafe.) 2010-10-06 20:54:08 -04:00
satyr
f90f1ef8e0 nodes: re{name,formatt}ed things 2010-10-07 09:28:53 +09:00
Jeremy Ashkenas
69b901a5b6 Fixing Issue #744 -- you can now use reserved words as static properties of a class. 2010-10-06 20:07:19 -04:00
Jeremy Ashkenas
af2e866947 rebuilding documentation 2010-10-05 21:05:57 -04:00
Jeremy Ashkenas
17eaf63c6d Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-05 21:02:05 -04:00
Jeremy Ashkenas
e2176a6521 whitespace 2010-10-05 21:02:03 -04:00
satyr
2e6b50335f lexer now distinguishes between IN/OF and FORIN/FOROF to help grammar, fixing #737 2010-10-06 04:46:17 +09:00
satyr
380bee97dd nagated relational operators are now grouped into NOT_RELATED, fixing #720 2010-10-06 00:43:44 +09:00
satyr
1e60c4c4d2 lexer: had some aligning fun 2010-10-05 23:31:48 +09:00
Jeremy Ashkenas
be0051ee69 s/lookahead/non-capturing 2010-10-05 00:34:49 -04:00
Jeremy Ashkenas
c79a7b5055 removing dollar-prefixed local vars (let's keep 'em for globals only) 2010-10-05 00:23:04 -04:00
Jeremy Ashkenas
08388fea5a testing issue 584 2010-10-05 00:16:55 -04:00
Jeremy Ashkenas
8bc706a94e Merging in heregexes 2010-10-05 00:11:28 -04:00
Jeremy Ashkenas
6f9ac01e71 redo-ing nodes.coffee with named classes. 2010-10-04 23:24:46 -04:00
Jeremy Ashkenas
19a92a4493 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-04 23:21:22 -04:00
Jeremy Ashkenas
2b66d5d6c0 First draft of named classes. 2010-10-04 23:21:16 -04:00
satyr
0ada1dfc3f follow-up to d1bca636; fixed unrolling of the single case ({@a} = o -> @a = o.a) 2010-10-05 12:04:44 +09:00
Timothy Jones
645075f910 All classes now named. 2010-10-05 15:52:33 +13:00
Jeremy Ashkenas
9fd031c896 tweaking the previous commit's test. 2010-10-04 22:12:30 -04:00
Jeremy Ashkenas
e14737dd88 tweaking the previous commit's test. 2010-10-04 22:12:22 -04:00
Jeremy Ashkenas
d1bca6364a Enchancing pattern matching with @vars ... issue #721 2010-10-04 22:10:10 -04:00
Jeremy Ashkenas
8eb283df2c Merge branch 'catchless' of http://github.com/satyr/coffee-script 2010-10-04 20:45:38 -04:00
Jeremy Ashkenas
b4d40c7501 Merge branch 'master' of github.com:jashkenas/coffee-script 2010-10-04 20:25:45 -04:00
Jeremy Ashkenas
ee8f53dd77 fixing @property = value typo. 2010-10-04 20:25:32 -04:00
satyr
d85910c17f made catch optional 2010-10-05 05:53:32 +09:00
satyr
42a91219cb fixed over-escaping in here documents and addressed Stan's comments 2010-10-05 03:47:50 +09:00
satyr
cdd033ffb0 disabled interpolations in normal regexes 2010-10-04 21:51:04 +09:00
satyr
493fa7d8fe heregex: now allows bare slashes and empty body 2010-10-04 11:55:49 +09:00
satyr
c605b3e232 first stub at heregex 2010-10-04 08:22:42 +09:00
satyr
ae55c70ac5 647: fixed quote/newline escaping in here documents 2010-10-03 07:50:41 +09:00
satyr
769870b493 [x] = [y] = [1] works again 2010-10-02 21:49:21 +09:00
satyr
765f57b658 refactored rewriter 2010-10-02 21:21:10 +09:00
satyr
a59d056ad2 [v] = a now compiles to v = a[0] 2010-10-02 20:53:29 +09:00
satyr
f7e6dabf6b fixed a regression where destructuring for miscompiles 2010-10-02 20:19:37 +09:00
Jeremy Ashkenas
baaec57d5c Fixing Issue #738 -- rewriter skips a token. 2010-10-01 21:02:48 -04:00
Jeremy Ashkenas
26de26f88f conditionals with no alternative now evaluate to 'undefined' instead of 'null' 2010-10-01 20:52:23 -04:00
satyr
4fd878447e nodes: removed o.chainRoot which went unused 2010-10-02 08:33:57 +09:00
satyr
8cdee9c0f4 ensured arguments in each scope 2010-10-02 08:21:34 +09:00
satyr
dafe6b09c5 removed remnant of 341f511b 2010-10-02 07:47:28 +09:00
satyr
2ea549ce5f made ForNode avoid needless cachings 2010-10-02 07:26:37 +09:00
satyr
341f511bbd #733: streamlined soak compilations and improved reference cachings 2010-10-02 07:17:35 +09:00
satyr
54f162e523 made --nodes output soak-aware 2010-09-30 05:29:20 +09:00
satyr
b5261abb6b nodes: made ExistenceNode omit typeof for known variables 2010-09-29 11:30:05 +09:00
satyr
9bc613e4a7 nodes: added THIS 2010-09-29 11:29:17 +09:00
Jeremy Ashkenas
5967b48348 Correcting contributor link in readme 2010-09-28 20:17:23 -04:00
Jeremy Ashkenas
b0f49be19e Can't rely on Array.isArray ... 2010-09-28 20:12:37 -04:00
Jeremy Ashkenas
35f395a0e4 Merge branch 'master' of http://github.com/stephank/coffee-script 2010-09-28 20:08:27 -04:00
Jeremy Ashkenas
61852aaddc Turning off a couple more warnings we'd like to ignore in JavaScriptLint. 2010-09-28 20:04:10 -04:00
satyr
7450df8104 #713: destructuring assignment is no longer statement and correctly returns RHS value 2010-09-29 05:47:12 +09:00
Stéphan Kochen
52e7d9a672 Fixing #723; switch cases not iterated by eachChild. 2010-09-28 20:28:05 +02:00
Stéphan Kochen
8f96f5f20f Added a (failing) test that reproduces #723. 2010-09-28 20:27:37 +02:00
satyr
b2313beaf4 added last to helpers 2010-09-29 00:10:03 +09:00
Jeremy Ashkenas
c064c90ee9 Issue #706 -- enchancing empty anonymous classes. 2010-09-27 23:59:47 -04:00
Jeremy Ashkenas
2e3f575f9c Fixing issue #276 -- unsoaked cached indexes. 2010-09-27 23:23:08 -04:00
Jeremy Ashkenas
dc0b03e54e linking to *all* the contributors in the readme. 2010-09-27 22:56:49 -04:00
Jeremy Ashkenas
bd08d06de3 Merge branch 'unary-new' of http://github.com/satyr/coffee-script 2010-09-27 22:52:40 -04:00
Jeremy Ashkenas
8568441221 merging in satyr's fix for #653 2010-09-27 22:17:46 -04:00
Jeremy Ashkenas
a3adc9c1b6 Merge branch '653' of http://github.com/satyr/coffee-script 2010-09-27 22:13:15 -04:00
Jeremy Ashkenas
e3ec325619 rebuilt the site with some IE fixes. 2010-09-27 15:21:45 -04:00
Jeremy Ashkenas
3c848736a7 Removing 'where' from COFFEE_KEYWORDS, and adding a missing equals sign to a test. 2010-09-27 10:16:34 -04:00
satyr
3bba51d5d9 made nodes cache more aggressively, fixing #653 2010-09-27 17:56:56 +09:00
satyr
72c83f5e43 updated tests toward fixing #653 2010-09-27 16:34:00 +09:00
satyr
159150c319 "cake test" now wraps all of the "assert" module to update test counts 2010-09-27 14:17:05 +09:00
satyr
bc87d9ed3d made --nodes output prettier 2010-09-27 04:47:52 +09:00
satyr
e188b9ff41 unary-new: built parser and new => now works 2010-09-27 02:16:41 +09:00
satyr
db531495b8 unary-new: merged master 2010-09-27 01:22:33 +09:00
Jeremy Ashkenas
ecb23d15c4 Merging in satyr's rewrite-lexer.coffee 2010-09-26 10:57:03 -04:00
Jeremy Ashkenas
bd047cbb4f Merge branch 'lexer-refactor' of http://github.com/satyr/coffee-script 2010-09-26 10:40:49 -04:00
Jeremy Ashkenas
008d2ba0d3 adding a cake:bench task 2010-09-26 10:38:28 -04:00
Jeremy Ashkenas
45bd0854b6 Merging in satyr's helpers-refactor 2010-09-26 10:28:48 -04:00
satyr
3e0c35bd0f lexer: enabled multiline interpolations 2010-09-26 07:06:14 +09:00
satyr
7945178f3a lexer: unrolled @extractNextToken/@match 2010-09-26 07:01:24 +09:00
satyr
19f08888e8 lexer: more regexes fixes 2010-09-26 06:57:23 +09:00
satyr
c515aaac5a lexer: fixed ASSIGNED 2010-09-25 23:37:33 +09:00
satyr
0b3b0ab68b unary-new: added tests 2010-09-25 18:13:37 +09:00
satyr
c24e1eacb9 (experimental) made new a unary operator 2010-09-25 17:39:19 +09:00
satyr
9a3b736174 lexer: fixed broken logics (due to f051d088) and a snakecased variable 2010-09-25 16:18:31 +09:00
satyr
e0ed254252 helpers: now directly exported 2010-09-25 09:29:44 +09:00
satyr
9005682cf1 helpers: refactored and fixed comments 2010-09-25 09:18:47 +09:00
satyr
3df82a757d helpers: added test 2010-09-25 09:15:47 +09:00
satyr
3fd7f9efdd added a test for JS literal 2010-09-24 23:06:49 +09:00
satyr
d457423c24 made simple strings shortcut 2010-09-24 22:38:28 +09:00
satyr
f051d0880e lexer: improved logics 2010-09-23 14:14:18 +09:00
satyr
ed501ea37e lexer: improved consistency, preferring charAt, slice and single quotes 2010-09-23 14:11:31 +09:00
satyr
20dae3758a lexer: optimized regexes 2010-09-23 14:05:30 +09:00
Jeremy Ashkenas
a04e17c4ea Merge branch 'master' of http://github.com/sstephenson/coffee-script 2010-09-22 23:32:56 -04:00
Jeremy Ashkenas
fc149fdada merging in satyr/for-of-diet 2010-09-22 23:26:11 -04:00
Jeremy Ashkenas
19dfe4b01d merging Tim's filename branch. 2010-09-22 22:44:42 -04:00
Tim-Smart
c4a3e170e2 Support for older revisions of Node.js for CoffeeScript.run() 2010-09-23 14:41:38 +12:00
Tim-Smart
dfd6025d04 Remove (compiled) from filenames, to keep __filename accurate 2010-09-23 11:55:05 +12:00
Sam Stephenson
01c14bc640 Heredoc indentation detector ignores blank lines without trailing whitespace. 2010-09-22 08:47:43 -05:00
Jeremy Ashkenas
c435647589 removing the ability to force an if/else chain to be compiled as a statement. Ternaries will now be used as much as possible. 2010-09-22 00:41:17 -04:00
Jeremy Ashkenas
c50cf23b7b CoffeeScript 0.9.4 2010-09-21 23:58:05 -04:00
satyr
540783a6dd removed useless property accesses from for-of 2010-09-22 12:55:19 +09:00
Jeremy Ashkenas
25c8b4b34f Using the Array spaces trick to generate padding and indentation. 2010-09-21 23:17:43 -04:00
Jeremy Ashkenas
c0a89a7988 Fixing issue #700, block comment after first line of class definition. 2010-09-21 23:13:46 -04:00
Jeremy Ashkenas
07d9e9b71e fixing up block comment indentation boondoggle. 2010-09-21 22:59:28 -04:00
Jeremy Ashkenas
269f4e8da8 Tweaks to browser.coffee 2010-09-21 22:31:59 -04:00
satyr
481c3d536b made browser.coffee override Node dependent exported methods 2010-09-22 01:05:00 +09:00
Jeremy Ashkenas
7e5db250d3 Merge branch 'master' of git://github.com/StanAngeloff/coffee-script 2010-09-21 08:06:12 -04:00
Jeremy Ashkenas
970bfbe151 Merge branch 'repl' of git://github.com/Tim-Smart/coffee-script 2010-09-21 08:05:03 -04:00
Jeremy Ashkenas
7d98bb216a merged in satyr's leakless branch. 2010-09-21 08:02:22 -04:00
satyr
e4b7d06f35 removed browser specific hacks from src/* by making "rake browser" provide fake require and exports 2010-09-21 18:37:44 +09:00
satyr
b19c004680 made wrapper function keep current this 2010-09-21 16:53:58 +09:00
satyr
7bc91bf6c6 removed global dependency from grammer 2010-09-21 16:50:32 +09:00
Tim-Smart
c49cd02365 Fix REPL. Add CoffeeScript.eval method as run doesn't return result. 2010-09-21 17:36:23 +12:00
Stan Angeloff
992f4192bf Re-compiling core with new temporary variable names, all tests pass. 2010-09-21 07:55:08 +03:00
Stan Angeloff
921ab3ce68 Using old temporary variable name generation for single-letter types
(e.g., i, j, k, and so on).
2010-09-21 07:53:52 +03:00
Jeremy Ashkenas
69942c9a81 commenting out the failing test for the time being, to be fixed later. 2010-09-21 00:14:22 -04:00
Jeremy Ashkenas
fb5158630a fixing herecomment newlines. 2010-09-21 00:06:03 -04:00
Tim-Smart
34c29b3406 Cleaner stack traces.
- Improves run() function
- Re-sets the module.filename to add (compiled)
2010-09-21 15:32:37 +12:00
Jeremy Ashkenas
c0796da7b9 hacking around Jison patch to remove module dependency. 2010-09-20 23:13:02 -04:00
Jeremy Ashkenas
83651a7d6a merging in Tim's registerExtension fix for the latest Node master. 2010-09-20 22:27:04 -04:00
Jeremy Ashkenas
10d57705a0 Merge branch 'registerExtension' of git://github.com/Tim-Smart/coffee-script 2010-09-20 22:24:19 -04:00
Jeremy Ashkenas
71998e06cf Merge branch 'master' of http://github.com/leobm/coffee-script 2010-09-20 22:14:41 -04:00
Jeremy Ashkenas
a16594ed7b Merging in Stan's temporary_junk improvements. 2010-09-20 22:13:08 -04:00
Jeremy Ashkenas
f7fce3cd68 tweaking compiled tempvar names to satisfaction. 2010-09-20 21:56:18 -04:00
Tim-Smart
ba850790ed Add require.extensions support. 2010-09-21 13:23:45 +12:00
Jan-Felix Wittmann
abc1e83319 fix invalid testcase 2010-09-20 12:02:16 +02:00
Stan Angeloff
99a06ce4ea Updating name for cached length temporary variables to '_length', 'length2', and
so on.
2010-09-20 08:42:31 +03:00
Stan Angeloff
31441868e0 Allowing temporary variables to be reused. 2010-09-19 19:34:27 +03:00
Jeremy Ashkenas
5d82dddfb1 merging in Stan's temporary variables. 2010-09-19 12:00:16 -04:00
Stan Angeloff
d568b56c5e First attempt at allowing temporary variables to be reused. 2010-09-19 17:47:26 +03:00
Stan Angeloff
3ab0c12bf1 Don't store tempVars as we can get the next available one from scope. 2010-09-19 17:03:45 +03:00
Stan Angeloff
ed74f42323 Refactoring temporary name generation in a separate method, no
functional changes.
2010-09-19 16:18:01 +03:00
Jeremy Ashkenas
15d84dbb4e Fixing issue #694. Destructuring assignment as first line of implicitly called block -- regression. 2010-09-19 09:04:38 -04:00
Stan Angeloff
65fa0411b4 Part of previous commit: updating how temporary variables are generated.
We no longer need to store the name of the last generated variable,
instead we store the index.
2010-09-19 15:50:17 +03:00
Stan Angeloff
408833daef Removing code added during the migration. freeVariable(..) is called with
a `type` at all times.
2010-09-19 15:37:26 +03:00
Stan Angeloff
bb35b3e3b2 Re-compiling core with new changes. All tests pass. 2010-09-19 15:29:15 +03:00
Stan Angeloff
4a3e1fb0cb Updating nodes.coffee to make use of new temporary variables code
generators.
2010-09-19 15:28:22 +03:00
Stan Angeloff
fe68261bc2 Added generator for custom free variable types, e.g., '_cache',
'_cache2', and so on.
2010-09-19 14:55:19 +03:00
Stan Angeloff
1f2c6c77fd s/tempVars/tempVars.general/ This should allow us to store more than one
category of temporary variables.
2010-09-19 14:36:37 +03:00
Jeremy Ashkenas
08e1101c1f fixing static class properties that are implicit objects. 2010-09-18 22:25:45 -04:00
Jeremy Ashkenas
72847b9b26 tweak to block indentation test. 2010-09-18 13:20:32 -04:00
Jeremy Ashkenas
4b2d40d3b5 Merging in Stephank's fix for #692. 2010-09-18 10:36:48 -04:00
Stéphan Kochen
72d7fe2f7a Function soaks should preserve this. Fixes issue #692. 2010-09-18 12:27:14 +02:00
Jeremy Ashkenas
43f7f6c355 documenting 'invoke' in Cakefiles a little bit. 2010-09-17 20:24:10 -04:00
Jeremy Ashkenas
a53c104db1 simpler default Try CoffeeScript scriptlet. 2010-09-16 00:41:13 -04:00
Jeremy Ashkenas
2a0bd1adc7 silencing another JavaScriptLint extraneous warning. 2010-09-16 00:36:46 -04:00
Jeremy Ashkenas
a2631759c0 CoffeeScript 0.9.3 2010-09-16 00:32:57 -04:00
Jeremy Ashkenas
2b87cabbb4 removing now-unused logic from the IfNode, that used to handle switch statements. 2010-09-15 23:48:20 -04:00
Jeremy Ashkenas
d8465ce767 First draft of real switch statements for CoffeeScript switch statements. 2010-09-15 23:46:01 -04:00
Jeremy Ashkenas
60f80e2698 Fixing the double-implicit-call-into-implicit-object problem. 2010-09-15 22:29:03 -04:00
Jeremy Ashkenas
c782c2ec1c Fix for issue #685. Over-aggressize heredoc cleanup when there is no leading indentation. 2010-09-15 22:08:13 -04:00
Jeremy Ashkenas
f0d778ce49 moving addImplicitBraces and addImplicitParentheses next to each other ... perhaps they should interleave. 2010-09-14 22:57:01 -04:00
Jeremy Ashkenas
a3c224e57a Fixing issue #676, chained accesses against the super() keyword. 2010-09-12 16:33:38 -04:00
Jeremy Ashkenas
b727245834 better error for external super() call. 2010-09-12 16:25:00 -04:00
Jeremy Ashkenas
6b19e61bd0 simplifying previous commit 2010-09-12 16:20:01 -04:00
Jeremy Ashkenas
38ce0cfd9a running cacheindexes on soaks that need them. 2010-09-12 16:18:05 -04:00
Jeremy Ashkenas
61a39e04fc Issue #680. @::prop versus this::prop, fixed lexing regex. 2010-09-12 15:48:31 -04:00
Jeremy Ashkenas
ea3aa6803a using @containsType. 2010-09-12 14:44:03 -04:00
Jeremy Ashkenas
3a20d7dacb Partial fix for 653. 2010-09-12 11:08:05 -04:00
Timothy Jones
e5837b4ee9 Actually caching the splatted constructor this time. 2010-09-12 01:49:25 +12:00
Timothy Jones
d1f31c5143 Ensuring constructors invoked with splats behave correctly, along with caching. 2010-09-12 01:28:22 +12:00
Jeremy Ashkenas
4af41e9bfb Fixing issue #678 -- missing parentheses in a mixed operation(call(soak)) 2010-09-11 08:39:14 -04:00
Jeremy Ashkenas
121110a485 Adding Roast to the Resources. 2010-09-10 15:41:35 -04:00
Jeremy Ashkenas
d41a414b5c Complexifying the indebt test, one more level. 2010-09-08 22:48:28 -04:00
Jeremy Ashkenas
9bd3cca7c4 Introducing the notion of 'indebt' to mirror 'outdebt', but for suppressed indentation with trailing operators etc. Issue #639. 2010-09-08 22:46:13 -04:00
Jeremy Ashkenas
18cbddff6a Fix for Issue #655. Leading empty commas in ArgLists are now disallowed. 2010-09-08 21:39:51 -04:00
Jeremy Ashkenas
df414dab02 Issue #665. Recompile on --watch when file changes size, or mtime changes. 2010-09-08 21:08:17 -04:00
Jeremy Ashkenas
904207ba8f throwing errs from fs.readFile in watch mode. 2010-09-08 20:55:34 -04:00
Jeremy Ashkenas
44618d5765 Adding a test for Issue #669 2010-09-08 20:25:17 -04:00
Jeremy Ashkenas
70cfd54ad4 Issue #670. 'THIS' tokens should trigger an implicit call. 2010-09-08 20:15:16 -04:00
Jeremy Ashkenas
62bf0a2bc9 Merge branch 'master' of git://github.com/StanAngeloff/coffee-script 2010-09-08 09:03:42 -04:00
Jeremy Ashkenas
c9289155b4 Merge branch 'master' of git://github.com/chrislloyd/coffee-script 2010-09-08 09:03:03 -04:00
Chris Lloyd
cd67ec6e69 Bad variable name clobbers correct path in compile event. 2010-09-08 14:51:59 +02:00
Stan Angeloff
cd6261d477 Fixed #669: Wrapper arguments 2010-09-08 15:18:08 +03:00
Jeremy Ashkenas
3b60aad487 simplifying RangeNode grammar a bit. 2010-09-04 06:48:20 -04:00
Jeremy Ashkenas
493780efab separate out browser.coffee from the core coffee-script module. 2010-09-04 06:39:01 -04:00
Jeremy Ashkenas
9290e508c6 fix broken simplenum regex for rangenodes... 2010-09-01 21:20:23 -04:00
Jeremy Ashkenas
a1ebb14495 fixing broken doc link (satyr) 2010-08-31 21:52:15 -04:00
Jeremy Ashkenas
eb9a524ea1 Adding unmatched 'then' to the list of things that closes a single-line implicit call early. Issue #611. 2010-08-30 22:04:13 -04:00
Jeremy Ashkenas
0caa731291 re-enabling the mis-dented call case. Issue #657 2010-08-30 20:59:16 -04:00
Jeremy Ashkenas
704fbf499b Merging in Tesco and rofrankel's soaks for function calls. A soaked check that fails will return undefined. 2010-08-28 09:00:04 -04:00
Jeremy Ashkenas
04fd24e068 Treat 'debugger' as a pure-statement keyword, not and identifier. 2010-08-28 08:26:47 -04:00
Richard Frankel
dc6a83c030 built Tesco's fix for function soaks 2010-08-25 18:59:21 -04:00
Richard Frankel
bcecbd051b added some tests for function soak 2010-08-25 18:54:42 -04:00
Timothy Jones
6607224493 Wrapping existence tests on functions. 2010-08-26 09:03:10 +12:00
Timothy Jones
6224edd6ce Existence checks on functions now supported. 2010-08-26 07:39:30 +12:00
Timothy Jones
9598b11c77 Existence functions now parsing. 2010-08-26 06:31:56 +12:00
Jeremy Ashkenas
fa95f743f3 Fixing Issue #643. Be a little bit safer about declaring block variables as close to the block scope as possible. 2010-08-24 22:19:53 -04:00
Jeremy Ashkenas
e2c46d14f0 CoffeeScript 0.9.2 2010-08-23 22:08:33 -04:00
Jeremy Ashkenas
bd3471b3d1 Issue #641. Rename __superClass__ to __super__ 2010-08-23 21:19:43 -04:00
Jeremy Ashkenas
1b88d18d61 more tweaks and futzes to block comments. 2010-08-23 21:00:47 -04:00
Jeremy Ashkenas
b4de17d504 more tweaks to the herecomment regex. 2010-08-23 20:33:18 -04:00
Jeremy Ashkenas
f90fac0e55 Issue #572. Flexible JavaScript block comments, compatible with JSDoc, YUI-compressor, and Google Closure compiler preservation syntax. 2010-08-23 20:27:34 -04:00
Jeremy Ashkenas
9fd92bf884 updating package.json for newer NPM. 2010-08-23 11:39:06 -04:00
Jeremy Ashkenas
117204a784 Revert "Issue #619. 'new' operator misbehavior."
This reverts commit e7834de929.
2010-08-21 19:16:02 -04:00
Jeremy Ashkenas
e7834de929 Issue #619. 'new' operator misbehavior. 2010-08-21 18:54:24 -04:00
Jeremy Ashkenas
d5d5de55ae Fixing the longstanding and important Issue #637. I'm glad this one got got. 2010-08-21 12:13:43 -04:00
Jeremy Ashkenas
143c4d5efc Issue #572. Block comments now compile to // for aesthetic reasons. 2010-08-21 09:30:25 -04:00
Jeremy Ashkenas
13adc44867 Issue #633. 'not instanceof' 2010-08-21 08:56:25 -04:00
Jeremy Ashkenas
87693d84cb Updating Underscore to 1.1.0, fixing a hasOwnProperty glitch in Scope, and a double-semicolon bug in ParentheticalNode. 2010-08-21 08:30:22 -04:00
Jeremy Ashkenas
6ed33fcc6d Updating contributors in README. 2010-08-20 17:53:45 -04:00
Jeremy Ashkenas
2e59cc4807 Using unbounded ranges in a couple spots in the compiler. 2010-08-18 22:08:09 -04:00
Jeremy Ashkenas
4ddd65a4c4 Issue #621. Added the ability to leave the start and end index off of arrays. list[5..] is now valid CoffeeScript, slicing to the end of the array. 2010-08-18 21:51:44 -04:00
Jeremy Ashkenas
bf6bafa3ac Disallowing Splats outside of ParamLists and ArgLists ... where they belong. This is in anticipation of the next commit... 2010-08-18 21:27:10 -04:00
Jeremy Ashkenas
24f1174b16 Adding a test for issue #631. 2010-08-18 20:42:23 -04:00
Jeremy Ashkenas
098caa9979 Revert "Fixes Issue #618. Close implicit arguments in the middle of param lists."
This reverts commit 474c372b17.
2010-08-18 20:39:55 -04:00
Jeremy Ashkenas
b608d4a5ea Issue #626. Making the isInvertible check a little stricter. 2010-08-17 21:46:00 -04:00
Jeremy Ashkenas
4d32c47bee Merge branch 'remote_script' of http://github.com/satyr/coffee-script 2010-08-17 21:35:00 -04:00
Jeremy Ashkenas
ec54b50c67 allowing empty parens. 2010-08-17 21:31:32 -04:00
satyr
387c690530 removed noWrap (setTimeout evaluates on global) 2010-08-18 10:29:13 +09:00
Jeremy Ashkenas
536e24b024 Merge branch 'remote_script' of http://github.com/satyr/coffee-script 2010-08-17 21:15:41 -04:00
Jeremy Ashkenas
1b05cd81f0 Enabling bound functions as static members of classes... Issue #627 2010-08-17 21:07:36 -04:00
satyr
db181e2a36 enabled remote scripts in browsers 2010-08-18 09:35:52 +09:00
Jeremy Ashkenas
f41ca2e5e8 a touch of safety from trailing catches falling off the end of the rewriter. 2010-08-17 20:04:34 -04:00
Jeremy Ashkenas
a8c6a641d7 stop supressing left-hand whitespace in newline'd strings. Make 'em more literal. 2010-08-16 22:02:37 -04:00
Jeremy Ashkenas
474c372b17 Fixes Issue #618. Close implicit arguments in the middle of param lists. 2010-08-16 21:19:34 -04:00
Jeremy Ashkenas
5b9b45814f Fixing Issue #622 with a light refactor to start using a 'tags' property on all nodes. 2010-08-16 20:18:42 -04:00
Stan Angeloff
01cd5476a0 '-r' should work with $NODE_PATH as well (where previously it was an absolute/relative path) 2010-08-16 17:36:55 +03:00
Jeremy Ashkenas
027b9e9dc3 simplifying generated output for unless/is to (a isnt b) instead of not (a is b). Ticket #617 2010-08-15 15:13:33 -04:00
Jeremy Ashkenas
197f576cab Merged in Stan's patch that allows -r scripts to modify input and output. 2010-08-15 08:32:09 -04:00
Jeremy Ashkenas
0b8facc66f Merge branch 'master' of git://github.com/StanAngeloff/coffee-script 2010-08-15 08:20:50 -04:00
Jeremy Ashkenas
7a0d95c612 Issue #575. Allowing implicit objects to force implicit calls. 2010-08-14 19:56:00 -04:00
Jeremy Ashkenas
975b82f09b Issue #609. Slightly faster implementation of ||= and &&= 2010-08-14 18:02:07 -04:00
Jeremy Ashkenas
f496cc229b Further reducing amount of redundant parentheses. 2010-08-14 17:52:37 -04:00
Jeremy Ashkenas
9894eeb8e9 Improving double-parentheses suppression. Issue #587 2010-08-14 17:43:58 -04:00
Jeremy Ashkenas
129e950c59 Fixing naked chained existential checks -- the associativity recently got reversed. 2010-08-14 16:33:20 -04:00
Jeremy Ashkenas
c90a75ebc5 Fixing first part of #614 -- improperly cached existential operator, when first operand is a function call. 2010-08-14 16:24:05 -04:00
Jeremy Ashkenas
1d6eca76f8 disabling javascriptlint's 'test for equality mistyped as assignment', because it's not relevant to coffeescript. 2010-08-14 16:05:14 -04:00
Jeremy Ashkenas
6555d86328 Adding a jsl.conf configuration file for JavaScript lint, and switching to == null for soaks, accordingly. 2010-08-14 16:02:01 -04:00
Jeremy Ashkenas
c71f2794eb Fixing compound assignment as a right-hand sub expression of a larger operation. Invalid in JS, valid in Coffee. 2010-08-14 14:43:25 -04:00
Jeremy Ashkenas
ca18f1fad6 Core Compiler is JSLint-free again, after removing a couple extra semicolons that snuck in when if statements compiled at the top level. 2010-08-14 11:42:19 -04:00
Jeremy Ashkenas
ead9b1041c tweaking existential compilation. 2010-08-14 11:29:10 -04:00
Jeremy Ashkenas
1eebbfe2bc allowing more flexible whitespace-started regexes. You have to wrap 'em in parens or assign to 'em, but it's better than nothing. 2010-08-12 20:24:53 -04:00
Stan Angeloff
d30c8b321c Allow required files to change the input and output of compiled files. 2010-08-13 01:28:38 +03:00
Jeremy Ashkenas
083500fc0e fixing string interpolation docco. 2010-08-12 00:00:28 -04:00
Jeremy Ashkenas
fd6e9a1e66 Adding support for compound assignment to indented implicit objects. 2010-08-11 23:14:50 -04:00
Jeremy Ashkenas
8c45aa480b Reduced the time it takes to build the grammar from 80 seconds to 15, by consolidating Operation terminals by precedence level. 2010-08-11 23:04:33 -04:00
Jeremy Ashkenas
d704afa0e9 Fixes Issue #574 ... number keys in implicit object literals. 2010-08-11 21:49:18 -04:00
Jeremy Ashkenas
2ec857ef8d Fixing implicit object literals with leading string keys. 2010-08-11 21:41:29 -04:00
Jeremy Ashkenas
ba02ebc3dc Fixes Issue #603 -- a longstanding precedence issue involving prefix vs postfix if and unless, involving using the entire single-line if statment as an expression. 2010-08-11 21:28:22 -04:00
Jeremy Ashkenas
ac752a46bc removing bound functions from the Rewriter. 2010-08-11 21:07:47 -04:00
Jeremy Ashkenas
398ec3be5a Issue #602. Adding JS's Bitwise Assignment operators. 2010-08-11 19:24:59 -04:00
Jeremy Ashkenas
6c997978bc CoffeeScript 0.9.1 is on the books. 2010-08-11 00:40:15 -04:00
Jeremy Ashkenas
642e7fada5 adding other implicit indentation/call/object test. 2010-08-11 00:27:01 -04:00
Jeremy Ashkenas
12493779b9 fixing Issue #545 ... whitespace-only heredocs. 2010-08-11 00:02:49 -04:00
Jeremy Ashkenas
7142131f3d adding herecomment in class definition test. 2010-08-10 23:06:06 -04:00
Jeremy Ashkenas
5bdf78d5ec Fixes Issue #573. Herecomments inside of class literals. 2010-08-10 23:02:24 -04:00
Jeremy Ashkenas
60a4138d50 refactor to simplify scanTokens method in Rewriter. 2010-08-10 22:56:21 -04:00
Jeremy Ashkenas
cb52be6475 adding a top-level object literal test for Issue #542 2010-08-10 22:18:15 -04:00
Jeremy Ashkenas
c2ec40e6ce Fixes Issue #542. Ensure that top-level objects are parenthesized. It's not valid code, but we might as well not SyntaxError out. 2010-08-10 22:16:51 -04:00
Jeremy Ashkenas
87fd05afb0 New implementation of Rewriter#addImplicitIndentation, using Rewriter#detectEnd 2010-08-10 22:05:01 -04:00
Jeremy Ashkenas
45b5bae7d7 New implementation of Rewriter#addImplicitParentheses, using Rewriter#detectEnd 2010-08-10 21:46:46 -04:00
Jeremy Ashkenas
d0b918e083 New implementation of Rewriter#addImplicitBraces -- uses detectEnd.. 2010-08-10 21:13:30 -04:00
Jeremy Ashkenas
0231f8da1b adding options argument to cake documentation. 2010-08-09 09:20:35 -04:00
Jeremy Ashkenas
3eda5a2e85 prefer the include() helper to 'in', except for array literals. 2010-08-08 17:41:10 -04:00
Jeremy Ashkenas
18d6fd72de First step of the general rewriter refactor. Added a generic 'detectEnd' function which is expression-pair sensitive. Use it to reimplement closeOpenCallsAndIndexes 2010-08-08 17:37:28 -04:00
Jeremy Ashkenas
d286b33601 Fixing closures-generated-within-comprehensions to preserve block local scope for range comprehensions 2010-08-08 10:52:59 -04:00
Jeremy Ashkenas
a749d43897 Use fs.realpathSync instead of something hacky. 2010-08-08 10:05:44 -04:00
Jeremy Ashkenas
08506f160d Adding CoffeeScript as a globally-available object, when invoked from the coffee command-line, only. 2010-08-08 09:54:45 -04:00
Jeremy Ashkenas
b902377304 Fixing Issue #589. Compound assignment to an operation should have lower precedence. 2010-08-08 00:07:00 -04:00
Jeremy Ashkenas
1c903450c8 Merging in Stan's patch for a --require flag that allows you to hook into CoffeeScript compiler events for on 'compile', 'success', and 'failure' ... a better way to extend the language or do growlnotify stuff. Issue #590 2010-08-07 23:33:35 -04:00
Jeremy Ashkenas
f950e282a6 Merge branch 'hooks' of git://github.com/StanAngeloff/coffee-script 2010-08-07 22:52:08 -04:00
Jeremy Ashkenas
4da982b253 Merge branch 'master' of http://github.com/brodyberg/coffee-script 2010-08-07 22:49:08 -04:00
Stan Angeloff
b1b78dca47 Add command-line compiler hooks. To invoke, pass a file after -r and listen for any of these events: 'compile', 'success' and 'exception'. Example:
coffee -e -r ./snarl 'Hello!'

Contents of 'snarl.coffee' in the working directory:

    http = require 'http'
    CoffeeScript.on 'exception', (err) ->
      client  = http.createClient 9889, 'localhost'
      request = client.request 'GET', '/?d={"action":1,"applicationName":"CoffeeScript","title":' + JSON.stringify(err.message) + ',"description":' + JSON.stringify(err.stack) + ',"priority":3}'
      request.end()
      err.handled = yes

To examine arguments available for each event (for debugging and getting started), use `puts JSON.stringify arguments`.

See http://nodejs.org/api.html#modules-309 and NODE_PATH for more details on how -r looks for files.
2010-08-07 20:24:37 +03:00
Jeremy Ashkenas
0ada5a7734 Issue #587 ... Removing the Attempted Removal of Erroneous Double Parens. 2010-08-07 08:13:36 -04:00
Jeremy Ashkenas
cc10641f38 Forbidding #interp-style interpolation ... Issue #581 2010-08-07 08:07:44 -04:00
Jeremy Ashkenas
9df3e6a538 first step towards requiring #{ ... } interpolation -- removing naked interps from the compiler. 2010-08-07 08:02:16 -04:00
Brody Berg
133aa7be4a Fix typo 2010-08-04 23:23:46 -07:00
Brody Berg
6555659e82 Fix typo 2010-08-04 22:53:45 -07:00
Jeremy Ashkenas
b1f7d5e33b compile empty coffee files to js anyway. 2010-08-04 23:42:46 -04:00
Jeremy Ashkenas
17bf3b7115 be more flexible about trailing commas in implicit object literals. 2010-08-04 23:25:30 -04:00
Jeremy Ashkenas
ff9af83358 CoffeeScript 0.9.0 2010-08-04 23:14:34 -04:00
Jeremy Ashkenas
5f2326e911 fixing Issue #569. Compiling empty source files to disk with --no-wrap on. 2010-08-04 21:36:03 -04:00
Brody Berg
4d2dd337f6 Fix typo 2010-08-03 22:59:17 -07:00
Jeremy Ashkenas
f43c79c101 more additions to the documentation for 0.9.0 2010-08-03 01:13:31 -04:00
Jeremy Ashkenas
b42045f3f7 regenerating large swathes of the docs 2010-08-03 00:06:34 -04:00
Jeremy Ashkenas
3301738b84 git-go 2010-07-31 07:44:49 -04:00
Jeremy Ashkenas
d4ac11cd4f fixing up compout assignment for ?=, which was using a sligtly different path. 2010-07-31 00:42:57 -04:00
Jeremy Ashkenas
8b953bbde6 Fixing Issue #509. Double-evaluation for function calls within IndexNodes as the left-hand-assignment part of a compound-assignment operation. 2010-07-30 23:37:13 -04:00
Jeremy Ashkenas
acd69b1c70 Fixing issue #544. Needed to special case implicit-object-closing for outdents -- it's different than a single-line implicit object with a terminator. 2010-07-30 22:50:35 -04:00
Jeremy Ashkenas
f3caa9292f Fixing Issue #552, Indentation bug with chained calls with nested object literals... 2010-07-30 22:06:22 -04:00
Jeremy Ashkenas
071b527b66 Issue #559, renaming {source} option to {fileName}, on CoffeeScript.compile 2010-07-30 20:37:12 -04:00
Jeremy Ashkenas
ebad1ec552 using double-quotes for auto-quoted object keys and hash accesses. JSON-style. Issue #556 2010-07-30 20:29:05 -04:00
Jeremy Ashkenas
af451bc530 tiny thing. 2010-07-29 21:59:12 -04:00
Jeremy Ashkenas
d1b17df38c better output when trying to force a pure statment to become a return 2010-07-29 21:33:35 -04:00
Jeremy Ashkenas
b18d7fb550 removing the last traces of half-assignments. Issue #541. 2010-07-29 21:23:49 -04:00
Jeremy Ashkenas
980a663c19 ported and regenerated examples. 2010-07-29 00:51:35 -04:00
Jeremy Ashkenas
65c107fc5d finished porting over the examples. 2010-07-29 00:17:48 -04:00
Jeremy Ashkenas
da6ea27454 most of the examples converted to symbology. 2010-07-29 00:03:42 -04:00
Jeremy Ashkenas
58a5d93214 adding a test for Issue #550. 2010-07-28 20:43:39 -04:00
Jeremy Ashkenas
5b848fbc47 Merge branch 'master' of git://github.com/Tesco/coffee-script 2010-07-28 20:39:25 -04:00
Jeremy Ashkenas
8522a11bcb getting the whole codebase passing jslint again. 2010-07-28 20:38:16 -04:00
Timothy Jones
d944f81163 Prevented parameter contents from causing unexpected returns in the body. 2010-07-29 12:35:59 +12:00
Jeremy Ashkenas
c67e7fbcea moving nodes.coffee over to use Tesco's new auto-setter style. 2010-07-28 19:34:02 -04:00
Jeremy Ashkenas
a80d8d55c4 merging tesco's branch for issue #535 2010-07-28 07:34:28 -04:00
Timothy Jones
9026069f79 Support for @-prefixed splats. 2010-07-28 18:17:50 +12:00
Timothy Jones
c9421cbfcd Implement @-prefixed parameters. 2010-07-28 17:54:36 +12:00
Jeremy Ashkenas
5399b989c0 Removing now unnecessary braces from the grammar. Still compiles to identical JS. 2010-07-28 00:35:57 -04:00
Jeremy Ashkenas
9d1fd38b69 removing extraneous tempvar declarations from range generation by re-ordering... 2010-07-27 23:39:28 -04:00
Jeremy Ashkenas
a4156b71fa fixing broken range literal expansions. 2010-07-27 23:06:11 -04:00
Jeremy Ashkenas
fa4871574a one more range literal expansion test 2010-07-27 23:02:26 -04:00
Jeremy Ashkenas
a59df2cf74 merged in evilpie's fix for faster small range comprehensions 2010-07-27 23:00:26 -04:00
Jeremy Ashkenas
051a863ff5 adding slightly optimized syntax for range comprehensions that could care less about the index variable. Issue #547 2010-07-27 22:38:38 -04:00
Jeremy Ashkenas
8d544ce80b Adding anonymous class support (gets a temporary variable for a name.) Issue #548 2010-07-27 22:05:55 -04:00
Jeremy Ashkenas
cc7b0f2e8f Allowing classes to be better decorated with implicit calls. Issue #548 2010-07-27 07:03:44 -04:00
Jeremy Ashkenas
b4ef4a9e28 make the compiler use 'obj = or default' for default values. 2010-07-26 23:58:06 -04:00
Jeremy Ashkenas
9be1453886 bringing back half assignments, but just for 'a = or b' and 'a = and b' 2010-07-26 23:53:03 -04:00
Jeremy Ashkenas
89cd25ab15 finished moving over string and regex interpolation to use '#' instead of '$', Issue #544 2010-07-26 23:31:55 -04:00
Jeremy Ashkenas
d624310be1 waypoint commit with both # and $ performing interpolation. Issue #544 2010-07-26 23:08:09 -04:00
Jeremy Ashkenas
9c8a22832c merging in symbology 2010-07-26 22:08:09 -04:00
Jeremy Ashkenas
55a0e1d2ff making inline implicit objects more flexible ... can be used with trailing blocks. 2010-07-26 21:39:43 -04:00
Jeremy Ashkenas
e638de5c7c a couple more implicit objects in the source. 2010-07-26 20:54:07 -04:00
Jeremy Ashkenas
0aa36899a8 fixing test for {} + {} 2010-07-26 07:40:18 -04:00
Jeremy Ashkenas
ac2f814eb4 fixing issue 542. Parse error with leading object literal as part of operation. 2010-07-25 20:59:28 -07:00
Jeremy Ashkenas
27e5c42023 fixing some implicit object parses for issue #541 2010-07-25 17:46:08 -07:00
Jeremy Ashkenas
6b0418a74a merging master changes into symbology 2010-07-25 00:15:12 -07:00
Jeremy Ashkenas
a0b2b78962 adding nice support for fancy implicit hashes 2010-07-24 23:52:02 -07:00
Jeremy Ashkenas
d1ffffab04 Using an experimental version of new optional-brace object literals. 2010-07-24 23:42:37 -07:00
Jeremy Ashkenas
f9dff6ffc4 added and= and or= to the language. 2010-07-24 22:36:50 -07:00
Jeremy Ashkenas
88847df70b tests are now passing on symbology 2010-07-24 22:23:37 -07:00
Jeremy Ashkenas
492ee57b8f finished basic port to equality of the compiler 2010-07-24 21:36:21 -07:00
Jeremy Ashkenas
5c85bf22bb converted nodes.coffee. a big step 2010-07-24 18:21:25 -07:00
Tom
527af3b69f simplfy generated code for static ranges 2010-07-25 00:49:15 +02:00
Jeremy Ashkenas
6b6beb588c optimizing the output of compiled splat arguments. 2010-07-24 12:40:36 -07:00
Jeremy Ashkenas
dc1288d319 slightly optimizing return values of AssignNodes. Issue #539 2010-07-24 12:27:11 -07:00
Jeremy Ashkenas
87226b6f44 fixing bound functions with an __bind helper. 2010-07-24 12:12:26 -07:00
Jeremy Ashkenas
3b6f020f8a Making the spacing of symbols on function declaration consistent. No-space when single-line. Spaced when block. (StanAngeloff) 2010-07-24 08:31:43 -07:00
Jeremy Ashkenas
93d77e2354 _this to __this, for consistency. (StanAngeloff) 2010-07-24 08:11:42 -07:00
Jeremy Ashkenas
85ed376748 adding correct semicolons to bound functions 2010-07-24 00:45:00 -07:00
Jeremy Ashkenas
bfc7704ca1 first bit of equals for symbology ... barely started on lexer.coffee 2010-07-24 00:31:04 -07:00
Jeremy Ashkenas
e41abe2d83 Changing implementation of bound functions to mirror sethaurus' suggestion for cleaner output. Issue #530. Tests pass. 2010-07-23 22:34:56 -07:00
Jeremy Ashkenas
de9fb7777b fixing If/else-to-ternary with instanceof as an unparenthesized condition. JS operator precedence. 2010-07-23 20:44:56 -07:00
Jeremy Ashkenas
24a5adc898 updating package.json to work better with NPM. Issue #522 2010-07-23 11:06:17 -07:00
Jeremy Ashkenas
0a3f6c49f8 updating documentation with correct variable names. 2010-07-23 09:34:54 -07:00
Jeremy Ashkenas
8262070f5c fixing extra spaces in nested empty functions. Issue #527 2010-07-22 14:08:07 -07:00
Jeremy Ashkenas
9c4164e7a3 removing unnecessary parens from the setup part of a range comprehension. Issue #528 2010-07-22 10:37:13 -07:00
Jeremy Ashkenas
1dab47176b switching interpolateString's method signature to take on options hash. 2010-07-22 09:38:26 -07:00
Jeremy Ashkenas
dfa50c90b3 Fixes Issue #525 -- String interpolation bug due to conflict with Heredoc interpolation. 2010-07-21 15:45:25 -07:00
Jeremy Ashkenas
ff88482034 fixing regex-interpolation-sans-flags issue. 2010-07-21 10:32:36 -07:00
Jeremy Ashkenas
7e225688cb making the 'cake loc' task reflect the lines of code in the compiler only. 2010-07-21 07:26:44 -07:00
Sam Stephenson
5678bf10fd class B extends A calls A.extended(B) 2010-07-18 14:22:26 -05:00
Jeremy Ashkenas
989d539af3 adding no-argument super calls. 2010-07-18 14:46:21 -04:00
Jeremy Ashkenas
d017a8f9f7 Moving from '.addListener' to '.on' for Node v0.1.101 2010-07-18 07:54:44 -04:00
Jeremy Ashkenas
5a34f53689 enhancements to range comprehensions, back to being safe -- and usable downwards without a 'by' clause, and optimized when working with integer literals. 2010-07-17 18:45:29 -04:00
Jeremy Ashkenas
96f076983e Reserving __hasProp and friends, for safety's sake. 2010-07-17 17:30:10 -04:00
Jeremy Ashkenas
a322b3ad68 renamed #strings sectiong to #heredocs 2010-07-17 10:33:32 -04:00
Jeremy Ashkenas
9814fc2e1c Updating documentation with endtime's suggestions. 2010-07-17 10:28:06 -04:00
Jeremy Ashkenas
ec2d358ae3 updating docco to better reflect lack of explicit ternaries. Issue #510 2010-07-16 22:44:07 -04:00
Jeremy Ashkenas
6c8eab7af5 michaelficarra's suggestion to make object comprehensions' hasOwnProperty check a continue, instead of a wrapped if. 2010-07-16 22:31:36 -04:00
Jeremy Ashkenas
b810d10e80 Fixing Issue #506. existential chains should force parentheses in the presense of a compiled ternary operator. 2010-07-15 21:38:35 -04:00
Jeremy Ashkenas
72c4efbc39 adding a new comprehension 'for all key, value of object', which compiles to the naked JS for..in, including enumerable properties inherited from prototypes. 2010-07-15 21:18:35 -04:00
Jeremy Ashkenas
2a932597e4 fixing existential chains directly against a 'new Func()' call. Issue #503 2010-07-15 09:08:51 -04:00
Jeremy Ashkenas
4eed514e37 Fixing (at least partially) Issue #502. Trailing block comment parse. 2010-07-15 08:50:49 -04:00
Jeremy Ashkenas
0337dc23c3 Fix for Issue number 501 ... 2010-07-14 09:40:07 -04:00
Jeremy Ashkenas
2b3b03c3c6 adding 0.7.2 changelog to the docco, as per request. 2010-07-13 23:39:58 -04:00
Jeremy Ashkenas
6a059bfab7 fixing issue #497 try/catch/finally all empty. 2010-07-13 23:33:59 -04:00
Jeremy Ashkenas
0b87387fab slightly nicer implementation of SplatNode.compileSplattedArray 2010-07-13 22:16:19 -04:00
Jeremy Ashkenas
8c34aff1c5 Fixing issue #495 ... options wasn't being passed down in ArrayNode#compileSplatLiteral 2010-07-13 21:51:27 -04:00
Jeremy Ashkenas
cc827b139d Turning --compile on when --output is set, because it's probably what was intended. 2010-07-13 21:04:32 -04:00
Jeremy Ashkenas
c6e1a96882 adding an instanceof test for constructors-called-with-splats 2010-07-13 08:57:42 -04:00
Jeremy Ashkenas
c3410e722e (cosmetic) removing occasional extra linebreaks in JS generated from class definitions. 2010-07-12 22:51:10 -04:00
Jeremy Ashkenas
534e2a25de enabling a variable number of arguments to be passed to constructor functions. 2010-07-12 22:42:21 -04:00
Jeremy Ashkenas
d2c820b5d7 removing sudo from the npm install script. 2010-07-12 21:50:29 -04:00
Jeremy Ashkenas
ff7e729b84 bumping version to 0.7.2 for --options patch. 2010-07-12 08:17:26 -04:00
Jeremy Ashkenas
a21606e348 toFixed() seems to be non-portable. Trying a different number test. 2010-07-11 20:39:54 -04:00
Jeremy Ashkenas
4bd657160d fixing bug in option parsing with flagged arguments and cake. 2010-07-11 17:55:22 -04:00
Jeremy Ashkenas
be8d812919 removing an errant mention of named functions. 2010-07-11 10:44:33 -04:00
Jeremy Ashkenas
e40d25e4bd rebuilding docs and compressed version for CoffeeScript 0.7.1 2010-07-11 10:40:44 -04:00
Jeremy Ashkenas
2a7a26482a fixing optparse to behave nicely in the presence of hashbangs -- stop parsing after the first non-option argument, and pass the rest along -- and adding an OptionParser test. 2010-07-11 09:57:42 -04:00
Jeremy Ashkenas
3d6cdfa636 making it possible to pass in command-line arguments to a hash-banged coffee script. Ticket #473 2010-07-10 15:36:54 -04:00
Jeremy Ashkenas
15a2b7d69a Fixing issue number #486 (which is debatable). Allowing an unparenthesized if/else ternary as a trailing parameter to a call. 2010-07-10 14:52:54 -04:00
Jeremy Ashkenas
9ff8433f21 fixing previously-escaped-inner-quotes-in-double-quoted-heredoc-interpolations. Issue #479 2010-07-10 11:54:59 -04:00
Jeremy Ashkenas
1c7d51a2c4 fixing issue #485, unary minus following an existential operator. 2010-07-10 11:27:43 -04:00
Jeremy Ashkenas
49020208f9 better printing for OpNodes with running with --nodes 2010-07-10 11:17:44 -04:00
Jeremy Ashkenas
6f32fe27f8 better formatting for top-level closured-values. 2010-07-10 09:49:01 -04:00
Jeremy Ashkenas
7a16db9ad3 fixing inline-loop object-in-array tests for instance variables. Issue #481 2010-07-10 09:01:22 -04:00
Jeremy Ashkenas
2f8a29b5a0 fixing a comment/block-comment combination lexing regex issue. Ticket #478 2010-07-10 08:44:30 -04:00
Jeremy Ashkenas
64b5ccc524 Fixes issue #477, missing global helpers in REPL. 2010-07-09 01:01:31 -04:00
Jeremy Ashkenas
4fc4edc7a0 adding wavded's gedit-coffeescript to the resources section of the docs 2010-07-08 10:18:18 -04:00
Jeremy Ashkenas
358edfb21f fixing return node squashing the possiblity of a ternary, when there should be one. Issue #475 2010-07-06 23:04:35 -04:00
Jeremy Ashkenas
577daf5457 fixing herecomment/indentation bugaboo ... issue #474 2010-07-06 22:20:42 -04:00
Jeremy Ashkenas
afa3bb4191 added dsc's coffeecup to the resources section. 2010-07-05 08:51:45 -04:00
Jeremy Ashkenas
e81810d845 fixing issue #427 -- incorrect stringification of reserved word 2010-07-04 20:55:21 -04:00
Jeremy Ashkenas
c57ebffe6f fixing Lexer::OPERATOR regex for non-spaced + unary arithmetic. Issue #471 2010-07-04 13:29:22 -04:00
Jeremy Ashkenas
e281133f12 fixing empty catch clauses ... Issue #470 2010-07-04 12:50:04 -04:00
Jeremy Ashkenas
92878558c6 fixing improper formatting in range-to-array expansion. 2010-07-03 17:00:30 -04:00
Jeremy Ashkenas
ec449158c6 fixing improperly-formatted-output of pattern matching within comprehension arguments. 2010-07-03 15:09:21 -04:00
Jeremy Ashkenas
eefa004b8f fixing the block comment test to use defined variables. 2010-07-01 21:51:28 -04:00
Jeremy Ashkenas
77a75ed365 adding passed-through block comments back to the grammar/lexer/rewriter/nodes ... thanks, Trevor Burnham. 2010-07-01 21:26:33 -04:00
Jeremy Ashkenas
364ec2a694 better syntax errors for tokens-not-in-the-grammar. Coming soon to a Jison near you (hopefully) 2010-07-01 20:40:08 -04:00
Jeremy Ashkenas
9a8a707016 throw a syntax error if you try to use the fat arrow to define a class constructor. 2010-06-30 22:03:20 -04:00
Jeremy Ashkenas
7a5f014014 fixing closurenode wrapping of bodies with bound function declarations inside -- this doesn't have to be mentioned explicitly. 2010-06-30 21:54:16 -04:00
Jeremy Ashkenas
5ca5a504a4 allowing empty bodies in try blocks and in catch blocks 2010-06-30 20:53:09 -04:00
Jeremy Ashkenas
cb45c8feac fixing html entity in the changelog 2010-06-30 19:51:49 -04:00
Jeremy Ashkenas
7d79d73b58 allowing paren-less instance creation, a la 'new Class' 2010-06-29 21:03:50 -04:00
Jeremy Ashkenas
7c426db36a fixing range literals (which had gone untested) oops. 2010-06-28 20:26:31 -04:00
Jeremy Ashkenas
744638ed08 adding a one-line exception test. 2010-06-28 08:52:13 -04:00
Jeremy Ashkenas
9bc7cd7904 adding a one-line exception test. 2010-06-28 08:50:44 -04:00
Jeremy Ashkenas
d83bbfb1d5 updating readme with NPM install. 2010-06-28 01:19:04 -04:00
Jeremy Ashkenas
4ad9e82f50 docs for the NPM install 2010-06-28 01:06:53 -04:00
Jeremy Ashkenas
677c7edf3f CoffeeScript 0.7.0 is on the books. 2010-06-28 01:00:53 -04:00
Jeremy Ashkenas
e56af4967c removing our vendor'd copy of Jison ... you should install it from NPM now. 2010-06-28 00:26:45 -04:00
Jeremy Ashkenas
1f7af35368 getting ready for a 0.7.0. cleanups and doc revisions, not quite there yet. 2010-06-28 00:19:58 -04:00
Jeremy Ashkenas
08ab4abd43 removing obvious redundant parentheses. 2010-06-27 23:55:18 -04:00
Jeremy Ashkenas
a810eb29db slightly simpler comment regex. 2010-06-27 22:26:59 -04:00
Jeremy Ashkenas
3881324007 cleaning up the grammar rule for Super 2010-06-27 16:50:31 -04:00
Jeremy Ashkenas
af3b356d70 fixing an improper-js-output bug when using a loop-compiled inarray clause as part of a larger expression 2010-06-27 13:27:51 -04:00
Jeremy Ashkenas
24676eea71 Fixing commented-out if-clauses or empty if-clauses. 2010-06-27 13:19:23 -04:00
Jeremy Ashkenas
7e2eb997a8 adding a test for trailing-comments-preceding-outdents 2010-06-27 13:02:47 -04:00
Jeremy Ashkenas
ec570c46bf Big commit. First draft of stripping comments from generated JS output. Issue #41 2010-06-27 12:59:54 -04:00
Jeremy Ashkenas
8eedfe4bc6 slight simplification of the if-else grammar rules 2010-06-27 11:46:30 -04:00
Jeremy Ashkenas
800fb81d1b Re-ordering lexer rules for fewer regex matches / slightly faster lexing. 2010-06-27 10:58:08 -04:00
Jeremy Ashkenas
e020f5849c adding a test for #454 2010-06-26 17:21:30 -04:00
Jeremy Ashkenas
698784e103 fixing issue #454 single-line function with single-line if/else 2010-06-26 17:20:13 -04:00
Jeremy Ashkenas
f7345ffaac removing extensions from CoffeeScript 2010-06-26 13:36:31 -04:00
Jeremy Ashkenas
b7faa4a7f2 using the new in-tests for the Rewriter. 2010-06-21 23:54:43 -04:00
Jeremy Ashkenas
0fcfb80be4 switching 'a in b' to 'a of b', and adding an array presence check for 'a in b'. 2010-06-21 23:51:12 -04:00
Jeremy Ashkenas
38a9b7166b Adding TrevorBurnham's suggestion for 'a not in b' 2010-06-21 22:25:28 -04:00
Jeremy Ashkenas
3b28f52ff7 adding non-ASCII characters to test_literals.coffee for Node v0.1.99 2010-06-21 20:47:58 -04:00
Jeremy Ashkenas
7725fe338e Merge branch 'npm' of git://github.com/Tim-Smart/coffee-script 2010-06-21 18:57:17 -04:00
Tim-Smart
2ed66f6e8b Update package.json to allow for npm publishing and installation 2010-06-22 10:48:49 +12:00
Jeremy Ashkenas
9aaf789c21 changing a couple repetitions to DRY objects ... doesn't change the compiled output. 2010-06-20 11:19:50 -04:00
Jeremy Ashkenas
d5cf339b83 adding a test for holmsand's patch for Object.prototype-named variables. 2010-06-16 07:24:17 -04:00
Dan Holmsand
6bc7b56e6e Make sure variables named e.g. "constructor" are declared with var 2010-06-16 12:54:53 +02:00
Jeremy Ashkenas
e4db6d47c2 Updated Cakefile from Tim_Smart with colorized, explained 'cake install' 2010-06-15 21:33:53 -04:00
Jeremy Ashkenas
ce4e00e5ae mistaken camelCase 'nodeLibraries' from the great under_score purge ... now fixed. 2010-06-15 20:40:10 -04:00
Jeremy Ashkenas
06ca2ef726 more streamlined code generation for instance-bound methods ... keep the prototype method around, and just bind it in the constructor. 2010-06-15 02:21:01 -04:00
Jeremy Ashkenas
8d853a6d58 adding the ability to have classes with functions pre-bound to the instance, using the fat arrow, and the constructor-function-definition pattern, avoiding prototypes. 2010-06-15 01:28:30 -04:00
Jeremy Ashkenas
de768aefc3 a bit more work on keywords-in-object-literals... 2010-06-15 01:03:14 -04:00
Jeremy Ashkenas
4b284f6687 first draft at ticket #437 ... automatic quoting of reserved words and keywords. 2010-06-15 00:54:02 -04:00
Jeremy Ashkenas
d0948e5586 fixing comprehensions to also close over the index variable, if used in an inner function... 2010-06-13 21:43:04 -04:00
Jeremy Ashkenas
b0a45e5b93 Ticket #423. When functions are generated within comprehensions ... the comprehensions should close over the element instead of sharing it. 2010-06-13 21:21:30 -04:00
Jeremy Ashkenas
6f91331626 slight refactor to IfNode::ensureExpressions 2010-06-13 18:04:09 -04:00
Jeremy Ashkenas
4ecb1bb2ed switching to 'Compiled' messages after the code has finished compiling on --watch ... 2010-06-13 14:21:02 -04:00
Jeremy Ashkenas
3bcca99cba adding another statement/expression/return test. 2010-06-13 01:19:31 -04:00
Jeremy Ashkenas
5612a59b30 allowing implicit returns to be pushed down into each branch of computation, even when there's an explicit return nested more deeply. Issue #401 2010-06-13 01:13:52 -04:00
Jeremy Ashkenas
88ea66b4c9 allowing a regex literal to be the last token in a file ... Lexer bug. 2010-06-13 00:56:42 -04:00
Jeremy Ashkenas
b61399fbde fixing issue #396 ... issue with nested if/elses getting mis-nested. 2010-06-12 19:38:14 -04:00
Jeremy Ashkenas
a8db2bcf10 fixing a mistaken camelCase in the Cakefile 2010-06-12 19:10:10 -04:00
Jeremy Ashkenas
e14f4c5db1 First draft of switching the CoffeeScript Compiler over to camelCase. Pour one on the ground for underscores... 2010-06-12 19:05:13 -04:00
Jeremy Ashkenas
1948b0c7c7 linebreaks in the rewriter ... cosmetic. 2010-06-12 18:09:07 -04:00
Jeremy Ashkenas
4b4b0e630e yet another rewriter-based comment fix, this time for issue #403 2010-06-12 18:06:33 -04:00
Jeremy Ashkenas
d9071a80a0 Unsatisfactory patch that fixes Issue #394 ... comments that prefix spaced out if/else clauses. 2010-06-12 17:41:46 -04:00
Jeremy Ashkenas
969740a263 slight simplification to if/else in the grammar. 2010-06-12 13:53:11 -04:00
Jeremy Ashkenas
0222d90fa3 adding a 'loop' keyword to CoffeeScript. Takes an expression or a block. Runs it until you break or return out. 2010-06-12 12:15:53 -04:00
Jeremy Ashkenas
a133e018cc Making the REPL the default behaviour of 'coffee', when called with no arguments, a-la Node and Python. 2010-06-12 11:09:30 -04:00
Jeremy Ashkenas
c2d1ae06c5 removing the <- bind operator from CoffeeScript... 2010-06-12 11:00:56 -04:00
Jeremy Ashkenas
59e41f195b simpler 'cake loc' task. 2010-06-11 18:53:12 -04:00
Jeremy Ashkenas
7987d4e5ce adding a cake task to check loc 2010-06-11 18:47:48 -04:00
Jeremy Ashkenas
a8e331a778 new improved REPL, using Node's new 'readline' module... 2010-06-11 18:36:18 -04:00
Jeremy Ashkenas
eb97652537 adding a sentence about parentheses wrapping. 2010-06-11 17:28:18 -04:00
Jeremy Ashkenas
0a4fe7ed97 fixing the lexer so that leading commas surpress newlines 2010-06-11 08:29:16 -04:00
Jeremy Ashkenas
676e893c14 reworking parser for more permissive non-comma-separated array elements. 2010-06-09 00:37:23 -04:00
Jeremy Ashkenas
e37056192b Fix for issue #414 -- apostrophes in heredocs. 2010-06-02 19:53:03 -04:00
Jeremy Ashkenas
8321f6bfe3 making block comments require their own lines for delimiters. Issue 379. 2010-06-02 00:03:07 -04:00
Jeremy Ashkenas
b3d1c238eb fixing block comments at the top of function blocks, and in other locations ... Issue #379 2010-06-01 23:56:10 -04:00
Jeremy Ashkenas
61d9bd7e5e making the lexer more sophisticated about incorrect outdents ... a little safer for everyone. 2010-06-01 23:32:46 -04:00
Jeremy Ashkenas
1fbb6e8734 adding copying header to extras/coffee-script.js 2010-06-01 22:09:00 -04:00
Jeremy Ashkenas
59de6b505a ahh, finally. switched up our Jison configuration to provide better syntax errors. Now you get the unexpected token, instead of the expected one. 2010-06-01 20:21:12 -04:00
Jeremy Ashkenas
ea1411cd07 removing call to deprecated sys.p() in the REPL, now it's 'puts inspect value' 2010-06-01 19:24:48 -04:00
Jeremy Ashkenas
c5fd64c72a allowing direct calls against numbers. 2010-05-31 22:56:51 -04:00
Jeremy Ashkenas
45f442bd73 allowing Klass::['dynamic-property'] syntax. Issue #392 2010-05-31 22:32:43 -04:00
Jeremy Ashkenas
b8a4adbdc7 whitespace adjustments 2010-05-31 19:54:28 -04:00
Jeremy Ashkenas
47fdcebb01 one more range comprehension vs range literal test, for thoroughness. 2010-05-31 19:43:30 -04:00
Jeremy Ashkenas
8cdd8de360 adding a negative range comprehension test. 2010-05-31 19:41:02 -04:00
Jeremy Ashkenas
7402aea9f2 cleaner generated code for range comprehensions, but you have to use an explicit step to go downwards. Forked the code path for cleaner range literals as well. 2010-05-31 19:38:45 -04:00
Jeremy Ashkenas
300c711af1 enabling compilation of non-.coffee-extension files passed directly to the coffee command (Issue #391) 2010-05-31 15:36:41 -04:00
Jeremy Ashkenas
39b8bbc39b Moving all of the 'test_issues' tests from 'hiatus' to their proper locations... 2010-05-31 15:13:48 -04:00
Jeremy Ashkenas
90f96af720 Simpler stab at a fix for issue #397. Allow CoffeeScript-only keywords to be used as accessors, or in assignment. 2010-05-31 14:42:30 -04:00
Jeremy Ashkenas
710b2b5fdc moving issue #381 test to the proper spot. 2010-05-31 14:03:07 -04:00
Jeremy Ashkenas
a577b81eb3 reworking fix for Issue #383 with a more sensitive regex. (decimals without a leading zero) 2010-05-31 13:40:03 -04:00
Jeremy Ashkenas
a5478b0712 refactoring name_access_type into tag_accessor 2010-05-31 13:25:06 -04:00
Jeremy Ashkenas
12587d8295 reworking Stan's nodes.coffee type/children work a bit for issue 386 2010-05-31 10:36:50 -04:00
Stan Angeloff
e17bb4ff11 FIXES #397: Can't use @variable in switch in instance method 2010-05-26 21:58:11 +03:00
Stan Angeloff
aba19841ee FIXES #390: super() calls in constructor of classes that are defined as object properties 2010-05-25 09:15:46 +03:00
Stan Angeloff
0288dba46c Whoops, forgot the extra condition before we perform the rewrite 2010-05-23 12:52:49 +03:00
Stan Angeloff
5a306785ba Tests to ensure reserver words and operators can be used as object keys 2010-05-23 12:44:40 +03:00
Stan Angeloff
c200b95f6a Allowing operators as object keys 2010-05-23 12:42:15 +03:00
Stan Angeloff
2cccd621ea First steps in allowing reserved words as object keys 2010-05-23 12:21:31 +03:00
Stan Angeloff
385b18f588 FIXES #383: Numbers that start with . not recognized 2010-05-20 00:20:33 +03:00
Stan Angeloff
bf1f9f4b95 FIXES #380: problem with @ and instanceof 2010-05-19 23:51:53 +03:00
Stan Angeloff
4c3271728d OOP love for nodes.coffee 2010-05-19 23:24:55 +03:00
Stan Angeloff
57231ae75d Merging type, children and statement functions 2010-05-19 22:53:05 +03:00
Stan Angeloff
97c2a70593 Baby steps fixing #386 2010-05-19 22:37:42 +03:00
Jeremy Ashkenas
485346f0e5 CoffeeScript 0.6.2 2010-05-15 01:18:05 -04:00
Jeremy Ashkenas
a8d4c3a567 sprinkling toString() throughout, for Node.js 0.1.95 compatibility. 2010-05-15 00:34:14 -04:00
Jeremy Ashkenas
dfb3a13246 Fixed lingering CoffeeScript Compiler running live in Internet Explorer bugs. Implemented helpers.index_of and removed named functions. Ticket #366 2010-05-14 23:40:04 -04:00
Jeremy Ashkenas
f84eb9ed47 fixing heredoc indentation from herecomment tweaks 2010-05-14 21:50:17 -04:00
Jeremy Ashkenas
8136c5f3de making regexes stricter about their flags. 2010-05-14 09:14:41 -04:00
Jeremy Ashkenas
45669e08c6 better indentation handling for far-left heredocs and herecomments 2010-05-12 21:49:46 -04:00
Jeremy Ashkenas
a5db69e1af better indentation handling for far-left heredocs and herecomments 2010-05-12 21:47:31 -04:00
Jeremy Ashkenas
8aceef20e1 Adding initial implementation of here-comments (block comments) Issue #368 2010-05-12 20:56:44 -04:00
Jeremy Ashkenas
7e3c71ed19 Allowing more flexible linebreaks/indentation within object literals. 2010-05-12 18:28:40 -04:00
Jeremy Ashkenas
9d09bee6fb better test for sans-condition switch... 2010-05-11 09:32:16 -04:00
Jeremy Ashkenas
cd6ee373ff enabling condition-less switches. 2010-05-10 22:57:51 -04:00
Jeremy Ashkenas
4d0acc9b02 fixing andreyvit's issue with parentheses not being applied to multi-operators as the condition clause of a switch... 2010-05-10 22:50:11 -04:00
Jeremy Ashkenas
393fbf1b66 merging in gfxmonk's cleanup to how children of nodes are determined. Removing some (so far) unused portions. 2010-05-10 22:41:18 -04:00
gfxmonk
3324b03a5d Merge remote branch 'upstream/master'
Conflicts:
	src/nodes.coffee
2010-05-10 21:09:00 +10:00
gfxmonk
eb91f9922d determine @children dynamically based on attribute names, instead of manual bookkeeping 2010-05-10 20:58:01 +10:00
Jeremy Ashkenas
9a7420ccd0 adding support for calling variadic functions with less than the requested number of arguments. 2010-05-08 12:44:54 -04:00
Jeremy Ashkenas
be72120311 further minor cleanup to varargs 2010-05-08 12:20:14 -04:00
Jeremy Ashkenas
c452c3a101 minor cleanup to varargs 2010-05-08 12:15:47 -04:00
Tim Jones
0b3bb66708 Added safe soaking on non-existent variables. 2010-05-05 21:58:48 +12:00
Jeremy Ashkenas
d0d0fa4d10 disallowing regex literals as implicit calls immediatly after ']', a rare case, I hope. Ticket #358 2010-05-04 23:50:22 -04:00
Jeremy Ashkenas
6222ed622f forcing spaces for implicit calls ... making '@ name' a call instead of an access. Ticket #353 2010-05-04 23:44:54 -04:00
Jeremy Ashkenas
1a03e98057 making 'while' and 'until' have the same associativity and precedence as 'for', #356 2010-05-04 23:37:03 -04:00
Jeremy Ashkenas
46cea93fc3 recompiling annotated documentation 2010-05-04 23:31:28 -04:00
Jeremy Ashkenas
d64b8fd9d8 merged in Trevor Burnham's recursive coffee compilation, with some adjustments... 2010-05-04 23:22:28 -04:00
Jeremy Ashkenas
c051daee2f Merge commit 'TrevorBurnham/master' 2010-05-04 23:01:15 -04:00
Tim Jones
ae70d10996 Removing obsolete delete calls. 2010-05-03 21:17:30 -04:00
Tim Jones
52e6399e02 Added missing or to IndexNode. 2010-05-03 21:17:23 -04:00
Tim Jones
ac05f62f2f Wrapping all soaked chains that are involved in operations. 2010-05-03 21:17:16 -04:00
Tim Jones
4d935efd09 Stop anonymous supers. 2010-05-03 21:16:50 -04:00
Trevor Burnham
fa8cc7976a Added recursive compilation and monitoring option to coffee command 2010-05-03 17:38:59 -04:00
Jeremy Ashkenas
ee4e34bf6d relative requires... 2010-05-01 11:00:43 -04:00
gfxmonk
c8e0f8b149 Cleaned up IfNodes
- renamed rewrite_condition() to switches_over(),
   and @switcher to @switch_subject
 - removed unused else_body constructor parameter, as well
   as unnecessary push() method
 - ensure both @body and @else_body are always Expressions
   (previously they could be either Expressions or IfNode)
2010-05-02 00:39:34 +10:00
gfxmonk
b47188763c add require statements to tests that depend on coffee-script modules 2010-05-02 00:27:50 +10:00
Jeremy Ashkenas
5e5c9df5c4 removing holmsand's cleanup 2010-05-01 08:40:02 -04:00
Jeremy Ashkenas
1a97f599dd added a test for the multiple-functions-passed-sans-parens 2010-04-30 23:20:22 -04:00
Tim Jones
3b264c9572 Added a small part to the rewriter to allow a better two-function call. 2010-05-01 14:04:57 +12:00
Dan Holmsand
144c096ae6 Remove unused variable index_var from for loops 2010-04-30 09:48:30 +02:00
Jeremy Ashkenas
adbcd320b2 adding until loops as the inverse of while loops 2010-04-28 22:08:00 -04:00
Jeremy Ashkenas
17ba44056e changing 'filter' to 'guard' to get around Express' clobbering of Object.prototype. 2010-04-28 21:46:47 -04:00
Jeremy Ashkenas
502abade7c rewriting the compiler using 'unless' blocks where appropriate. 2010-04-27 19:38:24 -04:00
Jeremy Ashkenas
b746c9018e adding 'unless' blocks 2010-04-27 19:35:15 -04:00
Jeremy Ashkenas
92af641827 no newline on no_such_task for Cake 2010-04-27 07:59:19 -04:00
Jeremy Ashkenas
b5606a247d adding pattern matching for comprehensions. 2010-04-26 23:46:35 -04:00
Jeremy Ashkenas
d62baf5a5d Merge branch 'for_destructuring' of git://github.com/StanAngeloff/coffee-script 2010-04-26 23:34:07 -04:00
Jeremy Ashkenas
e17567866a Merge branch 'master' of git://github.com/Tesco/coffee-script 2010-04-26 23:31:18 -04:00
Stan Angeloff
76f9596f22 Cleaning up. 2010-04-26 21:54:31 +03:00
Stan Angeloff
2a3a713811 Allowing pattern matching within for..loops 2010-04-26 21:35:35 +03:00
gfxmonk
175ebb3cd8 fail with appropriate error status if child process fails 2010-04-26 16:08:19 +10:00
Tim Jones
95367a4a63 Fixing silly mistake with the comments. 2010-04-26 16:00:12 +12:00
Tim Jones
8950c3c4c8 Fixing invalid pattern matching and object creation. 2010-04-26 15:54:47 +12:00
Jeremy Ashkenas
2d1abd099d rewriting the Lexer, CommandLine, Nodes, and Rewriter to take advantage of the new DRY object pattern matching. 2010-04-25 22:29:43 -04:00
Jeremy Ashkenas
a894db35fd Got the DRY object pattern matching style working properly, from Harmony. {name, age}: person now works correctly. 2010-04-25 22:21:53 -04:00
Jeremy Ashkenas
328a14014c eliminating the IndentedAssignList nonterminal. 2010-04-25 21:22:29 -04:00
Jeremy Ashkenas
315a2c63fa simplifying the grammar by replacing all of our trailing comma rules with an OptComma nonterminal. 2010-04-25 21:17:46 -04:00
Jeremy Ashkenas
ca4ea7649d Throwing an error when pattern matching has a non-identifier on the left-hand side. 2010-04-25 11:22:15 -04:00
Jeremy Ashkenas
08c877ec7b Fixing string keys in pattern matching on objects (ticket 325) 2010-04-25 11:07:09 -04:00
Jeremy Ashkenas
212ad45be4 merging gfxmonk's removed error event fix. 2010-04-24 22:13:13 -04:00
gfxmonk
e9b37c7578 replaced nonexistant error event callback with a combination of stderr and exit events 2010-04-25 11:24:06 +10:00
Jeremy Ashkenas
1438cecfad Fixing splats-with-super()-in-classes, an oversight. 2010-04-24 15:57:15 -04:00
Jeremy Ashkenas
49824ce1a6 removing yytext mentions for real this time. 2010-04-21 23:21:48 -04:00
Jeremy Ashkenas
bc0ec9dc07 Revert "removing yytext mentions from the grammar"
This reverts commit 5957b9f155.
2010-04-21 23:10:45 -04:00
Jeremy Ashkenas
5957b9f155 removing yytext mentions from the grammar 2010-04-21 23:01:14 -04:00
Jeremy Ashkenas
72e6e828f1 new version of Jison vendored ... rebuild the grammar, tests pass. 2010-04-21 22:52:20 -04:00
Jeremy Ashkenas
01b4393fa7 fixing Issue #328, parse error with indents and comments (StanAngeloff) 2010-04-21 22:26:45 -04:00
Jeremy Ashkenas
bf2a5386f9 requiring helpers module in test_bind.coffee 2010-04-21 19:52:58 -04:00
Jeremy Ashkenas
fb4d4a609b making bin/cake install add CoffeeScript as a Node.js library, and creating an index.js file for the top-level inclusion. 2010-04-20 20:20:38 -04:00
Jeremy Ashkenas
1cddb2aa88 Redoing Rewriter#add_implicit_parentheses to be more robust. 2010-04-20 01:32:12 -04:00
Jeremy Ashkenas
aac9679282 merging in gfodor's excellent Rewriter patch. 2010-04-19 23:18:39 -04:00
Jeremy Ashkenas
90472685e8 Merge branch 'master' of git://github.com/gfodor/coffee-script 2010-04-19 23:12:24 -04:00
Jeremy Ashkenas
7bb764b3e4 ignoring raw 2010-04-18 18:14:17 -04:00
Greg Fodor
1aed9c545f Fix for bug with chaining 2010-04-18 00:41:47 -04:00
Jeremy Ashkenas
c937e49689 adding 'coffeescript-idea' to the resources section. 2010-04-13 23:41:18 -04:00
Jeremy Ashkenas
0d860516ac fixing non-spaced function application. 2010-04-13 09:05:55 -04:00
Jeremy Ashkenas
4ced1d65b4 allowing 'debugger' ... it should never have been a reserved word. 2010-04-12 21:23:01 -04:00
Jeremy Ashkenas
92540d5e85 CoffeeScript 0.6.1, for Node.js v0.1.90 2010-04-12 21:20:00 -04:00
Jeremy Ashkenas
ea982a627e adding coffee-haml-filter to the docs 2010-04-11 17:57:29 -04:00
Jeremy Ashkenas
835ecac8db simplifying some unecessary interpolated expressions into interpolated values. 2010-04-11 16:57:53 -04:00
Jeremy Ashkenas
c3bbb48041 adding a test case for issue 309, interpolations with implicit calls. 2010-04-11 09:37:48 -04:00
Jeremy Ashkenas
2e842f0146 merging Stan's recursive tokenizing fix for interpolations. 2010-04-11 09:26:21 -04:00
Jeremy Ashkenas
8de2fb9009 Merge commit 'StanAngeloff/issue_309' 2010-04-11 09:22:31 -04:00
Stan Angeloff
17e177405a FIXES #309: Optional parens and interpolation. 2010-04-11 12:22:54 +03:00
Dr Nic Williams
ef67561fb3 Using anonymous callback for 'exit' event when running tests 2010-04-11 19:05:49 +10:00
Jeremy Ashkenas
df97effb9c fixing implicit-call-in-function-in-parens bug. 2010-04-10 18:56:46 -04:00
Jeremy Ashkenas
8317960f81 Battery of patches for compatibility with Node v0.1.90 2010-04-10 18:05:35 -04:00
Jeremy Ashkenas
065bf54094 generated closures should only call() or apply() when necessary. 2010-04-10 14:40:05 -04:00
Jeremy Ashkenas
f36acc27e5 safely preserving the arguments object through generated closure wrappers. 2010-04-10 14:20:32 -04:00
Jeremy Ashkenas
491ad6de95 adding webchat to the doc page 2010-04-10 13:42:39 -04:00
Jeremy Ashkenas
3eedf8ed1b Adding noonat to the contributor list 2010-04-06 21:09:23 -04:00
Jeremy Ashkenas
75b260e495 Merge branch 'master' of git://github.com/noonat/coffee-script 2010-04-06 21:08:29 -04:00
noonat
2351948291 Renamed Lexer.tag() argument to new_tag, due to Rhino scope confusion 2010-04-05 22:58:56 -07:00
Tim Jones
538e518d76 Realigning function arrows. 2010-04-06 02:29:38 +12:00
Tim Jones
de955dacc4 Added Statement to the grammar. 2010-04-06 02:26:23 +12:00
Chris Lloyd
19ed63129e Interpolated strings are expressions. 2010-04-04 17:05:52 +10:00
Chris Lloyd
2e744a1c1b Failing test for string interpolation. Interpolated strings need to be expressions, not values. 2010-04-04 16:54:59 +10:00
Jeremy Ashkenas
89534b88b1 merging in Chris Lloyd's fix for optional descriptions on Cake tasks. 2010-04-04 00:20:17 -04:00
Chris Lloyd
c9b6e82e2c Optional sentence descriptions for cake tasks. 2010-03-26 20:25:17 +11:00
324 changed files with 47144 additions and 21989 deletions

6
.gitignore vendored
View File

@@ -1,6 +1,10 @@
raw
presentation
test.coffee
test.litcoffee
parser.output
test/fixtures/underscore
test/*.js
examples/beautiful_code/parse.coffee
*.gem
*.gem
/node_modules

11
.npmignore Normal file
View File

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

1
CNAME Normal file
View File

@@ -0,0 +1 @@
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/coffee-script/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/coffee-script/tree/master/test).
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffee-script/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.

265
Cakefile
View File

@@ -1,48 +1,88 @@
fs: require 'fs'
helpers: require('./lib/helpers').helpers
CoffeeScript: require './lib/coffee-script'
fs = require 'fs'
path = require 'path'
CoffeeScript = require './lib/coffee-script'
{spawn, exec} = require 'child_process'
helpers = require './lib/coffee-script/helpers'
# ANSI Terminal Colors.
bold = red = green = reset = ''
unless process.env.NODE_DISABLE_COLORS
bold = '\x1B[0;1m'
red = '\x1B[0;31m'
green = '\x1B[0;32m'
reset = '\x1B[0m'
# Built file header.
header = """
/**
* CoffeeScript Compiler v#{CoffeeScript.VERSION}
* http://coffeescript.org
*
* Copyright 2011, Jeremy Ashkenas
* Released under the MIT License
*/
"""
# 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) ->
proc: process.createChildProcess 'bin/coffee', args
proc.addListener 'error', (err) -> if err then puts err
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
cb() if typeof cb is 'function'
# Log a message with a color.
log = (message, color, explanation) ->
console.log color + message + reset + ' ' + (explanation or '')
option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'
task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options) ->
base: options.prefix or '/usr/local'
lib: "$base/lib/coffee-script"
bin: "$base/bin"
base = options.prefix or '/usr/local'
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"
exec([
"mkdir -p $lib $bin"
"cp -rf bin lib LICENSE README package.json src vendor $lib"
"ln -sf $lib/bin/coffee $base/bin/coffee"
"ln -sf $lib/bin/cake $base/bin/cake"
"mkdir -p #{lib} #{bin}"
"cp -rf bin lib LICENSE README package.json src #{lib}"
"ln -sfn #{lib}/bin/coffee #{bin}/coffee"
"ln -sfn #{lib}/bin/cake #{bin}/cake"
"mkdir -p ~/.node_libraries"
"ln -sfn #{lib}/lib/coffee-script #{node}"
].join(' && '), (err, stdout, stderr) ->
if err then print stderr
if err then console.log stderr.trim() else log 'done', green
)
task 'build', 'build the CoffeeScript language from source', ->
files: fs.readdirSync 'src'
files: 'src/' + file for file in files when file.match(/\.coffee$/)
run ['-c', '-o', 'lib'].concat(files)
task 'build', 'build the CoffeeScript language from source', build
task 'build:full', 'rebuild the source twice, and run the tests', ->
exec 'bin/cake build && bin/cake build && bin/cake test', (err, stdout, stderr) ->
print stdout if stdout
print stderr if stderr
throw err if err
build ->
build ->
csPath = './lib/coffee-script'
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)', ->
require.paths.unshift 'vendor/jison/lib'
parser: require('./lib/grammar').parser
js: parser.generate()
parser_path: 'lib/parser.js'
fs.writeFile parser_path, js
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', ->
@@ -52,16 +92,43 @@ task 'build:ultraviolet', 'build and install the Ultraviolet syntax highlighter'
task 'build:browser', 'rebuild the merged script for inclusion in the browser', ->
exec 'rake browser', (err) ->
throw err if err
code = ''
for name in ['helpers', 'rewriter', 'lexer', 'parser', 'scope', 'nodes', 'sourcemap', 'coffee-script', 'browser']
code += """
require['./#{name}'] = new function() {
var exports = this;
#{fs.readFileSync "lib/coffee-script/#{name}.js"}
};
"""
code = """
(function(root) {
var CoffeeScript = function() {
function require(path){ return require[path]; }
#{code}
return require['./coffee-script'];
}();
if (typeof define === 'function' && define.amd) {
define(function() { return CoffeeScript; });
} else {
root.CoffeeScript = CoffeeScript;
}
}(this));
"""
unless process.env.MINIFY is 'false'
{code} = require('uglify-js').minify code, fromString: true
fs.writeFileSync 'extras/coffee-script.js', header + '\n' + code
console.log "built ... running browser tests:"
invoke 'test:browser'
task 'doc:site', 'watch and continually rebuild the documentation for the website', ->
exec 'rake doc'
exec 'rake doc', (err) ->
throw err if err
task 'doc:source', 'rebuild the internal documentation', ->
exec 'docco src/*.coffee && cp -rf docs documentation && rm -r docs', (err) ->
exec 'docco src/*.*coffee && cp -rf docs documentation && rm -r docs', (err) ->
throw err if err
@@ -69,32 +136,112 @@ 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'
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 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: yes
console.log "Compile#{time()} (#{js.length} chars)"
console.log "total #{ fmt total }"
# Run the CoffeeScript test suite.
runTests = (CoffeeScript) ->
startTime = Date.now()
currentFile = null
passedTests = 0
failures = []
global[name] = func for name, func of require 'assert'
# 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) ->
try
fn.test = {description, currentFile}
fn.call(fn)
++passedTests
catch 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 ? "Expected #{a} to equal #{b}"
global.arrayEq = (a, b, msg) -> ok arrayEgal(a,b), msg ? "Expected #{a} to deep equal #{b}"
# When all the tests have run, collect and print errors.
# If a stacktrace is available, output the compiled function source.
process.on 'exit', ->
time = ((Date.now() - startTime) / 1000).toFixed(2)
message = "passed #{passedTests} tests in #{time} seconds#{reset}"
return log(message, green) unless failures.length
log "failed #{failures.length} and #{message}", red
for fail in failures
{error, filename, description, source} = 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
console.log ''
log " #{description}", red if description
log " #{error.stack}", red
log " #{jsFilename}: line #{line ? 'unknown'}, column #{col ? 'unknown'}", red
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 /\.(lit)?coffee$/i
literate = helpers.isLiterate file
currentFile = filename = path.join 'test', file
code = fs.readFileSync filename
try
CoffeeScript.run code.toString(), {filename, literate}
catch error
failures.push {filename, error}
return !failures.length
task 'test', 'run the CoffeeScript language test suite', ->
helpers.extend global, require 'assert'
passed_tests: failed_tests: 0
start_time: new Date()
original_ok: ok
helpers.extend global, {
ok: (args...) -> passed_tests += 1; original_ok(args...)
CoffeeScript: CoffeeScript
}
red: '\033[0;31m'
green: '\033[0;32m'
reset: '\033[0m'
on_exit: ->
time: ((new Date() - start_time) / 1000).toFixed(2)
message: "passed $passed_tests tests in $time seconds$reset"
puts(if failed_tests then "${red}failed $failed_tests and $message" else "$green$message")
process.addListener 'exit', on_exit
fs.readdir 'test', (err, files) ->
files.forEach (file) ->
return unless file.match(/\.coffee$/i)
source: path.join 'test', file
fs.readFile source, (err, code) ->
try
CoffeeScript.run code, {source: source}
catch err
failed_tests += 1
puts "${red}failed:${reset} $source"
puts err.stack
runTests CoffeeScript
task 'test:browser', 'run the test suite against the merged browser script', ->
source = fs.readFileSync 'extras/coffee-script.js', 'utf-8'
result = {}
global.testingBrowser = yes
(-> eval source).call result
runTests result.CoffeeScript

View File

@@ -1,4 +1,4 @@
Copyright (c) 2010 Jeremy Ashkenas
Copyright (c) 2009-2012 Jeremy Ashkenas
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

77
README
View File

@@ -1,60 +1,51 @@
=
{
} } {
{ { } }
} }{ {
{ }{ } } _____ __ __
( }{ }{ { ) / ____| / _|/ _|
.- { { } { }} -. | | ___ | |_| |_ ___ ___
( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|`-..________ ..-'| | |___| (_) | | | || __/ __/
{
} } {
{ { } }
} }{ {
{ }{ } } _____ __ __
( }{ }{ { ) / ____| / _|/ _|
.- { { } { }} -. | | ___ | |_| |_ ___ ___
( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|`-..________ ..-'| | |___| (_) | | | || __/ __/
| | \_____\___/|_| |_| \___|\___|
| ;--.
| (__ \ _____ _ _
| | ) ) / ____| (_) | |
| |/ / | (___ ___ _ __ _ _ __ | |_
| ;--.
| (__ \ _____ _ _
| | ) ) / ____| (_) | |
| |/ / | (___ ___ _ __ _ _ __ | |_
| ( / \___ \ / __| '__| | '_ \| __|
| |/ ____) | (__| | | | |_) | |_
| |/ ____) | (__| | | | |_) | |_
| | |_____/ \___|_| |_| .__/ \__|
`-.._________..-' | |
`-.._________..-' | |
|_|
CoffeeScript is a little language that compiles into JavaScript.
Install Node.js, and then the CoffeeScript compiler:
sudo bin/cake install
Compile a script:
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
Contributors:
Stan Angeloff (StanAngeloff)
Jeremy Ashkenas (jashkenas)
Zach Carter (zaach)
Tim Cuthbertson (gfxmonk)
Mathieu D'Amours (matehat)
Chris Hoffman (cehoffman)
Jason Huggins (hugs)
Tim Jones (Tesco)
Matt Lyon (mattly)
Jeff Olson (olsonjeffery)
Samuel Reis (grgh)
Tom Robinson (tlrobinson)
Tim Smart (Tim-Smart)
Dr. Nic Williams (drnic)
All contributors are listed here:
http://github.com/jashkenas/coffee-script/contributors

View File

@@ -1,13 +1,13 @@
require 'rubygems'
require 'erb'
require 'fileutils'
require 'rake/testtask'
require 'rubygems'
require 'yui/compressor'
require 'json'
desc "Build the documentation page"
task :doc do
source = 'documentation/index.html.erb'
child = fork { exec "bin/coffee -c documentation/coffee/*.coffee -o documentation/js -w" }
child = fork { exec "bin/coffee -bcw -o documentation/js documentation/coffee/*.coffee" }
at_exit { Process.kill("INT", child) }
Signal.trap("INT") { exit }
loop do
@@ -21,11 +21,59 @@ task :doc do
end
end
desc "Build the single concatenated and minified script for the browser"
task :browser do
sources = %w(helpers.js rewriter.js lexer.js parser.js scope.js nodes.js coffee-script.js)
code = sources.map {|s| File.read('lib/' + s) }.join('')
code = YUI::JavaScriptCompressor.new.compress(code)
File.open('extras/coffee-script.js', 'w+') {|f| f.write(code) }
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'
s.license = "MIT"
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

View File

@@ -1,8 +1,7 @@
#!/usr/bin/env node
var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
require(lib + '/helpers').helpers.extend(global, require('sys'));
require(lib + '/cake').run();
require(lib + '/coffee-script/cake').run();

View File

@@ -1,8 +1,7 @@
#!/usr/bin/env node
var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
require(lib + '/helpers').helpers.extend(global, require('sys'));
require(lib + '/command').run();
require(lib + '/coffee-script/command').run();

View File

@@ -1,9 +1,11 @@
launch() if ignition is on
volume: 10 if band isnt spinal_tap
volume = 10 if band isnt SpinalTap
let_the_wild_rumpus_begin() unless answer is no
letTheWildRumpusBegin() unless answer is no
if car.speed < speed_limit then accelerate()
if car.speed < limit then accelerate()
print "My name is " + @name
winner = yes if pick in [47, 92, 13]
print inspect "My name is #{@name}"

View File

@@ -1,7 +1,10 @@
# Eat lunch.
lunch: eat food for food in ['toast', 'cheese', 'wine']
eat food for food in ['toast', 'cheese', 'wine']
# Naive collision detection.
for roid in asteroids
for roid2 in asteroids when roid isnt roid2
roid.explode() if roid.overlaps roid2
# Fine five course dining.
courses = ['greens', 'caviar', 'truffles', 'roast', 'cake']
menu i + 1, dish for dish, i in courses
# Health conscious meal.
foods = ['broccoli', 'spinach', 'chocolate']
eat food for food in foods when food isnt 'chocolate'

View File

@@ -1,2 +0,0 @@
greeting: "Hello CoffeeScript"
difficulty: 0.5

View File

@@ -1,5 +0,0 @@
url: "documentation/coffee/binding.coffee"
get_source: jQuery.get <- jQuery, url
get_source (response) -> alert response

View File

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

View File

@@ -1,3 +1,9 @@
task 'test', 'run each of the unit tests', ->
for test in test_files
fs.readFile test, (err, code) -> eval coffee.compile code
fs = require 'fs'
option '-o', '--output [DIR]', 'directory for compiled code'
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

View File

@@ -1,25 +1,21 @@
class Animal
constructor: (@name) ->
move: (meters) ->
alert @name + " moved " + meters + "m."
alert @name + " moved #{meters}m."
class Snake extends Animal
constructor: (name) ->
@name: name
move: ->
alert "Slithering..."
super 5
class Horse extends Animal
constructor: (name) ->
@name: name
move: ->
alert "Galloping..."
super 45
sam: new Snake "Sammy the Python"
tom: new Horse "Tommy the Palomino"
sam = new Snake "Sammy the Python"
tom = new Horse "Tommy the Palomino"
sam.move()
tom.move()

View File

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

View File

@@ -1,9 +1,12 @@
mood: greatly_improved if singing
mood = greatlyImproved if singing
if happy and knowsIt
clapsHands()
chaChaCha()
else
showIt()
date = if friday then sue else jill
if happy and knows_it
claps_hands()
cha_cha_cha()
date: if friday then sue else jill
expensive: or do_the_math()

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,13 @@
solipsism: true if mind? and not world?
solipsism = true if mind? and not world?
speed ?= 140
speed = 0
speed ?= 15
footprints = yeti ? "bear"

View File

@@ -1,9 +1,9 @@
grade: (student) ->
if student.excellent_work
grade = (student) ->
if student.excellentWork
"A+"
else if student.okay_stuff
if student.tried_hard then "B" else "B-"
else if student.okayStuff
if student.triedHard then "B" else "B-"
else
"C"
eldest: if 24 > 21 then "Liz" else "Ike"
eldest = if 24 > 21 then "Liz" else "Ike"

View File

@@ -1 +1,3 @@
six: (one: 1) + (two: 2) + (three: 3)
six = (one = 1) + (two = 2) + (three = 3)

View File

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

View File

@@ -2,5 +2,6 @@ alert(
try
nonexistent / undefined
catch error
"And the error is ... " + error
)
"And the error is ... #{error}"
)

View File

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

View File

@@ -1,2 +1,2 @@
square: (x) -> x * x
cube: (x) -> square(x) * x
square = (x) -> x * x
cube = (x) -> square(x) * x

View File

@@ -1,5 +1,6 @@
html: '''
<strong>
cup of coffeescript
</strong>
'''
html = """
<strong>
cup of coffeescript
</strong>
"""

View File

@@ -0,0 +1,11 @@
OPERATOR = /// ^ (
?: [-=]> # function
| [-+*/%<>&|^!?=]= # compound assign / compare
| >>>=? # zero-fill right shift
| ([-+:])\1 # doubles
| ([&|<>])\2=? # logic / shift
| \?\. # soak access
| \.{2,3} # range or splat
) ///

View File

@@ -1,2 +1,9 @@
author: "Wittgenstein"
quote: "A picture is a fact. -- $author"
author = "Wittgenstein"
quote = "A picture is a fact. -- #{ author }"
sentence = "#{ 22 / 7 } is a decent approximation of π"

View File

@@ -1,6 +0,0 @@
sentence: "${ 22 / 7 } is a decent approximation of π"
sep: "[.\\/\\- ]"
dates: /\d+$sep\d+$sep\d+/g

View File

@@ -1,5 +1,9 @@
weather_report: (location) ->
weatherReport = (location) ->
# Make an Ajax request to fetch the weather...
[location, 72, "Mostly Sunny"]
[city, temp, forecast]: weather_report "Berkeley, CA"
[city, temp, forecast] = weatherReport "Berkeley, CA"

View File

@@ -1,4 +1,4 @@
years_old: {max: 10, ida: 9, tim: 11}
yearsOld = max: 10, ida: 9, tim: 11
ages: for child, age of years_old
child + " is " + age
ages = for child, age of yearsOld
"#{child} is #{age}"

View File

@@ -1,13 +1,14 @@
futurists: {
futurists =
sculptor: "Umberto Boccioni"
painter: "Vladimir Burliuk"
poet: {
poet:
name: "F.T. Marinetti"
address: [
"Via Roma 42R"
"Bellagio, Italy 22021"
]
}
}
{poet: {name: poet, address: [street, city]}}: futurists
{poet: {name, address: [street, city]}} = futurists

View File

@@ -1,13 +1,19 @@
song: ["do", "re", "mi", "fa", "so"]
song = ["do", "re", "mi", "fa", "so"]
ages: {
max: 10
ida: 9
tim: 11
}
singers = {Jagger: "Rock", Elvis: "Roll"}
matrix: [
bitlist = [
1, 0, 1
0, 0, 1
1, 1, 0
]
]
kids =
brother:
name: "Max"
age: 11
sister:
name: "Ida"
age: 9

View File

@@ -0,0 +1,5 @@
$('.account').attr class: 'active'
log object.class

View File

@@ -1,29 +1,28 @@
# Assignment:
number: 42
opposite_day: true
number = 42
opposite = true
# Conditions:
number: -42 if opposite_day
number = -42 if opposite
# Functions:
square: (x) -> x * x
square = (x) -> x * x
# Arrays:
list: [1, 2, 3, 4, 5]
list = [1, 2, 3, 4, 5]
# Objects:
math: {
math =
root: Math.sqrt
square: square
cube: (x) -> x * square x
}
# Splats:
race: (winner, runners...) ->
race = (winner, runners...) ->
print winner, runners
# Existence:
alert "I knew it!" if elvis?
# Array comprehensions:
cubed_list: math.cube num for num in list
cubes = (math.cube num for num in list)

View File

@@ -1,4 +1,9 @@
bait: 1000
and_switch: 0
theBait = 1000
theSwitch = 0
[bait, and_switch]: [and_switch, bait]
[theBait, theSwitch] = [theSwitch, theBait]

View File

@@ -1,6 +1,8 @@
tag: "<impossible>"
tag = "<impossible>"
[open, contents..., close] = tag.split("")
[open, contents..., close]: tag.split("")

View File

@@ -1,2 +1,3 @@
String::dasherize: ->
this.replace(/_/g, "-")
String::dasherize = ->
this.replace /_/g, "-"

View File

@@ -1,6 +1,2 @@
countdown: num for num in [10..1]
countdown = (num for num in [10..1])
egg_delivery: ->
for i in [0...eggs.length] by 12
dozen_eggs: eggs[i...i+12]
deliver new egg_carton(dozen)

View File

@@ -1,5 +1,5 @@
num: 1
change_numbers: ->
new_num: -1
num: 10
new_num: change_numbers()
outer = 1
changeNumbers = ->
inner = -1
outer = 10
inner = changeNumbers()

View File

@@ -1,6 +1,9 @@
numbers: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
three_to_six: numbers[3..6]
start = numbers[0..2]
numbers_copy: numbers[0...numbers.length]
middle = numbers[3...6]
end = numbers[6..]
copy = numbers[..]

View File

@@ -1 +1 @@
lottery.draw_winner()?.address?.zipcode
zip = lottery.drawWinner?().address?.zipcode

View File

@@ -1,11 +1,11 @@
gold: silver: the_field: "unknown"
gold = silver = rest = "unknown"
award_medals: (first, second, rest...) ->
gold: first
silver: second
the_field: rest
awardMedals = (first, second, others...) ->
gold = first
silver = second
rest = others
contenders: [
contenders = [
"Michael Phelps"
"Liu Xiang"
"Yao Ming"
@@ -18,8 +18,10 @@ contenders: [
"Usain Bolt"
]
award_medals contenders...
awardMedals contenders...
alert "Gold: " + gold
alert "Silver: " + silver
alert "The Field: " + the_field
alert "The Field: " + rest

View File

@@ -1,5 +1,7 @@
numbers: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
numbers[3..6]: [-3, -4, -5, -6]
numbers[3..6] = [-3, -4, -5, -6]

View File

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

View File

@@ -1,10 +1,10 @@
switch day
when "Mon" then go_to_work()
when "Tue" then go_to_the_park()
when "Thu" then go_ice_fishing()
when "Mon" then go work
when "Tue" then go relax
when "Thu" then go iceFishing
when "Fri", "Sat"
if day is bingo_day
go_to_bingo()
go_dancing()
when "Sun" then go_to_church()
else go_to_work()
if day is bingoDay
go bingo
go dancing
when "Sun" then go church
else go work

View File

@@ -1,7 +1,8 @@
try
all_hell_breaks_loose()
cats_and_dogs_living_together()
allHellBreaksLoose()
catsAndDogsLivingTogether()
catch error
print error
finally
clean_up()
cleanUp()

View File

@@ -1,10 +1,10 @@
# Econ 101
if this.studying_economics
while supply > demand then buy()
while supply < demand then sell()
if this.studyingEconomics
buy() while supply > demand
sell() until supply > demand
# Nursery Rhyme
num: 6
lyrics: while num -= 1
num + " little monkeys, jumping on the bed.
num = 6
lyrics = while num -= 1
"#{num} little monkeys, jumping on the bed.
One fell out and bumped his head."

View File

@@ -1,21 +1,27 @@
body {
font-size: 14px;
line-height: 20px;
color: #191933;
font-family: Arial, Helvetica, sans-serif;
line-height: 21px;
color: #333;
background: #f6f6f6 url(../images/background.png);
font-family: "Helvetica Neue", "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif !important;
}
div.container {
.container {
width: 950px;
margin: 100px 0 50px 50px;
margin: 0;
padding: 80px 0px 50px 50px;
}
p, li {
width: 625px;
}
a {
color: #000055;
color: #191933;
}
h1, h2, h3, h4, h5, h6 {
h1, h2, h3, h4, h5, h6, b.header {
font-size: 18px;
color: #000;
margin-top: 40px;
margin-bottom: 15px;
text-shadow: #fff 0 1px 1px;
}
br.clear {
height: 0;
@@ -25,10 +31,7 @@ ul {
padding-left: 20px;
}
b.header {
color: #000055;
display: block;
margin: 40px 0 5px 0;
font-size: 16px;
}
li {
margin-bottom: 10px;
@@ -42,24 +45,33 @@ table {
}
td {
padding: 9px 15px 9px 0;
vertical-align: top;
}
table.definitions {
width: auto;
margin: 30px 0;
border-left: 5px solid rgba(0,0,0,0.2);;
}
table.definitions td {
text-align: center;
padding: 5px 20px;
}
code, pre, tt, textarea {
font-family: Monaco, Consolas, "Lucida Console", monospace;
font-size: 12px;
line-height: 18px;
color: #191955;
color: #155;
white-space: pre-wrap;
word-wrap: break-word;
}
tt {
background: #f8f8ff;
display: inline-block;
background: #fff;
border: 1px solid #dedede;
font-size: 85%;
padding: 0px 0.2em;
}
pre {
border-left: 6px solid #222255;
margin-left: 13px;
border-left: 5px solid rgba(0,0,0,0.2);
padding: 3px 0 3px 12px;
font-size: 12px;
}
@@ -68,25 +80,39 @@ code, pre, tt, textarea {
margin-left: 0;
padding-left: 0;
}
.timestamp {
font-size: 12px;
font-weight: normal;
color: black;
}
.timestamp small {
font-size: 11px;
text-transform: uppercase;
}
div.code {
position: relative;
border: 1px solid #cacaca;
background: #fafaff;
padding: 7px 0 10px 0;
-moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px;
-webkit-box-shadow: 0px 0px 7px #cacaca;
background: #fff;
border: 1px solid #d8d8d8;
-webkit-box-shadow: 0px 0px 4px rgba(0,0,0,0.23);
-moz-box-shadow: 0px 0px 4px rgba(0,0,0,0.23);
box-shadow: 0px 0px 4px rgba(0,0,0,0.23);
zoom: 1;
}
div.code button {
div.code .minibutton {
text-transform: none;
position: absolute;
right: 8px; bottom: 8px;
}
div.code .load {
left: 8px; right: auto;
}
div.code pre, div.code textarea {
float: left;
width: 450px;
background: #fafaff;
border-left: 1px dotted #559;
background: #fff;
border-left: 1px dotted #d0d0d0;
margin: 10px 0 15px 3px;
padding: 0 0 0 12px;
margin: 0;
}
div.code pre:first-child {
border-left: 0;
@@ -107,117 +133,143 @@ div.code {
height: 50px;
min-width: 490px;
left: 40px; right: 40px; top: 25px;
background: #ddd;
padding-left: 235px;
background: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#d0d0d0));
background: -moz-linear-gradient(top, #f5f5f5, #d0d0d0);
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#F5F5F5', EndColorStr='#D0D0D0');
-webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
padding-left: 252px;
background: #eee;
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#dadada));
background: -moz-linear-gradient(top, #f8f8f8, #dadada);
border: 1px solid #aaa;
border-top: 1px solid #bbb;
border-bottom: 1px solid #888;
-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;
-webkit-box-shadow: 0 3px 5px rgba(0,0,0,0.1);
-moz-box-shadow: 0 3px 5px rgba(0,0,0,0.1);
box-shadow: 0 3px 5px rgba(0,0,0,0.1);
}
#logo {
display: block;
width: 215px; height: 50px;
background: url('../images/logo.png');
outline: none;
position: absolute;
top: 0px; left: 10px;
}
#logo img {
margin: 5px 0 0 3px;
}
#error {
position: absolute;
-webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px;
right: 15px; top: 15px; left: 722px;
height: 15px;
padding: 2px 5px;
-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;
color: #864544;
border: 1px solid #864544;
font: 10px/15px Arial;
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;
}
.navigation {
height: 50px;
font: bold 11px/50px Arial;
font-size: 11px;
line-height: 50px;
text-transform: uppercase;
position: relative;
float: left;
padding: 0 20px;
border: 1px solid #bbb;
border: 1px solid #aaa;
border-top: 0; border-bottom: 0; border-left-width: 0;
cursor: pointer;
}
body.full_screen .navigation {
position: static;
}
.navigation.toc {
border-left-width: 1px;
}
.navigation:hover,
.navigation.active {
background: #d0d0d0;
background: -webkit-gradient(linear, left top, left bottom, from(#f0f0f0), to(#c0c0c0));
background: -moz-linear-gradient(top, #f0f0f0, #c0c0c0);
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#F0F0F0', EndColorStr='#C0C0C0');
background: #eee;
background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#f8f8f8));
background: -moz-linear-gradient(top, #eee, #f8f8f8);
}
.navigation.active {
height: 51px;
color: #000;
background: -webkit-gradient(linear, left top, left bottom, from(#e5e5e5), to(#fff));
background: -moz-linear-gradient(top, #e5e5e5, #fff);
}
.navigation .button {
font-weight: bold;
}
.navigation .button::selection {
background: transparent;
}
.navigation .contents {
display: none;
position: absolute;
background: #fff;
top: 50px; left: 0;
opacity: 0.97;
top: 51px; left: 0;
padding: 5px 0;
-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;
-webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0;
-webkit-border-top-right-radius: 0; -moz-border-radius-topright: 0;
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
margin-left: -1px;
border: 1px solid #aaa;
-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;
-webkit-box-shadow: 0 3px 5px rgba(0,0,0,0.2);
-moz-box-shadow: 0 3px 5px rgba(0,0,0,0.2);
box-shadow: 0 3px 5px rgba(0,0,0,0.2);
}
.navigation.active .contents {
display: block;
}
.navigation .contents.repl_wrapper {
left: -162px;
width: 700px;
padding: 0;
}
body.full_screen .navigation .contents.repl_wrapper {
position: fixed;
width: auto; height: auto;
left: 60px; top: 75px; right: 60px; bottom: 30px;
}
.navigation .contents.repl_wrapper .code {
-webkit-box-shadow: none; -moz-box-shadow: none;
background: transparent;
border: 0;
position: static;
}
body.full_screen .navigation .contents.repl_wrapper .code {
height: 100%;
padding: 0; margin: 0;
}
.navigation .code button {
bottom: 10px;
text-transform: none;
}
.navigation .full_screen, .navigation .minimize {
right: auto;
left: 10px;
display: none;
}
body.minimized .full_screen, body.full_screen .minimize {
display: inline;
}
.navigation .contents a {
display: block;
width: 290px;
text-transform: none;
text-decoration: none;
font-weight: normal;
height: 12px;
line-height: 12px;
padding: 4px 10px;
border: 1px solid transparent;
border-left: 0; border-right: 0;
}
.navigation .contents a:hover {
background: #f0f0f0;
border-color: #ddd;
background: #eee;
}
.navigation.active .contents {
display: block;
}
.navigation .contents.menu {
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;
}
.navigation .contents.repl_wrapper {
padding: 0;
position: fixed;
width: auto; height: auto;
left: 40px; top: 90px; right: 40px; bottom: 30px;
background: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#eaeaea));
}
.navigation .repl_bridge {
position: absolute;
height: 12px;
left: -1px; right: -1px;
bottom: -14px;
border: 1px solid #aaa;
z-index: 5;
background: #fff;
display: none;
border-top-color: #fff; border-bottom-color: #fff;
}
.navigation.active .repl_bridge {
display: block;
}
.navigation .code .minibutton {
top: 10px; right: 10px;
width: 40px;
text-transform: none;
}
.navigation .code a.minibutton.permalink {
top: 38px;
display: block;
}
.bookmark {
display: block;
@@ -226,42 +278,108 @@ div.code {
top: -90px;
}
.navigation .contents.repl_wrapper .code {
cursor: text;
-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;
background: #181a3a url(../images/banding.png);
border: 2px solid #555;
padding: 0;
position: absolute;
top: 15px; left: 15px; right: 15px; bottom: 15px;
}
.repl_wrapper .screenshadow {
position: absolute;
width: 200px; height: 150px;
background: url(../images/screenshadow.png?2);
}
.repl_wrapper .screenshadow.tl {
top: 0; left: 0;
background-position: 0 0;
}
.repl_wrapper .screenshadow.tr {
top: 0; right: 0;
background-position: -200px 0;
}
.repl_wrapper .screenshadow.bl {
bottom: 0; left: 0;
background-position: 0 -150px;
}
.repl_wrapper .screenshadow.br {
bottom: 0; right: 0;
background-position: -200px -150px;
}
#repl_source, #repl_results {
background: transparent;
outline: none;
margin: 5px 0 20px;
color: #def;
}
#repl_source_wrap {
margin-left: 5px;
height: 250px;
width: 307px;
position: relative;
float: left;
#repl_results, #repl_source_wrap {
width: auto; height: auto;
position: absolute;
margin-bottom: 0;
top: 10px; left: 10px; right: 10px; bottom: 15px;
}
#repl_source {
width: 96%;
height: 100%;
border: 0;
resize: none;
#repl_source_wrap {
margin-left: 5px;
width: 47%; right: 50%;
float: left;
}
#repl_results {
font-family: Monaco, Consolas, "Lucida Console", monospace;
text-transform: none;
font-weight: normal;
height: 260px;
margin-bottom: 25px;
overflow-y: auto;
width: 370px;
}
body.full_screen #repl_results, body.full_screen #repl_source_wrap {
width: auto; height: auto;
position: absolute;
margin-bottom: 0;
top: 10px; left: 10px; right: 10px; bottom: 40px;
}
body.full_screen #repl_source_wrap {
right: 50%;
#repl_source {
padding-left: 5px;
width: 100%;
height: 100%;
border: 0;
overflow-y: auto;
resize: none;
}
body.full_screen #repl_results {
#repl_results_wrap {
white-space: pre;
}
#repl_results {
text-transform: none;
overflow-y: auto;
left: 50%;
border-left-color: #555;
}
/*----------------------------- Mini Buttons ---------------------------------*/
.minibutton {
cursor: pointer;
color: #333;
text-shadow: #eee 0 1px 1px;
font-weight: bold;
font-size: 11px;
line-height: 11px;
padding: 5px 10px 6px;
height: 11px;
text-align: center;
-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;
box-shadow: 0 1px 2px rgba(0,0,0,0.2); -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.2); -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.2);
border: 1px solid #b2b2b2; border-top-color: #c9c9c9; border-bottom-color: #9a9a9a;
background: url(../images/button_bg.png) repeat-x left top;
}
.minibutton:active {
border-color: #aaa;
box-shadow: 0 1px 2px #e4e4e4; -webkit-box-shadow: 0 1px 2px #e4e4e4; -moz-box-shadow: 0 1px 2px #e4e4e4;
}
.minibutton::selection {
background: transparent;
}
.minibutton ::-moz-selection {
background: transparent;
}
.minibutton.ok {
color: #fff;
background-image: url(../images/button_bg_green.gif);
border-color: #4ba47c; border-top-color: #53b388; border-bottom-color: #459671;
text-shadow: #aaa 0 -1px 0;
}
.minibutton.dark {
border: 0;
color: #fff;
box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none;
background-image: url(../images/button_bg_dark.gif);
text-shadow: none;
}

View File

@@ -0,0 +1,274 @@
<!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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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>Override exported methods for non-Node.js engines.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">CoffeeScript = </span><span class="nx">require</span> <span class="s">&#39;./coffee-script&#39;</span>
<span class="nv">CoffeeScript.require = </span><span class="nx">require</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>Use standard JavaScript <code>eval</code> to eval code.
</p>
</div>
<div class="content"><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></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><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></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>If we&#39;re not in a browser environment, we&#39;re finished with the public API.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="k">return</span> <span class="k">unless</span> <span class="nb">window</span><span class="o">?</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>Load a remote script from the current domain via XHR.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">CoffeeScript.load = </span><span class="nf">(url, callback, options = {}) -&gt;</span>
<span class="nv">xhr = </span><span class="k">if</span> <span class="nb">window</span><span class="p">.</span><span class="nx">ActiveXObject</span>
<span class="k">new</span> <span class="nb">window</span><span class="p">.</span><span class="nx">ActiveXObject</span><span class="p">(</span><span class="s">&#39;Microsoft.XMLHTTP&#39;</span><span class="p">)</span>
<span class="k">else</span>
<span class="k">new</span> <span class="nx">XMLHttpRequest</span><span class="p">()</span>
<span class="nx">xhr</span><span class="p">.</span><span class="nx">open</span> <span class="s">&#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="s">&#39;text/plain&#39;</span> <span class="k">if</span> <span class="s">&#39;overrideMimeType&#39;</span> <span class="k">of</span> <span class="nx">xhr</span>
<span class="nv">xhr.onreadystatechange = </span><span class="nf">-&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="p">,</span> <span class="nx">options</span>
<span class="k">else</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s">&quot;Could not load </span><span class="si">#{</span><span class="nx">url</span><span class="si">}</span><span class="s">&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></div>
</li>
<li id="section-6">
<div class="annotation">
<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>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">runScripts = </span><span class="nf">-&gt;</span>
<span class="nv">scripts = </span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span> <span class="s">&#39;script&#39;</span>
<span class="nv">coffeetypes = </span><span class="p">[</span><span class="s">&#39;text/coffeescript&#39;</span><span class="p">,</span> <span class="s">&#39;text/literate-coffeescript&#39;</span><span class="p">]</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="k">in</span> <span class="nx">coffeetypes</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="nf">-&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="nv">mediatype = </span><span class="nx">script</span><span class="o">?</span><span class="p">.</span><span class="nx">type</span>
<span class="k">if</span> <span class="nx">mediatype</span> <span class="k">in</span> <span class="nx">coffeetypes</span>
<span class="nv">options = </span><span class="p">{</span><span class="nv">literate: </span><span class="nx">mediatype</span> <span class="o">is</span> <span class="s">&#39;text/literate-coffeescript&#39;</span><span class="p">}</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="p">,</span> <span class="nx">options</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="p">,</span> <span class="nx">options</span>
<span class="nx">execute</span><span class="p">()</span>
<span class="kc">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>Listen for window load, both in browsers and in IE.
</p>
</div>
<div class="content"><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="s">&#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="s">&#39;onload&#39;</span><span class="p">,</span> <span class="nx">runScripts</span>
</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -1,43 +1,347 @@
<!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="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="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="octowrap"> <a class="octothorpe" href="#section-1">#</a> </div> <p><code>cake</code> is a simplified version of <a href="http://www.gnu.org/software/make/">Make</a>
<!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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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>
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="octowrap"> <a class="octothorpe" href="#section-2">#</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="p">(</span><span class="s1">&#39;./helpers&#39;</span><span class="p">).</span><span class="nx">helpers</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="octowrap"> <a class="octothorpe" href="#section-3">#</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="octowrap"> <a class="octothorpe" href="#section-4">#</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> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</a> </div> <p>Define a Cake task with a short name, a 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="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> <span class="o">-&gt;</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="nv">name: </span><span class="nx">name</span><span class="p">,</span> <span class="nv">description: </span><span class="nx">description</span><span class="p">,</span> <span class="nv">action: </span><span class="nx">action</span><span class="p">}</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-6">#</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="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> <span class="o">-&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="octowrap"> <a class="octothorpe" href="#section-7">#</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="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">no_such_task</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>
current directory&#39;s Cakefile.
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-8">#</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.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.run: </span><span class="o">-&gt;</span>
<span class="nx">path</span><span class="p">.</span><span class="nx">exists</span> <span class="s1">&#39;Cakefile&#39;</span><span class="p">,</span> <span class="p">(</span><span class="nx">exists</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Cakefile not found in ${process.cwd()}&quot;</span><span class="p">)</span> <span class="nx">unless</span> <span class="nx">exists</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">process</span><span class="p">.</span><span class="nx">argv</span><span class="p">.</span><span class="nx">length</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="p">{</span><span class="nv">source: </span><span class="s1">&#39;Cakefile&#39;</span><span class="p">}</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">print_tasks</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="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="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="octowrap"> <a class="octothorpe" href="#section-9">#</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">print_tasks: </span><span class="o">-&gt;</span>
<span class="nx">puts</span> <span class="s1">&#39;&#39;</span>
</p>
<p>External dependencies.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s">&#39;fs&#39;</span>
<span class="nv">path = </span><span class="nx">require</span> <span class="s">&#39;path&#39;</span>
<span class="nv">helpers = </span><span class="nx">require</span> <span class="s">&#39;./helpers&#39;</span>
<span class="nv">optparse = </span><span class="nx">require</span> <span class="s">&#39;./optparse&#39;</span>
<span class="nv">CoffeeScript = </span><span class="nx">require</span> <span class="s">&#39;./coffee-script&#39;</span>
<span class="nv">existsSync = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">existsSync</span> <span class="o">or</span> <span class="nx">path</span><span class="p">.</span><span class="nx">existsSync</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>Keep track of the list of defined tasks, the accepted options, and so on.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Mixin the top-level Cake functions for Cakefiles to use directly.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#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> <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="k">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></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#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> <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></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Invoke another task in the current Cakefile.
</p>
</div>
<div class="content"><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="k">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></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Node&#39;s
asynchrony may cause tasks to execute in a different order than you&#39;d expect.
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><span class="nv">exports.run = </span><span class="nf">-&gt;</span>
<span class="nv">global.__originalDirname = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">realpathSync</span> <span class="s">&#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="s">&#39;Cakefile&#39;</span><span class="p">).</span><span class="nx">toString</span><span class="p">(),</span> <span class="nv">filename: </span><span class="s">&#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="k">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="s">&quot;</span><span class="si">#{</span><span class="nx">e</span><span class="si">}</span><span class="s">&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></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#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="nv">printTasks = </span><span class="nf">-&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="s">&#39;Cakefile&#39;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s">&quot;</span><span class="si">#{</span><span class="nx">cakefilePath</span><span class="si">}</span><span class="s"> 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="p">(</span><span class="s1">&#39; &#39;</span> <span class="k">for</span> <span class="nx">i</span> <span class="k">in</span> <span class="p">[</span><span class="mi">0</span><span class="p">..</span><span class="nx">spaces</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="nx">puts</span> <span class="s2">&quot;cake $name$spaces # ${task.description}&quot;</span>
<span class="nx">puts</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="octowrap"> <a class="octothorpe" href="#section-10">#</a> </div> <p>Print an error and exit when attempting to all an undefined task.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">no_such_task: </span><span class="p">(</span><span class="nx">task</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">stdio</span><span class="p">.</span><span class="nx">writeError</span> <span class="s2">&quot;No such task: \&quot;$task\&quot;\n&quot;</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="s">&#39; &#39;</span><span class="p">)</span> <span class="k">else</span> <span class="s">&#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="s">&quot;</span><span class="err">#</span><span class="s"> </span><span class="si">#{</span><span class="nx">task</span><span class="p">.</span><span class="nx">description</span><span class="si">}</span><span class="s">&quot;</span> <span class="k">else</span> <span class="s">&#39;&#39;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s">&quot;cake </span><span class="si">#{</span><span class="nx">name</span><span class="si">}#{</span><span class="nx">spaces</span><span class="si">}</span><span class="s"> </span><span class="si">#{</span><span class="nx">desc</span><span class="si">}</span><span class="s">&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></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#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="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="s">&#39;\n&#39;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s">&#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>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
<span class="nv">missingTask = </span><span class="nf">(task) -&gt;</span> <span class="nx">fatalError</span> <span class="s">&quot;No such task: </span><span class="si">#{</span><span class="nx">task</span><span class="si">}</span><span class="s">&quot;</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>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="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">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="s">&#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="s">&#39;..&#39;</span>
<span class="k">return</span> <span class="nx">cakefileDirectory</span> <span class="nx">parent</span> <span class="k">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="s">&quot;Cakefile not found in </span><span class="si">#{</span><span class="nx">process</span><span class="p">.</span><span class="nx">cwd</span><span class="p">()</span><span class="si">}</span><span class="s">&quot;</span>
</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -1,65 +1,579 @@
<!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="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="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="octowrap"> <a class="octothorpe" href="#section-1">#</a> </div> <p>CoffeeScript can be used both on the server, as a command-line compiler based
<!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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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 CoffeeScripts directly in the browser. This module
contains the main entry functions for tokenzing, parsing, and compiling source
CoffeeScript into JavaScript.</p>
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></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-2">#</a> </div> <p>Set up dependencies correctly for both the server and the browser.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">if</span> <span class="nx">process</span><span class="o">?</span>
<span class="nv">path: </span> <span class="nx">require</span> <span class="s1">&#39;path&#39;</span>
<span class="nv">Lexer: </span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./lexer&#39;</span><span class="p">).</span><span class="nx">Lexer</span>
<span class="nv">parser: </span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./parser&#39;</span><span class="p">).</span><span class="nx">parser</span>
<span class="nv">helpers: </span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./helpers&#39;</span><span class="p">).</span><span class="nx">helpers</span>
<span class="nx">helpers</span><span class="p">.</span><span class="nx">extend</span> <span class="nx">global</span><span class="p">,</span> <span class="nx">require</span> <span class="s1">&#39;./nodes&#39;</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="p">(</span><span class="nx">content</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">compile</span> <span class="nx">content</span>
<span class="k">else</span>
<span class="k">this</span><span class="p">.</span><span class="nv">exports: </span><span class="k">this</span><span class="p">.</span><span class="nv">CoffeeScript: </span><span class="p">{}</span>
<span class="nv">Lexer: </span> <span class="k">this</span><span class="p">.</span><span class="nx">Lexer</span>
<span class="nv">parser: </span> <span class="k">this</span><span class="p">.</span><span class="nx">parser</span>
<span class="nv">helpers: </span> <span class="k">this</span><span class="p">.</span><span class="nx">helpers</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-3">#</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;0.6.0&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-4">#</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><span class="p">()</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</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="p">(</span><span class="nx">code</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">options: </span><span class="o">or</span> <span class="p">{}</span>
<span class="k">try</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">catch</span> <span class="nx">err</span>
<span class="nv">err.message: </span><span class="s2">&quot;In ${options.source}, ${err.message}&quot;</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">source</span>
<span class="k">throw</span> <span class="nx">err</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-6">#</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="p">(</span><span class="nx">code</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">lexer</span><span class="p">.</span><span class="nx">tokenize</span> <span class="nx">code</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-7">#</a> </div> <p>Tokenize and parse a string of CoffeeScript code, and return the AST. You can
then compile it by calling <code>.compile()</code> on the root, or traverse it by using
<code>.traverse()</code> with a callback.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.nodes: </span><span class="p">(</span><span class="nx">code</span><span class="p">)</span> <span class="o">-&gt;</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></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-8">#</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="p">((</span><span class="nx">code</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">module.filename: __filename: </span><span class="nx">options</span><span class="p">.</span><span class="nx">source</span>
<span class="nv">__dirname: </span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">__filename</span><span class="p">)</span>
<span class="nb">eval</span> <span class="nx">exports</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-9"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-9">#</a> </div> <p>Extend CoffeeScript with a custom language extension. It should hook in to
the <strong>Lexer</strong> (as a peer of any of the lexer's tokenizing methods), and
push a token on to the stack that contains a <strong>Node</strong> as the value (as a
peer of the nodes in <a href="nodes.html">nodes.coffee</a>).</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.extend: </span><span class="p">(</span><span class="nx">func</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">Lexer</span><span class="p">.</span><span class="nx">extensions</span><span class="p">.</span><span class="nx">push</span> <span class="nx">func</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-10">#</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="p">{</span>
<span class="nv">lex: </span><span class="o">-&gt;</span>
<span class="nv">token: </span><span class="nx">@tokens</span><span class="p">[</span><span class="nx">@pos</span><span class="p">]</span> <span class="o">or</span> <span class="p">[</span><span class="s2">&quot;&quot;</span><span class="p">]</span>
<span class="vi">@pos: </span><span class="o">+</span> <span class="mi">1</span>
<span class="k">this</span><span class="p">.</span><span class="nv">yylineno: </span><span class="nx">token</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="k">this</span><span class="p">.</span><span class="nv">yytext: </span> <span class="nx">token</span><span class="p">[</span><span class="mi">1</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="nv">setInput: </span><span class="p">(</span><span class="nx">tokens</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="vi">@tokens: </span><span class="nx">tokens</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">showPosition: </span><span class="o">-&gt;</span> <span class="nx">@pos</span>
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-11">#</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. Unfortunately, the text contents of remote scripts cannot be
accessed from the browser, so only inline script tags will work.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">if</span> <span class="nb">document</span><span class="o">?</span> <span class="o">and</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span>
<span class="nv">process_scripts: </span><span class="o">-&gt;</span>
<span class="k">for</span> <span class="nx">tag</span> <span class="k">in</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;script&#39;</span><span class="p">)</span> <span class="k">when</span> <span class="nx">tag</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="nb">eval</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">compile</span> <span class="nx">tag</span><span class="p">.</span><span class="nx">innerHTML</span>
<span class="k">if</span> <span class="nb">window</span><span class="p">.</span><span class="nx">addEventListener</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">addEventListener</span> <span class="s1">&#39;load&#39;</span><span class="p">,</span> <span class="nx">process_scripts</span><span class="p">,</span> <span class="kc">false</span>
<span class="k">else</span> <span class="k">if</span> <span class="nb">window</span><span class="p">.</span><span class="nx">attachEvent</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">attachEvent</span> <span class="s1">&#39;onload&#39;</span><span class="p">,</span> <span class="nx">process_scripts</span>
execute all scripts present in <code>text/coffeescript</code> tags.
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s">&#39;fs&#39;</span>
<span class="nv">path = </span><span class="nx">require</span> <span class="s">&#39;path&#39;</span>
<span class="p">{</span><span class="nx">Lexer</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s">&#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="s">&#39;./parser&#39;</span>
<span class="nv">helpers = </span><span class="nx">require</span> <span class="s">&#39;./helpers&#39;</span>
<span class="nv">vm = </span><span class="nx">require</span> <span class="s">&#39;vm&#39;</span>
<span class="nv">sourcemap = </span><span class="nx">require</span> <span class="s">&#39;./sourcemap&#39;</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="nv">loadFile = </span><span class="nf">(module, filename) -&gt;</span>
<span class="nv">raw = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span> <span class="nx">filename</span><span class="p">,</span> <span class="s">&#39;utf8&#39;</span>
<span class="nv">stripped = </span><span class="k">if</span> <span class="nx">raw</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">is</span> <span class="mh">0xFEFF</span> <span class="k">then</span> <span class="nx">raw</span><span class="p">.</span><span class="nx">substring</span> <span class="mi">1</span> <span class="k">else</span> <span class="nx">raw</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">_compile</span> <span class="nx">compile</span><span class="p">(</span><span class="nx">stripped</span><span class="p">,</span> <span class="p">{</span><span class="nx">filename</span><span class="p">,</span> <span class="nv">literate: </span><span class="nx">helpers</span><span class="p">.</span><span class="nx">isLiterate</span> <span class="nx">filename</span><span class="p">}),</span> <span class="nx">filename</span>
<span class="k">if</span> <span class="nx">require</span><span class="p">.</span><span class="nx">extensions</span>
<span class="k">for</span> <span class="nx">ext</span> <span class="k">in</span> <span class="p">[</span><span class="s">&#39;.coffee&#39;</span><span class="p">,</span> <span class="s">&#39;.litcoffee&#39;</span><span class="p">,</span> <span class="s">&#39;.md&#39;</span><span class="p">,</span> <span class="s">&#39;.coffee.md&#39;</span><span class="p">]</span>
<span class="nx">require</span><span class="p">.</span><span class="nx">extensions</span><span class="p">[</span><span class="nx">ext</span><span class="p">]</span> <span class="o">=</span> <span class="nx">loadFile</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>The current CoffeeScript version number.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.VERSION = </span><span class="s">&#39;1.6.1&#39;</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>Expose helpers for testing.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.helpers = </span><span class="nx">helpers</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>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.
</p>
<p>This returns a javascript string, unless <code>options.sourceMap</code> is passed,
in which case this returns a `{js, v3SourceMap, sourceMap}
object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic
lookups.
</p>
</div>
<div class="content"><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="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">sourceMap</span>
<span class="nv">coffeeFile = </span><span class="nx">helpers</span><span class="p">.</span><span class="nx">baseFileName</span> <span class="nx">options</span><span class="p">.</span><span class="nx">filename</span>
<span class="nv">jsFile = </span><span class="nx">helpers</span><span class="p">.</span><span class="nx">baseFileName</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="kc">yes</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;.js&quot;</span>
<span class="nv">sourceMap = </span><span class="k">new</span> <span class="nx">sourcemap</span><span class="p">.</span><span class="nx">SourceMap</span><span class="p">()</span>
<span class="nv">fragments = </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="p">(</span><span class="nx">code</span><span class="p">,</span> <span class="nx">options</span><span class="p">)).</span><span class="nx">compileToFragments</span> <span class="nx">options</span>
<span class="nv">currentLine = </span><span class="mi">0</span>
<span class="nx">currentLine</span> <span class="o">+=</span> <span class="mi">1</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">header</span>
<span class="nx">currentLine</span> <span class="o">+=</span> <span class="mi">1</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">sourceMap</span>
<span class="nv">currentColumn = </span><span class="mi">0</span>
<span class="nv">js = </span><span class="s">&quot;&quot;</span>
<span class="k">for</span> <span class="nx">fragment</span> <span class="k">in</span> <span class="nx">fragments</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>Update the sourcemap with data from each fragment
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">if</span> <span class="nx">sourceMap</span>
<span class="k">if</span> <span class="nx">fragment</span><span class="p">.</span><span class="nx">locationData</span>
<span class="nx">sourceMap</span><span class="p">.</span><span class="nx">addMapping</span><span class="p">(</span>
<span class="p">[</span><span class="nx">fragment</span><span class="p">.</span><span class="nx">locationData</span><span class="p">.</span><span class="nx">first_line</span><span class="p">,</span> <span class="nx">fragment</span><span class="p">.</span><span class="nx">locationData</span><span class="p">.</span><span class="nx">first_column</span><span class="p">],</span>
<span class="p">[</span><span class="nx">currentLine</span><span class="p">,</span> <span class="nx">currentColumn</span><span class="p">],</span>
<span class="p">{</span><span class="nv">noReplace: </span><span class="kc">true</span><span class="p">})</span>
<span class="nv">newLines = </span><span class="nx">helpers</span><span class="p">.</span><span class="nx">count</span> <span class="nx">fragment</span><span class="p">.</span><span class="nx">code</span><span class="p">,</span> <span class="s">&quot;\n&quot;</span>
<span class="nx">currentLine</span> <span class="o">+=</span> <span class="nx">newLines</span>
<span class="nv">currentColumn = </span><span class="nx">fragment</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="p">(</span><span class="k">if</span> <span class="nx">newLines</span> <span class="k">then</span> <span class="nx">fragment</span><span class="p">.</span><span class="nx">code</span><span class="p">.</span><span class="nx">lastIndexOf</span> <span class="s">&quot;\n&quot;</span> <span class="k">else</span> <span class="mi">0</span><span class="p">)</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>Copy the code from each fragment into the final JavaScript.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nx">js</span> <span class="o">+=</span> <span class="nx">fragment</span><span class="p">.</span><span class="nx">code</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="nv">err.message = </span><span class="s">&quot;In </span><span class="si">#{</span><span class="nx">options</span><span class="p">.</span><span class="nx">filename</span><span class="si">}</span><span class="s">, </span><span class="si">#{</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="si">}</span><span class="s">&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="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">header</span>
<span class="nv">header = </span><span class="s">&quot;Generated by CoffeeScript </span><span class="si">#{</span><span class="nx">@VERSION</span><span class="si">}</span><span class="s">&quot;</span>
<span class="nv">js = </span><span class="s">&quot;// </span><span class="si">#{</span><span class="nx">header</span><span class="si">}</span><span class="s">\n</span><span class="si">#{</span><span class="nx">js</span><span class="si">}</span><span class="s">&quot;</span>
<span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">sourceMap</span>
<span class="nv">answer = </span><span class="p">{</span><span class="nx">js</span><span class="p">}</span>
<span class="k">if</span> <span class="nx">sourceMap</span>
<span class="nv">answer.sourceMap = </span><span class="nx">sourceMap</span>
<span class="nv">answer.v3SourceMap = </span><span class="nx">sourcemap</span><span class="p">.</span><span class="nx">generateV3SourceMap</span> <span class="nx">sourceMap</span><span class="p">,</span> <span class="nx">coffeeFile</span><span class="p">,</span> <span class="nx">jsFile</span>
<span class="nx">answer</span>
<span class="k">else</span>
<span class="nx">js</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>Tokenize a string of CoffeeScript code, and return the array of tokens.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#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><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="s">&#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></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#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><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></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Set the filename.
</p>
</div>
<div class="content"><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="s">&#39;.&#39;</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>Clear the module cache.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Assign paths for node_modules loading
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">mainModule.paths = </span><span class="nx">require</span><span class="p">(</span><span class="s">&#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></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Compile.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">if</span> <span class="o">not</span> <span class="nx">helpers</span><span class="p">.</span><span class="nx">isCoffee</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">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></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#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><span class="nv">exports.eval = </span><span class="nf">(code, options = {}) -&gt;</span>
<span class="k">return</span> <span class="k">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="k">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="s">&#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></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#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="k">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="s">&#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="s">&#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="s">&#39;paths&#39;</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>use the same hack node currently uses for their own REPL
</p>
</div>
<div class="content"><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="k">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></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Instantiate a Lexer for our use here.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">lexer = </span><span class="k">new</span> <span class="nx">Lexer</span></pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#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 &quot;Jison lexer&quot;.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">parser.lexer =</span>
<span class="nv">lex: </span><span class="nf">-&gt;</span>
<span class="nv">token = </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="k">if</span> <span class="nx">token</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">@yylloc</span><span class="p">]</span> <span class="o">=</span> <span class="nx">token</span>
<span class="vi">@yylineno = </span><span class="nx">@yylloc</span><span class="p">.</span><span class="nx">first_line</span>
<span class="k">else</span>
<span class="nv">tag = </span><span class="s">&#39;&#39;</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="nf">-&gt;</span>
<span class="s">&quot;&quot;</span>
<span class="nv">parser.yy = </span><span class="nx">require</span> <span class="s">&#39;./nodes&#39;</span>
</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -1,115 +1,820 @@
<!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="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="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="octowrap"> <a class="octothorpe" href="#section-1">#</a> </div> <p>The <code>coffee</code> utility. Handles command-line compilation of CoffeeScript
<!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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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, piped to
<a href="http://javascriptlint.com/">JSLint</a> or recompiled every time the source is
<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="octowrap"> <a class="octothorpe" href="#section-2">#</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">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="octowrap"> <a class="octothorpe" href="#section-3">#</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"> coffee compiles CoffeeScript source files into JavaScript.</span>
interactive REPL.
<span class="s1"> Usage:</span>
<span class="s1"> coffee path/to/script.coffee</span>
<span class="s1"> &#39;&#39;&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-4">#</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;-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;-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;-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 directory for compiled JavaScript&#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 recompile&#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 the compiled JavaScript to stdout&#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 JSLint&#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;-e&#39;</span><span class="p">,</span> <span class="s1">&#39;--eval&#39;</span><span class="p">,</span> <span class="s1">&#39;compile a string from the command line&#39;</span><span class="p">]</span>
<span class="p">[</span> <span class="s1">&#39;--no-wrap&#39;</span><span class="p">,</span> <span class="s1">&#39;compile without the top-level function wrapper&#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 the tokens that the lexer produces&#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 the parse tree that Jison produces&#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 CoffeeScript version&#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></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</a> </div> <p>Top-level objects shared by all the functions.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">options: </span><span class="p">{}</span>
<span class="nv">sources: </span><span class="p">[]</span>
<span class="nv">option_parser: </span><span class="kc">null</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-6">#</a> </div> <p>Run <code>coffee</code> by parsing passed options and determining what action to take.
</p>
<p>External dependencies.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s">&#39;fs&#39;</span>
<span class="nv">path = </span><span class="nx">require</span> <span class="s">&#39;path&#39;</span>
<span class="nv">helpers = </span><span class="nx">require</span> <span class="s">&#39;./helpers&#39;</span>
<span class="nv">optparse = </span><span class="nx">require</span> <span class="s">&#39;./optparse&#39;</span>
<span class="nv">CoffeeScript = </span><span class="nx">require</span> <span class="s">&#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="s">&#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="s">&#39;events&#39;</span>
<span class="nv">exists = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">exists</span> <span class="o">or</span> <span class="nx">path</span><span class="p">.</span><span class="nx">exists</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>Allow CoffeeScript to emit Node.js events.
</p>
</div>
<div class="content"><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="s">&#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="s">&#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="o">/</span><span class="p">.</span><span class="nx">test</span> <span class="nx">file</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>The help banner that is printed when <code>coffee</code> is called without arguments.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">BANNER = </span><span class="s">&#39;&#39;&#39;</span>
<span class="s"> Usage: coffee [options] path/to/script.coffee -- [args]</span>
<span class="s"> If called without options, `coffee` will run your script.</span>
<span class="s">&#39;&#39;&#39;</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>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><span class="nv">SWITCHES = </span><span class="p">[</span>
<span class="p">[</span><span class="s">&#39;-b&#39;</span><span class="p">,</span> <span class="s">&#39;--bare&#39;</span><span class="p">,</span> <span class="s">&#39;compile without a top-level function wrapper&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-c&#39;</span><span class="p">,</span> <span class="s">&#39;--compile&#39;</span><span class="p">,</span> <span class="s">&#39;compile to JavaScript and save as .js files&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-e&#39;</span><span class="p">,</span> <span class="s">&#39;--eval&#39;</span><span class="p">,</span> <span class="s">&#39;pass a string from the command line as input&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-h&#39;</span><span class="p">,</span> <span class="s">&#39;--help&#39;</span><span class="p">,</span> <span class="s">&#39;display this help message&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-i&#39;</span><span class="p">,</span> <span class="s">&#39;--interactive&#39;</span><span class="p">,</span> <span class="s">&#39;run an interactive CoffeeScript REPL&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-j&#39;</span><span class="p">,</span> <span class="s">&#39;--join [FILE]&#39;</span><span class="p">,</span> <span class="s">&#39;concatenate the source CoffeeScript before compiling&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-l&#39;</span><span class="p">,</span> <span class="s">&#39;--lint&#39;</span><span class="p">,</span> <span class="s">&#39;pipe the compiled JavaScript through JavaScript Lint&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-m&#39;</span><span class="p">,</span> <span class="s">&#39;--map&#39;</span><span class="p">,</span> <span class="s">&#39;generate source map and save as .map files&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-n&#39;</span><span class="p">,</span> <span class="s">&#39;--nodes&#39;</span><span class="p">,</span> <span class="s">&#39;print out the parse tree that the parser produces&#39;</span><span class="p">]</span>
<span class="p">[</span> <span class="s">&#39;--nodejs [ARGS]&#39;</span><span class="p">,</span> <span class="s">&#39;pass options directly to the &quot;node&quot; binary&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-o&#39;</span><span class="p">,</span> <span class="s">&#39;--output [DIR]&#39;</span><span class="p">,</span> <span class="s">&#39;set the output directory for compiled JavaScript&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-p&#39;</span><span class="p">,</span> <span class="s">&#39;--print&#39;</span><span class="p">,</span> <span class="s">&#39;print out the compiled JavaScript&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-s&#39;</span><span class="p">,</span> <span class="s">&#39;--stdio&#39;</span><span class="p">,</span> <span class="s">&#39;listen for and compile scripts over stdio&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-t&#39;</span><span class="p">,</span> <span class="s">&#39;--tokens&#39;</span><span class="p">,</span> <span class="s">&#39;print out the tokens that the lexer/rewriter produce&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-v&#39;</span><span class="p">,</span> <span class="s">&#39;--version&#39;</span><span class="p">,</span> <span class="s">&#39;display the version number&#39;</span><span class="p">]</span>
<span class="p">[</span><span class="s">&#39;-w&#39;</span><span class="p">,</span> <span class="s">&#39;--watch&#39;</span><span class="p">,</span> <span class="s">&#39;watch scripts for changes and rerun commands&#39;</span><span class="p">]</span>
<span class="p">]</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>Top-level objects shared by all the functions.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#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">parse_options</span><span class="p">()</span>
<span class="k">return</span> <span class="nx">usage</span><span class="p">()</span> <span class="k">if</span> <span class="nx">options</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">options</span><span class="p">.</span><span class="nx">version</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">options</span><span class="p">.</span><span class="nx">interactive</span>
<span class="k">return</span> <span class="nx">compile_stdio</span><span class="p">()</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">stdio</span>
<span class="k">return</span> <span class="nx">compile_script</span> <span class="s1">&#39;console&#39;</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">options</span><span class="p">.</span><span class="nb">eval</span>
<span class="k">return</span> <span class="nx">usage</span><span class="p">()</span> <span class="nx">unless</span> <span class="nx">sources</span><span class="p">.</span><span class="nx">length</span>
<span class="nv">separator: </span><span class="nx">sources</span><span class="p">.</span><span class="nx">indexOf</span> <span class="s1">&#39;--&#39;</span>
<span class="nv">flags: </span><span class="p">[]</span>
<span class="k">if</span> <span class="nx">separator</span> <span class="o">&gt;=</span> <span class="mi">0</span>
<span class="nv">flags: </span><span class="nx">sources</span><span class="p">[(</span><span class="nx">separator</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)...</span><span class="nx">sources</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span>
<span class="nv">sources: </span><span class="nx">sources</span><span class="p">[</span><span class="mi">0</span><span class="p">...</span><span class="nx">separator</span><span class="p">]</span>
<span class="nv">process.ARGV: process.argv: </span><span class="nx">flags</span>
<span class="nx">watch_scripts</span><span class="p">()</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">watch</span>
<span class="nx">compile_scripts</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-7">#</a> </div> <p>Asynchronously read in each CoffeeScript in a list of source files and
compile them.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">compile_scripts: </span><span class="o">-&gt;</span>
<span class="nv">compile: </span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">path</span><span class="p">.</span><span class="nx">exists</span> <span class="nx">source</span><span class="p">,</span> <span class="p">(</span><span class="nx">exists</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s2">&quot;File not found: $source&quot;</span> <span class="nx">unless</span> <span class="nx">exists</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="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">code</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">compile_script</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">compile</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="k">for</span> <span class="nx">source</span> <span class="k">in</span> <span class="nx">sources</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-8">#</a> </div> <p>Compile a single source script, containing the given code, according to the
requested options. Both compile_scripts and watch_scripts share this method
in common. 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">compile_script: </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="o">-&gt;</span>
<span class="nv">o: </span><span class="nx">options</span>
<span class="nv">code_opts: </span><span class="nx">compile_options</span> <span class="nx">source</span>
<span class="k">try</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">print_tokens</span> <span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">tokens</span> <span class="nx">code</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">puts</span> <span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">nodes</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="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">code</span><span class="p">,</span> <span class="nx">code_opts</span>
<span class="k">else</span>
<span class="nv">js: </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">code_opts</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">process</span><span class="p">.</span><span class="nx">stdio</span><span class="p">.</span><span class="nx">write</span> <span class="nx">js</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">write_js</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">js</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">js</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">watch</span> <span class="k">then</span> <span class="nx">puts</span> <span class="nx">err</span><span class="p">.</span><span class="nx">message</span> <span class="k">else</span> <span class="k">throw</span> <span class="nx">err</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-9">#</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">compile_stdio: </span><span class="o">-&gt;</span>
<span class="nv">code: </span><span class="s1">&#39;&#39;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">stdio</span><span class="p">.</span><span class="nx">open</span><span class="p">()</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">stdio</span><span class="p">.</span><span class="nx">addListener</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="p">(</span><span class="nx">string</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">code: </span><span class="o">+</span> <span class="nx">string</span> <span class="k">if</span> <span class="nx">string</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">stdio</span><span class="p">.</span><span class="nx">addListener</span> <span class="s1">&#39;close&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nx">compile_script</span> <span class="s1">&#39;stdio&#39;</span><span class="p">,</span> <span class="nx">code</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-10">#</a> </div> <p>Watch a list of source CoffeeScript files using <code>fs.watchFile</code>, recompiling
them every time the files are 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_scripts: </span><span class="o">-&gt;</span>
<span class="nv">watch: </span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">watchFile</span> <span class="nx">source</span><span class="p">,</span> <span class="p">{</span><span class="nv">persistent: </span><span class="kc">true</span><span class="p">,</span> <span class="nv">interval: </span><span class="mi">500</span><span class="p">},</span> <span class="p">(</span><span class="nx">curr</span><span class="p">,</span> <span class="nx">prev</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">return</span> <span class="k">if</span> <span class="nx">curr</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">prev</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="nx">fs</span><span class="p">.</span><span class="nx">readFile</span> <span class="nx">source</span><span class="p">,</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">code</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">compile_script</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">watch</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="k">for</span> <span class="nx">source</span> <span class="k">in</span> <span class="nx">sources</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-11">#</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">write_js: </span><span class="p">(</span><span class="nx">source</span><span class="p">,</span> <span class="nx">js</span><span class="p">)</span> <span class="o">-&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">dir: </span> <span class="nx">options</span><span class="p">.</span><span class="nx">output</span> <span class="o">or</span> <span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span>
<span class="nv">js_path: </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>
<span class="nx">fs</span><span class="p">.</span><span class="nx">writeFile</span> <span class="nx">js_path</span><span class="p">,</span> <span class="nx">js</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-12">#</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="p">(</span><span class="nx">js</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">jsl: </span><span class="nx">process</span><span class="p">.</span><span class="nx">createChildProcess</span><span class="p">(</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="nx">jsl</span><span class="p">.</span><span class="nx">addListener</span> <span class="s1">&#39;output&#39;</span><span class="p">,</span> <span class="p">(</span><span class="nx">result</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">puts</span> <span class="nx">result</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\n/g</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="k">if</span> <span class="nx">result</span>
<span class="nx">jsl</span><span class="p">.</span><span class="nx">addListener</span> <span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="p">(</span><span class="nx">result</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">puts</span> <span class="nx">result</span> <span class="k">if</span> <span class="nx">result</span>
<span class="nx">jsl</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">close</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-13">#</a> </div> <p>Pretty-print a stream of tokens.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">print_tokens: </span><span class="p">(</span><span class="nx">tokens</span><span class="p">)</span> <span class="o">-&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">puts</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-14"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-14">#</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">parse_options: </span><span class="o">-&gt;</span>
<span class="nv">option_parser: </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: options: </span> <span class="nx">option_parser</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">process</span><span class="p">.</span><span class="nx">argv</span><span class="p">)</span>
<span class="nv">options.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">options.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">options</span><span class="p">.</span><span class="nx">arguments</span><span class="p">[</span><span class="mi">2</span><span class="p">...</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="p">]</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-15">#</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">compile_options: </span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">o: </span><span class="p">{</span><span class="nv">source: </span><span class="nx">source</span><span class="p">}</span>
<span class="nx">o</span><span class="p">[</span><span class="s1">&#39;no_wrap&#39;</span><span class="p">]</span><span class="o">:</span> <span class="nx">options</span><span class="p">[</span><span class="s1">&#39;no-wrap&#39;</span><span class="p">]</span>
<span class="nx">o</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-16">#</a> </div> <p>Print the <code>--help</code> usage message and exit.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">usage: </span><span class="o">-&gt;</span>
<span class="nx">puts</span> <span class="nx">option_parser</span><span class="p">.</span><span class="nx">help</span><span class="p">()</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">exit</span> <span class="mi">0</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-17">#</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">puts</span> <span class="s2">&quot;CoffeeScript version ${CoffeeScript.VERSION}&quot;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">exit</span> <span class="mi">0</span>
<code>--</code> will be passed verbatim to your script as arguments in <code>process.argv</code>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.run = </span><span class="nf">-&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="k">return</span> <span class="nx">require</span><span class="p">(</span><span class="s">&#39;./repl&#39;</span><span class="p">).</span><span class="nx">start</span><span class="p">()</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="s">&quot;The --watch feature depends on Node v0.6.0+. You are running </span><span class="si">#{</span><span class="nx">process</span><span class="p">.</span><span class="nx">version</span><span class="si">}</span><span class="s">.&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="p">(</span><span class="s">&#39;./repl&#39;</span><span class="p">).</span><span class="nx">start</span><span class="p">()</span> <span class="k">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="s">&#39;coffee&#39;</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></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Compile a path, which could be a script or a directory. If a directory
is passed, recursively compile all &#39;.coffee&#39;, &#39;.litcoffee&#39;, and &#39;.coffee.md&#39;
extension source files in it and all subdirectories.
</p>
</div>
<div class="content"><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="s">&#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="s">&#39;ENOENT&#39;</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">error</span> <span class="s">&quot;File not found: </span><span class="si">#{</span><span class="nx">source</span><span class="si">}</span><span class="s">&quot;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">exit</span> <span class="mi">1</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="o">and</span> <span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="o">isnt</span> <span class="s">&#39;node_modules&#39;</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="s">&#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="s">&#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="nf">-&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">helpers</span><span class="p">.</span><span class="nx">isCoffee</span> <span class="nx">source</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="s">&#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="s">&#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></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#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&#39;s path.
</p>
</div>
<div class="content"><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="s">&#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="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">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">t</span><span class="p">.</span><span class="nx">options</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">compiled = </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="nv">t.output = </span><span class="nx">compiled</span>
<span class="k">if</span> <span class="nx">o</span><span class="p">.</span><span class="nx">map</span>
<span class="nv">t.output = </span><span class="nx">compiled</span><span class="p">.</span><span class="nx">js</span>
<span class="nv">t.sourceMap = </span><span class="nx">compiled</span><span class="p">.</span><span class="nx">v3SourceMap</span>
<span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">emit</span> <span class="s">&#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="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="o">||</span> <span class="nx">o</span><span class="p">.</span><span class="nx">map</span>
<span class="nx">writeJs</span> <span class="nx">base</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="nx">t</span><span class="p">.</span><span class="nx">output</span><span class="p">,</span> <span class="nx">t</span><span class="p">.</span><span class="nx">sourceMap</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="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="s">&#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="s">&#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="s">&#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="s">&quot;ERROR: </span><span class="si">#{</span><span class="nx">err</span><span class="si">}</span><span class="s">&quot;</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">exit</span> <span class="mi">1</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>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="nv">compileStdio = </span><span class="nf">-&gt;</span>
<span class="nv">code = </span><span class="s">&#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="nx">on</span> <span class="s">&#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="nx">on</span> <span class="s">&#39;end&#39;</span><span class="p">,</span> <span class="nf">-&gt;</span>
<span class="nx">compileScript</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">code</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>If all of the source files are done being read, concatenate and compile
them together.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">joinTimeout = </span><span class="kc">null</span>
<span class="nv">compileJoin = </span><span class="nf">-&gt;</span>
<span class="k">return</span> <span class="k">unless</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">join</span>
<span class="k">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="nf">-&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="s">&#39;\n&#39;</span><span class="p">),</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">join</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>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>
</div>
<div class="content"><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="s">&#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="nf">-&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="nf">-&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="nf">-&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></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Watch a directory of files for new additions.
</p>
</div>
<div class="content"><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="nf">-&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="nf">-&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="k">unless</span> <span class="nx">err</span><span class="p">.</span><span class="nx">code</span> <span class="o">is</span> <span class="s">&#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="k">unless</span> <span class="nx">e</span><span class="p">.</span><span class="nx">code</span> <span class="o">is</span> <span class="s">&#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="k">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></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#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="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">exists</span> <span class="nx">jsPath</span><span class="p">,</span> <span class="nf">(itExists) -&gt;</span>
<span class="k">if</span> <span class="nx">itExists</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="s">&#39;ENOENT&#39;</span>
<span class="nx">timeLog</span> <span class="s">&quot;removed </span><span class="si">#{</span><span class="nx">source</span><span class="si">}</span><span class="s">&quot;</span></pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Get the corresponding output JavaScript path for a source file.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">outputPath = </span><span class="nf">(source, base, extension=&quot;.js&quot;) -&gt;</span>
<span class="nv">basename = </span><span class="nx">helpers</span><span class="p">.</span><span class="nx">baseFileName</span> <span class="nx">source</span><span class="p">,</span> <span class="kc">yes</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="s">&#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">basename</span> <span class="o">+</span> <span class="nx">extension</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>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>.map</code> file into the
same directory as the <code>.js</code> file.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">writeJs = </span><span class="nf">(base, sourcePath, js, generatedSourceMap = null) -&gt;</span>
<span class="nv">jsPath = </span><span class="nx">outputPath</span> <span class="nx">sourcePath</span><span class="p">,</span> <span class="nx">base</span>
<span class="nv">sourceMapPath = </span><span class="nx">outputPath</span> <span class="nx">sourcePath</span><span class="p">,</span> <span class="nx">base</span><span class="p">,</span> <span class="s">&quot;.map&quot;</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="nf">-&gt;</span>
<span class="k">if</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">compile</span>
<span class="nv">js = </span><span class="s">&#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="k">if</span> <span class="nx">generatedSourceMap</span> <span class="k">then</span> <span class="nv">js = </span><span class="s">&quot;//@ sourceMappingURL=</span><span class="si">#{</span><span class="nx">helpers</span><span class="p">.</span><span class="nx">baseFileName</span> <span class="nx">sourceMapPath</span><span class="si">}</span><span class="s">\n</span><span class="si">#{</span><span class="nx">js</span><span class="si">}</span><span class="s">&quot;</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="s">&quot;compiled </span><span class="si">#{</span><span class="nx">sourcePath</span><span class="si">}</span><span class="s">&quot;</span>
<span class="k">if</span> <span class="nx">generatedSourceMap</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">writeFile</span> <span class="nx">sourceMapPath</span><span class="p">,</span> <span class="nx">generatedSourceMap</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="s">&quot;Could not write source map: </span><span class="si">#{</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="si">}</span><span class="s">&quot;</span>
<span class="nx">exists</span> <span class="nx">jsDir</span><span class="p">,</span> <span class="nf">(itExists) -&gt;</span>
<span class="k">if</span> <span class="nx">itExists</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="s">&quot;mkdir -p </span><span class="si">#{</span><span class="nx">jsDir</span><span class="si">}</span><span class="s">&quot;</span><span class="p">,</span> <span class="nx">compile</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>Convenience for cleaner setTimeouts.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>When watching scripts, it&#39;s useful to log changes with the timestamp.
</p>
</div>
<div class="content"><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="s">&quot;</span><span class="si">#{</span><span class="p">(</span><span class="k">new</span> <span class="nb">Date</span><span class="p">).</span><span class="nx">toLocaleTimeString</span><span class="p">()</span><span class="si">}</span><span class="s"> - </span><span class="si">#{</span><span class="nx">message</span><span class="si">}</span><span class="s">&quot;</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>Pipe compiled JS through JSLint (requires a working <code>jsl</code> command), printing
any errors or warnings that arise.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="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="s">&#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="s">&#39;/../../extras/jsl.conf&#39;</span>
<span class="nv">jsl = </span><span class="nx">spawn</span> <span class="s">&#39;jsl&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s">&#39;-nologo&#39;</span><span class="p">,</span> <span class="s">&#39;-stdin&#39;</span><span class="p">,</span> <span class="s">&#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="nx">on</span> <span class="s">&#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="nx">on</span> <span class="s">&#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></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Pretty-print a stream of tokens, sans location data.
</p>
</div>
<div class="content"><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="nv">tag = </span><span class="nx">token</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="nv">value = </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="s">&#39;\\n&#39;</span><span class="p">)</span>
<span class="s">&quot;[</span><span class="si">#{</span><span class="nx">tag</span><span class="si">}</span><span class="s"> </span><span class="si">#{</span><span class="nx">value</span><span class="si">}</span><span class="s">]&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="s">&#39; &#39;</span><span class="p">)</span></pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#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="nv">parseOptions = </span><span class="nf">-&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="o">or</span> <span class="nx">o</span><span class="p">.</span><span class="nx">map</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></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#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="nv">compileOptions = </span><span class="nf">(filename) -&gt;</span>
<span class="p">{</span>
<span class="nx">filename</span>
<span class="nv">literate: </span><span class="nx">helpers</span><span class="p">.</span><span class="nx">isLiterate</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="nv">header: </span><span class="nx">opts</span><span class="p">.</span><span class="nx">compile</span>
<span class="nv">sourceMap: </span><span class="nx">opts</span><span class="p">.</span><span class="nx">map</span>
<span class="p">}</span></pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Start 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="nv">forkNode = </span><span class="nf">-&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="s">&#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></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#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="nv">usage = </span><span class="nf">-&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></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Print the <code>--version</code> message and exit.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">version = </span><span class="nf">-&gt;</span>
<span class="nx">printLine</span> <span class="s">&quot;CoffeeScript version </span><span class="si">#{</span><span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">VERSION</span><span class="si">}</span><span class="s">&quot;</span>
</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -1,123 +1,364 @@
/*--------------------- Layout and Typography ----------------------------*/
/*--------------------- 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: 'novecento-bold';
src: url('public/fonts/novecento-bold.eot');
src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'),
url('public/fonts/novecento-bold.woff') format('woff'),
url('public/fonts/novecento-bold.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
/*--------------------- Layout ----------------------------*/
html { height: 100%; }
body {
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
font-size: 16px;
line-height: 24px;
color: #252519;
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, ul, ol {
margin: 15px 0 0px;
}
h1, h2, h3, h4, h5, h6 {
color: #112233;
line-height: 1em;
font-weight: normal;
font-family: "novecento-bold";
text-transform: uppercase;
margin: 30px 0 15px 0;
}
h1 {
margin-top: 40px;
}
hr {
border: 0;
background: 1px solid #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;
}
a {
color: #261a3b;
}
a:visited {
color: #261a3b;
.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;
}
p {
margin: 0 0 15px 0;
.annotation pre code {
border: 0;
padding: 0;
background: transparent;
}
blockquote {
border-left: 5px solid #ccc;
margin-left: 0;
padding: 1px 0 1px 1em;
}
h1, h2, h3, h4, h5, h6 {
margin: 40px 0 15px 0;
}
h3, h4, h5, h6 {
margin-top: 20px;
.sections blockquote p {
font-family: Menlo, Consolas, Monaco, monospace;
font-size: 14px; line-height: 19px;
color: #999;
margin: 10px 0 0;
white-space: pre-wrap;
}
#container {
position: relative;
ul.sections {
list-style: none;
padding:0 0 5px 0;;
margin:0;
}
#background {
position: fixed;
top: 0; left: 580px; right: 0; bottom: 0;
background: #f5f5ff;
border-left: 1px solid #e5e5ee;
z-index: -1;
/*
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: 10px Arial;
text-transform: uppercase;
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: 5px 10px;
padding: 10px 15px;
margin:0;
}
#jump_wrapper {
display: none;
padding:0;
}
#jump_to:hover #jump_wrapper {
display: block;
}
#jump_page {
padding: 5px 0 3px;
margin: 0 0 25px 25px;
}
#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 {
background: #f5f5ff;
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;
}
#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: 500px;
min-width: 500px;
#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: 10px 25px 1px 50px;
padding: 13px;
overflow-x: hidden;
white-space: normal;
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;
}
.octowrap {
position: relative;
}
.octothorpe {
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 .octothorpe {
opacity: 1;
}
td.code, th.code {
padding: 14px 15px 16px 50px;
width: 100%;
ul.sections > li > div.annotation pre {
margin: 15px 0 15px;
padding-left: 15px;
}
ul.sections > li > div.content {
padding: 13px;
vertical-align: top;
background: #f5f5ff;
border-left: 1px solid #e5e5ee;
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
pre, tt, code {
font-size: 12px; line-height: 18px;
font-family: Monaco, Consolas, "Lucida Console", monospace;
margin: 0; padding: 0;
.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; }
@@ -182,4 +423,4 @@ 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 */
body .il { color: #666666 } /* Literal.Number.Integer.Long */

File diff suppressed because it is too large Load Diff

View File

@@ -1,59 +1,458 @@
<!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="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="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="octowrap"> <a class="octothorpe" href="#section-1">#</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="octowrap"> <a class="octothorpe" href="#section-2">#</a> </div> <p>Set up exported variables for both <strong>Node.js</strong> and the browser.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">this</span><span class="p">.</span><span class="nv">exports: </span><span class="k">this</span> <span class="nx">unless</span> <span class="nx">process</span><span class="o">?</span>
<span class="nv">helpers: exports.helpers: </span><span class="p">{}</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-3">#</a> </div> <p>Does a list include a value?</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">helpers.include: include: </span><span class="p">(</span><span class="nx">list</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">list</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">0</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-4">#</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">helpers.starts: starts: </span><span class="p">(</span><span class="nx">string</span><span class="p">,</span> <span class="nx">literal</span><span class="p">,</span> <span class="nx">start</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">string</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="nx">start</span><span class="p">,</span> <span class="p">(</span><span class="nx">start</span> <span class="o">or</span> <span class="mi">0</span><span class="p">)</span> <span class="o">+</span> <span class="nx">literal</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">is</span> <span class="nx">literal</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</a> </div> <p>Trim out all falsy values from an array.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">helpers.compact: compact: </span><span class="p">(</span><span class="nx">array</span><span class="p">)</span> <span class="o">-&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-6"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-6">#</a> </div> <p>Count the number of occurences of a character in a string.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">helpers.count: count: </span><span class="p">(</span><span class="nx">string</span><span class="p">,</span> <span class="nx">letter</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">num: </span><span class="mi">0</span>
<span class="nv">pos: </span><span class="nx">string</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">letter</span><span class="p">)</span>
<span class="k">while</span> <span class="nx">pos</span> <span class="o">isnt</span> <span class="o">-</span><span class="mi">1</span>
<span class="nv">num: </span><span class="o">+</span> <span class="mi">1</span>
<span class="nv">pos: </span><span class="nx">string</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">letter</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="nx">num</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-7">#</a> </div> <p>Merge objects, returning a fresh copy with attributes from both sides.
Used every time <code>BaseNode#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">helpers.merge: merge: </span><span class="p">(</span><span class="nx">options</span><span class="p">,</span> <span class="nx">overrides</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">fresh: </span><span class="p">{}</span>
<span class="p">(</span><span class="nx">fresh</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="p">)</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">options</span>
<span class="p">(</span><span class="nx">fresh</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="p">)</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">overrides</span> <span class="k">if</span> <span class="nx">overrides</span>
<span class="nx">fresh</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-8">#</a> </div> <p>Extend a source object with the properties of another object (shallow copy).
We use this to simulate Node's deprecated <code>process.mixin</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">helpers.extend: extend: </span><span class="p">(</span><span class="nx">object</span><span class="p">,</span> <span class="nx">properties</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="p">(</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="p">)</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></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-9">#</a> </div> <p>Return a completely 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">helpers.flatten: flatten: </span><span class="p">(</span><span class="nx">array</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">memo: </span><span class="p">[]</span>
<span class="k">for</span> <span class="nx">item</span> <span class="k">in</span> <span class="nx">array</span>
<span class="k">if</span> <span class="nx">item</span> <span class="k">instanceof</span> <span class="nb">Array</span> <span class="k">then</span> <span class="nv">memo: </span><span class="nx">memo</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">item</span><span class="p">)</span> <span class="k">else</span> <span class="nx">memo</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">item</span><span class="p">)</span>
<span class="nx">memo</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-10">#</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">helpers.del: del: </span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">key</span><span class="p">)</span> <span class="o">-&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-11"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-11">#</a> </div> <p>Matches a balanced group such as a single or double-quoted string. Pass in
a series of delimiters, all of which must be nested correctly within the
contents of the string. This method allows us to have strings within
interpolations within strings, ad infinitum.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">helpers.balanced_string: balanced_string: </span><span class="p">(</span><span class="nx">str</span><span class="p">,</span> <span class="nx">delimited</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">options: </span><span class="o">or</span> <span class="p">{}</span>
<span class="nv">slash: </span><span class="nx">delimited</span><span class="p">[</span><span class="mi">0</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="nv">levels: </span><span class="p">[]</span>
<span class="nv">i: </span><span class="mi">0</span>
<span class="k">while</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">str</span><span class="p">.</span><span class="nx">length</span>
<span class="k">if</span> <span class="nx">levels</span><span class="p">.</span><span class="nx">length</span> <span class="o">and</span> <span class="nx">starts</span> <span class="nx">str</span><span class="p">,</span> <span class="s1">&#39;\\&#39;</span><span class="p">,</span> <span class="nx">i</span>
<span class="nv">i: </span><span class="o">+</span> <span class="mi">1</span>
<span class="k">else</span>
<span class="k">for</span> <span class="nx">pair</span> <span class="k">in</span> <span class="nx">delimited</span>
<span class="p">[</span><span class="nx">open</span><span class="p">,</span> <span class="nx">close</span><span class="p">]</span><span class="o">:</span> <span class="nx">pair</span>
<span class="k">if</span> <span class="nx">levels</span><span class="p">.</span><span class="nx">length</span> <span class="o">and</span> <span class="nx">starts</span><span class="p">(</span><span class="nx">str</span><span class="p">,</span> <span class="nx">close</span><span class="p">,</span> <span class="nx">i</span><span class="p">)</span> <span class="o">and</span> <span class="nx">levels</span><span class="p">[</span><span class="nx">levels</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="nx">pair</span>
<span class="nx">levels</span><span class="p">.</span><span class="nx">pop</span><span class="p">()</span>
<span class="nv">i: </span><span class="o">+</span> <span class="nx">close</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span>
<span class="nv">i: </span><span class="o">+</span> <span class="mi">1</span> <span class="nx">unless</span> <span class="nx">levels</span><span class="p">.</span><span class="nx">length</span>
<span class="k">break</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">starts</span> <span class="nx">str</span><span class="p">,</span> <span class="nx">open</span><span class="p">,</span> <span class="nx">i</span>
<span class="nx">levels</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">pair</span><span class="p">)</span>
<span class="nv">i: </span><span class="o">+</span> <span class="nx">open</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span>
<span class="k">break</span>
<span class="k">break</span> <span class="k">if</span> <span class="o">not</span> <span class="nx">levels</span><span class="p">.</span><span class="nx">length</span> <span class="o">or</span> <span class="nx">slash</span> <span class="o">and</span> <span class="nx">starts</span> <span class="nx">str</span><span class="p">,</span> <span class="s1">&#39;\n&#39;</span><span class="p">,</span> <span class="nx">i</span>
<span class="nv">i: </span><span class="o">+</span> <span class="mi">1</span>
<span class="k">if</span> <span class="nx">levels</span><span class="p">.</span><span class="nx">length</span>
<span class="k">return</span> <span class="kc">false</span> <span class="k">if</span> <span class="nx">slash</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s2">&quot;SyntaxError: Unterminated ${levels.pop()[0]} starting on line ${@line + 1}&quot;</span>
<span class="k">if</span> <span class="o">not</span> <span class="nx">i</span> <span class="k">then</span> <span class="kc">false</span> <span class="k">else</span> <span class="nx">str</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">i</span><span class="p">)</span>
<!DOCTYPE html>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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 we&#39;d like to share among
the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten
arrays, count characters, that sort of thing.
</p>
<p>Peek at the beginning of a given string to see if it matches a sequence.
</p>
</div>
<div class="content"><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></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 end of a given string to see if it matches a sequence.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<p>Trim out all falsy values from an array.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
</div>
<p>Count the number of occurrences of a string in a string.
</p>
</div>
<div class="content"><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="k">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></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#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><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></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#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><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></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#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><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></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#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><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></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
</div>
<p>Gets the last item of an array(-like) object.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Typical Array::some
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.some = </span><span class="nb">Array</span><span class="o">::</span><span class="nx">some</span> <span class="o">?</span> <span class="nf">(fn) -&gt;</span>
<span class="k">return</span> <span class="kc">true</span> <span class="k">for</span> <span class="nx">e</span> <span class="k">in</span> <span class="k">this</span> <span class="k">when</span> <span class="nx">fn</span> <span class="nx">e</span>
<span class="kc">false</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>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="nv">buildLocationData = </span><span class="nf">(first, last) -&gt;</span>
<span class="k">if</span> <span class="o">not</span> <span class="nx">last</span>
<span class="nx">first</span>
<span class="k">else</span>
<span class="nv">first_line: </span><span class="nx">first</span><span class="p">.</span><span class="nx">first_line</span>
<span class="nv">first_column: </span><span class="nx">first</span><span class="p">.</span><span class="nx">first_column</span>
<span class="nv">last_line: </span><span class="nx">last</span><span class="p">.</span><span class="nx">last_line</span>
<span class="nv">last_column: </span><span class="nx">last</span><span class="p">.</span><span class="nx">last_column</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>This returns a function which takes an object as a parameter, and if that object is an AST node,
updates that object&#39;s locationData. The object is returned either way.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.addLocationDataFn = </span><span class="nf">(first, last) -&gt;</span>
<span class="nf">(obj) -&gt;</span>
<span class="k">if</span> <span class="p">((</span><span class="k">typeof</span> <span class="nx">obj</span><span class="p">)</span> <span class="o">is</span> <span class="s">&#39;object&#39;</span><span class="p">)</span> <span class="o">and</span> <span class="p">(</span><span class="o">!!</span><span class="nx">obj</span><span class="p">[</span><span class="s">&#39;updateLocationDataIfMissing&#39;</span><span class="p">])</span>
<span class="nx">obj</span><span class="p">.</span><span class="nx">updateLocationDataIfMissing</span> <span class="nx">buildLocationData</span><span class="p">(</span><span class="nx">first</span><span class="p">,</span> <span class="nx">last</span><span class="p">)</span>
<span class="k">return</span> <span class="nx">obj</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>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><span class="nv">exports.locationDataToString = </span><span class="nf">(obj) -&gt;</span>
<span class="k">if</span> <span class="p">(</span><span class="s">&quot;2&quot;</span> <span class="k">of</span> <span class="nx">obj</span><span class="p">)</span> <span class="o">and</span> <span class="p">(</span><span class="s">&quot;first_line&quot;</span> <span class="k">of</span> <span class="nx">obj</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="k">then</span> <span class="nv">locationData = </span><span class="nx">obj</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="k">else</span> <span class="k">if</span> <span class="s">&quot;first_line&quot;</span> <span class="k">of</span> <span class="nx">obj</span> <span class="k">then</span> <span class="nv">locationData = </span><span class="nx">obj</span>
<span class="k">if</span> <span class="nx">locationData</span>
<span class="s">&quot;</span><span class="si">#{</span><span class="nx">locationData</span><span class="p">.</span><span class="nx">first_line</span> <span class="o">+</span> <span class="mi">1</span><span class="si">}</span><span class="s">:</span><span class="si">#{</span><span class="nx">locationData</span><span class="p">.</span><span class="nx">first_column</span> <span class="o">+</span> <span class="mi">1</span><span class="si">}</span><span class="s">-&quot;</span> <span class="o">+</span>
<span class="s">&quot;</span><span class="si">#{</span><span class="nx">locationData</span><span class="p">.</span><span class="nx">last_line</span> <span class="o">+</span> <span class="mi">1</span><span class="si">}</span><span class="s">:</span><span class="si">#{</span><span class="nx">locationData</span><span class="p">.</span><span class="nx">last_column</span> <span class="o">+</span> <span class="mi">1</span><span class="si">}</span><span class="s">&quot;</span>
<span class="k">else</span>
<span class="s">&quot;No location data&quot;</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>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><span class="nv">exports.baseFileName = </span><span class="nf">(file, stripExt = no) -&gt;</span>
<span class="nv">parts = </span><span class="nx">file</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s">&#39;/&#39;</span><span class="p">)</span>
<span class="nv">file = </span><span class="nx">parts</span><span class="p">[</span><span class="nx">parts</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">return</span> <span class="nx">file</span> <span class="k">unless</span> <span class="nx">stripExt</span>
<span class="nv">parts = </span><span class="nx">file</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</span>
<span class="nx">parts</span><span class="p">.</span><span class="nx">pop</span><span class="p">()</span>
<span class="nx">parts</span><span class="p">.</span><span class="nx">pop</span><span class="p">()</span> <span class="k">if</span> <span class="nx">parts</span><span class="p">[</span><span class="nx">parts</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="s">&#39;coffee&#39;</span>
<span class="nx">parts</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</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>Determine if a filename represents a CoffeeScript file.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.isCoffee = </span><span class="nf">(file) -&gt;</span> <span class="o">/</span><span class="err">\</span><span class="p">.((</span><span class="nx">lit</span><span class="p">)</span><span class="o">?</span><span class="nx">coffee</span><span class="o">|</span><span class="nx">coffee</span><span class="err">\</span><span class="p">.</span><span class="nx">md</span><span class="p">)</span><span class="nx">$</span><span class="o">/</span><span class="p">.</span><span class="nx">test</span> <span class="nx">file</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>Determine if a filename represents a Literate CoffeeScript file.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.isLiterate = </span><span class="nf">(file) -&gt;</span> <span class="o">/</span><span class="err">\</span><span class="p">.(</span><span class="nx">litcoffee</span><span class="o">|</span><span class="nx">coffee</span><span class="err">\</span><span class="p">.</span><span class="nx">md</span><span class="p">)</span><span class="nx">$</span><span class="o">/</span><span class="p">.</span><span class="nx">test</span> <span class="nx">file</span>
</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,125 @@
<!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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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><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="s">&#39;./coffee-script&#39;</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

@@ -1,67 +1,365 @@
<!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="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="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="octowrap"> <a class="octothorpe" href="#section-1">#</a> </div> <p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
Use it like so:</p>
<!DOCTYPE html>
<pre><code>parser: new OptionParser switches, help_banner
options: parser.parse process.argv
</code></pre> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.OptionParser: </span><span class="nx">class</span> <span class="nx">OptionParser</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-2">#</a> </div> <p>Initialize with a list of valid options, in the form:</p>
<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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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>
<p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
Use it like so:
<pre><code>[short-flag, long-flag, description]
</code></pre>
</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>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="p">(</span><span class="nx">rules</span><span class="p">,</span> <span class="nx">banner</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="vi">@banner: </span> <span class="nx">banner</span>
<span class="vi">@rules: </span> <span class="nx">build_rules</span><span class="p">(</span><span class="nx">rules</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-3">#</a> </div> <p>Parse the list of arguments, populating an <code>options</code> object with all of the
specified options, and returning it. <code>options.arguments</code> will be an array
containing the remaning non-option 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="p">(</span><span class="nx">args</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">options: </span><span class="p">{</span><span class="nv">arguments: </span><span class="p">[]}</span>
<span class="nv">args: </span><span class="nx">normalize_arguments</span> <span class="nx">args</span>
<span class="k">while</span> <span class="p">(</span><span class="nv">arg: </span><span class="nx">args</span><span class="p">.</span><span class="nx">shift</span><span class="p">())</span>
<span class="nv">is_option: </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>
<span class="nv">matched_rule: </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">short_flag</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">long_flag</span> <span class="o">is</span> <span class="nx">arg</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">has_argument</span> <span class="k">then</span> <span class="nx">args</span><span class="p">.</span><span class="nx">shift</span><span class="p">()</span> <span class="k">else</span> <span class="kc">true</span>
<span class="nv">matched_rule: </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">is_option</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">matched_rule</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">unless</span> <span class="nx">is_option</span>
<span class="nx">options</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-4">#</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="s1">&#39;Available options:&#39;</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>
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.OptionParser = </span><span class="k">class</span> <span class="nx">OptionParser</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 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>
</div>
<div class="content"><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></div>
</li>
<li id="section-3">
<div class="annotation">
<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&#39;re responsible for interpreting the options object.
</p>
</div>
<div class="content"><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="s">&#39;--&#39;</span>
<span class="nv">pos = </span><span class="nx">originalArgs</span><span class="p">.</span><span class="nx">indexOf</span> <span class="s">&#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></div>
</li>
<li id="section-4">
<div class="annotation">
<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>
</div>
<div class="content"><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="k">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="s">&quot;unrecognized option: </span><span class="si">#{</span><span class="nx">arg</span><span class="si">}</span><span class="s">&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></div>
</li>
<li id="section-5">
<div class="annotation">
<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>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">help: </span><span class="nf">-&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="s">&quot;</span><span class="si">#{</span><span class="nx">@banner</span><span class="si">}</span><span class="s">\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">long_flag</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="p">(</span><span class="s1">&#39; &#39;</span> <span class="k">for</span> <span class="nx">i</span> <span class="k">in</span> <span class="p">[</span><span class="mi">0</span><span class="p">..</span><span class="nx">spaces</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">let_part: </span><span class="k">if</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">short_flag</span> <span class="k">then</span> <span class="nx">rule</span><span class="p">.</span><span class="nx">short_flag</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="s2">&quot; $let_part${rule.long_flag}$spaces${rule.description}&quot;</span>
<span class="s2">&quot;\n${ lines.join(&#39;\n&#39;) }\n&quot;</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</a> </div> <h2>Helpers</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-6">#</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">/\[(.+)\]/</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-7">#</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">build_rules: </span><span class="p">(</span><span class="nx">rules</span><span class="p">)</span> <span class="o">-&gt;</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="s">&#39; &#39;</span><span class="p">)</span> <span class="k">else</span> <span class="s">&#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="s">&#39;, &#39;</span> <span class="k">else</span> <span class="s">&#39; &#39;</span>
<span class="nx">lines</span><span class="p">.</span><span class="nx">push</span> <span class="s">&#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="s">&quot;\n</span><span class="si">#{</span> <span class="nx">lines</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s">&#39;\n&#39;</span><span class="p">)</span> <span class="si">}</span><span class="s">\n&quot;</span></pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap for-h2">
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<h2>Helpers</h2>
</div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
</div>
<p>Regex matchers for option flags.
</p>
</div>
<div class="content"><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></div>
</li>
<li id="section-8">
<div class="annotation">
<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>
</div>
<div class="content"><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">build_rule</span> <span class="nx">tuple</span><span class="p">...</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-8">#</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">build_rule: </span><span class="p">(</span><span class="nx">short_flag</span><span class="p">,</span> <span class="nx">long_flag</span><span class="p">,</span> <span class="nx">description</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">match: </span> <span class="nx">long_flag</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">long_flag: </span> <span class="nx">long_flag</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="nx">buildRule</span> <span class="nx">tuple</span><span class="p">...</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>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="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">long_flag</span><span class="p">.</span><span class="nx">substr</span> <span class="mi">2</span>
<span class="nv">short_flag: </span> <span class="nx">short_flag</span>
<span class="nv">long_flag: </span> <span class="nx">long_flag</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">has_argument: </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="p">}</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-9">#</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">normalize_arguments: </span><span class="p">(</span><span class="nx">args</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">args: </span><span class="nx">args</span><span class="p">.</span><span class="nx">slice</span> <span class="mi">0</span>
<span class="nv">result: </span><span class="p">[]</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></div>
</li>
<li id="section-10">
<div class="annotation">
<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>
</div>
<div class="content"><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">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="s">&#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="s">&#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>
</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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

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

@@ -1,21 +1,356 @@
<!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="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="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="octowrap"> <a class="octothorpe" href="#section-1">#</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>
<!DOCTYPE html>
<pre><code>coffee&gt; puts "$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="octowrap"> <a class="octothorpe" href="#section-2">#</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">helpers: </span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./helpers&#39;</span><span class="p">).</span><span class="nx">helpers</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-3">#</a> </div> <p>Our prompt.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">prompt: </span><span class="s1">&#39;coffee&gt; &#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-4">#</a> </div> <p>Quick alias for quitting the REPL.</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> <span class="p">{</span>
<span class="nv">quit: </span><span class="o">-&gt;</span> <span class="nx">process</span><span class="p">.</span><span class="nx">exit</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</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="p">(</span><span class="nx">code</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">try</span>
<span class="nv">val: </span><span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">run</span> <span class="nx">code</span><span class="p">,</span> <span class="p">{</span><span class="nv">no_wrap: </span><span class="kc">true</span><span class="p">,</span> <span class="nv">globals: </span><span class="kc">true</span><span class="p">,</span> <span class="nv">source: </span><span class="s1">&#39;repl&#39;</span><span class="p">}</span>
<span class="nx">p</span> <span class="nx">val</span> <span class="k">if</span> <span class="nx">val</span> <span class="o">isnt</span> <span class="kc">undefined</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="nx">puts</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="nx">print</span> <span class="nx">prompt</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-6">#</a> </div> <p>Start up the REPL by opening <strong>stdio</strong> and listening for input.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">process</span><span class="p">.</span><span class="nx">stdio</span><span class="p">.</span><span class="nx">addListener</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nx">run</span>
<span class="nx">process</span><span class="p">.</span><span class="nx">stdio</span><span class="p">.</span><span class="nx">open</span><span class="p">()</span>
<span class="nx">print</span> <span class="nx">prompt</span>
<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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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><span class="nv">vm = </span><span class="nx">require</span> <span class="s">&#39;vm&#39;</span>
<span class="nv">nodeREPL = </span><span class="nx">require</span> <span class="s">&#39;repl&#39;</span>
<span class="nv">CoffeeScript = </span><span class="nx">require</span> <span class="s">&#39;./coffee-script&#39;</span>
<span class="p">{</span><span class="nx">merge</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s">&#39;./helpers&#39;</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
<span class="nv">replDefaults =</span>
<span class="nv">prompt: </span><span class="s">&#39;coffee&gt; &#39;</span><span class="p">,</span>
<span class="nb">eval</span><span class="o">:</span> <span class="nf">(input, context, filename, cb) -&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> <span class="nv">input = </span><span class="nx">input</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\uFF00/g</span><span class="p">,</span> <span class="s">&#39;\n&#39;</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>strip single-line comments
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">input = </span><span class="nx">input</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="s">&#39;$1$2$3&#39;</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>empty command
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">return</span> <span class="nx">cb</span> <span class="kc">null</span> <span class="k">if</span> <span class="sr">/^(\s*|\(\s*\))$/</span><span class="p">.</span><span class="nx">test</span> <span class="nx">input</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>TODO: fix #1829: pass in-scope vars and avoid accidentally shadowing them by omitting those declarations
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">try</span>
<span class="nv">js = </span><span class="nx">CoffeeScript</span><span class="p">.</span><span class="nx">compile</span> <span class="s">&quot;_=(</span><span class="si">#{</span><span class="nx">input</span><span class="si">}</span><span class="s">\n)&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">filename</span><span class="p">,</span> <span class="nv">bare: </span><span class="kc">yes</span><span class="p">}</span>
<span class="nx">cb</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">vm</span><span class="p">.</span><span class="nx">runInContext</span><span class="p">(</span><span class="nx">js</span><span class="p">,</span> <span class="nx">context</span><span class="p">,</span> <span class="nx">filename</span><span class="p">)</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="nx">cb</span> <span class="nx">err</span>
<span class="nv">addMultilineHandler = </span><span class="nf">(repl) -&gt;</span>
<span class="p">{</span><span class="nx">rli</span><span class="p">,</span> <span class="nx">inputStream</span><span class="p">,</span> <span class="nx">outputStream</span><span class="p">}</span> <span class="o">=</span> <span class="nx">repl</span>
<span class="nv">multiline =</span>
<span class="nv">enabled: </span><span class="kc">off</span>
<span class="nv">initialPrompt: </span><span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/^[^&gt; ]*/</span><span class="p">,</span> <span class="nf">(x) -&gt;</span> <span class="nx">x</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/./g</span><span class="p">,</span> <span class="s">&#39;-&#39;</span><span class="p">)</span>
<span class="nv">prompt: </span><span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/^[^&gt; ]*&gt;?/</span><span class="p">,</span> <span class="nf">(x) -&gt;</span> <span class="nx">x</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/./g</span><span class="p">,</span> <span class="s">&#39;.&#39;</span><span class="p">)</span>
<span class="nv">buffer: </span><span class="s">&#39;&#39;</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>Proxy node&#39;s line listener
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">nodeLineListener = </span><span class="nx">rli</span><span class="p">.</span><span class="nx">listeners</span><span class="p">(</span><span class="s">&#39;line&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">removeListener</span> <span class="s">&#39;line&#39;</span><span class="p">,</span> <span class="nx">nodeLineListener</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">on</span> <span class="s">&#39;line&#39;</span><span class="p">,</span> <span class="nf">(cmd) -&gt;</span>
<span class="k">if</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">enabled</span>
<span class="nx">multiline</span><span class="p">.</span><span class="nx">buffer</span> <span class="o">+=</span> <span class="s">&quot;</span><span class="si">#{</span><span class="nx">cmd</span><span class="si">}</span><span class="s">\n&quot;</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">prompt</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">prompt</span> <span class="kc">true</span>
<span class="k">else</span>
<span class="nx">nodeLineListener</span> <span class="nx">cmd</span>
<span class="k">return</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>Handle Ctrl-v
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nx">inputStream</span><span class="p">.</span><span class="nx">on</span> <span class="s">&#39;keypress&#39;</span><span class="p">,</span> <span class="nf">(char, key) -&gt;</span>
<span class="k">return</span> <span class="k">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="s">&#39;v&#39;</span>
<span class="k">if</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">enabled</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>allow arbitrarily switching between modes any time before multiple lines are entered
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">unless</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">buffer</span><span class="p">.</span><span class="nx">match</span> <span class="sr">/\n/</span>
<span class="nv">multiline.enabled = </span><span class="o">not</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">enabled</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="nx">repl</span><span class="p">.</span><span class="nx">prompt</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">prompt</span> <span class="kc">true</span>
<span class="k">return</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>no-op unless the current line is empty
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">return</span> <span class="k">if</span> <span class="nx">rli</span><span class="p">.</span><span class="nx">line</span><span class="o">?</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">rli</span><span class="p">.</span><span class="nx">line</span><span class="p">.</span><span class="nx">match</span> <span class="sr">/^\s*$/</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>eval, print, loop
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">multiline.enabled = </span><span class="o">not</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">enabled</span>
<span class="nv">rli.line = </span><span class="s">&#39;&#39;</span>
<span class="nv">rli.cursor = </span><span class="mi">0</span>
<span class="nx">rli</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">rli</span><span class="p">.</span><span class="nx">output</span><span class="p">.</span><span class="nx">clearLine</span> <span class="mi">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>XXX: multiline hack
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">multiline.buffer = </span><span class="nx">multiline</span><span class="p">.</span><span class="nx">buffer</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\n/g</span><span class="p">,</span> <span class="s">&#39;\uFF00&#39;</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">emit</span> <span class="s">&#39;line&#39;</span><span class="p">,</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">buffer</span>
<span class="nv">multiline.buffer = </span><span class="s">&#39;&#39;</span>
<span class="k">else</span>
<span class="nv">multiline.enabled = </span><span class="o">not</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">enabled</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">setPrompt</span> <span class="nx">multiline</span><span class="p">.</span><span class="nx">initialPrompt</span>
<span class="nx">rli</span><span class="p">.</span><span class="nx">prompt</span> <span class="kc">true</span>
<span class="k">return</span>
<span class="nv">module.exports =</span>
<span class="nv">start: </span><span class="nf">(opts = {}) -&gt;</span>
<span class="nv">opts = </span><span class="nx">merge</span> <span class="nx">replDefaults</span><span class="p">,</span> <span class="nx">opts</span>
<span class="nv">repl = </span><span class="nx">nodeREPL</span><span class="p">.</span><span class="nx">start</span> <span class="nx">opts</span>
<span class="nx">repl</span><span class="p">.</span><span class="nx">on</span> <span class="s">&#39;exit&#39;</span><span class="p">,</span> <span class="nf">-&gt;</span> <span class="nx">repl</span><span class="p">.</span><span class="nx">outputStream</span><span class="p">.</span><span class="nx">write</span> <span class="s">&#39;\n&#39;</span>
<span class="nx">addMultilineHandler</span> <span class="nx">repl</span>
<span class="nx">repl</span>
</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -1,48 +1,450 @@
<!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="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="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="octowrap"> <a class="octothorpe" href="#section-1">#</a> </div> <p>The <strong>Scope</strong> class regulates lexical scoping within CoffeeScript. As you
<!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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</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 the outside.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-2">#</a> </div> <p>Set up exported variables for both <strong>Node.js</strong> and the browser.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">this</span><span class="p">.</span><span class="nv">exports: </span><span class="k">this</span> <span class="nx">unless</span> <span class="nx">process</span><span class="o">?</span>
with external scopes.
<span class="nv">exports.Scope: </span><span class="nx">class</span> <span class="nx">Scope</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-3">#</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="octowrap"> <a class="octothorpe" href="#section-4">#</a> </div> <p>Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the <strong>Expressions</strong> node is belongs to, which is
</p>
<p>Import the helpers we plan to use.
</p>
</div>
<div class="content"><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="s">&#39;./helpers&#39;</span>
<span class="nv">exports.Scope = </span><span class="k">class</span> <span class="nx">Scope</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 <code>root</code> is the top-level <strong>Scope</strong> object for a given file.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="vi">@root: </span><span class="kc">null</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 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="p">(</span><span class="nx">parent</span><span class="p">,</span> <span class="nx">expressions</span><span class="p">,</span> <span class="nx">method</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="p">[</span><span class="nx">@parent</span><span class="p">,</span> <span class="nx">@expressions</span><span class="p">,</span> <span class="nx">@method</span><span class="p">]</span><span class="o">:</span> <span class="p">[</span><span class="nx">parent</span><span class="p">,</span> <span class="nx">expressions</span><span class="p">,</span> <span class="nx">method</span><span class="p">]</span>
<span class="vi">@variables: </span><span class="p">{}</span>
<span class="k">if</span> <span class="nx">@parent</span>
<span class="vi">@temp_var: </span><span class="nx">@parent</span><span class="p">.</span><span class="nx">temp_var</span>
<span class="k">else</span>
<span class="nv">Scope.root: </span><span class="k">this</span>
<span class="vi">@temp_var: </span><span class="s1">&#39;_a&#39;</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</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="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">return</span> <span class="kc">true</span> <span class="k">if</span> <span class="nx">@check</span> <span class="nx">name</span>
<span class="nx">@variables</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span><span class="o">:</span> <span class="s1">&#39;var&#39;</span>
<span class="kc">false</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-6">#</a> </div> <p>Test variables and return true the first time fn(v, k) returns true</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">any: </span><span class="p">(</span><span class="nx">fn</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">for</span> <span class="nx">v</span><span class="p">,</span> <span class="nx">k</span> <span class="k">of</span> <span class="nx">@variables</span> <span class="k">when</span> <span class="nx">fn</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">k</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">true</span>
<span class="k">return</span> <span class="kc">false</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-7">#</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="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">@variables</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span><span class="o">:</span> <span class="s1">&#39;param&#39;</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-8">#</a> </div> <p>Just check to see if a variable has already been declared, without reserving.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">check: </span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">return</span> <span class="kc">true</span> <span class="k">if</span> <span class="nx">@variables</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">@parent</span> <span class="o">and</span> <span class="nx">@parent</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-9"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-9">#</a> </div> <p>If we need to store an intermediate result, find an available name for a
compiler-generated variable. <code>_a</code>, <code>_b</code>, and so on...</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">free_variable: </span><span class="o">-&gt;</span>
<span class="k">while</span> <span class="nx">@check</span> <span class="nx">@temp_var</span>
<span class="nv">ordinal: </span><span class="mi">1</span> <span class="o">+</span> <span class="nb">parseInt</span> <span class="nx">@temp_var</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">36</span>
<span class="vi">@temp_var: </span><span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="nx">ordinal</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="p">(</span><span class="sr">/\d/g</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">)</span>
<span class="nx">@variables</span><span class="p">[</span><span class="nx">@temp_var</span><span class="p">]</span><span class="o">:</span> <span class="s1">&#39;var&#39;</span>
<span class="nx">@temp_var</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-10">#</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="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">@variables</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span><span class="o">:</span> <span class="p">{</span><span class="nv">value: </span><span class="nx">value</span><span class="p">,</span> <span class="nv">assigned: </span><span class="kc">true</span><span class="p">}</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-11">#</a> </div> <p>Does this scope reference any variables that need to be declared in the
given function body?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">has_declarations: </span><span class="p">(</span><span class="nx">body</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">body</span> <span class="o">is</span> <span class="nx">@expressions</span> <span class="o">and</span> <span class="nx">@any</span> <span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="nx">val</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">val</span> <span class="o">is</span> <span class="s1">&#39;var&#39;</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-12">#</a> </div> <p>Does this scope reference any assignments that need to be declared at the
top of the given function body?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">has_assignments: </span><span class="p">(</span><span class="nx">body</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">body</span> <span class="o">is</span> <span class="nx">@expressions</span> <span class="o">and</span> <span class="nx">@any</span> <span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="nx">val</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">val</span><span class="p">.</span><span class="nx">assigned</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-13">#</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">declared_variables: </span><span class="o">-&gt;</span>
<span class="p">(</span><span class="nx">key</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">@variables</span> <span class="k">when</span> <span class="nx">val</span> <span class="o">is</span> <span class="s1">&#39;var&#39;</span><span class="p">).</span><span class="nx">sort</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-14">#</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">assigned_variables: </span><span class="o">-&gt;</span>
<span class="s2">&quot;$key = ${val.value}&quot;</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">@variables</span> <span class="k">when</span> <span class="nx">val</span><span class="p">.</span><span class="nx">assigned</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-15">#</a> </div> <p>Compile the JavaScript for all of the variable declarations in this scope.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">compiled_declarations: </span><span class="o">-&gt;</span>
<span class="nx">@declared_variables</span><span class="p">().</span><span class="nx">join</span> <span class="s1">&#39;, &#39;</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-16">#</a> </div> <p>Compile the JavaScript for all of the variable assignments in this scope.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">compiled_assignments: </span><span class="o">-&gt;</span>
<span class="nx">@assigned_variables</span><span class="p">().</span><span class="nx">join</span> <span class="s1">&#39;, &#39;</span>
it belongs to.
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
</p>
</div>
<div class="content"><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="s">&#39;arguments&#39;</span><span class="p">,</span> <span class="nv">type: </span><span class="s">&#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="k">unless</span> <span class="nx">@parent</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> <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></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 we&#39;re
in, so that we know how to invoke the same method of the parent class. This
can get complicated if super is being called from an inner function.
<code>namedMethod</code> will walk up the scope tree until it either finds the first
function object that has a name filled in, or bottoms out.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">namedMethod: </span><span class="nf">-&gt;</span>
<span class="k">return</span> <span class="nx">@method</span> <span class="k">if</span> <span class="nx">@method</span><span class="o">?</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></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> <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="s">&#39;var&#39;</span>
<span class="kc">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> <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="s">&#39;param&#39;</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> <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></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> <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="s">&#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="s">&#39;&#39;</span>
<span class="k">else</span>
<span class="s">&#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="s">&#39;a&#39;</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> <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></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> <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="s">&#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></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> <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></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> <span class="nv">hasDeclarations: </span><span class="nf">-&gt;</span>
<span class="o">!!</span><span class="nx">@declaredVariables</span><span class="p">().</span><span class="nx">length</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>Return the list of variables first declared in this scope.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">declaredVariables: </span><span class="nf">-&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="s">&#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="s">&#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></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> <span class="nv">assignedVariables: </span><span class="nf">-&gt;</span>
<span class="s">&quot;</span><span class="si">#{</span><span class="nx">v</span><span class="p">.</span><span class="nx">name</span><span class="si">}</span><span class="s"> = </span><span class="si">#{</span><span class="nx">v</span><span class="p">.</span><span class="nx">type</span><span class="p">.</span><span class="nx">value</span><span class="si">}</span><span class="s">&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></div>
</li>
</ul>
</div>
</body>
</html>

View File

@@ -0,0 +1,777 @@
<!DOCTYPE html>
<html>
<head>
<title>sourcemap.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">
<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.litcoffee
</a>
<a class="source" href="sourcemap.html">
sourcemap.coffee
</a>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>sourcemap.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>Hold data about mappings for one line of generated source code.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="k">class</span> <span class="nx">LineMapping</span>
<span class="nv">constructor: </span><span class="nf">(@generatedLine) -&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>columnMap keeps track of which columns we&#39;ve already mapped.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="vi">@columnMap = </span><span class="p">{}</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>columnMappings is an array of all column mappings, sorted by generated-column.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="vi">@columnMappings = </span><span class="p">[]</span>
<span class="nv">addMapping: </span><span class="nf">(generatedColumn, [sourceLine, sourceColumn], options={}) -&gt;</span>
<span class="k">if</span> <span class="nx">@columnMap</span><span class="p">[</span><span class="nx">generatedColumn</span><span class="p">]</span> <span class="o">and</span> <span class="nx">options</span><span class="p">.</span><span class="nx">noReplace</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>We already have a mapping for this column.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">return</span>
<span class="nx">@columnMap</span><span class="p">[</span><span class="nx">generatedColumn</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
<span class="nv">generatedLine: </span><span class="nx">@generatedLine</span>
<span class="nx">generatedColumn</span>
<span class="nx">sourceLine</span>
<span class="nx">sourceColumn</span>
<span class="p">}</span>
<span class="nx">@columnMappings</span><span class="p">.</span><span class="nx">push</span> <span class="nx">@columnMap</span><span class="p">[</span><span class="nx">generatedColumn</span><span class="p">]</span>
<span class="nx">@columnMappings</span><span class="p">.</span><span class="nx">sort</span> <span class="nf">(a,b) -&gt;</span> <span class="nx">a</span><span class="p">.</span><span class="nx">generatedColumn</span> <span class="o">-</span> <span class="nx">b</span><span class="p">.</span><span class="nx">generatedColumn</span>
<span class="nv">getSourcePosition: </span><span class="nf">(generatedColumn) -&gt;</span>
<span class="nv">answer = </span><span class="kc">null</span>
<span class="nv">lastColumnMapping = </span><span class="kc">null</span>
<span class="k">for</span> <span class="nx">columnMapping</span> <span class="k">in</span> <span class="nx">@columnMappings</span>
<span class="k">if</span> <span class="nx">columnMapping</span><span class="p">.</span><span class="nx">generatedColumn</span> <span class="o">&gt;</span> <span class="nx">generatedColumn</span>
<span class="k">break</span>
<span class="k">else</span>
<span class="nv">lastColumnMapping = </span><span class="nx">columnMapping</span>
<span class="k">if</span> <span class="nx">lastColumnMapping</span>
<span class="nv">answer = </span><span class="p">[</span><span class="nx">lastColumnMapping</span><span class="p">.</span><span class="nx">sourceLine</span><span class="p">,</span> <span class="nx">lastColumnMapping</span><span class="p">.</span><span class="nx">sourceColumn</span><span class="p">]</span></pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap for-h3">
<a class="pilcrow" href="#section-5">&#182;</a>
</div>
<h3>SourceMap</h3>
<p>Maps locations in a generated source file back to locations in the original source file.
</p>
<p>This is intentionally agnostic towards how a source map might be represented on disk. A
SourceMap can be converted to a &quot;v3&quot; style sourcemap with <code>#generateV3SourceMap()</code>, for example
but the SourceMap class itself knows nothing about v3 source maps.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="k">class</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">SourceMap</span>
<span class="nv">constructor: </span><span class="p">()</span> <span class="nf">-&gt;</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><code>generatedLines</code> is an array of LineMappings, one per generated line.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="vi">@generatedLines = </span><span class="p">[]</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>Adds a mapping to this SourceMap.
</p>
<p><code>sourceLocation</code> and <code>generatedLocation</code> are both [line, column] arrays.
</p>
<p>If <code>options.noReplace</code> is true, then if there is already a mapping for
the specified <code>generatedLine</code> and <code>generatedColumn</code>, this will have no effect.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">addMapping: </span><span class="nf">(sourceLocation, generatedLocation, options={}) -&gt;</span>
<span class="p">[</span><span class="nx">generatedLine</span><span class="p">,</span> <span class="nx">generatedColumn</span><span class="p">]</span> <span class="o">=</span> <span class="nx">generatedLocation</span>
<span class="nv">lineMapping = </span><span class="nx">@generatedLines</span><span class="p">[</span><span class="nx">generatedLine</span><span class="p">]</span>
<span class="k">if</span> <span class="o">not</span> <span class="nx">lineMapping</span>
<span class="nv">lineMapping = </span><span class="nx">@generatedLines</span><span class="p">[</span><span class="nx">generatedLine</span><span class="p">]</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">LineMapping</span><span class="p">(</span><span class="nx">generatedLine</span><span class="p">)</span>
<span class="nx">lineMapping</span><span class="p">.</span><span class="nx">addMapping</span> <span class="nx">generatedColumn</span><span class="p">,</span> <span class="nx">sourceLocation</span><span class="p">,</span> <span class="nx">options</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>Returns [sourceLine, sourceColumn], or null if no mapping could be found.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">getSourcePosition: </span><span class="nf">([generatedLine, generatedColumn]) -&gt;</span>
<span class="nv">answer = </span><span class="kc">null</span>
<span class="nv">lineMapping = </span><span class="nx">@generatedLines</span><span class="p">[</span><span class="nx">generatedLine</span><span class="p">]</span>
<span class="k">if</span> <span class="o">not</span> <span class="nx">lineMapping</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>TODO: Search backwards for the line?
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">else</span>
<span class="nv">answer = </span><span class="nx">lineMapping</span><span class="p">.</span><span class="nx">getSourcePosition</span> <span class="nx">generatedColumn</span>
<span class="nx">answer</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><code>fn</code> will be called once for every recorded mapping, in the order in
which they occur in the generated source. <code>fn</code> will be passed an object
with four properties: sourceLine, sourceColumn, generatedLine, and
generatedColumn.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">forEachMapping: </span><span class="nf">(fn) -&gt;</span>
<span class="k">for</span> <span class="nx">lineMapping</span><span class="p">,</span> <span class="nx">generatedLineNumber</span> <span class="k">in</span> <span class="nx">@generatedLines</span>
<span class="k">if</span> <span class="nx">lineMapping</span>
<span class="k">for</span> <span class="nx">columnMapping</span> <span class="k">in</span> <span class="nx">lineMapping</span><span class="p">.</span><span class="nx">columnMappings</span>
<span class="nx">fn</span><span class="p">(</span><span class="nx">columnMapping</span><span class="p">)</span></pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap for-h3">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<h3>generateV3SourceMap</h3>
<p>Builds a V3 source map from a SourceMap object.
Returns the generated JSON as a string.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.generateV3SourceMap = </span><span class="nf">(sourceMap, sourceFile=null, generatedFile=null) -&gt;</span>
<span class="nv">writingGeneratedLine = </span><span class="mi">0</span>
<span class="nv">lastGeneratedColumnWritten = </span><span class="mi">0</span>
<span class="nv">lastSourceLineWritten = </span><span class="mi">0</span>
<span class="nv">lastSourceColumnWritten = </span><span class="mi">0</span>
<span class="nv">needComma = </span><span class="kc">no</span>
<span class="nv">mappings = </span><span class="s">&quot;&quot;</span>
<span class="nx">sourceMap</span><span class="p">.</span><span class="nx">forEachMapping</span> <span class="nf">(mapping) -&gt;</span>
<span class="k">while</span> <span class="nx">writingGeneratedLine</span> <span class="o">&lt;</span> <span class="nx">mapping</span><span class="p">.</span><span class="nx">generatedLine</span>
<span class="nv">lastGeneratedColumnWritten = </span><span class="mi">0</span>
<span class="nv">needComma = </span><span class="kc">no</span>
<span class="nx">mappings</span> <span class="o">+=</span> <span class="s">&quot;;&quot;</span>
<span class="nx">writingGeneratedLine</span><span class="o">++</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>Write a comma if we&#39;ve already written a segment on this line.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="k">if</span> <span class="nx">needComma</span>
<span class="nx">mappings</span> <span class="o">+=</span> <span class="s">&quot;,&quot;</span>
<span class="nv">needComma = </span><span class="kc">no</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>Write the next segment.
Segments can be 1, 4, or 5 values. If just one, then it is a generated column which
doesn&#39;t match anything in the source code.
</p>
<p>Fields are all zero-based, and relative to the previous occurence unless otherwise noted:
<em> starting-column in generated source, relative to previous occurence for the current line.
</em> index into the &quot;sources&quot; list
<em> starting line in the original source
</em> starting column in the original source
* index into the &quot;names&quot; list associated with this segment.
</p>
<p>Add the generated start-column
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nx">mappings</span> <span class="o">+=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">vlqEncodeValue</span><span class="p">(</span><span class="nx">mapping</span><span class="p">.</span><span class="nx">generatedColumn</span> <span class="o">-</span> <span class="nx">lastGeneratedColumnWritten</span><span class="p">)</span>
<span class="nv">lastGeneratedColumnWritten = </span><span class="nx">mapping</span><span class="p">.</span><span class="nx">generatedColumn</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>Add the index into the sources list
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nx">mappings</span> <span class="o">+=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">vlqEncodeValue</span><span class="p">(</span><span class="mi">0</span><span class="p">)</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>Add the source start-line
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nx">mappings</span> <span class="o">+=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">vlqEncodeValue</span><span class="p">(</span><span class="nx">mapping</span><span class="p">.</span><span class="nx">sourceLine</span> <span class="o">-</span> <span class="nx">lastSourceLineWritten</span><span class="p">)</span>
<span class="nv">lastSourceLineWritten = </span><span class="nx">mapping</span><span class="p">.</span><span class="nx">sourceLine</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>Add the source start-column
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nx">mappings</span> <span class="o">+=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">vlqEncodeValue</span><span class="p">(</span><span class="nx">mapping</span><span class="p">.</span><span class="nx">sourceColumn</span> <span class="o">-</span> <span class="nx">lastSourceColumnWritten</span><span class="p">)</span>
<span class="nv">lastSourceColumnWritten = </span><span class="nx">mapping</span><span class="p">.</span><span class="nx">sourceColumn</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>TODO: Do we care about symbol names for CoffeeScript? Probably not.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">needComma = </span><span class="kc">yes</span>
<span class="nv">answer = </span><span class="p">{</span>
<span class="nv">version: </span><span class="mi">3</span>
<span class="nv">file: </span><span class="nx">generatedFile</span>
<span class="nv">sourceRoot: </span><span class="s">&quot;&quot;</span>
<span class="nv">sources: </span><span class="k">if</span> <span class="nx">sourceFile</span> <span class="k">then</span> <span class="p">[</span><span class="nx">sourceFile</span><span class="p">]</span> <span class="k">else</span> <span class="p">[]</span>
<span class="nv">names: </span><span class="p">[]</span>
<span class="nx">mappings</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span> <span class="nx">answer</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="mi">2</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>Load a SourceMap from a JSON string. Returns the SourceMap object.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.loadV3SourceMap = </span><span class="nf">(sourceMap) -&gt;</span>
<span class="nx">todo</span><span class="p">()</span></pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap for-h3">
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<h3>Base64 encoding helpers</h3>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">BASE64_CHARS = </span><span class="s">&#39;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/&#39;</span>
<span class="nv">MAX_BASE64_VALUE = </span><span class="nx">BASE64_CHARS</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span>
<span class="nv">encodeBase64Char = </span><span class="nf">(value) -&gt;</span>
<span class="k">if</span> <span class="nx">value</span> <span class="o">&gt;</span> <span class="nx">MAX_BASE64_VALUE</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s">&quot;Cannot encode value </span><span class="si">#{</span><span class="nx">value</span><span class="si">}</span><span class="s"> &gt; </span><span class="si">#{</span><span class="nx">MAX_BASE64_VALUE</span><span class="si">}</span><span class="s">&quot;</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">value</span> <span class="o">&lt;</span> <span class="mi">0</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s">&quot;Cannot encode value </span><span class="si">#{</span><span class="nx">value</span><span class="si">}</span><span class="s"> &lt; 0&quot;</span>
<span class="nx">BASE64_CHARS</span><span class="p">[</span><span class="nx">value</span><span class="p">]</span>
<span class="nv">decodeBase64Char = </span><span class="nf">(char) -&gt;</span>
<span class="nv">value = </span><span class="nx">BASE64_CHARS</span><span class="p">.</span><span class="nx">indexOf</span> <span class="nx">char</span>
<span class="k">if</span> <span class="nx">value</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s">&quot;Invalid Base 64 character: </span><span class="si">#{</span><span class="nx">char</span><span class="si">}</span><span class="s">&quot;</span>
<span class="nx">value</span></pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap for-h3">
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<h3>Base 64 VLQ encoding/decoding helpers</h3>
<p>Note that SourceMap VLQ encoding is &quot;backwards&quot;. MIDI style VLQ encoding puts the
most-significant-bit (MSB) from the original value into the MSB of the VLQ encoded value
(see <a href="http://en.wikipedia.org/wiki/File:Uintvar_coding.svg">http://en.wikipedia.org/wiki/File:Uintvar_coding.svg</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><span class="nv">VLQ_SHIFT = </span><span class="mi">5</span>
<span class="nv">VLQ_CONTINUATION_BIT = </span><span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="nx">VLQ_SHIFT</span> <span class="c1"># 0010 0000</span>
<span class="nv">VLQ_VALUE_MASK = </span><span class="nx">VLQ_CONTINUATION_BIT</span> <span class="o">-</span> <span class="mi">1</span> <span class="c1"># 0001 1111</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>Encode a value as Base 64 VLQ.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.vlqEncodeValue = </span><span class="nf">(value) -&gt;</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>Least significant bit represents the sign.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">signBit = </span><span class="k">if</span> <span class="nx">value</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="k">then</span> <span class="mi">1</span> <span class="k">else</span> <span class="mi">0</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>Next bits are the actual value
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">valueToEncode = </span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">abs</span><span class="p">(</span><span class="nx">value</span><span class="p">)</span> <span class="o">&lt;&lt;</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="nx">signBit</span>
<span class="nv">answer = </span><span class="s">&quot;&quot;</span></pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#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="k">while</span> <span class="nx">valueToEncode</span> <span class="o">||</span> <span class="o">!</span><span class="nx">answer</span>
<span class="nv">nextVlqChunk = </span><span class="nx">valueToEncode</span> <span class="o">&amp;</span> <span class="nx">VLQ_VALUE_MASK</span>
<span class="nv">valueToEncode = </span><span class="nx">valueToEncode</span> <span class="o">&gt;&gt;</span> <span class="nx">VLQ_SHIFT</span>
<span class="k">if</span> <span class="nx">valueToEncode</span>
<span class="nx">nextVlqChunk</span> <span class="o">|=</span> <span class="nx">VLQ_CONTINUATION_BIT</span>
<span class="nx">answer</span> <span class="o">+=</span> <span class="nx">encodeBase64Char</span><span class="p">(</span><span class="nx">nextVlqChunk</span><span class="p">)</span>
<span class="k">return</span> <span class="nx">answer</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>Decode a Base 64 VLQ value.
</p>
<p>Returns <code>[value, consumed]</code> where <code>value</code> is the decoded value, and <code>consumed</code> is the number
of characters consumed from <code>str</code>.
</p>
</div>
<div class="content"><div class="highlight"><pre><span class="nv">exports.vlqDecodeValue = </span><span class="nf">(str, offset=0) -&gt;</span>
<span class="nv">position = </span><span class="nx">offset</span>
<span class="nv">done = </span><span class="kc">false</span>
<span class="nv">value = </span><span class="mi">0</span>
<span class="nv">continuationShift = </span><span class="mi">0</span>
<span class="k">while</span> <span class="o">!</span><span class="nx">done</span>
<span class="nv">nextVlqChunk = </span><span class="nx">decodeBase64Char</span><span class="p">(</span><span class="nx">str</span><span class="p">[</span><span class="nx">position</span><span class="p">])</span>
<span class="nx">position</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="nv">nextChunkValue = </span><span class="nx">nextVlqChunk</span> <span class="o">&amp;</span> <span class="nx">VLQ_VALUE_MASK</span>
<span class="nx">value</span> <span class="o">+=</span> <span class="p">(</span><span class="nx">nextChunkValue</span> <span class="o">&lt;&lt;</span> <span class="nx">continuationShift</span><span class="p">)</span>
<span class="k">if</span> <span class="o">!</span><span class="p">(</span><span class="nx">nextVlqChunk</span> <span class="o">&amp;</span> <span class="nx">VLQ_CONTINUATION_BIT</span><span class="p">)</span></pre></div></div>
</li>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>We&#39;ll be done after this character.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">done = </span><span class="kc">true</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>Bits are encoded least-significant first (opposite of MIDI VLQ). Increase the
continuationShift, so the next byte will end up where it should in the value.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nx">continuationShift</span> <span class="o">+=</span> <span class="nx">VLQ_SHIFT</span>
<span class="nv">consumed = </span><span class="nx">position</span> <span class="o">-</span> <span class="nx">offset</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>Least significant bit represents the sign.
</p>
</div>
<div class="content"><div class="highlight"><pre> <span class="nv">signBit = </span><span class="nx">value</span> <span class="o">&amp;</span> <span class="mi">1</span>
<span class="nv">value = </span><span class="nx">value</span> <span class="o">&gt;&gt;</span> <span class="mi">1</span>
<span class="k">if</span> <span class="nx">signBit</span> <span class="k">then</span> <span class="nv">value = </span><span class="o">-</span><span class="nx">value</span>
<span class="k">return</span> <span class="p">[</span><span class="nx">value</span><span class="p">,</span> <span class="nx">consumed</span><span class="p">]</span>
</pre></div></div>
</li>
</ul>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,24 @@
(function(){
var volume;
if (ignition === true) {
launch();
}
if (band !== spinal_tap) {
volume = 10;
}
if (!(answer === false)) {
let_the_wild_rumpus_begin();
}
car.speed < speed_limit ? accelerate() : null;
print("My name is " + this.name);
})();
// Generated by CoffeeScript 1.6.1
var volume, winner;
if (ignition === true) {
launch();
}
if (band !== SpinalTap) {
volume = 10;
}
if (answer !== false) {
letTheWildRumpusBegin();
}
if (car.speed < limit) {
accelerate();
}
if (pick === 47 || pick === 92 || pick === 13) {
winner = true;
}
print(inspect("My name is " + this.name));

View File

@@ -1,26 +1,24 @@
(function(){
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, food, lunch, roid, roid2;
// Eat lunch.
lunch = (function() {
_a = []; _c = ['toast', 'cheese', 'wine'];
for (_b = 0, _d = _c.length; _b < _d; _b++) {
food = _c[_b];
_a.push(eat(food));
}
return _a;
}).call(this);
// Naive collision detection.
_f = asteroids;
for (_e = 0, _g = _f.length; _e < _g; _e++) {
roid = _f[_e];
_i = asteroids;
for (_h = 0, _j = _i.length; _h < _j; _h++) {
roid2 = _i[_h];
if (roid !== roid2) {
if (roid.overlaps(roid2)) {
roid.explode();
}
}
}
// Generated by CoffeeScript 1.6.1
var courses, dish, food, foods, i, _i, _j, _k, _len, _len1, _len2, _ref;
_ref = ['toast', 'cheese', 'wine'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
food = _ref[_i];
eat(food);
}
courses = ['greens', 'caviar', 'truffles', 'roast', 'cake'];
for (i = _j = 0, _len1 = courses.length; _j < _len1; i = ++_j) {
dish = courses[i];
menu(i + 1, dish);
}
foods = ['broccoli', 'spinach', 'chocolate'];
for (_k = 0, _len2 = foods.length; _k < _len2; _k++) {
food = foods[_k];
if (food !== 'chocolate') {
eat(food);
}
})();
}

View File

@@ -1,5 +0,0 @@
(function(){
var difficulty, greeting;
greeting = "Hello CoffeeScript";
difficulty = 0.5;
})();

View File

@@ -1,13 +0,0 @@
(function(){
var get_source, url;
var __slice = Array.prototype.slice, __bind = function(func, obj, args) {
return function() {
return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);
};
};
url = "documentation/coffee/binding.coffee";
get_source = __bind(jQuery.get, jQuery, [url]);
get_source(function(response) {
return alert(response);
});
})();

View File

@@ -0,0 +1,7 @@
// Generated by CoffeeScript 1.6.1
/*
CoffeeScript Compiler v1.6.1
Released under the MIT License
*/

View File

@@ -1,13 +1,14 @@
(function(){
task('test', 'run each of the unit tests', function() {
var _a, _b, _c, _d, test;
_a = []; _c = test_files;
for (_b = 0, _d = _c.length; _b < _d; _b++) {
test = _c[_b];
_a.push(fs.readFile(test, function(err, code) {
return eval(coffee.compile(code));
}));
}
return _a;
});
})();
// Generated by CoffeeScript 1.6.1
var fs;
fs = require('fs');
option('-o', '--output [DIR]', 'directory for compiled code');
task('build:parser', 'rebuild the Jison parser', function(options) {
var code, dir;
require('jison');
code = require('./lib/grammar').parser.generate();
dir = options.output || 'lib';
return fs.writeFile("" + dir + "/parser.js", code);
});

View File

@@ -1,36 +1,60 @@
(function(){
var Animal, Horse, Snake, sam, tom;
var __extends = function(child, parent) {
var ctor = function(){ };
ctor.prototype = parent.prototype;
child.__superClass__ = parent.prototype;
child.prototype = new ctor();
child.prototype.constructor = child;
};
Animal = function Animal() { };
Animal.prototype.move = function move(meters) {
return alert(this.name + " moved " + meters + "m.");
};
Snake = function Snake(name) {
// Generated by CoffeeScript 1.6.1
var Animal, Horse, Snake, sam, tom,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Animal = (function() {
function Animal(name) {
this.name = name;
return this;
}
Animal.prototype.move = function(meters) {
return alert(this.name + (" moved " + meters + "m."));
};
__extends(Snake, Animal);
Snake.prototype.move = function move() {
alert("Slithering...");
return Snake.__superClass__.move.call(this, 5);
};
Horse = function Horse(name) {
this.name = name;
return this;
};
__extends(Horse, Animal);
Horse.prototype.move = function move() {
alert("Galloping...");
return Horse.__superClass__.move.call(this, 45);
};
sam = new Snake("Sammy the Python");
tom = new Horse("Tommy the Palomino");
sam.move();
tom.move();
return Animal;
})();
Snake = (function(_super) {
__extends(Snake, _super);
function Snake() {
return Snake.__super__.constructor.apply(this, arguments);
}
Snake.prototype.move = function() {
alert("Slithering...");
return Snake.__super__.move.call(this, 5);
};
return Snake;
})(Animal);
Horse = (function(_super) {
__extends(Horse, _super);
function Horse() {
return Horse.__super__.constructor.apply(this, arguments);
}
Horse.prototype.move = function() {
alert("Galloping...");
return Horse.__super__.move.call(this, 45);
};
return Horse;
})(Animal);
sam = new Snake("Sammy the Python");
tom = new Horse("Tommy the Palomino");
sam.move();
tom.move();

View File

@@ -1,5 +1,6 @@
(function(){
var cholesterol, healthy;
cholesterol = 127;
healthy = (200 > cholesterol) && (cholesterol > 60);
})();
// Generated by CoffeeScript 1.6.1
var cholesterol, healthy;
cholesterol = 127;
healthy = (200 > cholesterol && cholesterol > 60);

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