mobile_template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +3 -0
- data/bin/mobile_template +71 -0
- data/lib/mobile_template/version.rb +4 -0
- data/lib/mobile_template.rb +5 -0
- data/mobile_template.gemspec +21 -0
- data/templates/assets/Gemfile +4 -0
- data/templates/assets/config.rb +96 -0
- data/templates/assets/config.ru +4 -0
- data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
- data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
- data/templates/assets/source/index.html.erb +2 -0
- data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
- data/templates/assets/source/javascripts/application.js.coffee +5 -0
- data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
- data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
- data/templates/assets/source/layout.erb +24 -0
- data/templates/assets/source/stylesheets/application.css.scss +2 -0
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
- data/templates/cordova_android/.gitignore +18 -0
- data/templates/cordova_android/LICENSE +202 -0
- data/templates/cordova_android/NOTICE +5 -0
- data/templates/cordova_android/README.md +95 -0
- data/templates/cordova_android/VERSION +1 -0
- data/templates/cordova_android/bin/BOOM +4 -0
- data/templates/cordova_android/bin/autotest +2 -0
- data/templates/cordova_android/bin/bench +29 -0
- data/templates/cordova_android/bin/create +46 -0
- data/templates/cordova_android/bin/create.bat +1 -0
- data/templates/cordova_android/bin/create.js +88 -0
- data/templates/cordova_android/bin/create.xml +79 -0
- data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
- data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
- data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
- data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
- data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
- data/templates/cordova_android/bin/test +26 -0
- data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
- data/templates/cordova_android/bin/tests/create.coffee +21 -0
- data/templates/cordova_android/bin/tests/debug.coffee +0 -0
- data/templates/cordova_android/bin/tests/test.coffee +0 -0
- data/templates/cordova_android/framework/.classpath +8 -0
- data/templates/cordova_android/framework/.project +33 -0
- data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
- data/templates/cordova_android/framework/ant.properties +34 -0
- data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
- data/templates/cordova_android/framework/assets/js/app.js +89 -0
- data/templates/cordova_android/framework/assets/js/battery.js +134 -0
- data/templates/cordova_android/framework/assets/js/camera.js +168 -0
- data/templates/cordova_android/framework/assets/js/capture.js +203 -0
- data/templates/cordova_android/framework/assets/js/compass.js +168 -0
- data/templates/cordova_android/framework/assets/js/contact.js +310 -0
- data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
- data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
- data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
- data/templates/cordova_android/framework/assets/js/device.js +83 -0
- data/templates/cordova_android/framework/assets/js/file.js +1082 -0
- data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
- data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
- data/templates/cordova_android/framework/assets/js/header.txt +19 -0
- data/templates/cordova_android/framework/assets/js/media.js +233 -0
- data/templates/cordova_android/framework/assets/js/network.js +100 -0
- data/templates/cordova_android/framework/assets/js/notification.js +133 -0
- data/templates/cordova_android/framework/assets/js/position.js +100 -0
- data/templates/cordova_android/framework/assets/js/storage.js +439 -0
- data/templates/cordova_android/framework/assets/www/index.html +27 -0
- data/templates/cordova_android/framework/build.xml +216 -0
- data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
- data/templates/cordova_android/framework/proguard-project.txt +20 -0
- data/templates/cordova_android/framework/project.properties +14 -0
- data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/layout/main.xml +29 -0
- data/templates/cordova_android/framework/res/values/strings.xml +23 -0
- data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
- metadata +279 -0
@@ -0,0 +1,591 @@
|
|
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(?:Block\.wrap|extend)\b/g, 'yy.$&');
|
14
|
+
return [patternString, "$$ = " + action + ";", options];
|
15
|
+
};
|
16
|
+
grammar = {
|
17
|
+
Root: [
|
18
|
+
o('', function() {
|
19
|
+
return new Block;
|
20
|
+
}), o('Body'), o('Block TERMINATOR')
|
21
|
+
],
|
22
|
+
Body: [
|
23
|
+
o('Line', function() {
|
24
|
+
return Block.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 Block;
|
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
|
+
var val;
|
62
|
+
val = new Literal($1);
|
63
|
+
if ($1 === 'undefined') {
|
64
|
+
val.isUndefined = true;
|
65
|
+
}
|
66
|
+
return val;
|
67
|
+
})
|
68
|
+
],
|
69
|
+
Assign: [
|
70
|
+
o('Assignable = Expression', function() {
|
71
|
+
return new Assign($1, $3);
|
72
|
+
}), o('Assignable = INDENT Expression OUTDENT', function() {
|
73
|
+
return new Assign($1, $4);
|
74
|
+
})
|
75
|
+
],
|
76
|
+
AssignObj: [
|
77
|
+
o('ObjAssignable', function() {
|
78
|
+
return new Value($1);
|
79
|
+
}), o('ObjAssignable : Expression', function() {
|
80
|
+
return new Assign(new Value($1), $3, 'object');
|
81
|
+
}), o('ObjAssignable :\
|
82
|
+
INDENT Expression OUTDENT', function() {
|
83
|
+
return new Assign(new Value($1), $4, 'object');
|
84
|
+
}), o('Comment')
|
85
|
+
],
|
86
|
+
ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')],
|
87
|
+
Return: [
|
88
|
+
o('RETURN Expression', function() {
|
89
|
+
return new Return($2);
|
90
|
+
}), o('RETURN', function() {
|
91
|
+
return new Return;
|
92
|
+
})
|
93
|
+
],
|
94
|
+
Comment: [
|
95
|
+
o('HERECOMMENT', function() {
|
96
|
+
return new Comment($1);
|
97
|
+
})
|
98
|
+
],
|
99
|
+
Code: [
|
100
|
+
o('PARAM_START ParamList PARAM_END FuncGlyph Block', function() {
|
101
|
+
return new Code($2, $5, $4);
|
102
|
+
}), o('FuncGlyph Block', function() {
|
103
|
+
return new Code([], $2, $1);
|
104
|
+
})
|
105
|
+
],
|
106
|
+
FuncGlyph: [
|
107
|
+
o('->', function() {
|
108
|
+
return 'func';
|
109
|
+
}), o('=>', function() {
|
110
|
+
return 'boundfunc';
|
111
|
+
})
|
112
|
+
],
|
113
|
+
OptComma: [o(''), o(',')],
|
114
|
+
ParamList: [
|
115
|
+
o('', function() {
|
116
|
+
return [];
|
117
|
+
}), o('Param', function() {
|
118
|
+
return [$1];
|
119
|
+
}), o('ParamList , Param', function() {
|
120
|
+
return $1.concat($3);
|
121
|
+
})
|
122
|
+
],
|
123
|
+
Param: [
|
124
|
+
o('ParamVar', function() {
|
125
|
+
return new Param($1);
|
126
|
+
}), o('ParamVar ...', function() {
|
127
|
+
return new Param($1, null, true);
|
128
|
+
}), o('ParamVar = Expression', function() {
|
129
|
+
return new Param($1, $3);
|
130
|
+
})
|
131
|
+
],
|
132
|
+
ParamVar: [o('Identifier'), o('ThisProperty'), o('Array'), o('Object')],
|
133
|
+
Splat: [
|
134
|
+
o('Expression ...', function() {
|
135
|
+
return new Splat($1);
|
136
|
+
})
|
137
|
+
],
|
138
|
+
SimpleAssignable: [
|
139
|
+
o('Identifier', function() {
|
140
|
+
return new Value($1);
|
141
|
+
}), o('Value Accessor', function() {
|
142
|
+
return $1.push($2);
|
143
|
+
}), o('Invocation Accessor', function() {
|
144
|
+
return new Value($1, [$2]);
|
145
|
+
}), o('ThisProperty')
|
146
|
+
],
|
147
|
+
Assignable: [
|
148
|
+
o('SimpleAssignable'), o('Array', function() {
|
149
|
+
return new Value($1);
|
150
|
+
}), o('Object', function() {
|
151
|
+
return new Value($1);
|
152
|
+
})
|
153
|
+
],
|
154
|
+
Value: [
|
155
|
+
o('Assignable'), o('Literal', function() {
|
156
|
+
return new Value($1);
|
157
|
+
}), o('Parenthetical', function() {
|
158
|
+
return new Value($1);
|
159
|
+
}), o('Range', function() {
|
160
|
+
return new Value($1);
|
161
|
+
}), o('This')
|
162
|
+
],
|
163
|
+
Accessor: [
|
164
|
+
o('. Identifier', function() {
|
165
|
+
return new Access($2);
|
166
|
+
}), o('?. Identifier', function() {
|
167
|
+
return new Access($2, 'soak');
|
168
|
+
}), o(':: Identifier', function() {
|
169
|
+
return new Access($2, 'proto');
|
170
|
+
}), o('::', function() {
|
171
|
+
return new Access(new Literal('prototype'));
|
172
|
+
}), o('Index')
|
173
|
+
],
|
174
|
+
Index: [
|
175
|
+
o('INDEX_START IndexValue INDEX_END', function() {
|
176
|
+
return $2;
|
177
|
+
}), o('INDEX_SOAK Index', function() {
|
178
|
+
return extend($2, {
|
179
|
+
soak: true
|
180
|
+
});
|
181
|
+
}), o('INDEX_PROTO Index', function() {
|
182
|
+
return extend($2, {
|
183
|
+
proto: true
|
184
|
+
});
|
185
|
+
})
|
186
|
+
],
|
187
|
+
IndexValue: [
|
188
|
+
o('Expression', function() {
|
189
|
+
return new Index($1);
|
190
|
+
}), o('Slice', function() {
|
191
|
+
return new Slice($1);
|
192
|
+
})
|
193
|
+
],
|
194
|
+
Object: [
|
195
|
+
o('{ AssignList OptComma }', function() {
|
196
|
+
return new Obj($2, $1.generated);
|
197
|
+
})
|
198
|
+
],
|
199
|
+
AssignList: [
|
200
|
+
o('', function() {
|
201
|
+
return [];
|
202
|
+
}), o('AssignObj', function() {
|
203
|
+
return [$1];
|
204
|
+
}), o('AssignList , AssignObj', function() {
|
205
|
+
return $1.concat($3);
|
206
|
+
}), o('AssignList OptComma TERMINATOR AssignObj', function() {
|
207
|
+
return $1.concat($4);
|
208
|
+
}), o('AssignList OptComma INDENT AssignList OptComma OUTDENT', function() {
|
209
|
+
return $1.concat($4);
|
210
|
+
})
|
211
|
+
],
|
212
|
+
Class: [
|
213
|
+
o('CLASS', function() {
|
214
|
+
return new Class;
|
215
|
+
}), o('CLASS Block', function() {
|
216
|
+
return new Class(null, null, $2);
|
217
|
+
}), o('CLASS EXTENDS Value', function() {
|
218
|
+
return new Class(null, $3);
|
219
|
+
}), o('CLASS EXTENDS Value Block', function() {
|
220
|
+
return new Class(null, $3, $4);
|
221
|
+
}), o('CLASS SimpleAssignable', function() {
|
222
|
+
return new Class($2);
|
223
|
+
}), o('CLASS SimpleAssignable Block', function() {
|
224
|
+
return new Class($2, null, $3);
|
225
|
+
}), o('CLASS SimpleAssignable EXTENDS Value', function() {
|
226
|
+
return new Class($2, $4);
|
227
|
+
}), o('CLASS SimpleAssignable EXTENDS Value Block', function() {
|
228
|
+
return new Class($2, $4, $5);
|
229
|
+
})
|
230
|
+
],
|
231
|
+
Invocation: [
|
232
|
+
o('Value OptFuncExist Arguments', function() {
|
233
|
+
return new Call($1, $3, $2);
|
234
|
+
}), o('Invocation OptFuncExist Arguments', function() {
|
235
|
+
return new Call($1, $3, $2);
|
236
|
+
}), o('SUPER', function() {
|
237
|
+
return new Call('super', [new Splat(new Literal('arguments'))]);
|
238
|
+
}), o('SUPER Arguments', function() {
|
239
|
+
return new Call('super', $2);
|
240
|
+
})
|
241
|
+
],
|
242
|
+
OptFuncExist: [
|
243
|
+
o('', function() {
|
244
|
+
return false;
|
245
|
+
}), o('FUNC_EXIST', function() {
|
246
|
+
return true;
|
247
|
+
})
|
248
|
+
],
|
249
|
+
Arguments: [
|
250
|
+
o('CALL_START CALL_END', function() {
|
251
|
+
return [];
|
252
|
+
}), o('CALL_START ArgList OptComma CALL_END', function() {
|
253
|
+
return $2;
|
254
|
+
})
|
255
|
+
],
|
256
|
+
This: [
|
257
|
+
o('THIS', function() {
|
258
|
+
return new Value(new Literal('this'));
|
259
|
+
}), o('@', function() {
|
260
|
+
return new Value(new Literal('this'));
|
261
|
+
})
|
262
|
+
],
|
263
|
+
ThisProperty: [
|
264
|
+
o('@ Identifier', function() {
|
265
|
+
return new Value(new Literal('this'), [new Access($2)], 'this');
|
266
|
+
})
|
267
|
+
],
|
268
|
+
Array: [
|
269
|
+
o('[ ]', function() {
|
270
|
+
return new Arr([]);
|
271
|
+
}), o('[ ArgList OptComma ]', function() {
|
272
|
+
return new Arr($2);
|
273
|
+
})
|
274
|
+
],
|
275
|
+
RangeDots: [
|
276
|
+
o('..', function() {
|
277
|
+
return 'inclusive';
|
278
|
+
}), o('...', function() {
|
279
|
+
return 'exclusive';
|
280
|
+
})
|
281
|
+
],
|
282
|
+
Range: [
|
283
|
+
o('[ Expression RangeDots Expression ]', function() {
|
284
|
+
return new Range($2, $4, $3);
|
285
|
+
})
|
286
|
+
],
|
287
|
+
Slice: [
|
288
|
+
o('Expression RangeDots Expression', function() {
|
289
|
+
return new Range($1, $3, $2);
|
290
|
+
}), o('Expression RangeDots', function() {
|
291
|
+
return new Range($1, null, $2);
|
292
|
+
}), o('RangeDots Expression', function() {
|
293
|
+
return new Range(null, $2, $1);
|
294
|
+
})
|
295
|
+
],
|
296
|
+
ArgList: [
|
297
|
+
o('Arg', function() {
|
298
|
+
return [$1];
|
299
|
+
}), o('ArgList , Arg', function() {
|
300
|
+
return $1.concat($3);
|
301
|
+
}), o('ArgList OptComma TERMINATOR Arg', function() {
|
302
|
+
return $1.concat($4);
|
303
|
+
}), o('INDENT ArgList OptComma OUTDENT', function() {
|
304
|
+
return $2;
|
305
|
+
}), o('ArgList OptComma INDENT ArgList OptComma OUTDENT', function() {
|
306
|
+
return $1.concat($4);
|
307
|
+
})
|
308
|
+
],
|
309
|
+
Arg: [o('Expression'), o('Splat')],
|
310
|
+
SimpleArgs: [
|
311
|
+
o('Expression'), o('SimpleArgs , Expression', function() {
|
312
|
+
return [].concat($1, $3);
|
313
|
+
})
|
314
|
+
],
|
315
|
+
Try: [
|
316
|
+
o('TRY Block', function() {
|
317
|
+
return new Try($2);
|
318
|
+
}), o('TRY Block Catch', function() {
|
319
|
+
return new Try($2, $3[0], $3[1]);
|
320
|
+
}), o('TRY Block FINALLY Block', function() {
|
321
|
+
return new Try($2, null, null, $4);
|
322
|
+
}), o('TRY Block Catch FINALLY Block', function() {
|
323
|
+
return new Try($2, $3[0], $3[1], $5);
|
324
|
+
})
|
325
|
+
],
|
326
|
+
Catch: [
|
327
|
+
o('CATCH Identifier Block', function() {
|
328
|
+
return [$2, $3];
|
329
|
+
})
|
330
|
+
],
|
331
|
+
Throw: [
|
332
|
+
o('THROW Expression', function() {
|
333
|
+
return new Throw($2);
|
334
|
+
})
|
335
|
+
],
|
336
|
+
Parenthetical: [
|
337
|
+
o('( Body )', function() {
|
338
|
+
return new Parens($2);
|
339
|
+
}), o('( INDENT Body OUTDENT )', function() {
|
340
|
+
return new Parens($3);
|
341
|
+
})
|
342
|
+
],
|
343
|
+
WhileSource: [
|
344
|
+
o('WHILE Expression', function() {
|
345
|
+
return new While($2);
|
346
|
+
}), o('WHILE Expression WHEN Expression', function() {
|
347
|
+
return new While($2, {
|
348
|
+
guard: $4
|
349
|
+
});
|
350
|
+
}), o('UNTIL Expression', function() {
|
351
|
+
return new While($2, {
|
352
|
+
invert: true
|
353
|
+
});
|
354
|
+
}), o('UNTIL Expression WHEN Expression', function() {
|
355
|
+
return new While($2, {
|
356
|
+
invert: true,
|
357
|
+
guard: $4
|
358
|
+
});
|
359
|
+
})
|
360
|
+
],
|
361
|
+
While: [
|
362
|
+
o('WhileSource Block', function() {
|
363
|
+
return $1.addBody($2);
|
364
|
+
}), o('Statement WhileSource', function() {
|
365
|
+
return $2.addBody(Block.wrap([$1]));
|
366
|
+
}), o('Expression WhileSource', function() {
|
367
|
+
return $2.addBody(Block.wrap([$1]));
|
368
|
+
}), o('Loop', function() {
|
369
|
+
return $1;
|
370
|
+
})
|
371
|
+
],
|
372
|
+
Loop: [
|
373
|
+
o('LOOP Block', function() {
|
374
|
+
return new While(new Literal('true')).addBody($2);
|
375
|
+
}), o('LOOP Expression', function() {
|
376
|
+
return new While(new Literal('true')).addBody(Block.wrap([$2]));
|
377
|
+
})
|
378
|
+
],
|
379
|
+
For: [
|
380
|
+
o('Statement ForBody', function() {
|
381
|
+
return new For($1, $2);
|
382
|
+
}), o('Expression ForBody', function() {
|
383
|
+
return new For($1, $2);
|
384
|
+
}), o('ForBody Block', function() {
|
385
|
+
return new For($2, $1);
|
386
|
+
})
|
387
|
+
],
|
388
|
+
ForBody: [
|
389
|
+
o('FOR Range', function() {
|
390
|
+
return {
|
391
|
+
source: new Value($2)
|
392
|
+
};
|
393
|
+
}), o('ForStart ForSource', function() {
|
394
|
+
$2.own = $1.own;
|
395
|
+
$2.name = $1[0];
|
396
|
+
$2.index = $1[1];
|
397
|
+
return $2;
|
398
|
+
})
|
399
|
+
],
|
400
|
+
ForStart: [
|
401
|
+
o('FOR ForVariables', function() {
|
402
|
+
return $2;
|
403
|
+
}), o('FOR OWN ForVariables', function() {
|
404
|
+
$3.own = true;
|
405
|
+
return $3;
|
406
|
+
})
|
407
|
+
],
|
408
|
+
ForValue: [
|
409
|
+
o('Identifier'), o('Array', function() {
|
410
|
+
return new Value($1);
|
411
|
+
}), o('Object', function() {
|
412
|
+
return new Value($1);
|
413
|
+
})
|
414
|
+
],
|
415
|
+
ForVariables: [
|
416
|
+
o('ForValue', function() {
|
417
|
+
return [$1];
|
418
|
+
}), o('ForValue , ForValue', function() {
|
419
|
+
return [$1, $3];
|
420
|
+
})
|
421
|
+
],
|
422
|
+
ForSource: [
|
423
|
+
o('FORIN Expression', function() {
|
424
|
+
return {
|
425
|
+
source: $2
|
426
|
+
};
|
427
|
+
}), o('FOROF Expression', function() {
|
428
|
+
return {
|
429
|
+
source: $2,
|
430
|
+
object: true
|
431
|
+
};
|
432
|
+
}), o('FORIN Expression WHEN Expression', function() {
|
433
|
+
return {
|
434
|
+
source: $2,
|
435
|
+
guard: $4
|
436
|
+
};
|
437
|
+
}), o('FOROF Expression WHEN Expression', function() {
|
438
|
+
return {
|
439
|
+
source: $2,
|
440
|
+
guard: $4,
|
441
|
+
object: true
|
442
|
+
};
|
443
|
+
}), o('FORIN Expression BY Expression', function() {
|
444
|
+
return {
|
445
|
+
source: $2,
|
446
|
+
step: $4
|
447
|
+
};
|
448
|
+
}), o('FORIN Expression WHEN Expression BY Expression', function() {
|
449
|
+
return {
|
450
|
+
source: $2,
|
451
|
+
guard: $4,
|
452
|
+
step: $6
|
453
|
+
};
|
454
|
+
}), o('FORIN Expression BY Expression WHEN Expression', function() {
|
455
|
+
return {
|
456
|
+
source: $2,
|
457
|
+
step: $4,
|
458
|
+
guard: $6
|
459
|
+
};
|
460
|
+
})
|
461
|
+
],
|
462
|
+
Switch: [
|
463
|
+
o('SWITCH Expression INDENT Whens OUTDENT', function() {
|
464
|
+
return new Switch($2, $4);
|
465
|
+
}), o('SWITCH Expression INDENT Whens ELSE Block OUTDENT', function() {
|
466
|
+
return new Switch($2, $4, $6);
|
467
|
+
}), o('SWITCH INDENT Whens OUTDENT', function() {
|
468
|
+
return new Switch(null, $3);
|
469
|
+
}), o('SWITCH INDENT Whens ELSE Block OUTDENT', function() {
|
470
|
+
return new Switch(null, $3, $5);
|
471
|
+
})
|
472
|
+
],
|
473
|
+
Whens: [
|
474
|
+
o('When'), o('Whens When', function() {
|
475
|
+
return $1.concat($2);
|
476
|
+
})
|
477
|
+
],
|
478
|
+
When: [
|
479
|
+
o('LEADING_WHEN SimpleArgs Block', function() {
|
480
|
+
return [[$2, $3]];
|
481
|
+
}), o('LEADING_WHEN SimpleArgs Block TERMINATOR', function() {
|
482
|
+
return [[$2, $3]];
|
483
|
+
})
|
484
|
+
],
|
485
|
+
IfBlock: [
|
486
|
+
o('IF Expression Block', function() {
|
487
|
+
return new If($2, $3, {
|
488
|
+
type: $1
|
489
|
+
});
|
490
|
+
}), o('IfBlock ELSE IF Expression Block', function() {
|
491
|
+
return $1.addElse(new If($4, $5, {
|
492
|
+
type: $3
|
493
|
+
}));
|
494
|
+
})
|
495
|
+
],
|
496
|
+
If: [
|
497
|
+
o('IfBlock'), o('IfBlock ELSE Block', function() {
|
498
|
+
return $1.addElse($3);
|
499
|
+
}), o('Statement POST_IF Expression', function() {
|
500
|
+
return new If($3, Block.wrap([$1]), {
|
501
|
+
type: $2,
|
502
|
+
statement: true
|
503
|
+
});
|
504
|
+
}), o('Expression POST_IF Expression', function() {
|
505
|
+
return new If($3, Block.wrap([$1]), {
|
506
|
+
type: $2,
|
507
|
+
statement: true
|
508
|
+
});
|
509
|
+
})
|
510
|
+
],
|
511
|
+
Operation: [
|
512
|
+
o('UNARY Expression', function() {
|
513
|
+
return new Op($1, $2);
|
514
|
+
}), o('- Expression', (function() {
|
515
|
+
return new Op('-', $2);
|
516
|
+
}), {
|
517
|
+
prec: 'UNARY'
|
518
|
+
}), o('+ Expression', (function() {
|
519
|
+
return new Op('+', $2);
|
520
|
+
}), {
|
521
|
+
prec: 'UNARY'
|
522
|
+
}), o('-- SimpleAssignable', function() {
|
523
|
+
return new Op('--', $2);
|
524
|
+
}), o('++ SimpleAssignable', function() {
|
525
|
+
return new Op('++', $2);
|
526
|
+
}), o('SimpleAssignable --', function() {
|
527
|
+
return new Op('--', $1, null, true);
|
528
|
+
}), o('SimpleAssignable ++', function() {
|
529
|
+
return new Op('++', $1, null, true);
|
530
|
+
}), o('Expression ?', function() {
|
531
|
+
return new Existence($1);
|
532
|
+
}), o('Expression + Expression', function() {
|
533
|
+
return new Op('+', $1, $3);
|
534
|
+
}), o('Expression - Expression', function() {
|
535
|
+
return new Op('-', $1, $3);
|
536
|
+
}), o('Expression MATH Expression', function() {
|
537
|
+
return new Op($2, $1, $3);
|
538
|
+
}), o('Expression SHIFT Expression', function() {
|
539
|
+
return new Op($2, $1, $3);
|
540
|
+
}), o('Expression COMPARE Expression', function() {
|
541
|
+
return new Op($2, $1, $3);
|
542
|
+
}), o('Expression LOGIC Expression', function() {
|
543
|
+
return new Op($2, $1, $3);
|
544
|
+
}), o('Expression RELATION Expression', function() {
|
545
|
+
if ($2.charAt(0) === '!') {
|
546
|
+
return new Op($2.slice(1), $1, $3).invert();
|
547
|
+
} else {
|
548
|
+
return new Op($2, $1, $3);
|
549
|
+
}
|
550
|
+
}), o('SimpleAssignable COMPOUND_ASSIGN\
|
551
|
+
Expression', function() {
|
552
|
+
return new Assign($1, $3, $2);
|
553
|
+
}), o('SimpleAssignable COMPOUND_ASSIGN\
|
554
|
+
INDENT Expression OUTDENT', function() {
|
555
|
+
return new Assign($1, $4, $2);
|
556
|
+
}), o('SimpleAssignable EXTENDS Expression', function() {
|
557
|
+
return new Extends($1, $3);
|
558
|
+
})
|
559
|
+
]
|
560
|
+
};
|
561
|
+
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']];
|
562
|
+
tokens = [];
|
563
|
+
for (name in grammar) {
|
564
|
+
alternatives = grammar[name];
|
565
|
+
grammar[name] = (function() {
|
566
|
+
var _i, _j, _len, _len2, _ref, _results;
|
567
|
+
_results = [];
|
568
|
+
for (_i = 0, _len = alternatives.length; _i < _len; _i++) {
|
569
|
+
alt = alternatives[_i];
|
570
|
+
_ref = alt[0].split(' ');
|
571
|
+
for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
|
572
|
+
token = _ref[_j];
|
573
|
+
if (!grammar[token]) {
|
574
|
+
tokens.push(token);
|
575
|
+
}
|
576
|
+
}
|
577
|
+
if (name === 'Root') {
|
578
|
+
alt[1] = "return " + alt[1];
|
579
|
+
}
|
580
|
+
_results.push(alt);
|
581
|
+
}
|
582
|
+
return _results;
|
583
|
+
})();
|
584
|
+
}
|
585
|
+
exports.parser = new Parser({
|
586
|
+
tokens: tokens.join(' '),
|
587
|
+
bnf: grammar,
|
588
|
+
operators: operators.reverse(),
|
589
|
+
startSymbol: 'Root'
|
590
|
+
});
|
591
|
+
}).call(this);
|
@@ -0,0 +1,66 @@
|
|
1
|
+
(function() {
|
2
|
+
var extend, flatten;
|
3
|
+
exports.starts = function(string, literal, start) {
|
4
|
+
return literal === string.substr(start, literal.length);
|
5
|
+
};
|
6
|
+
exports.ends = function(string, literal, back) {
|
7
|
+
var len;
|
8
|
+
len = literal.length;
|
9
|
+
return literal === string.substr(string.length - len - (back || 0), len);
|
10
|
+
};
|
11
|
+
exports.compact = function(array) {
|
12
|
+
var item, _i, _len, _results;
|
13
|
+
_results = [];
|
14
|
+
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
15
|
+
item = array[_i];
|
16
|
+
if (item) {
|
17
|
+
_results.push(item);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return _results;
|
21
|
+
};
|
22
|
+
exports.count = function(string, substr) {
|
23
|
+
var num, pos;
|
24
|
+
num = pos = 0;
|
25
|
+
if (!substr.length) {
|
26
|
+
return 1 / 0;
|
27
|
+
}
|
28
|
+
while (pos = 1 + string.indexOf(substr, pos)) {
|
29
|
+
num++;
|
30
|
+
}
|
31
|
+
return num;
|
32
|
+
};
|
33
|
+
exports.merge = function(options, overrides) {
|
34
|
+
return extend(extend({}, options), overrides);
|
35
|
+
};
|
36
|
+
extend = exports.extend = function(object, properties) {
|
37
|
+
var key, val;
|
38
|
+
for (key in properties) {
|
39
|
+
val = properties[key];
|
40
|
+
object[key] = val;
|
41
|
+
}
|
42
|
+
return object;
|
43
|
+
};
|
44
|
+
exports.flatten = flatten = function(array) {
|
45
|
+
var element, flattened, _i, _len;
|
46
|
+
flattened = [];
|
47
|
+
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
48
|
+
element = array[_i];
|
49
|
+
if (element instanceof Array) {
|
50
|
+
flattened = flattened.concat(flatten(element));
|
51
|
+
} else {
|
52
|
+
flattened.push(element);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
return flattened;
|
56
|
+
};
|
57
|
+
exports.del = function(obj, key) {
|
58
|
+
var val;
|
59
|
+
val = obj[key];
|
60
|
+
delete obj[key];
|
61
|
+
return val;
|
62
|
+
};
|
63
|
+
exports.last = function(array, back) {
|
64
|
+
return array[array.length - (back || 0) - 1];
|
65
|
+
};
|
66
|
+
}).call(this);
|