vulcan 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vulcan/cli.rb +20 -10
- data/lib/vulcan/version.rb +1 -1
- data/server/Procfile +1 -1
- data/server/bin/web +10 -0
- data/server/lib/cloudant.coffee +20 -0
- data/server/lib/logger.coffee +17 -0
- data/server/lib/on.coffee +10 -0
- data/server/lib/spawner.coffee +65 -0
- data/server/node_modules/coffee-script/CNAME +1 -0
- data/server/node_modules/coffee-script/LICENSE +22 -0
- data/server/node_modules/coffee-script/README +51 -0
- data/server/node_modules/coffee-script/Rakefile +78 -0
- data/server/node_modules/coffee-script/bin/cake +7 -0
- data/server/node_modules/coffee-script/bin/coffee +7 -0
- data/server/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/server/node_modules/coffee-script/lib/coffee-script/browser.js +92 -0
- data/server/node_modules/coffee-script/lib/coffee-script/cake.js +111 -0
- data/server/node_modules/coffee-script/lib/coffee-script/coffee-script.js +167 -0
- data/server/node_modules/coffee-script/lib/coffee-script/command.js +500 -0
- data/server/node_modules/coffee-script/lib/coffee-script/grammar.js +606 -0
- data/server/node_modules/coffee-script/lib/coffee-script/helpers.js +77 -0
- data/server/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
- data/server/node_modules/coffee-script/lib/coffee-script/lexer.js +788 -0
- data/server/node_modules/coffee-script/lib/coffee-script/nodes.js +2986 -0
- data/server/node_modules/coffee-script/lib/coffee-script/optparse.js +138 -0
- data/server/node_modules/coffee-script/lib/coffee-script/parser.js +683 -0
- data/server/node_modules/coffee-script/lib/coffee-script/repl.js +261 -0
- data/server/node_modules/coffee-script/lib/coffee-script/rewriter.js +349 -0
- data/server/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
- data/server/node_modules/coffee-script/package.json +55 -0
- data/server/node_modules/connect-form/History.md +0 -6
- data/server/node_modules/connect-form/lib/connect-form.js +2 -4
- data/server/node_modules/connect-form/node_modules/formidable/Readme.md +64 -36
- data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +5 -1
- data/server/node_modules/connect-form/node_modules/formidable/package.json +20 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/common.js +5 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/funkyfilename.txt +1 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +1 -1
- data/server/node_modules/connect-form/node_modules/formidable/test/{slow → integration}/test-fixtures.js +38 -33
- data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/run.js +1 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/unit/test-incoming-form.js +63 -0
- data/server/node_modules/connect-form/package.json +27 -5
- data/server/node_modules/cradle/README.md +10 -10
- data/server/node_modules/cradle/lib/cradle.js +117 -523
- data/server/node_modules/cradle/lib/cradle/database/attachments.js +120 -0
- data/server/node_modules/cradle/lib/cradle/database/changes.js +56 -0
- data/server/node_modules/cradle/lib/cradle/database/documents.js +215 -0
- data/server/node_modules/cradle/lib/cradle/database/index.js +65 -0
- data/server/node_modules/cradle/lib/cradle/database/views.js +125 -0
- data/server/node_modules/cradle/node_modules/follow/LICENSE +202 -0
- data/server/node_modules/cradle/node_modules/follow/README.md +164 -0
- data/server/node_modules/cradle/node_modules/follow/Rakefile +54 -0
- data/server/node_modules/cradle/node_modules/follow/api.js +35 -0
- data/server/node_modules/cradle/node_modules/follow/browser/eventemitter2.js +453 -0
- data/server/node_modules/cradle/node_modules/follow/browser/export.js +78 -0
- data/server/node_modules/cradle/node_modules/follow/browser/index.html +14 -0
- data/server/node_modules/cradle/node_modules/follow/browser/jquery-1.6.1.min.js +18 -0
- data/server/node_modules/cradle/node_modules/follow/browser/log4js.js +46 -0
- data/server/node_modules/cradle/node_modules/follow/browser/main.js +92 -0
- data/server/node_modules/cradle/node_modules/follow/browser/querystring.js +28 -0
- data/server/node_modules/cradle/node_modules/follow/browser/request.jquery.js +237 -0
- data/server/node_modules/cradle/node_modules/follow/browser/require.js +33 -0
- data/server/node_modules/cradle/node_modules/follow/browser/util.js +28 -0
- data/server/node_modules/cradle/node_modules/follow/cli.js +101 -0
- data/server/node_modules/cradle/node_modules/follow/lib/feed.js +556 -0
- data/server/node_modules/cradle/node_modules/follow/lib/index.js +66 -0
- data/server/node_modules/cradle/node_modules/follow/lib/stream.js +305 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/LICENSE +55 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/README.md +285 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/main.js +618 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/mimetypes.js +146 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/oauth.js +34 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/package.json +42 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/googledoodle.png +0 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/run.sh +6 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/server.js +57 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-body.js +90 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookie.js +29 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookiejar.js +90 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-errors.js +30 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-oauth.js +109 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-pipes.js +167 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-proxy.js +39 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-timeout.js +87 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/uuid.js +19 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/index.js +55 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/jar.js +72 -0
- data/server/node_modules/cradle/node_modules/follow/package.json +45 -0
- data/server/node_modules/cradle/node_modules/follow/test/couch.js +153 -0
- data/server/node_modules/cradle/node_modules/follow/test/follow.js +136 -0
- data/server/node_modules/cradle/node_modules/follow/test/issues.js +178 -0
- data/server/node_modules/cradle/node_modules/follow/test/issues/10.js +24 -0
- data/server/node_modules/cradle/node_modules/follow/test/stream.js +493 -0
- data/server/node_modules/cradle/node_modules/request/LICENSE +55 -0
- data/server/node_modules/cradle/node_modules/request/README.md +287 -0
- data/server/node_modules/cradle/node_modules/request/forever.js +103 -0
- data/server/node_modules/cradle/node_modules/request/main.js +913 -0
- data/server/node_modules/cradle/node_modules/request/mimetypes.js +152 -0
- data/server/node_modules/cradle/node_modules/request/oauth.js +34 -0
- data/server/node_modules/cradle/node_modules/request/package.json +42 -0
- data/server/node_modules/cradle/node_modules/request/tests/googledoodle.png +0 -0
- data/server/node_modules/cradle/node_modules/request/tests/run.js +38 -0
- data/server/node_modules/cradle/node_modules/request/tests/server.js +82 -0
- data/server/node_modules/cradle/node_modules/request/tests/squid.conf +77 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.cnf +20 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crl +0 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crt +17 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.csr +13 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.key +18 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.srl +1 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.cnf +19 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.crt +16 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.csr +11 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.js +28 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.key +9 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/npm-ca.crt +16 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/test.crt +15 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/test.key +15 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-body.js +95 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-cookie.js +29 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-cookiejar.js +90 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-defaults.js +68 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-errors.js +37 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-headers.js +52 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-httpModule.js +94 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-https-strict.js +97 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-https.js +86 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-oauth.js +117 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-params.js +92 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-pipes.js +202 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-proxy.js +39 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-qs.js +28 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-redirect.js +154 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-timeout.js +87 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-toJSON.js +14 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-tunnel.js +61 -0
- data/server/node_modules/cradle/node_modules/request/tunnel.js +229 -0
- data/server/node_modules/cradle/node_modules/request/uuid.js +19 -0
- data/server/node_modules/cradle/node_modules/request/vendor/cookie/index.js +65 -0
- data/server/node_modules/cradle/node_modules/request/vendor/cookie/jar.js +72 -0
- data/server/node_modules/cradle/node_modules/vargs/package.json +33 -10
- data/server/node_modules/cradle/package.json +50 -12
- data/server/node_modules/cradle/test/cache-test.js +1 -4
- data/server/node_modules/cradle/test/connection-test.js +179 -0
- data/server/node_modules/cradle/test/database-attachment-test.js +344 -0
- data/server/node_modules/cradle/test/database-cache-test.js +132 -0
- data/server/node_modules/cradle/test/database-test.js +219 -0
- data/server/node_modules/cradle/test/database-view-test.js +141 -0
- data/server/node_modules/cradle/test/fixtures/databases.json +28 -1
- data/server/node_modules/cradle/test/helpers/seed.js +14 -5
- data/server/node_modules/cradle/test/response-test.js +1 -1
- data/server/node_modules/express/History.md +16 -0
- data/server/node_modules/express/bin/express +7 -6
- data/server/node_modules/express/lib-cov/application.js +510 -0
- data/server/node_modules/express/lib-cov/express.js +65 -0
- data/server/node_modules/express/lib-cov/middleware.js +54 -0
- data/server/node_modules/express/lib-cov/request.js +225 -0
- data/server/node_modules/express/lib-cov/response.js +611 -0
- data/server/node_modules/express/lib-cov/router/collection.js +40 -0
- data/server/node_modules/express/lib-cov/router/index.js +515 -0
- data/server/node_modules/express/lib-cov/router/methods.js +9 -0
- data/server/node_modules/express/lib-cov/router/route.js +68 -0
- data/server/node_modules/express/lib-cov/utils.js +151 -0
- data/server/node_modules/express/lib-cov/view.js +81 -0
- data/server/node_modules/express/lib/express.js +1 -1
- data/server/node_modules/express/lib/http.js +1 -2
- data/server/node_modules/express/lib/request.js +2 -2
- data/server/node_modules/express/lib/router/methods.js +10 -1
- data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
- data/server/node_modules/express/node_modules/connect/lib/http.js +3 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +0 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +1 -2
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +42 -25
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +1 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +14 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
- data/server/node_modules/express/node_modules/connect/package.json +35 -7
- data/server/node_modules/express/node_modules/mime/package.json +30 -8
- data/server/node_modules/express/node_modules/mkdirp/README.markdown +35 -2
- data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +1 -1
- data/server/node_modules/express/node_modules/mkdirp/index.js +72 -13
- data/server/node_modules/express/node_modules/mkdirp/package.json +39 -21
- data/server/node_modules/express/node_modules/mkdirp/test/chmod.js +38 -0
- data/server/node_modules/express/node_modules/mkdirp/test/clobber.js +37 -0
- data/server/node_modules/express/node_modules/mkdirp/test/perm.js +32 -0
- data/server/node_modules/express/node_modules/mkdirp/test/perm_sync.js +39 -0
- data/server/node_modules/express/node_modules/mkdirp/test/sync.js +27 -0
- data/server/node_modules/express/node_modules/mkdirp/test/umask.js +28 -0
- data/server/node_modules/express/node_modules/mkdirp/test/umask_sync.js +27 -0
- data/server/node_modules/express/node_modules/qs/History.md +10 -0
- data/server/node_modules/express/node_modules/qs/Readme.md +9 -2
- data/server/node_modules/express/node_modules/qs/examples.js +3 -0
- data/server/node_modules/express/node_modules/qs/lib/querystring.js +8 -6
- data/server/node_modules/express/node_modules/qs/package.json +26 -8
- data/server/node_modules/express/node_modules/qs/test/parse.js +13 -1
- data/server/node_modules/express/node_modules/qs/test/stringify.js +45 -37
- data/server/node_modules/express/package.json +55 -16
- data/server/node_modules/express/test.js +41 -0
- data/server/node_modules/knox/package.json +26 -4
- data/server/node_modules/node-uuid/package.json +40 -11
- data/server/node_modules/node-uuid/test/test.js +1 -1
- data/server/node_modules/nodemon/README.md +120 -0
- data/server/node_modules/nodemon/nodemon.js +518 -0
- data/server/node_modules/nodemon/nodemonignore.example +11 -0
- data/server/node_modules/nodemon/package.json +49 -0
- data/server/node_modules/restler/README.md +144 -94
- data/server/node_modules/restler/lib/multipartform.js +2 -0
- data/server/node_modules/restler/lib/restler.js +218 -61
- data/server/node_modules/restler/package.json +35 -8
- data/server/node_modules/restler/test/all.js +6 -1
- data/server/node_modules/restler/test/restler.js +624 -118
- data/server/package.json +14 -10
- data/server/web.coffee +64 -0
- data/server/web.js +15 -3
- metadata +170 -57
- data/server/index.js +0 -14
- data/server/node_modules/connect-form/LICENSE +0 -22
- data/server/node_modules/connect-form/index.js +0 -100
- data/server/node_modules/connect-form/node_modules/formidable/test/fast/test-incoming-form.js +0 -45
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/cradle/Makefile +0 -10
- data/server/node_modules/cradle/test/cradle-test.js +0 -650
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/express/node_modules/connect/test.js +0 -52
- data/server/node_modules/express/testing/foo/app.js +0 -35
- data/server/node_modules/express/testing/foo/package.json +0 -9
- data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
- data/server/node_modules/express/testing/foo/routes/index.js +0 -10
- data/server/node_modules/express/testing/foo/views/index.jade +0 -2
- data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
- data/server/node_modules/express/testing/index.js +0 -43
- data/server/node_modules/express/testing/public/test.txt +0 -2971
- data/server/node_modules/express/testing/views/page.html +0 -1
- data/server/node_modules/express/testing/views/page.jade +0 -3
- data/server/node_modules/express/testing/views/test.md +0 -1
- data/server/node_modules/express/testing/views/user/index.jade +0 -1
- data/server/node_modules/express/testing/views/user/list.jade +0 -1
- data/server/node_modules/knox/lib/knox/mime/index.js +0 -308
- data/server/node_modules/knox/lib/knox/mime/test.js +0 -59
- data/server/node_modules/node-uuid/test/benchmark-native +0 -0
- data/server/node_modules/on/index.js +0 -13
- data/server/node_modules/restler/test/test_helper.js +0 -163
- data/server/node_modules/spawner/index.js +0 -106
@@ -0,0 +1,261 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
2
|
+
(function() {
|
3
|
+
var ACCESSOR, CoffeeScript, Module, REPL_PROMPT, REPL_PROMPT_CONTINUATION, REPL_PROMPT_MULTILINE, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, enableColours, error, getCompletions, inspect, multilineMode, pipedInput, readline, repl, run, stdin, stdout;
|
4
|
+
|
5
|
+
stdin = process.openStdin();
|
6
|
+
|
7
|
+
stdout = process.stdout;
|
8
|
+
|
9
|
+
CoffeeScript = require('./coffee-script');
|
10
|
+
|
11
|
+
readline = require('readline');
|
12
|
+
|
13
|
+
inspect = require('util').inspect;
|
14
|
+
|
15
|
+
Script = require('vm').Script;
|
16
|
+
|
17
|
+
Module = require('module');
|
18
|
+
|
19
|
+
REPL_PROMPT = 'coffee> ';
|
20
|
+
|
21
|
+
REPL_PROMPT_MULTILINE = '------> ';
|
22
|
+
|
23
|
+
REPL_PROMPT_CONTINUATION = '......> ';
|
24
|
+
|
25
|
+
enableColours = false;
|
26
|
+
|
27
|
+
if (process.platform !== 'win32') {
|
28
|
+
enableColours = !process.env.NODE_DISABLE_COLORS;
|
29
|
+
}
|
30
|
+
|
31
|
+
error = function(err) {
|
32
|
+
return stdout.write((err.stack || err.toString()) + '\n');
|
33
|
+
};
|
34
|
+
|
35
|
+
ACCESSOR = /\s*([\w\.]+)(?:\.(\w*))$/;
|
36
|
+
|
37
|
+
SIMPLEVAR = /(\w+)$/i;
|
38
|
+
|
39
|
+
autocomplete = function(text) {
|
40
|
+
return completeAttribute(text) || completeVariable(text) || [[], text];
|
41
|
+
};
|
42
|
+
|
43
|
+
completeAttribute = function(text) {
|
44
|
+
var all, completions, key, match, obj, possibilities, prefix, val;
|
45
|
+
if (match = text.match(ACCESSOR)) {
|
46
|
+
all = match[0], obj = match[1], prefix = match[2];
|
47
|
+
try {
|
48
|
+
val = Script.runInThisContext(obj);
|
49
|
+
} catch (error) {
|
50
|
+
return;
|
51
|
+
}
|
52
|
+
val = Object(val);
|
53
|
+
possibilities = Object.getOwnPropertyNames(val);
|
54
|
+
for (key in val) {
|
55
|
+
if (~possibilities.indexOf(val)) {
|
56
|
+
possibilities.push(key);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
completions = getCompletions(prefix, possibilities);
|
60
|
+
return [completions, prefix];
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
completeVariable = function(text) {
|
65
|
+
var completions, free, keywords, possibilities, r, vars, _ref;
|
66
|
+
free = (_ref = text.match(SIMPLEVAR)) != null ? _ref[1] : void 0;
|
67
|
+
if (text === "") {
|
68
|
+
free = "";
|
69
|
+
}
|
70
|
+
if (free != null) {
|
71
|
+
vars = Script.runInThisContext('Object.getOwnPropertyNames(Object(this))');
|
72
|
+
keywords = (function() {
|
73
|
+
var _i, _len, _ref1, _results;
|
74
|
+
_ref1 = CoffeeScript.RESERVED;
|
75
|
+
_results = [];
|
76
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
77
|
+
r = _ref1[_i];
|
78
|
+
if (r.slice(0, 2) !== '__') {
|
79
|
+
_results.push(r);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return _results;
|
83
|
+
})();
|
84
|
+
possibilities = vars.concat(keywords);
|
85
|
+
completions = getCompletions(free, possibilities);
|
86
|
+
return [completions, free];
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
getCompletions = function(prefix, candidates) {
|
91
|
+
var el, _i, _len, _results;
|
92
|
+
_results = [];
|
93
|
+
for (_i = 0, _len = candidates.length; _i < _len; _i++) {
|
94
|
+
el = candidates[_i];
|
95
|
+
if (el.indexOf(prefix) === 0) {
|
96
|
+
_results.push(el);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
return _results;
|
100
|
+
};
|
101
|
+
|
102
|
+
process.on('uncaughtException', error);
|
103
|
+
|
104
|
+
backlog = '';
|
105
|
+
|
106
|
+
run = function(buffer) {
|
107
|
+
var code, returnValue, _;
|
108
|
+
buffer = buffer.replace(/(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, "$1$2$3");
|
109
|
+
buffer = buffer.replace(/[\r\n]+$/, "");
|
110
|
+
if (multilineMode) {
|
111
|
+
backlog += "" + buffer + "\n";
|
112
|
+
repl.setPrompt(REPL_PROMPT_CONTINUATION);
|
113
|
+
repl.prompt();
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
if (!buffer.toString().trim() && !backlog) {
|
117
|
+
repl.prompt();
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
code = backlog += buffer;
|
121
|
+
if (code[code.length - 1] === '\\') {
|
122
|
+
backlog = "" + backlog.slice(0, -1) + "\n";
|
123
|
+
repl.setPrompt(REPL_PROMPT_CONTINUATION);
|
124
|
+
repl.prompt();
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
repl.setPrompt(REPL_PROMPT);
|
128
|
+
backlog = '';
|
129
|
+
try {
|
130
|
+
_ = global._;
|
131
|
+
returnValue = CoffeeScript["eval"]("_=(" + code + "\n)", {
|
132
|
+
filename: 'repl',
|
133
|
+
modulename: 'repl'
|
134
|
+
});
|
135
|
+
if (returnValue === void 0) {
|
136
|
+
global._ = _;
|
137
|
+
}
|
138
|
+
repl.output.write("" + (inspect(returnValue, false, 2, enableColours)) + "\n");
|
139
|
+
} catch (err) {
|
140
|
+
error(err);
|
141
|
+
}
|
142
|
+
return repl.prompt();
|
143
|
+
};
|
144
|
+
|
145
|
+
if (stdin.readable) {
|
146
|
+
pipedInput = '';
|
147
|
+
repl = {
|
148
|
+
prompt: function() {
|
149
|
+
return stdout.write(this._prompt);
|
150
|
+
},
|
151
|
+
setPrompt: function(p) {
|
152
|
+
return this._prompt = p;
|
153
|
+
},
|
154
|
+
input: stdin,
|
155
|
+
output: stdout,
|
156
|
+
on: function() {}
|
157
|
+
};
|
158
|
+
stdin.on('data', function(chunk) {
|
159
|
+
var line, lines, _i, _len, _ref;
|
160
|
+
pipedInput += chunk;
|
161
|
+
if (!/\n/.test(pipedInput)) {
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
lines = pipedInput.split("\n");
|
165
|
+
pipedInput = lines[lines.length - 1];
|
166
|
+
_ref = lines.slice(0, -1);
|
167
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
168
|
+
line = _ref[_i];
|
169
|
+
if (!(line)) {
|
170
|
+
continue;
|
171
|
+
}
|
172
|
+
stdout.write("" + line + "\n");
|
173
|
+
run(line);
|
174
|
+
}
|
175
|
+
});
|
176
|
+
stdin.on('end', function() {
|
177
|
+
var line, _i, _len, _ref;
|
178
|
+
_ref = pipedInput.trim().split("\n");
|
179
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
180
|
+
line = _ref[_i];
|
181
|
+
if (!(line)) {
|
182
|
+
continue;
|
183
|
+
}
|
184
|
+
stdout.write("" + line + "\n");
|
185
|
+
run(line);
|
186
|
+
}
|
187
|
+
stdout.write('\n');
|
188
|
+
return process.exit(0);
|
189
|
+
});
|
190
|
+
} else {
|
191
|
+
if (readline.createInterface.length < 3) {
|
192
|
+
repl = readline.createInterface(stdin, autocomplete);
|
193
|
+
stdin.on('data', function(buffer) {
|
194
|
+
return repl.write(buffer);
|
195
|
+
});
|
196
|
+
} else {
|
197
|
+
repl = readline.createInterface(stdin, stdout, autocomplete);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
multilineMode = false;
|
202
|
+
|
203
|
+
repl.input.on('keypress', function(char, key) {
|
204
|
+
var cursorPos, newPrompt;
|
205
|
+
if (!(key && key.ctrl && !key.meta && !key.shift && key.name === 'v')) {
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
cursorPos = repl.cursor;
|
209
|
+
repl.output.cursorTo(0);
|
210
|
+
repl.output.clearLine(1);
|
211
|
+
multilineMode = !multilineMode;
|
212
|
+
if (!multilineMode && backlog) {
|
213
|
+
repl._line();
|
214
|
+
}
|
215
|
+
backlog = '';
|
216
|
+
repl.setPrompt((newPrompt = multilineMode ? REPL_PROMPT_MULTILINE : REPL_PROMPT));
|
217
|
+
repl.prompt();
|
218
|
+
return repl.output.cursorTo(newPrompt.length + (repl.cursor = cursorPos));
|
219
|
+
});
|
220
|
+
|
221
|
+
repl.input.on('keypress', function(char, key) {
|
222
|
+
if (!(multilineMode && repl.line)) {
|
223
|
+
return;
|
224
|
+
}
|
225
|
+
if (!(key && key.ctrl && !key.meta && !key.shift && key.name === 'd')) {
|
226
|
+
return;
|
227
|
+
}
|
228
|
+
multilineMode = false;
|
229
|
+
return repl._line();
|
230
|
+
});
|
231
|
+
|
232
|
+
repl.on('attemptClose', function() {
|
233
|
+
if (multilineMode) {
|
234
|
+
multilineMode = false;
|
235
|
+
repl.output.cursorTo(0);
|
236
|
+
repl.output.clearLine(1);
|
237
|
+
repl._onLine(repl.line);
|
238
|
+
return;
|
239
|
+
}
|
240
|
+
if (backlog) {
|
241
|
+
backlog = '';
|
242
|
+
repl.output.write('\n');
|
243
|
+
repl.setPrompt(REPL_PROMPT);
|
244
|
+
return repl.prompt();
|
245
|
+
} else {
|
246
|
+
return repl.close();
|
247
|
+
}
|
248
|
+
});
|
249
|
+
|
250
|
+
repl.on('close', function() {
|
251
|
+
repl.output.write('\n');
|
252
|
+
return repl.input.destroy();
|
253
|
+
});
|
254
|
+
|
255
|
+
repl.on('line', run);
|
256
|
+
|
257
|
+
repl.setPrompt(REPL_PROMPT);
|
258
|
+
|
259
|
+
repl.prompt();
|
260
|
+
|
261
|
+
}).call(this);
|
@@ -0,0 +1,349 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
2
|
+
(function() {
|
3
|
+
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref,
|
4
|
+
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
5
|
+
__slice = [].slice;
|
6
|
+
|
7
|
+
exports.Rewriter = (function() {
|
8
|
+
|
9
|
+
function Rewriter() {}
|
10
|
+
|
11
|
+
Rewriter.prototype.rewrite = function(tokens) {
|
12
|
+
this.tokens = tokens;
|
13
|
+
this.removeLeadingNewlines();
|
14
|
+
this.removeMidExpressionNewlines();
|
15
|
+
this.closeOpenCalls();
|
16
|
+
this.closeOpenIndexes();
|
17
|
+
this.addImplicitIndentation();
|
18
|
+
this.tagPostfixConditionals();
|
19
|
+
this.addImplicitBraces();
|
20
|
+
this.addImplicitParentheses();
|
21
|
+
return this.tokens;
|
22
|
+
};
|
23
|
+
|
24
|
+
Rewriter.prototype.scanTokens = function(block) {
|
25
|
+
var i, token, tokens;
|
26
|
+
tokens = this.tokens;
|
27
|
+
i = 0;
|
28
|
+
while (token = tokens[i]) {
|
29
|
+
i += block.call(this, token, i, tokens);
|
30
|
+
}
|
31
|
+
return true;
|
32
|
+
};
|
33
|
+
|
34
|
+
Rewriter.prototype.detectEnd = function(i, condition, action) {
|
35
|
+
var levels, token, tokens, _ref, _ref1;
|
36
|
+
tokens = this.tokens;
|
37
|
+
levels = 0;
|
38
|
+
while (token = tokens[i]) {
|
39
|
+
if (levels === 0 && condition.call(this, token, i)) {
|
40
|
+
return action.call(this, token, i);
|
41
|
+
}
|
42
|
+
if (!token || levels < 0) {
|
43
|
+
return action.call(this, token, i - 1);
|
44
|
+
}
|
45
|
+
if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
46
|
+
levels += 1;
|
47
|
+
} else if (_ref1 = token[0], __indexOf.call(EXPRESSION_END, _ref1) >= 0) {
|
48
|
+
levels -= 1;
|
49
|
+
}
|
50
|
+
i += 1;
|
51
|
+
}
|
52
|
+
return i - 1;
|
53
|
+
};
|
54
|
+
|
55
|
+
Rewriter.prototype.removeLeadingNewlines = function() {
|
56
|
+
var i, tag, _i, _len, _ref;
|
57
|
+
_ref = this.tokens;
|
58
|
+
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
59
|
+
tag = _ref[i][0];
|
60
|
+
if (tag !== 'TERMINATOR') {
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
if (i) {
|
65
|
+
return this.tokens.splice(0, i);
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
Rewriter.prototype.removeMidExpressionNewlines = function() {
|
70
|
+
return this.scanTokens(function(token, i, tokens) {
|
71
|
+
var _ref;
|
72
|
+
if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) {
|
73
|
+
return 1;
|
74
|
+
}
|
75
|
+
tokens.splice(i, 1);
|
76
|
+
return 0;
|
77
|
+
});
|
78
|
+
};
|
79
|
+
|
80
|
+
Rewriter.prototype.closeOpenCalls = function() {
|
81
|
+
var action, condition;
|
82
|
+
condition = function(token, i) {
|
83
|
+
var _ref;
|
84
|
+
return ((_ref = token[0]) === ')' || _ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')';
|
85
|
+
};
|
86
|
+
action = function(token, i) {
|
87
|
+
return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END';
|
88
|
+
};
|
89
|
+
return this.scanTokens(function(token, i) {
|
90
|
+
if (token[0] === 'CALL_START') {
|
91
|
+
this.detectEnd(i + 1, condition, action);
|
92
|
+
}
|
93
|
+
return 1;
|
94
|
+
});
|
95
|
+
};
|
96
|
+
|
97
|
+
Rewriter.prototype.closeOpenIndexes = function() {
|
98
|
+
var action, condition;
|
99
|
+
condition = function(token, i) {
|
100
|
+
var _ref;
|
101
|
+
return (_ref = token[0]) === ']' || _ref === 'INDEX_END';
|
102
|
+
};
|
103
|
+
action = function(token, i) {
|
104
|
+
return token[0] = 'INDEX_END';
|
105
|
+
};
|
106
|
+
return this.scanTokens(function(token, i) {
|
107
|
+
if (token[0] === 'INDEX_START') {
|
108
|
+
this.detectEnd(i + 1, condition, action);
|
109
|
+
}
|
110
|
+
return 1;
|
111
|
+
});
|
112
|
+
};
|
113
|
+
|
114
|
+
Rewriter.prototype.addImplicitBraces = function() {
|
115
|
+
var action, condition, sameLine, stack, start, startIndent, startIndex, startsLine;
|
116
|
+
stack = [];
|
117
|
+
start = null;
|
118
|
+
startsLine = null;
|
119
|
+
sameLine = true;
|
120
|
+
startIndent = 0;
|
121
|
+
startIndex = 0;
|
122
|
+
condition = function(token, i) {
|
123
|
+
var one, tag, three, two, _ref, _ref1;
|
124
|
+
_ref = this.tokens.slice(i + 1, (i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
|
125
|
+
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
|
126
|
+
return false;
|
127
|
+
}
|
128
|
+
tag = token[0];
|
129
|
+
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
|
130
|
+
sameLine = false;
|
131
|
+
}
|
132
|
+
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine && !(i - startIndex === 1))) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT'));
|
133
|
+
};
|
134
|
+
action = function(token, i) {
|
135
|
+
var tok;
|
136
|
+
tok = this.generate('}', '}', token[2]);
|
137
|
+
return this.tokens.splice(i, 0, tok);
|
138
|
+
};
|
139
|
+
return this.scanTokens(function(token, i, tokens) {
|
140
|
+
var ago, idx, prevTag, tag, tok, value, _ref, _ref1;
|
141
|
+
if (_ref = (tag = token[0]), __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
142
|
+
stack.push([(tag === 'INDENT' && this.tag(i - 1) === '{' ? '{' : tag), i]);
|
143
|
+
return 1;
|
144
|
+
}
|
145
|
+
if (__indexOf.call(EXPRESSION_END, tag) >= 0) {
|
146
|
+
start = stack.pop();
|
147
|
+
return 1;
|
148
|
+
}
|
149
|
+
if (!(tag === ':' && ((ago = this.tag(i - 2)) === ':' || ((_ref1 = stack[stack.length - 1]) != null ? _ref1[0] : void 0) !== '{'))) {
|
150
|
+
return 1;
|
151
|
+
}
|
152
|
+
sameLine = true;
|
153
|
+
startIndex = i + 1;
|
154
|
+
stack.push(['{']);
|
155
|
+
idx = ago === '@' ? i - 2 : i - 1;
|
156
|
+
while (this.tag(idx - 2) === 'HERECOMMENT') {
|
157
|
+
idx -= 2;
|
158
|
+
}
|
159
|
+
prevTag = this.tag(idx - 1);
|
160
|
+
startsLine = !prevTag || (__indexOf.call(LINEBREAKS, prevTag) >= 0);
|
161
|
+
value = new String('{');
|
162
|
+
value.generated = true;
|
163
|
+
tok = this.generate('{', value, token[2]);
|
164
|
+
tokens.splice(idx, 0, tok);
|
165
|
+
this.detectEnd(i + 2, condition, action);
|
166
|
+
return 2;
|
167
|
+
});
|
168
|
+
};
|
169
|
+
|
170
|
+
Rewriter.prototype.addImplicitParentheses = function() {
|
171
|
+
var action, condition, noCall, seenControl, seenSingle;
|
172
|
+
noCall = seenSingle = seenControl = false;
|
173
|
+
condition = function(token, i) {
|
174
|
+
var post, tag, _ref, _ref1;
|
175
|
+
tag = token[0];
|
176
|
+
if (!seenSingle && token.fromThen) {
|
177
|
+
return true;
|
178
|
+
}
|
179
|
+
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>' || tag === 'CLASS') {
|
180
|
+
seenSingle = true;
|
181
|
+
}
|
182
|
+
if (tag === 'IF' || tag === 'ELSE' || tag === 'SWITCH' || tag === 'TRY' || tag === '=') {
|
183
|
+
seenControl = true;
|
184
|
+
}
|
185
|
+
if ((tag === '.' || tag === '?.' || tag === '::') && this.tag(i - 1) === 'OUTDENT') {
|
186
|
+
return true;
|
187
|
+
}
|
188
|
+
return !token.generated && this.tag(i - 1) !== ',' && (__indexOf.call(IMPLICIT_END, tag) >= 0 || (tag === 'INDENT' && !seenControl)) && (tag !== 'INDENT' || (((_ref = this.tag(i - 2)) !== 'CLASS' && _ref !== 'EXTENDS') && (_ref1 = this.tag(i - 1), __indexOf.call(IMPLICIT_BLOCK, _ref1) < 0) && !((post = this.tokens[i + 1]) && post.generated && post[0] === '{')));
|
189
|
+
};
|
190
|
+
action = function(token, i) {
|
191
|
+
return this.tokens.splice(i, 0, this.generate('CALL_END', ')', token[2]));
|
192
|
+
};
|
193
|
+
return this.scanTokens(function(token, i, tokens) {
|
194
|
+
var callObject, current, next, prev, tag, _ref, _ref1, _ref2;
|
195
|
+
tag = token[0];
|
196
|
+
if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') {
|
197
|
+
noCall = true;
|
198
|
+
}
|
199
|
+
_ref = tokens.slice(i - 1, (i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
200
|
+
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0);
|
201
|
+
seenSingle = false;
|
202
|
+
seenControl = false;
|
203
|
+
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
|
204
|
+
noCall = false;
|
205
|
+
}
|
206
|
+
if (prev && !prev.spaced && tag === '?') {
|
207
|
+
token.call = true;
|
208
|
+
}
|
209
|
+
if (token.fromThen) {
|
210
|
+
return 1;
|
211
|
+
}
|
212
|
+
if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) {
|
213
|
+
return 1;
|
214
|
+
}
|
215
|
+
tokens.splice(i, 0, this.generate('CALL_START', '(', token[2]));
|
216
|
+
this.detectEnd(i + 1, condition, action);
|
217
|
+
if (prev[0] === '?') {
|
218
|
+
prev[0] = 'FUNC_EXIST';
|
219
|
+
}
|
220
|
+
return 2;
|
221
|
+
});
|
222
|
+
};
|
223
|
+
|
224
|
+
Rewriter.prototype.addImplicitIndentation = function() {
|
225
|
+
var action, condition, indent, outdent, starter;
|
226
|
+
starter = indent = outdent = null;
|
227
|
+
condition = function(token, i) {
|
228
|
+
var _ref;
|
229
|
+
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN'));
|
230
|
+
};
|
231
|
+
action = function(token, i) {
|
232
|
+
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
|
233
|
+
};
|
234
|
+
return this.scanTokens(function(token, i, tokens) {
|
235
|
+
var tag, _ref, _ref1;
|
236
|
+
tag = token[0];
|
237
|
+
if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') {
|
238
|
+
tokens.splice(i, 1);
|
239
|
+
return 0;
|
240
|
+
}
|
241
|
+
if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') {
|
242
|
+
tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation(token))));
|
243
|
+
return 2;
|
244
|
+
}
|
245
|
+
if (tag === 'CATCH' && ((_ref = this.tag(i + 2)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) {
|
246
|
+
tokens.splice.apply(tokens, [i + 2, 0].concat(__slice.call(this.indentation(token))));
|
247
|
+
return 4;
|
248
|
+
}
|
249
|
+
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) {
|
250
|
+
starter = tag;
|
251
|
+
_ref1 = this.indentation(token, true), indent = _ref1[0], outdent = _ref1[1];
|
252
|
+
if (starter === 'THEN') {
|
253
|
+
indent.fromThen = true;
|
254
|
+
}
|
255
|
+
tokens.splice(i + 1, 0, indent);
|
256
|
+
this.detectEnd(i + 2, condition, action);
|
257
|
+
if (tag === 'THEN') {
|
258
|
+
tokens.splice(i, 1);
|
259
|
+
}
|
260
|
+
return 1;
|
261
|
+
}
|
262
|
+
return 1;
|
263
|
+
});
|
264
|
+
};
|
265
|
+
|
266
|
+
Rewriter.prototype.tagPostfixConditionals = function() {
|
267
|
+
var action, condition, original;
|
268
|
+
original = null;
|
269
|
+
condition = function(token, i) {
|
270
|
+
var _ref;
|
271
|
+
return (_ref = token[0]) === 'TERMINATOR' || _ref === 'INDENT';
|
272
|
+
};
|
273
|
+
action = function(token, i) {
|
274
|
+
if (token[0] !== 'INDENT' || (token.generated && !token.fromThen)) {
|
275
|
+
return original[0] = 'POST_' + original[0];
|
276
|
+
}
|
277
|
+
};
|
278
|
+
return this.scanTokens(function(token, i) {
|
279
|
+
if (token[0] !== 'IF') {
|
280
|
+
return 1;
|
281
|
+
}
|
282
|
+
original = token;
|
283
|
+
this.detectEnd(i + 1, condition, action);
|
284
|
+
return 1;
|
285
|
+
});
|
286
|
+
};
|
287
|
+
|
288
|
+
Rewriter.prototype.indentation = function(token, implicit) {
|
289
|
+
var indent, outdent;
|
290
|
+
if (implicit == null) {
|
291
|
+
implicit = false;
|
292
|
+
}
|
293
|
+
indent = ['INDENT', 2, token[2]];
|
294
|
+
outdent = ['OUTDENT', 2, token[2]];
|
295
|
+
if (implicit) {
|
296
|
+
indent.generated = outdent.generated = true;
|
297
|
+
}
|
298
|
+
return [indent, outdent];
|
299
|
+
};
|
300
|
+
|
301
|
+
Rewriter.prototype.generate = function(tag, value, line) {
|
302
|
+
var tok;
|
303
|
+
tok = [tag, value, line];
|
304
|
+
tok.generated = true;
|
305
|
+
return tok;
|
306
|
+
};
|
307
|
+
|
308
|
+
Rewriter.prototype.tag = function(i) {
|
309
|
+
var _ref;
|
310
|
+
return (_ref = this.tokens[i]) != null ? _ref[0] : void 0;
|
311
|
+
};
|
312
|
+
|
313
|
+
return Rewriter;
|
314
|
+
|
315
|
+
})();
|
316
|
+
|
317
|
+
BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['CALL_START', 'CALL_END'], ['PARAM_START', 'PARAM_END'], ['INDEX_START', 'INDEX_END']];
|
318
|
+
|
319
|
+
exports.INVERSES = INVERSES = {};
|
320
|
+
|
321
|
+
EXPRESSION_START = [];
|
322
|
+
|
323
|
+
EXPRESSION_END = [];
|
324
|
+
|
325
|
+
for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; _i++) {
|
326
|
+
_ref = BALANCED_PAIRS[_i], left = _ref[0], rite = _ref[1];
|
327
|
+
EXPRESSION_START.push(INVERSES[rite] = left);
|
328
|
+
EXPRESSION_END.push(INVERSES[left] = rite);
|
329
|
+
}
|
330
|
+
|
331
|
+
EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END);
|
332
|
+
|
333
|
+
IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS'];
|
334
|
+
|
335
|
+
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++'];
|
336
|
+
|
337
|
+
IMPLICIT_UNSPACED_CALL = ['+', '-'];
|
338
|
+
|
339
|
+
IMPLICIT_BLOCK = ['->', '=>', '{', '[', ','];
|
340
|
+
|
341
|
+
IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR'];
|
342
|
+
|
343
|
+
SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN'];
|
344
|
+
|
345
|
+
SINGLE_CLOSERS = ['TERMINATOR', 'CATCH', 'FINALLY', 'ELSE', 'OUTDENT', 'LEADING_WHEN'];
|
346
|
+
|
347
|
+
LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT'];
|
348
|
+
|
349
|
+
}).call(this);
|