spade-packager 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.gitmodules +6 -0
- data/bin/spadepkg +8 -0
- data/lib/libgems_ext.rb +8 -0
- data/lib/libgems_ext/config_file.rb +33 -0
- data/lib/libgems_ext/dependency_installer.rb +150 -0
- data/lib/libgems_ext/installer.rb +39 -0
- data/lib/libgems_ext/libgems.rb +39 -0
- data/lib/libgems_ext/spec_fetcher.rb +11 -0
- data/lib/spade-packager.rb +1 -0
- data/lib/spade/packager.rb +18 -0
- data/lib/spade/packager/cli.rb +9 -0
- data/lib/spade/packager/cli/base.rb +196 -0
- data/lib/spade/packager/cli/owner.rb +46 -0
- data/lib/spade/packager/cli/project_generator.rb +117 -0
- data/lib/spade/packager/credentials.rb +38 -0
- data/lib/spade/packager/local.rb +50 -0
- data/lib/spade/packager/package.rb +160 -0
- data/lib/spade/packager/remote.rb +98 -0
- data/lib/spade/packager/repository.rb +18 -0
- data/lib/spade/packager/version.rb +5 -0
- data/packages/coffee-script/.gitignore +8 -0
- data/packages/coffee-script/.npmignore +11 -0
- data/packages/coffee-script/Cakefile +229 -0
- data/packages/coffee-script/LICENSE +22 -0
- data/packages/coffee-script/README +47 -0
- data/packages/coffee-script/Rakefile +78 -0
- data/packages/coffee-script/bin/cake +7 -0
- data/packages/coffee-script/bin/coffee +7 -0
- data/packages/coffee-script/documentation/coffee/aliases.coffee +11 -0
- data/packages/coffee-script/documentation/coffee/array_comprehensions.coffee +2 -0
- data/packages/coffee-script/documentation/coffee/block_comment.coffee +6 -0
- data/packages/coffee-script/documentation/coffee/cake_tasks.coffee +9 -0
- data/packages/coffee-script/documentation/coffee/classes.coffee +25 -0
- data/packages/coffee-script/documentation/coffee/comparisons.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/conditionals.coffee +13 -0
- data/packages/coffee-script/documentation/coffee/default_args.coffee +8 -0
- data/packages/coffee-script/documentation/coffee/do.coffee +4 -0
- data/packages/coffee-script/documentation/coffee/embedded.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/existence.coffee +10 -0
- data/packages/coffee-script/documentation/coffee/expressions.coffee +9 -0
- data/packages/coffee-script/documentation/coffee/expressions_assignment.coffee +3 -0
- data/packages/coffee-script/documentation/coffee/expressions_comprehension.coffee +3 -0
- data/packages/coffee-script/documentation/coffee/expressions_try.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/fat_arrow.coffee +6 -0
- data/packages/coffee-script/documentation/coffee/functions.coffee +2 -0
- data/packages/coffee-script/documentation/coffee/heredocs.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/heregexes.coffee +11 -0
- data/packages/coffee-script/documentation/coffee/interpolation.coffee +6 -0
- data/packages/coffee-script/documentation/coffee/multiple_return_values.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/object_comprehensions.coffee +4 -0
- data/packages/coffee-script/documentation/coffee/object_extraction.coffee +13 -0
- data/packages/coffee-script/documentation/coffee/objects_and_arrays.coffee +19 -0
- data/packages/coffee-script/documentation/coffee/objects_reserved.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/overview.coffee +28 -0
- data/packages/coffee-script/documentation/coffee/parallel_assignment.coffee +6 -0
- data/packages/coffee-script/documentation/coffee/patterns_and_splats.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/prototypes.coffee +3 -0
- data/packages/coffee-script/documentation/coffee/range_comprehensions.coffee +2 -0
- data/packages/coffee-script/documentation/coffee/scope.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/slices.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/soaks.coffee +1 -0
- data/packages/coffee-script/documentation/coffee/splats.coffee +27 -0
- data/packages/coffee-script/documentation/coffee/splices.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/strings.coffee +8 -0
- data/packages/coffee-script/documentation/coffee/switch.coffee +10 -0
- data/packages/coffee-script/documentation/coffee/try.coffee +8 -0
- data/packages/coffee-script/documentation/coffee/while.coffee +10 -0
- data/packages/coffee-script/documentation/css/docs.css +374 -0
- data/packages/coffee-script/documentation/css/idle.css +64 -0
- data/packages/coffee-script/documentation/docs/browser.html +25 -0
- data/packages/coffee-script/documentation/docs/cake.html +43 -0
- data/packages/coffee-script/documentation/docs/coffee-script.html +51 -0
- data/packages/coffee-script/documentation/docs/command.html +161 -0
- data/packages/coffee-script/documentation/docs/docco.css +186 -0
- data/packages/coffee-script/documentation/docs/grammar.html +399 -0
- data/packages/coffee-script/documentation/docs/helpers.html +31 -0
- data/packages/coffee-script/documentation/docs/index.html +3 -0
- data/packages/coffee-script/documentation/docs/lexer.html +490 -0
- data/packages/coffee-script/documentation/docs/nodes.html +1338 -0
- data/packages/coffee-script/documentation/docs/optparse.html +78 -0
- data/packages/coffee-script/documentation/docs/repl.html +24 -0
- data/packages/coffee-script/documentation/docs/rewriter.html +251 -0
- data/packages/coffee-script/documentation/docs/scope.html +54 -0
- data/packages/coffee-script/documentation/docs/underscore.html +295 -0
- data/packages/coffee-script/documentation/images/background.png +0 -0
- data/packages/coffee-script/documentation/images/banding.png +0 -0
- data/packages/coffee-script/documentation/images/button_bg.png +0 -0
- data/packages/coffee-script/documentation/images/button_bg_dark.gif +0 -0
- data/packages/coffee-script/documentation/images/button_bg_green.gif +0 -0
- data/packages/coffee-script/documentation/images/favicon.ico +0 -0
- data/packages/coffee-script/documentation/images/logo.png +0 -0
- data/packages/coffee-script/documentation/images/screenshadow.png +0 -0
- data/packages/coffee-script/documentation/index.html.erb +1607 -0
- data/packages/coffee-script/documentation/js/aliases.js +17 -0
- data/packages/coffee-script/documentation/js/array_comprehensions.js +6 -0
- data/packages/coffee-script/documentation/js/block_comment.js +4 -0
- data/packages/coffee-script/documentation/js/cake_tasks.js +10 -0
- data/packages/coffee-script/documentation/js/classes.js +44 -0
- data/packages/coffee-script/documentation/js/comparisons.js +3 -0
- data/packages/coffee-script/documentation/js/conditionals.js +12 -0
- data/packages/coffee-script/documentation/js/default_args.js +7 -0
- data/packages/coffee-script/documentation/js/do.js +10 -0
- data/packages/coffee-script/documentation/js/embedded.js +4 -0
- data/packages/coffee-script/documentation/js/existence.js +6 -0
- data/packages/coffee-script/documentation/js/expressions.js +15 -0
- data/packages/coffee-script/documentation/js/expressions_assignment.js +2 -0
- data/packages/coffee-script/documentation/js/expressions_comprehension.js +9 -0
- data/packages/coffee-script/documentation/js/expressions_try.js +7 -0
- data/packages/coffee-script/documentation/js/fat_arrow.js +9 -0
- data/packages/coffee-script/documentation/js/functions.js +7 -0
- data/packages/coffee-script/documentation/js/heredocs.js +2 -0
- data/packages/coffee-script/documentation/js/heregexes.js +2 -0
- data/packages/coffee-script/documentation/js/interpolation.js +4 -0
- data/packages/coffee-script/documentation/js/multiple_return_values.js +5 -0
- data/packages/coffee-script/documentation/js/object_comprehensions.js +15 -0
- data/packages/coffee-script/documentation/js/object_extraction.js +10 -0
- data/packages/coffee-script/documentation/js/objects_and_arrays.js +17 -0
- data/packages/coffee-script/documentation/js/objects_reserved.js +4 -0
- data/packages/coffee-script/documentation/js/overview.js +35 -0
- data/packages/coffee-script/documentation/js/parallel_assignment.js +4 -0
- data/packages/coffee-script/documentation/js/patterns_and_splats.js +4 -0
- data/packages/coffee-script/documentation/js/prototypes.js +3 -0
- data/packages/coffee-script/documentation/js/range_comprehensions.js +9 -0
- data/packages/coffee-script/documentation/js/scope.js +8 -0
- data/packages/coffee-script/documentation/js/slices.js +4 -0
- data/packages/coffee-script/documentation/js/soaks.js +2 -0
- data/packages/coffee-script/documentation/js/splats.js +15 -0
- data/packages/coffee-script/documentation/js/splices.js +3 -0
- data/packages/coffee-script/documentation/js/strings.js +2 -0
- data/packages/coffee-script/documentation/js/switch.js +23 -0
- data/packages/coffee-script/documentation/js/try.js +8 -0
- data/packages/coffee-script/documentation/js/while.js +18 -0
- data/packages/coffee-script/documentation/vendor/jquery-1.4.2.js +6240 -0
- data/packages/coffee-script/examples/beautiful_code/binary_search.coffee +16 -0
- data/packages/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +13 -0
- data/packages/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +34 -0
- data/packages/coffee-script/examples/blocks.coffee +54 -0
- data/packages/coffee-script/examples/code.coffee +167 -0
- data/packages/coffee-script/examples/computer_science/README +4 -0
- data/packages/coffee-script/examples/computer_science/binary_search.coffee +25 -0
- data/packages/coffee-script/examples/computer_science/bubble_sort.coffee +11 -0
- data/packages/coffee-script/examples/computer_science/linked_list.coffee +108 -0
- data/packages/coffee-script/examples/computer_science/luhn_algorithm.coffee +36 -0
- data/packages/coffee-script/examples/computer_science/merge_sort.coffee +19 -0
- data/packages/coffee-script/examples/computer_science/selection_sort.coffee +23 -0
- data/packages/coffee-script/examples/poignant.coffee +181 -0
- data/packages/coffee-script/examples/potion.coffee +206 -0
- data/packages/coffee-script/examples/underscore.coffee +682 -0
- data/packages/coffee-script/examples/web_server.coffee +12 -0
- data/packages/coffee-script/extras/EXTRAS +7 -0
- data/packages/coffee-script/extras/coffee-script.js +8 -0
- data/packages/coffee-script/extras/jsl.conf +44 -0
- data/packages/coffee-script/index.html +2515 -0
- data/packages/coffee-script/lib/browser.js +52 -0
- data/packages/coffee-script/lib/cake.js +76 -0
- data/packages/coffee-script/lib/coffee-script.js +82 -0
- data/packages/coffee-script/lib/command.js +263 -0
- data/packages/coffee-script/lib/grammar.js +581 -0
- data/packages/coffee-script/lib/helpers.js +66 -0
- data/packages/coffee-script/lib/index.js +8 -0
- data/packages/coffee-script/lib/lexer.js +633 -0
- data/packages/coffee-script/lib/nodes.js +2165 -0
- data/packages/coffee-script/lib/optparse.js +111 -0
- data/packages/coffee-script/lib/parser.js +649 -0
- data/packages/coffee-script/lib/repl.js +42 -0
- data/packages/coffee-script/lib/rewriter.js +353 -0
- data/packages/coffee-script/lib/scope.js +120 -0
- data/packages/coffee-script/lib/spade-format.js +45 -0
- data/packages/coffee-script/package.json +26 -0
- data/packages/coffee-script/src/browser.coffee +43 -0
- data/packages/coffee-script/src/cake.coffee +69 -0
- data/packages/coffee-script/src/coffee-script.coffee +92 -0
- data/packages/coffee-script/src/command.coffee +214 -0
- data/packages/coffee-script/src/grammar.coffee +590 -0
- data/packages/coffee-script/src/helpers.coffee +56 -0
- data/packages/coffee-script/src/index.coffee +2 -0
- data/packages/coffee-script/src/lexer.coffee +653 -0
- data/packages/coffee-script/src/nodes.coffee +1754 -0
- data/packages/coffee-script/src/optparse.coffee +99 -0
- data/packages/coffee-script/src/repl.coffee +42 -0
- data/packages/coffee-script/src/rewriter.coffee +326 -0
- data/packages/coffee-script/src/scope.coffee +94 -0
- data/packages/coffee-script/test/arguments.coffee +127 -0
- data/packages/coffee-script/test/assignment.coffee +98 -0
- data/packages/coffee-script/test/break.coffee +18 -0
- data/packages/coffee-script/test/comments.coffee +201 -0
- data/packages/coffee-script/test/conditionals.coffee +181 -0
- data/packages/coffee-script/test/exception_handling.coffee +90 -0
- data/packages/coffee-script/test/helpers.coffee +96 -0
- data/packages/coffee-script/test/importing.coffee +18 -0
- data/packages/coffee-script/test/operators.coffee +225 -0
- data/packages/coffee-script/test/ranges_slices_and_splices.coffee +186 -0
- data/packages/coffee-script/test/regular_expressions.coffee +56 -0
- data/packages/coffee-script/test/test.html +123 -0
- data/packages/coffee-script/test/test_chaining.coffee +77 -0
- data/packages/coffee-script/test/test_classes.coffee +372 -0
- data/packages/coffee-script/test/test_compilation.coffee +26 -0
- data/packages/coffee-script/test/test_comprehensions.coffee +318 -0
- data/packages/coffee-script/test/test_existence.coffee +165 -0
- data/packages/coffee-script/test/test_functions.coffee +379 -0
- data/packages/coffee-script/test/test_heredocs.coffee +111 -0
- data/packages/coffee-script/test/test_literals.coffee +270 -0
- data/packages/coffee-script/test/test_option_parser.coffee +27 -0
- data/packages/coffee-script/test/test_pattern_matching.coffee +162 -0
- data/packages/coffee-script/test/test_returns.coffee +63 -0
- data/packages/coffee-script/test/test_splats.coffee +102 -0
- data/packages/coffee-script/test/test_strings.coffee +118 -0
- data/packages/coffee-script/test/test_switch.coffee +103 -0
- data/packages/coffee-script/test/test_while.coffee +71 -0
- data/packages/ivory/LICENSE.txt +1 -0
- data/packages/ivory/README.md +19 -0
- data/packages/ivory/lib/buffer.js +111 -0
- data/packages/ivory/lib/events.js +137 -0
- data/packages/ivory/lib/fs.js +266 -0
- data/packages/ivory/lib/main.js +13 -0
- data/packages/ivory/lib/path.js +158 -0
- data/packages/ivory/lib/ruby/buffer.rb +145 -0
- data/packages/ivory/lib/ruby/constants.rb +585 -0
- data/packages/ivory/lib/ruby/events.rb +32 -0
- data/packages/ivory/lib/ruby/fs.rb +245 -0
- data/packages/ivory/lib/ruby/process.rb +28 -0
- data/packages/ivory/lib/stream.js +115 -0
- data/packages/ivory/lib/util.js +414 -0
- data/packages/ivory/package.json +11 -0
- data/packages/ivory/spade-boot.js +78 -0
- data/packages/jquery/main.js +7179 -0
- data/packages/jquery/package.json +10 -0
- data/packages/json/lib/main.js +14 -0
- data/packages/json/package.json +8 -0
- data/packages/lproj/README.md +77 -0
- data/packages/lproj/examples/demo-app/en.lproj/localized.strings +2 -0
- data/packages/lproj/examples/demo-app/fr.lproj/localized.strings +3 -0
- data/packages/lproj/examples/demo-app/index.html +8 -0
- data/packages/lproj/examples/demo-app/lib/main.js +7 -0
- data/packages/lproj/examples/demo-app/package.json +9 -0
- data/packages/lproj/lib/main.js +78 -0
- data/packages/lproj/lib/strings-format.js +6 -0
- data/packages/lproj/package.json +9 -0
- data/packages/optparse/README.md +161 -0
- data/packages/optparse/TODO +1 -0
- data/packages/optparse/examples/browser-test.html +75 -0
- data/packages/optparse/examples/nodejs-test.js +90 -0
- data/packages/optparse/lib/optparse.js +309 -0
- data/packages/optparse/package.json +13 -0
- data/packages/optparse/seed.yml +5 -0
- data/packages/text/lib/main.js +8 -0
- data/packages/text/package.json +9 -0
- data/packages/web-file/README.md +7 -0
- data/packages/web-file/lib/errors.js +32 -0
- data/packages/web-file/lib/file-reader.js +10 -0
- data/packages/web-file/lib/file-system.js +234 -0
- data/packages/web-file/lib/file-writer.js +10 -0
- data/packages/web-file/lib/file.js +9 -0
- data/packages/web-file/lib/main.js +34 -0
- data/packages/web-file/lib/platform.js +25 -0
- data/packages/web-file/lib/ruby/file.rb +252 -0
- data/packages/web-file/lib/ruby/file_reader.rb +69 -0
- data/packages/web-file/lib/ruby/file_system.rb +134 -0
- data/packages/web-file/lib/ruby/file_writer.rb +78 -0
- data/packages/web-file/package.json +12 -0
- data/packages/web-typed-array/README.md +7 -0
- data/packages/web-typed-array/lib/array-buffer-view.js +9 -0
- data/packages/web-typed-array/lib/array-buffer.js +7 -0
- data/packages/web-typed-array/lib/main.js +33 -0
- data/packages/web-typed-array/lib/platform.js +20 -0
- data/packages/web-typed-array/lib/ruby/array_buffer.rb +31 -0
- data/packages/web-typed-array/lib/ruby/array_buffer_view.rb +130 -0
- data/packages/web-typed-array/lib/ruby/typed_array.rb +133 -0
- data/packages/web-typed-array/lib/typed-array.js +26 -0
- data/packages/web-typed-array/package.json +9 -0
- data/spade-packager.gemspec +39 -0
- data/spec/cli/build_spec.rb +57 -0
- data/spec/cli/install_spec.rb +119 -0
- data/spec/cli/installed_spec.rb +55 -0
- data/spec/cli/list_spec.rb +74 -0
- data/spec/cli/login_spec.rb +75 -0
- data/spec/cli/new_spec.rb +5 -0
- data/spec/cli/owner_spec.rb +114 -0
- data/spec/cli/push_spec.rb +73 -0
- data/spec/cli/uninstall_spec.rb +58 -0
- data/spec/cli/unpack_spec.rb +72 -0
- data/spec/cli/unyank_spec.rb +73 -0
- data/spec/cli/yank_spec.rb +73 -0
- data/spec/credentials_spec.rb +23 -0
- data/spec/fixtures/badrake-0.8.7.spd +0 -0
- data/spec/fixtures/builder-3.0.0.spd +0 -0
- data/spec/fixtures/bundler-1.1.pre.spd +0 -0
- data/spec/fixtures/coffee-1.0.1.pre.spd +0 -0
- data/spec/fixtures/core-test-0.4.3.spd +0 -0
- data/spec/fixtures/core-test/bin/cot +3 -0
- data/spec/fixtures/core-test/lib/main.js +1 -0
- data/spec/fixtures/core-test/resources/runner.css +0 -0
- data/spec/fixtures/core-test/tests/test.js +1 -0
- data/spec/fixtures/highline-1.6.1.spd +0 -0
- data/spec/fixtures/ivory-0.0.1.spd +0 -0
- data/spec/fixtures/jquery-1.4.3.spd +0 -0
- data/spec/fixtures/optparse-1.0.1.spd +0 -0
- data/spec/fixtures/package.json +30 -0
- data/spec/fixtures/rake-0.8.6.spd +0 -0
- data/spec/fixtures/rake-0.8.7.spd +0 -0
- data/spec/gauntlet_spec.rb +27 -0
- data/spec/package_spec.rb +267 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/cli.rb +103 -0
- data/spec/support/fake.rb +48 -0
- data/spec/support/fake_gem_server.rb +67 -0
- data/spec/support/fake_gemcutter.rb +50 -0
- data/spec/support/matchers.rb +32 -0
- data/spec/support/path.rb +61 -0
- data/templates/project/LICENSE +19 -0
- data/templates/project/README.md +21 -0
- data/templates/project/lib/main.js +9 -0
- data/templates/project/project.json +31 -0
- data/templates/project/tests/main-test.js +8 -0
- metadata +484 -0
@@ -0,0 +1,581 @@
|
|
1
|
+
(function() {
|
2
|
+
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
|
3
|
+
Parser = require('jison').Parser;
|
4
|
+
unwrap = /^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/;
|
5
|
+
o = function(patternString, action, options) {
|
6
|
+
var match;
|
7
|
+
patternString = patternString.replace(/\s{2,}/g, ' ');
|
8
|
+
if (!action) {
|
9
|
+
return [patternString, '$$ = $1;', options];
|
10
|
+
}
|
11
|
+
action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())";
|
12
|
+
action = action.replace(/\bnew /g, '$&yy.');
|
13
|
+
action = action.replace(/\b(?:Expressions\.wrap|extend)\b/g, 'yy.$&');
|
14
|
+
return [patternString, "$$ = " + action + ";", options];
|
15
|
+
};
|
16
|
+
grammar = {
|
17
|
+
Root: [
|
18
|
+
o('', function() {
|
19
|
+
return new Expressions;
|
20
|
+
}), o('Body'), o('Block TERMINATOR')
|
21
|
+
],
|
22
|
+
Body: [
|
23
|
+
o('Line', function() {
|
24
|
+
return Expressions.wrap([$1]);
|
25
|
+
}), o('Body TERMINATOR Line', function() {
|
26
|
+
return $1.push($3);
|
27
|
+
}), o('Body TERMINATOR')
|
28
|
+
],
|
29
|
+
Line: [o('Expression'), o('Statement')],
|
30
|
+
Statement: [
|
31
|
+
o('Return'), o('Throw'), o('Comment'), o('STATEMENT', function() {
|
32
|
+
return new Literal($1);
|
33
|
+
})
|
34
|
+
],
|
35
|
+
Expression: [o('Value'), o('Invocation'), o('Code'), o('Operation'), o('Assign'), o('If'), o('Try'), o('While'), o('For'), o('Switch'), o('Class')],
|
36
|
+
Block: [
|
37
|
+
o('INDENT OUTDENT', function() {
|
38
|
+
return new Expressions;
|
39
|
+
}), o('INDENT Body OUTDENT', function() {
|
40
|
+
return $2;
|
41
|
+
})
|
42
|
+
],
|
43
|
+
Identifier: [
|
44
|
+
o('IDENTIFIER', function() {
|
45
|
+
return new Literal($1);
|
46
|
+
})
|
47
|
+
],
|
48
|
+
AlphaNumeric: [
|
49
|
+
o('NUMBER', function() {
|
50
|
+
return new Literal($1);
|
51
|
+
}), o('STRING', function() {
|
52
|
+
return new Literal($1);
|
53
|
+
})
|
54
|
+
],
|
55
|
+
Literal: [
|
56
|
+
o('AlphaNumeric'), o('JS', function() {
|
57
|
+
return new Literal($1);
|
58
|
+
}), o('REGEX', function() {
|
59
|
+
return new Literal($1);
|
60
|
+
}), o('BOOL', function() {
|
61
|
+
return new Literal($1 === 'undefined' ? 'void 0' : $1);
|
62
|
+
})
|
63
|
+
],
|
64
|
+
Assign: [
|
65
|
+
o('Assignable = Expression', function() {
|
66
|
+
return new Assign($1, $3);
|
67
|
+
}), o('Assignable = INDENT Expression OUTDENT', function() {
|
68
|
+
return new Assign($1, $4);
|
69
|
+
})
|
70
|
+
],
|
71
|
+
AssignObj: [
|
72
|
+
o('ObjAssignable', function() {
|
73
|
+
return new Value($1);
|
74
|
+
}), o('ObjAssignable : Expression', function() {
|
75
|
+
return new Assign(new Value($1), $3, 'object');
|
76
|
+
}), o('ObjAssignable :\
|
77
|
+
INDENT Expression OUTDENT', function() {
|
78
|
+
return new Assign(new Value($1), $4, 'object');
|
79
|
+
}), o('Comment')
|
80
|
+
],
|
81
|
+
ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')],
|
82
|
+
Return: [
|
83
|
+
o('RETURN Expression', function() {
|
84
|
+
return new Return($2);
|
85
|
+
}), o('RETURN', function() {
|
86
|
+
return new Return;
|
87
|
+
})
|
88
|
+
],
|
89
|
+
Comment: [
|
90
|
+
o('HERECOMMENT', function() {
|
91
|
+
return new Comment($1);
|
92
|
+
})
|
93
|
+
],
|
94
|
+
Code: [
|
95
|
+
o('PARAM_START ParamList PARAM_END FuncGlyph Block', function() {
|
96
|
+
return new Code($2, $5, $4);
|
97
|
+
}), o('FuncGlyph Block', function() {
|
98
|
+
return new Code([], $2, $1);
|
99
|
+
})
|
100
|
+
],
|
101
|
+
FuncGlyph: [
|
102
|
+
o('->', function() {
|
103
|
+
return 'func';
|
104
|
+
}), o('=>', function() {
|
105
|
+
return 'boundfunc';
|
106
|
+
})
|
107
|
+
],
|
108
|
+
OptComma: [o(''), o(',')],
|
109
|
+
ParamList: [
|
110
|
+
o('', function() {
|
111
|
+
return [];
|
112
|
+
}), o('Param', function() {
|
113
|
+
return [$1];
|
114
|
+
}), o('ParamList , Param', function() {
|
115
|
+
return $1.concat($3);
|
116
|
+
})
|
117
|
+
],
|
118
|
+
Param: [
|
119
|
+
o('ParamVar', function() {
|
120
|
+
return new Param($1);
|
121
|
+
}), o('ParamVar ...', function() {
|
122
|
+
return new Param($1, null, true);
|
123
|
+
}), o('ParamVar = Expression', function() {
|
124
|
+
return new Param($1, $3);
|
125
|
+
})
|
126
|
+
],
|
127
|
+
ParamVar: [o('Identifier'), o('ThisProperty'), o('Array'), o('Object')],
|
128
|
+
Splat: [
|
129
|
+
o('Expression ...', function() {
|
130
|
+
return new Splat($1);
|
131
|
+
})
|
132
|
+
],
|
133
|
+
SimpleAssignable: [
|
134
|
+
o('Identifier', function() {
|
135
|
+
return new Value($1);
|
136
|
+
}), o('Value Accessor', function() {
|
137
|
+
return $1.push($2);
|
138
|
+
}), o('Invocation Accessor', function() {
|
139
|
+
return new Value($1, [$2]);
|
140
|
+
}), o('ThisProperty')
|
141
|
+
],
|
142
|
+
Assignable: [
|
143
|
+
o('SimpleAssignable'), o('Array', function() {
|
144
|
+
return new Value($1);
|
145
|
+
}), o('Object', function() {
|
146
|
+
return new Value($1);
|
147
|
+
})
|
148
|
+
],
|
149
|
+
Value: [
|
150
|
+
o('Assignable'), o('Literal', function() {
|
151
|
+
return new Value($1);
|
152
|
+
}), o('Parenthetical', function() {
|
153
|
+
return new Value($1);
|
154
|
+
}), o('Range', function() {
|
155
|
+
return new Value($1);
|
156
|
+
}), o('This')
|
157
|
+
],
|
158
|
+
Accessor: [
|
159
|
+
o('. Identifier', function() {
|
160
|
+
return new Access($2);
|
161
|
+
}), o('?. Identifier', function() {
|
162
|
+
return new Access($2, 'soak');
|
163
|
+
}), o(':: Identifier', function() {
|
164
|
+
return new Access($2, 'proto');
|
165
|
+
}), o('::', function() {
|
166
|
+
return new Access(new Literal('prototype'));
|
167
|
+
}), o('Index'), o('Slice', function() {
|
168
|
+
return new Slice($1);
|
169
|
+
})
|
170
|
+
],
|
171
|
+
Index: [
|
172
|
+
o('INDEX_START Expression INDEX_END', function() {
|
173
|
+
return new Index($2);
|
174
|
+
}), o('INDEX_SOAK Index', function() {
|
175
|
+
return extend($2, {
|
176
|
+
soak: true
|
177
|
+
});
|
178
|
+
}), o('INDEX_PROTO Index', function() {
|
179
|
+
return extend($2, {
|
180
|
+
proto: true
|
181
|
+
});
|
182
|
+
})
|
183
|
+
],
|
184
|
+
Object: [
|
185
|
+
o('{ AssignList OptComma }', function() {
|
186
|
+
return new Obj($2, $1.generated);
|
187
|
+
})
|
188
|
+
],
|
189
|
+
AssignList: [
|
190
|
+
o('', function() {
|
191
|
+
return [];
|
192
|
+
}), o('AssignObj', function() {
|
193
|
+
return [$1];
|
194
|
+
}), o('AssignList , AssignObj', function() {
|
195
|
+
return $1.concat($3);
|
196
|
+
}), o('AssignList OptComma TERMINATOR AssignObj', function() {
|
197
|
+
return $1.concat($4);
|
198
|
+
}), o('AssignList OptComma INDENT AssignList OptComma OUTDENT', function() {
|
199
|
+
return $1.concat($4);
|
200
|
+
})
|
201
|
+
],
|
202
|
+
Class: [
|
203
|
+
o('CLASS', function() {
|
204
|
+
return new Class;
|
205
|
+
}), o('CLASS Block', function() {
|
206
|
+
return new Class(null, null, $2);
|
207
|
+
}), o('CLASS EXTENDS Value', function() {
|
208
|
+
return new Class(null, $3);
|
209
|
+
}), o('CLASS EXTENDS Value Block', function() {
|
210
|
+
return new Class(null, $3, $4);
|
211
|
+
}), o('CLASS SimpleAssignable', function() {
|
212
|
+
return new Class($2);
|
213
|
+
}), o('CLASS SimpleAssignable Block', function() {
|
214
|
+
return new Class($2, null, $3);
|
215
|
+
}), o('CLASS SimpleAssignable EXTENDS Value', function() {
|
216
|
+
return new Class($2, $4);
|
217
|
+
}), o('CLASS SimpleAssignable EXTENDS Value Block', function() {
|
218
|
+
return new Class($2, $4, $5);
|
219
|
+
})
|
220
|
+
],
|
221
|
+
Invocation: [
|
222
|
+
o('Value OptFuncExist Arguments', function() {
|
223
|
+
return new Call($1, $3, $2);
|
224
|
+
}), o('Invocation OptFuncExist Arguments', function() {
|
225
|
+
return new Call($1, $3, $2);
|
226
|
+
}), o('SUPER', function() {
|
227
|
+
return new Call('super', [new Splat(new Literal('arguments'))]);
|
228
|
+
}), o('SUPER Arguments', function() {
|
229
|
+
return new Call('super', $2);
|
230
|
+
})
|
231
|
+
],
|
232
|
+
OptFuncExist: [
|
233
|
+
o('', function() {
|
234
|
+
return false;
|
235
|
+
}), o('FUNC_EXIST', function() {
|
236
|
+
return true;
|
237
|
+
})
|
238
|
+
],
|
239
|
+
Arguments: [
|
240
|
+
o('CALL_START CALL_END', function() {
|
241
|
+
return [];
|
242
|
+
}), o('CALL_START ArgList OptComma CALL_END', function() {
|
243
|
+
return $2;
|
244
|
+
})
|
245
|
+
],
|
246
|
+
This: [
|
247
|
+
o('THIS', function() {
|
248
|
+
return new Value(new Literal('this'));
|
249
|
+
}), o('@', function() {
|
250
|
+
return new Value(new Literal('this'));
|
251
|
+
})
|
252
|
+
],
|
253
|
+
ThisProperty: [
|
254
|
+
o('@ Identifier', function() {
|
255
|
+
return new Value(new Literal('this'), [new Access($2)], 'this');
|
256
|
+
})
|
257
|
+
],
|
258
|
+
Array: [
|
259
|
+
o('[ ]', function() {
|
260
|
+
return new Arr([]);
|
261
|
+
}), o('[ ArgList OptComma ]', function() {
|
262
|
+
return new Arr($2);
|
263
|
+
})
|
264
|
+
],
|
265
|
+
RangeDots: [
|
266
|
+
o('..', function() {
|
267
|
+
return 'inclusive';
|
268
|
+
}), o('...', function() {
|
269
|
+
return 'exclusive';
|
270
|
+
})
|
271
|
+
],
|
272
|
+
Range: [
|
273
|
+
o('[ Expression RangeDots Expression ]', function() {
|
274
|
+
return new Range($2, $4, $3);
|
275
|
+
})
|
276
|
+
],
|
277
|
+
Slice: [
|
278
|
+
o('INDEX_START Expression RangeDots Expression INDEX_END', function() {
|
279
|
+
return new Range($2, $4, $3);
|
280
|
+
}), o('INDEX_START Expression RangeDots INDEX_END', function() {
|
281
|
+
return new Range($2, null, $3);
|
282
|
+
}), o('INDEX_START RangeDots Expression INDEX_END', function() {
|
283
|
+
return new Range(null, $3, $2);
|
284
|
+
})
|
285
|
+
],
|
286
|
+
ArgList: [
|
287
|
+
o('Arg', function() {
|
288
|
+
return [$1];
|
289
|
+
}), o('ArgList , Arg', function() {
|
290
|
+
return $1.concat($3);
|
291
|
+
}), o('ArgList OptComma TERMINATOR Arg', function() {
|
292
|
+
return $1.concat($4);
|
293
|
+
}), o('INDENT ArgList OptComma OUTDENT', function() {
|
294
|
+
return $2;
|
295
|
+
}), o('ArgList OptComma INDENT ArgList OptComma OUTDENT', function() {
|
296
|
+
return $1.concat($4);
|
297
|
+
})
|
298
|
+
],
|
299
|
+
Arg: [o('Expression'), o('Splat')],
|
300
|
+
SimpleArgs: [
|
301
|
+
o('Expression'), o('SimpleArgs , Expression', function() {
|
302
|
+
return [].concat($1, $3);
|
303
|
+
})
|
304
|
+
],
|
305
|
+
Try: [
|
306
|
+
o('TRY Block', function() {
|
307
|
+
return new Try($2);
|
308
|
+
}), o('TRY Block Catch', function() {
|
309
|
+
return new Try($2, $3[0], $3[1]);
|
310
|
+
}), o('TRY Block FINALLY Block', function() {
|
311
|
+
return new Try($2, null, null, $4);
|
312
|
+
}), o('TRY Block Catch FINALLY Block', function() {
|
313
|
+
return new Try($2, $3[0], $3[1], $5);
|
314
|
+
})
|
315
|
+
],
|
316
|
+
Catch: [
|
317
|
+
o('CATCH Identifier Block', function() {
|
318
|
+
return [$2, $3];
|
319
|
+
})
|
320
|
+
],
|
321
|
+
Throw: [
|
322
|
+
o('THROW Expression', function() {
|
323
|
+
return new Throw($2);
|
324
|
+
})
|
325
|
+
],
|
326
|
+
Parenthetical: [
|
327
|
+
o('( Body )', function() {
|
328
|
+
return new Parens($2);
|
329
|
+
}), o('( INDENT Body OUTDENT )', function() {
|
330
|
+
return new Parens($3);
|
331
|
+
})
|
332
|
+
],
|
333
|
+
WhileSource: [
|
334
|
+
o('WHILE Expression', function() {
|
335
|
+
return new While($2);
|
336
|
+
}), o('WHILE Expression WHEN Expression', function() {
|
337
|
+
return new While($2, {
|
338
|
+
guard: $4
|
339
|
+
});
|
340
|
+
}), o('UNTIL Expression', function() {
|
341
|
+
return new While($2, {
|
342
|
+
invert: true
|
343
|
+
});
|
344
|
+
}), o('UNTIL Expression WHEN Expression', function() {
|
345
|
+
return new While($2, {
|
346
|
+
invert: true,
|
347
|
+
guard: $4
|
348
|
+
});
|
349
|
+
})
|
350
|
+
],
|
351
|
+
While: [
|
352
|
+
o('WhileSource Block', function() {
|
353
|
+
return $1.addBody($2);
|
354
|
+
}), o('Statement WhileSource', function() {
|
355
|
+
return $2.addBody(Expressions.wrap([$1]));
|
356
|
+
}), o('Expression WhileSource', function() {
|
357
|
+
return $2.addBody(Expressions.wrap([$1]));
|
358
|
+
}), o('Loop', function() {
|
359
|
+
return $1;
|
360
|
+
})
|
361
|
+
],
|
362
|
+
Loop: [
|
363
|
+
o('LOOP Block', function() {
|
364
|
+
return new While(new Literal('true')).addBody($2);
|
365
|
+
}), o('LOOP Expression', function() {
|
366
|
+
return new While(new Literal('true')).addBody(Expressions.wrap([$2]));
|
367
|
+
})
|
368
|
+
],
|
369
|
+
For: [
|
370
|
+
o('Statement ForBody', function() {
|
371
|
+
return new For($1, $2);
|
372
|
+
}), o('Expression ForBody', function() {
|
373
|
+
return new For($1, $2);
|
374
|
+
}), o('ForBody Block', function() {
|
375
|
+
return new For($2, $1);
|
376
|
+
})
|
377
|
+
],
|
378
|
+
ForBody: [
|
379
|
+
o('FOR Range', function() {
|
380
|
+
return {
|
381
|
+
source: new Value($2)
|
382
|
+
};
|
383
|
+
}), o('ForStart ForSource', function() {
|
384
|
+
$2.own = $1.own;
|
385
|
+
$2.name = $1[0];
|
386
|
+
$2.index = $1[1];
|
387
|
+
return $2;
|
388
|
+
})
|
389
|
+
],
|
390
|
+
ForStart: [
|
391
|
+
o('FOR ForVariables', function() {
|
392
|
+
return $2;
|
393
|
+
}), o('FOR OWN ForVariables', function() {
|
394
|
+
$3.own = true;
|
395
|
+
return $3;
|
396
|
+
})
|
397
|
+
],
|
398
|
+
ForValue: [
|
399
|
+
o('Identifier'), o('Array', function() {
|
400
|
+
return new Value($1);
|
401
|
+
}), o('Object', function() {
|
402
|
+
return new Value($1);
|
403
|
+
})
|
404
|
+
],
|
405
|
+
ForVariables: [
|
406
|
+
o('ForValue', function() {
|
407
|
+
return [$1];
|
408
|
+
}), o('ForValue , ForValue', function() {
|
409
|
+
return [$1, $3];
|
410
|
+
})
|
411
|
+
],
|
412
|
+
ForSource: [
|
413
|
+
o('FORIN Expression', function() {
|
414
|
+
return {
|
415
|
+
source: $2
|
416
|
+
};
|
417
|
+
}), o('FOROF Expression', function() {
|
418
|
+
return {
|
419
|
+
source: $2,
|
420
|
+
object: true
|
421
|
+
};
|
422
|
+
}), o('FORIN Expression WHEN Expression', function() {
|
423
|
+
return {
|
424
|
+
source: $2,
|
425
|
+
guard: $4
|
426
|
+
};
|
427
|
+
}), o('FOROF Expression WHEN Expression', function() {
|
428
|
+
return {
|
429
|
+
source: $2,
|
430
|
+
guard: $4,
|
431
|
+
object: true
|
432
|
+
};
|
433
|
+
}), o('FORIN Expression BY Expression', function() {
|
434
|
+
return {
|
435
|
+
source: $2,
|
436
|
+
step: $4
|
437
|
+
};
|
438
|
+
}), o('FORIN Expression WHEN Expression BY Expression', function() {
|
439
|
+
return {
|
440
|
+
source: $2,
|
441
|
+
guard: $4,
|
442
|
+
step: $6
|
443
|
+
};
|
444
|
+
}), o('FORIN Expression BY Expression WHEN Expression', function() {
|
445
|
+
return {
|
446
|
+
source: $2,
|
447
|
+
step: $4,
|
448
|
+
guard: $6
|
449
|
+
};
|
450
|
+
})
|
451
|
+
],
|
452
|
+
Switch: [
|
453
|
+
o('SWITCH Expression INDENT Whens OUTDENT', function() {
|
454
|
+
return new Switch($2, $4);
|
455
|
+
}), o('SWITCH Expression INDENT Whens ELSE Block OUTDENT', function() {
|
456
|
+
return new Switch($2, $4, $6);
|
457
|
+
}), o('SWITCH INDENT Whens OUTDENT', function() {
|
458
|
+
return new Switch(null, $3);
|
459
|
+
}), o('SWITCH INDENT Whens ELSE Block OUTDENT', function() {
|
460
|
+
return new Switch(null, $3, $5);
|
461
|
+
})
|
462
|
+
],
|
463
|
+
Whens: [
|
464
|
+
o('When'), o('Whens When', function() {
|
465
|
+
return $1.concat($2);
|
466
|
+
})
|
467
|
+
],
|
468
|
+
When: [
|
469
|
+
o('LEADING_WHEN SimpleArgs Block', function() {
|
470
|
+
return [[$2, $3]];
|
471
|
+
}), o('LEADING_WHEN SimpleArgs Block TERMINATOR', function() {
|
472
|
+
return [[$2, $3]];
|
473
|
+
})
|
474
|
+
],
|
475
|
+
IfBlock: [
|
476
|
+
o('IF Expression Block', function() {
|
477
|
+
return new If($2, $3, {
|
478
|
+
type: $1
|
479
|
+
});
|
480
|
+
}), o('IfBlock ELSE IF Expression Block', function() {
|
481
|
+
return $1.addElse(new If($4, $5, {
|
482
|
+
type: $3
|
483
|
+
}));
|
484
|
+
}), o('IfBlock ELSE Block', function() {
|
485
|
+
return $1.addElse($3);
|
486
|
+
})
|
487
|
+
],
|
488
|
+
If: [
|
489
|
+
o('IfBlock'), o('Statement POST_IF Expression', function() {
|
490
|
+
return new If($3, Expressions.wrap([$1]), {
|
491
|
+
type: $2,
|
492
|
+
statement: true
|
493
|
+
});
|
494
|
+
}), o('Expression POST_IF Expression', function() {
|
495
|
+
return new If($3, Expressions.wrap([$1]), {
|
496
|
+
type: $2,
|
497
|
+
statement: true
|
498
|
+
});
|
499
|
+
})
|
500
|
+
],
|
501
|
+
Operation: [
|
502
|
+
o('UNARY Expression', function() {
|
503
|
+
return new Op($1, $2);
|
504
|
+
}), o('- Expression', (function() {
|
505
|
+
return new Op('-', $2);
|
506
|
+
}), {
|
507
|
+
prec: 'UNARY'
|
508
|
+
}), o('+ Expression', (function() {
|
509
|
+
return new Op('+', $2);
|
510
|
+
}), {
|
511
|
+
prec: 'UNARY'
|
512
|
+
}), o('-- SimpleAssignable', function() {
|
513
|
+
return new Op('--', $2);
|
514
|
+
}), o('++ SimpleAssignable', function() {
|
515
|
+
return new Op('++', $2);
|
516
|
+
}), o('SimpleAssignable --', function() {
|
517
|
+
return new Op('--', $1, null, true);
|
518
|
+
}), o('SimpleAssignable ++', function() {
|
519
|
+
return new Op('++', $1, null, true);
|
520
|
+
}), o('Expression ?', function() {
|
521
|
+
return new Existence($1);
|
522
|
+
}), o('Expression + Expression', function() {
|
523
|
+
return new Op('+', $1, $3);
|
524
|
+
}), o('Expression - Expression', function() {
|
525
|
+
return new Op('-', $1, $3);
|
526
|
+
}), o('Expression MATH Expression', function() {
|
527
|
+
return new Op($2, $1, $3);
|
528
|
+
}), o('Expression SHIFT Expression', function() {
|
529
|
+
return new Op($2, $1, $3);
|
530
|
+
}), o('Expression COMPARE Expression', function() {
|
531
|
+
return new Op($2, $1, $3);
|
532
|
+
}), o('Expression LOGIC Expression', function() {
|
533
|
+
return new Op($2, $1, $3);
|
534
|
+
}), o('Expression RELATION Expression', function() {
|
535
|
+
if ($2.charAt(0) === '!') {
|
536
|
+
return new Op($2.slice(1), $1, $3).invert();
|
537
|
+
} else {
|
538
|
+
return new Op($2, $1, $3);
|
539
|
+
}
|
540
|
+
}), o('SimpleAssignable COMPOUND_ASSIGN\
|
541
|
+
Expression', function() {
|
542
|
+
return new Assign($1, $3, $2);
|
543
|
+
}), o('SimpleAssignable COMPOUND_ASSIGN\
|
544
|
+
INDENT Expression OUTDENT', function() {
|
545
|
+
return new Assign($1, $4, $2);
|
546
|
+
}), o('SimpleAssignable EXTENDS Expression', function() {
|
547
|
+
return new Extends($1, $3);
|
548
|
+
})
|
549
|
+
]
|
550
|
+
};
|
551
|
+
operators = [['left', '.', '?.', '::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'DO', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['right', 'POST_IF']];
|
552
|
+
tokens = [];
|
553
|
+
for (name in grammar) {
|
554
|
+
alternatives = grammar[name];
|
555
|
+
grammar[name] = (function() {
|
556
|
+
var _i, _j, _len, _len2, _ref, _results;
|
557
|
+
_results = [];
|
558
|
+
for (_i = 0, _len = alternatives.length; _i < _len; _i++) {
|
559
|
+
alt = alternatives[_i];
|
560
|
+
_ref = alt[0].split(' ');
|
561
|
+
for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
|
562
|
+
token = _ref[_j];
|
563
|
+
if (!grammar[token]) {
|
564
|
+
tokens.push(token);
|
565
|
+
}
|
566
|
+
}
|
567
|
+
if (name === 'Root') {
|
568
|
+
alt[1] = "return " + alt[1];
|
569
|
+
}
|
570
|
+
_results.push(alt);
|
571
|
+
}
|
572
|
+
return _results;
|
573
|
+
})();
|
574
|
+
}
|
575
|
+
exports.parser = new Parser({
|
576
|
+
tokens: tokens.join(' '),
|
577
|
+
bnf: grammar,
|
578
|
+
operators: operators.reverse(),
|
579
|
+
startSymbol: 'Root'
|
580
|
+
});
|
581
|
+
}).call(this);
|