sproutcore 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +19 -0
- data/Manifest.txt +103 -26
- data/app_generators/sproutcore/templates/README +1 -1
- data/bin/sc-build +1 -1
- data/bin/sc-gen +0 -0
- data/bin/sc-ide +278 -0
- data/bin/sc-init +38 -0
- data/bin/sc-install +96 -0
- data/bin/sc-remove +94 -0
- data/bin/sc-server +4 -0
- data/bin/sc-update +94 -0
- data/bin/sproutcore +3 -14
- data/clients/sc_docs/controllers/docs.js +1 -1
- data/clients/sc_docs/models/doc.js +6 -0
- data/clients/sc_docs/views/doc_frame.js +1 -1
- data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
- data/frameworks/sproutcore/HISTORY +34 -2
- data/frameworks/sproutcore/controllers/array.js +1 -1
- data/frameworks/sproutcore/controllers/controller.js +1 -1
- data/frameworks/sproutcore/controllers/object.js +9 -6
- data/frameworks/sproutcore/core.js +19 -4
- data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
- data/frameworks/sproutcore/english.lproj/core.css +1 -0
- data/frameworks/sproutcore/english.lproj/menu.css +1 -0
- data/frameworks/sproutcore/foundation/application.js +3 -3
- data/frameworks/sproutcore/foundation/benchmark.js +1 -1
- data/frameworks/sproutcore/foundation/node_descriptor.js +13 -1
- data/frameworks/sproutcore/foundation/page.js +3 -2
- data/frameworks/sproutcore/foundation/path_module.js +33 -16
- data/frameworks/sproutcore/foundation/run_loop.js +1 -1
- data/frameworks/sproutcore/foundation/server.js +68 -18
- data/frameworks/sproutcore/foundation/string.js +1 -1
- data/frameworks/sproutcore/globals/window.js +62 -15
- data/frameworks/sproutcore/lib/core_views.rb +1 -0
- data/frameworks/sproutcore/lib/index.rhtml +4 -3
- data/frameworks/sproutcore/lib/menu_views.rb +2 -2
- data/frameworks/sproutcore/models/collection.js +122 -107
- data/frameworks/sproutcore/models/record.js +2 -2
- data/frameworks/sproutcore/panes/manager.js +1 -1
- data/frameworks/sproutcore/panes/overlay.js +3 -3
- data/frameworks/sproutcore/tests/controllers/object.rhtml +26 -0
- data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +2 -2
- data/frameworks/sproutcore/views/button/disclosure.js +1 -1
- data/frameworks/sproutcore/views/collection/collection.js +19 -15
- data/frameworks/sproutcore/views/collection/source_list.js +1 -1
- data/frameworks/sproutcore/views/collection/table.js +2 -2
- data/frameworks/sproutcore/views/error_explanation.js +1 -1
- data/frameworks/sproutcore/views/field/checkbox_field.js +1 -1
- data/frameworks/sproutcore/views/field/field.js +1 -1
- data/frameworks/sproutcore/views/field/radio_field.js +1 -1
- data/frameworks/sproutcore/views/field/select_field.js +1 -1
- data/frameworks/sproutcore/views/form.js +1 -1
- data/frameworks/sproutcore/views/image.js +1 -1
- data/frameworks/sproutcore/views/menu_item.js +1 -1
- data/frameworks/sproutcore/views/popup_button.js +1 -1
- data/frameworks/sproutcore/views/popup_menu.js +1 -1
- data/frameworks/sproutcore/views/progress.js +4 -2
- data/frameworks/sproutcore/views/radio_group.js +1 -1
- data/frameworks/sproutcore/views/scroll.js +1 -1
- data/frameworks/sproutcore/views/source_list_group.js +1 -1
- data/frameworks/sproutcore/views/split.js +1 -1
- data/frameworks/sproutcore/views/tab.js +3 -1
- data/frameworks/sproutcore/views/view.js +19 -3
- data/jsdoc/README.txt +89 -57
- data/jsdoc/app/frame/Chain.js +102 -0
- data/jsdoc/app/frame/Dumper.js +144 -0
- data/jsdoc/app/frame/Hash.js +47 -0
- data/jsdoc/app/frame/Link.js +142 -0
- data/jsdoc/app/frame/Namespace.js +10 -0
- data/jsdoc/app/frame/Opt.js +134 -0
- data/jsdoc/app/frame/Reflection.js +26 -0
- data/jsdoc/app/frame/String.js +93 -0
- data/jsdoc/app/frame/Testrun.js +129 -0
- data/jsdoc/app/frame.js +33 -0
- data/jsdoc/app/handlers/FOODOC.js +26 -0
- data/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
- data/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
- data/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
- data/jsdoc/app/handlers/XMLDOC.js +26 -0
- data/jsdoc/app/lib/JSDOC/DocComment.js +200 -0
- data/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
- data/jsdoc/app/lib/JSDOC/JsDoc.js +180 -0
- data/jsdoc/app/lib/JSDOC/JsPlate.js +100 -0
- data/jsdoc/app/lib/JSDOC/Lang.js +144 -0
- data/jsdoc/app/lib/JSDOC/Parser.js +109 -0
- data/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
- data/jsdoc/app/lib/JSDOC/Symbol.js +600 -0
- data/jsdoc/app/lib/JSDOC/SymbolSet.js +220 -0
- data/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
- data/jsdoc/app/lib/JSDOC/Token.js +18 -0
- data/jsdoc/app/lib/JSDOC/TokenReader.js +323 -0
- data/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
- data/jsdoc/app/lib/JSDOC/Util.js +32 -0
- data/jsdoc/app/lib/JSDOC/Walker.js +416 -0
- data/jsdoc/app/lib/JSDOC.js +97 -0
- data/jsdoc/app/main.js +74 -0
- data/jsdoc/app/plugins/commentSrcJson.js +19 -0
- data/jsdoc/app/plugins/frameworkPrototype.js +16 -0
- data/jsdoc/app/plugins/functionCall.js +10 -0
- data/jsdoc/app/plugins/publishSrcHilite.js +62 -0
- data/jsdoc/app/plugins/sproutcoreTags.js +26 -0
- data/jsdoc/app/plugins/symbolLink.js +9 -0
- data/jsdoc/app/plugins/tagParamConfig.js +31 -0
- data/jsdoc/app/plugins/tagSynonyms.js +43 -0
- data/jsdoc/app/run.js +339 -137
- data/jsdoc/changes.txt +47 -0
- data/jsdoc/conf/sample.conf +31 -0
- data/jsdoc/java/build.xml +36 -0
- data/jsdoc/java/build_1.4.xml +36 -0
- data/jsdoc/java/classes/js.jar +0 -0
- data/jsdoc/java/src/JsDebugRun.java +21 -0
- data/jsdoc/java/src/JsRun.java +21 -0
- data/jsdoc/jsdebug.jar +0 -0
- data/jsdoc/jsrun.jar +0 -0
- data/jsdoc/t/TestDoc.js +144 -0
- data/jsdoc/t/runner.js +13 -0
- data/jsdoc/templates/sproutcore/allclasses.tmpl +17 -0
- data/jsdoc/templates/sproutcore/allfiles.tmpl +56 -0
- data/jsdoc/templates/sproutcore/class.tmpl +408 -326
- data/jsdoc/templates/sproutcore/index.tmpl +30 -31
- data/jsdoc/templates/sproutcore/publish.js +173 -81
- data/jsdoc/templates/sproutcore/static/default.css +191 -0
- data/jsdoc/templates/sproutcore/static/header.html +2 -0
- data/jsdoc/templates/sproutcore/static/index.html +19 -0
- data/jsdoc/templates/sproutcore/symbol.tmpl +35 -0
- data/jsdoc/test/addon.js +24 -0
- data/jsdoc/test/anon_inner.js +14 -0
- data/jsdoc/test/augments.js +31 -0
- data/jsdoc/test/augments2.js +26 -0
- data/jsdoc/test/borrows.js +41 -0
- data/jsdoc/test/borrows2.js +23 -0
- data/jsdoc/test/config.js +22 -0
- data/jsdoc/test/constructs.js +18 -0
- data/jsdoc/test/encoding.js +10 -0
- data/jsdoc/test/encoding_other.js +12 -0
- data/jsdoc/test/functions_anon.js +39 -0
- data/jsdoc/test/functions_nested.js +33 -0
- data/jsdoc/test/global.js +13 -0
- data/jsdoc/test/globals.js +25 -0
- data/jsdoc/test/ignore.js +10 -0
- data/jsdoc/test/inner.js +16 -0
- data/jsdoc/test/jsdoc_test.js +477 -0
- data/jsdoc/test/lend.js +33 -0
- data/jsdoc/test/memberof.js +20 -0
- data/jsdoc/test/memberof_constructor.js +15 -0
- data/jsdoc/test/name.js +19 -0
- data/jsdoc/test/namespace_nested.js +23 -0
- data/jsdoc/test/nocode.js +13 -0
- data/jsdoc/test/oblit_anon.js +20 -0
- data/jsdoc/test/overview.js +20 -0
- data/jsdoc/test/param_inline.js +37 -0
- data/jsdoc/test/params_optional.js +8 -0
- data/jsdoc/test/prototype.js +17 -0
- data/jsdoc/test/prototype_nested.js +9 -0
- data/jsdoc/test/prototype_oblit.js +13 -0
- data/jsdoc/test/prototype_oblit_constructor.js +24 -0
- data/jsdoc/test/public.js +10 -0
- data/jsdoc/test/shared.js +42 -0
- data/jsdoc/test/shared2.js +2 -0
- data/jsdoc/test/shortcuts.js +22 -0
- data/jsdoc/test/static_this.js +13 -0
- data/jsdoc/test/synonyms.js +23 -0
- data/jsdoc/test/tosource.js +23 -0
- data/jsdoc/test/variable_redefine.js +14 -0
- data/jsdoc/test.js +304 -0
- data/lib/sproutcore/build_tools/resource_builder.rb +6 -1
- data/lib/sproutcore/bundle_installer.rb +268 -0
- data/lib/sproutcore/jsdoc.rb +7 -6
- data/lib/sproutcore/library.rb +38 -0
- data/lib/sproutcore/merb/bundle_controller.rb +8 -4
- data/lib/sproutcore/version.rb +1 -1
- data/lib/sproutcore.rb +1 -1
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/txt2html +0 -0
- metadata +117 -29
- data/clients/view_builder/core.js +0 -19
- data/clients/view_builder/english.lproj/body.css +0 -149
- data/clients/view_builder/english.lproj/body.rhtml +0 -18
- data/clients/view_builder/english.lproj/strings.js +0 -14
- data/clients/view_builder/main.js +0 -37
- data/jsdoc/app/DocFile.js +0 -137
- data/jsdoc/app/DocTag.js +0 -110
- data/jsdoc/app/Doclet.js +0 -63
- data/jsdoc/app/Dumper.js +0 -143
- data/jsdoc/app/JsDoc.js +0 -103
- data/jsdoc/app/JsHilite.js +0 -45
- data/jsdoc/app/JsIO.js +0 -163
- data/jsdoc/app/JsParse.js +0 -385
- data/jsdoc/app/JsPlate.js +0 -130
- data/jsdoc/app/JsTestrun.js +0 -129
- data/jsdoc/app/JsToke.js +0 -564
- data/jsdoc/app/Symbol.js +0 -298
- data/jsdoc/app/Transformer.js +0 -14
- data/jsdoc/app/Util.js +0 -97
- data/jsdoc/app/js.jar +0 -0
- data/jsdoc/plugins/min.js +0 -316
- data/jsdoc/plugins/strip.js +0 -20
- data/jsdoc/templates/sproutcore/default.css +0 -191
- data/jsdoc/templates/sproutcore/index.html +0 -13
- data/jsdoc/templates/sproutcore/prototype.js +0 -4186
- data/jsdoc/templates/sproutcore/splash.html +0 -7
data/jsdoc/app/JsToke.js
DELETED
@@ -1,564 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileOverview A library for finding the parts of JavaScript source code.
|
3
|
-
* @name JsToke
|
4
|
-
* @author Michael Mathews micmath@gmail.com
|
5
|
-
* @url $HeadURL: https://jsdoc-toolkit.googlecode.com/svn/tags/jsdoc_toolkit-1.4.0b/app/JsToke.js $
|
6
|
-
* @revision $Id: JsToke.js 213 2007-08-22 10:21:50Z micmath $
|
7
|
-
* @license <a href="http://en.wikipedia.org/wiki/MIT_License">X11/MIT License</a>
|
8
|
-
* (See the accompanying README file for full details.)
|
9
|
-
*/
|
10
|
-
|
11
|
-
/** Defines the internal names for tokens. */
|
12
|
-
var TOKN = {};
|
13
|
-
TOKN.WHIT = {
|
14
|
-
" ": "SPACE",
|
15
|
-
"\f": "FORMFEED",
|
16
|
-
"\t": "TAB",
|
17
|
-
"\u0009": "UNICODE_TAB",
|
18
|
-
"\u000A": "UNICODE_NBR",
|
19
|
-
"\u0008": "VERTICAL_TAB"
|
20
|
-
};
|
21
|
-
TOKN.NEWLINE = {
|
22
|
-
"\n": "NEWLINE",
|
23
|
-
"\r": "RETURN",
|
24
|
-
"\u000A": "UNICODE_LF",
|
25
|
-
"\u000D": "UNICODE_CR",
|
26
|
-
"\u2029": "UNICODE_PS",
|
27
|
-
"\u2028": "UNICODE_LS"
|
28
|
-
};
|
29
|
-
TOKN.KEYW = {
|
30
|
-
"=break": "BREAK",
|
31
|
-
"=case": "CASE",
|
32
|
-
"=catch": "CATCH",
|
33
|
-
"=continue": "CONTINUE",
|
34
|
-
"=default": "DEFAULT",
|
35
|
-
"=delete": "DELETE",
|
36
|
-
"=do": "DO",
|
37
|
-
"=else": "ELSE",
|
38
|
-
"=false": "FALSE",
|
39
|
-
"=finally": "FINALLY",
|
40
|
-
"=for": "FOR",
|
41
|
-
"=function": "FUNCTION",
|
42
|
-
"=if": "IF",
|
43
|
-
"=in": "IN",
|
44
|
-
"=instanceof": "INSTANCEOF",
|
45
|
-
"=new": "NEW",
|
46
|
-
"=null": "NULL",
|
47
|
-
"=return": "RETURN",
|
48
|
-
"=switch": "SWITCH",
|
49
|
-
"=this": "THIS",
|
50
|
-
"=throw": "THROW",
|
51
|
-
"=true": "TRUE",
|
52
|
-
"=try": "TRY",
|
53
|
-
"=typeof": "TYPEOF",
|
54
|
-
"=void": "VOID",
|
55
|
-
"=while": "WHILE",
|
56
|
-
"=with": "WITH",
|
57
|
-
"=var": "VAR"
|
58
|
-
};
|
59
|
-
|
60
|
-
TOKN.PUNC = {
|
61
|
-
";": "SEMICOLON",
|
62
|
-
",": "COMMA",
|
63
|
-
"?": "HOOK",
|
64
|
-
":": "COLON",
|
65
|
-
"||": "OR",
|
66
|
-
"&&": "AND",
|
67
|
-
"|": "BITWISE_OR",
|
68
|
-
"^": "BITWISE_XOR",
|
69
|
-
"&": "BITWISE_AND",
|
70
|
-
"===": "STRICT_EQ",
|
71
|
-
"==": "EQ",
|
72
|
-
"=": "ASSIGN",
|
73
|
-
"!==": "STRICT_NE",
|
74
|
-
"!=": "NE",
|
75
|
-
"<<": "LSH",
|
76
|
-
"<=": "LE",
|
77
|
-
"<": "LT",
|
78
|
-
">>>": "URSH",
|
79
|
-
">>": "RSH",
|
80
|
-
">=": "GE",
|
81
|
-
">": "GT",
|
82
|
-
"++": "INCREMENT",
|
83
|
-
"--": "DECREMENT",
|
84
|
-
"+": "PLUS",
|
85
|
-
"-": "MINUS",
|
86
|
-
"*": "MUL",
|
87
|
-
"/": "DIV",
|
88
|
-
"%": "MOD",
|
89
|
-
"!": "NOT",
|
90
|
-
"~": "BITWISE_NOT",
|
91
|
-
".": "DOT",
|
92
|
-
"[": "LEFT_BRACKET",
|
93
|
-
"]": "RIGHT_BRACKET",
|
94
|
-
"{": "LEFT_CURLY",
|
95
|
-
"}": "RIGHT_CURLY",
|
96
|
-
"(": "LEFT_PAREN",
|
97
|
-
")": "RIGHT_PAREN"
|
98
|
-
};
|
99
|
-
TOKN.MATCHING = {
|
100
|
-
"LEFT_PAREN": "RIGHT_PAREN",
|
101
|
-
"LEFT_CURLY": "RIGHT_CURLY",
|
102
|
-
"LEFT_BRACE": "RIGHT_BRACE"
|
103
|
-
};
|
104
|
-
TOKN.NUMB = /^(\.[0-9]|[0-9]+\.|[0-9])[0-9]*([eE][+-][0-9]+)?$/i;
|
105
|
-
TOKN.HEX_DEC = /^0x[0-9A-F]+$/i;
|
106
|
-
|
107
|
-
String.prototype.isWordChar = function() {
|
108
|
-
return /^[a-zA-Z0-9$_.]+$/.test(this);
|
109
|
-
}
|
110
|
-
String.prototype.isNewline = function() {
|
111
|
-
return (typeof TOKN.NEWLINE[this] != "undefined")
|
112
|
-
}
|
113
|
-
String.prototype.isSpace = function() {
|
114
|
-
return (typeof TOKN.WHIT[this] != "undefined");
|
115
|
-
}
|
116
|
-
String.prototype.last = function() {
|
117
|
-
return this.charAt[this.length-1];
|
118
|
-
}
|
119
|
-
|
120
|
-
/**
|
121
|
-
* @class Extends built-in Array under a new name.
|
122
|
-
* @constructor
|
123
|
-
*/
|
124
|
-
var List = function() {
|
125
|
-
that = Array.apply(this, arguments);
|
126
|
-
|
127
|
-
/**
|
128
|
-
* Get the last item on the list.
|
129
|
-
* @name last
|
130
|
-
* @function
|
131
|
-
* @memberOf List
|
132
|
-
*/
|
133
|
-
that.last = function() {
|
134
|
-
return this[this.length-1];
|
135
|
-
}
|
136
|
-
return that;
|
137
|
-
}
|
138
|
-
|
139
|
-
/**
|
140
|
-
* @class A single element of the source code.
|
141
|
-
* @constructor
|
142
|
-
*/
|
143
|
-
function Token(data, type, name) {
|
144
|
-
this.data = data;
|
145
|
-
this.type = type;
|
146
|
-
this.name = name;
|
147
|
-
}
|
148
|
-
Token.prototype.toString = function() {
|
149
|
-
return "<"+this.type+" name=\""+this.name+"\">"+this.data+"</"+this.type+">";
|
150
|
-
}
|
151
|
-
|
152
|
-
/**
|
153
|
-
* Check to see what this token is.
|
154
|
-
* @param {string} what Either a name or a token type, like "COMMA" or "PUNC".
|
155
|
-
* @return {boolean}
|
156
|
-
*/
|
157
|
-
Token.prototype.is = function(what) {
|
158
|
-
return this.name === what || this.type === what;
|
159
|
-
}
|
160
|
-
|
161
|
-
/**
|
162
|
-
* @class Like a string that you can easily move forward and backward through.
|
163
|
-
* @constructor
|
164
|
-
*/
|
165
|
-
function TextStream(text) {
|
166
|
-
this.text = text;
|
167
|
-
this.cursor = 0;
|
168
|
-
}
|
169
|
-
|
170
|
-
/**
|
171
|
-
* Return the character n places away.
|
172
|
-
* @param {integer} n Positive or negative (defaults to zero), where to look relative to the current cursor position.
|
173
|
-
* @return {character}
|
174
|
-
*/
|
175
|
-
TextStream.prototype.look = function(n) {
|
176
|
-
if (typeof n == "undefined") n = 0;
|
177
|
-
|
178
|
-
if (this.cursor+n < 0 || this.cursor+n >= this.text.length) {
|
179
|
-
var result = new String("");
|
180
|
-
result.eof = true;
|
181
|
-
return result;
|
182
|
-
}
|
183
|
-
return this.text.charAt(this.cursor+n);
|
184
|
-
}
|
185
|
-
|
186
|
-
/**
|
187
|
-
* Get the next n characters from the string relative to the current cursor position, and advance the cursor to the new position.
|
188
|
-
* @param {integer} n Positive (defaults to one), how many tokens to return.
|
189
|
-
* @return {string}
|
190
|
-
*/
|
191
|
-
TextStream.prototype.next = function(n) {
|
192
|
-
if (typeof n == "undefined") n = 1;
|
193
|
-
if (n < 1) return null;
|
194
|
-
|
195
|
-
var pulled = "";
|
196
|
-
for (var i = 0; i < n; i++) {
|
197
|
-
if (this.cursor+i < this.text.length) {
|
198
|
-
pulled += this.text.charAt(this.cursor+i);
|
199
|
-
}
|
200
|
-
else {
|
201
|
-
var result = new String("");
|
202
|
-
result.eof = true;
|
203
|
-
return result;
|
204
|
-
}
|
205
|
-
}
|
206
|
-
|
207
|
-
this.cursor += n;
|
208
|
-
return pulled;
|
209
|
-
}
|
210
|
-
|
211
|
-
/**
|
212
|
-
* @class Scan the source code for possible tokens.
|
213
|
-
* @constructor
|
214
|
-
* @param {string} src The JavaScript source code.
|
215
|
-
*/
|
216
|
-
function TokenReader(src){
|
217
|
-
this.src = src;
|
218
|
-
this.keepDocs = true;
|
219
|
-
this.keepWhite = false;
|
220
|
-
this.keepComments = false;
|
221
|
-
};
|
222
|
-
|
223
|
-
/**
|
224
|
-
* Turn source code into a Token array.
|
225
|
-
* @return {List} All Tokens found in the source code.
|
226
|
-
*/
|
227
|
-
TokenReader.prototype.tokenize = function() {
|
228
|
-
var stream = new TextStream(this.src);
|
229
|
-
var tokens = new List();
|
230
|
-
|
231
|
-
while (!stream.look().eof) {
|
232
|
-
if (this.read_mlcomment(stream, tokens)) continue;
|
233
|
-
if (this.read_slcomment(stream, tokens)) continue;
|
234
|
-
if (this.read_dbquote(stream, tokens)) continue;
|
235
|
-
if (this.read_snquote(stream, tokens)) continue;
|
236
|
-
if (this.read_regx(stream, tokens)) continue;
|
237
|
-
if (this.read_numb(stream, tokens)) continue;
|
238
|
-
if (this.read_punc(stream, tokens)) continue;
|
239
|
-
if (this.read_space(stream, tokens)) continue;
|
240
|
-
if (this.read_newline(stream, tokens)) continue;
|
241
|
-
if (this.read_word(stream, tokens)) continue;
|
242
|
-
|
243
|
-
tokens.push(new Token(stream.next(), "TOKN", "UNKNOWN_TOKEN")); // This is an error case.
|
244
|
-
}
|
245
|
-
return tokens;
|
246
|
-
}
|
247
|
-
|
248
|
-
TokenReader.prototype.read_word = function(stream, tokens) {
|
249
|
-
var found = "";
|
250
|
-
while (!stream.look().eof && stream.look().isWordChar()) {
|
251
|
-
found += stream.next();
|
252
|
-
}
|
253
|
-
|
254
|
-
if (found === "") {
|
255
|
-
return false;
|
256
|
-
}
|
257
|
-
else {
|
258
|
-
var name;
|
259
|
-
if ((name = TOKN.KEYW["="+found])) tokens.push(new Token(found, "KEYW", name));
|
260
|
-
else tokens.push(new Token(found, "NAME", "NAME"));
|
261
|
-
return true;
|
262
|
-
}
|
263
|
-
}
|
264
|
-
TokenReader.prototype.read_punc = function(stream, tokens) {
|
265
|
-
var found = "";
|
266
|
-
var name;
|
267
|
-
while (!stream.look().eof && TOKN.PUNC[found+stream.look()]) {
|
268
|
-
found += stream.next();
|
269
|
-
}
|
270
|
-
|
271
|
-
if (found === "") {
|
272
|
-
return false;
|
273
|
-
}
|
274
|
-
else {
|
275
|
-
tokens.push(new Token(found, "PUNC", TOKN.PUNC[found]));
|
276
|
-
return true;
|
277
|
-
}
|
278
|
-
}
|
279
|
-
TokenReader.prototype.read_space = function(stream, tokens) {
|
280
|
-
var found = "";
|
281
|
-
|
282
|
-
while (!stream.look().eof && stream.look().isSpace()) {
|
283
|
-
found += stream.next();
|
284
|
-
}
|
285
|
-
|
286
|
-
if (found === "") {
|
287
|
-
return false;
|
288
|
-
}
|
289
|
-
else {
|
290
|
-
if (this.collapseWhite) found = " ";
|
291
|
-
if (this.keepWhite) tokens.push(new Token(found, "WHIT", "SPACE"));
|
292
|
-
return true;
|
293
|
-
}
|
294
|
-
}
|
295
|
-
TokenReader.prototype.read_newline = function(stream, tokens) {
|
296
|
-
var found = "";
|
297
|
-
|
298
|
-
while (!stream.look().eof && stream.look().isNewline()) {
|
299
|
-
found += stream.next();
|
300
|
-
}
|
301
|
-
|
302
|
-
if (found === "") {
|
303
|
-
return false;
|
304
|
-
}
|
305
|
-
else {
|
306
|
-
if (this.collapseWhite) found = "\n";
|
307
|
-
if (this.keepWhite) tokens.push(new Token(found, "WHIT", "NEWLINE"));
|
308
|
-
return true;
|
309
|
-
}
|
310
|
-
}
|
311
|
-
TokenReader.prototype.read_mlcomment = function(stream, tokens) {
|
312
|
-
if (stream.look() == "/" && stream.look(1) == "*") {
|
313
|
-
var found = stream.next(2);
|
314
|
-
|
315
|
-
while (!stream.look().eof && !(stream.look(-1) == "/" && stream.look(-2) == "*")) {
|
316
|
-
found += stream.next();
|
317
|
-
}
|
318
|
-
|
319
|
-
if (/^\/\*\*[^*]/.test(found) && this.keepDocs) tokens.push(new Token(found, "COMM", "JSDOC"));
|
320
|
-
else if (this.keepComments) tokens.push(new Token(found, "COMM", "MULTI_LINE_COMM"));
|
321
|
-
return true;
|
322
|
-
}
|
323
|
-
return false;
|
324
|
-
}
|
325
|
-
TokenReader.prototype.read_slcomment = function(stream, tokens) {
|
326
|
-
var found;
|
327
|
-
if (
|
328
|
-
(stream.look() == "/" && stream.look(1) == "/" && (found=stream.next(2)))
|
329
|
-
||
|
330
|
-
(stream.look() == "<" && stream.look(1) == "!" && stream.look(2) == "-" && stream.look(3) == "-" && (found=stream.next(4)))
|
331
|
-
) {
|
332
|
-
|
333
|
-
while (!stream.look().eof && !stream.look().isNewline()) {
|
334
|
-
found += stream.next();
|
335
|
-
}
|
336
|
-
|
337
|
-
if (this.keepComments) {
|
338
|
-
tokens.push(new Token(found, "COMM", "SINGLE_LINE_COMM"));
|
339
|
-
}
|
340
|
-
return true;
|
341
|
-
}
|
342
|
-
return false;
|
343
|
-
}
|
344
|
-
TokenReader.prototype.read_dbquote = function(stream, tokens) {
|
345
|
-
if (stream.look() == "\"") {
|
346
|
-
// find terminator
|
347
|
-
var string = stream.next();
|
348
|
-
|
349
|
-
while (!stream.look().eof) {
|
350
|
-
if (stream.look() == "\\") {
|
351
|
-
if (stream.look(1).isNewline()) {
|
352
|
-
do {
|
353
|
-
stream.next();
|
354
|
-
} while (!stream.look().eof && stream.look().isNewline());
|
355
|
-
string += "\\\n";
|
356
|
-
}
|
357
|
-
else {
|
358
|
-
string += stream.next(2);
|
359
|
-
}
|
360
|
-
}
|
361
|
-
else if (stream.look() == "\"") {
|
362
|
-
string += stream.next();
|
363
|
-
tokens.push(new Token(string, "STRN", "DOUBLE_QUOTE"));
|
364
|
-
return true;
|
365
|
-
}
|
366
|
-
else {
|
367
|
-
string += stream.next();
|
368
|
-
}
|
369
|
-
}
|
370
|
-
}
|
371
|
-
return false; // error! unterminated string
|
372
|
-
}
|
373
|
-
TokenReader.prototype.read_snquote = function(stream, tokens) {
|
374
|
-
if (stream.look() == "'") {
|
375
|
-
// find terminator
|
376
|
-
var string = stream.next();
|
377
|
-
|
378
|
-
while (!stream.look().eof) {
|
379
|
-
if (stream.look() == "\\") { // escape sequence
|
380
|
-
string += stream.next(2);
|
381
|
-
}
|
382
|
-
else if (stream.look() == "'") {
|
383
|
-
string += stream.next();
|
384
|
-
tokens.push(new Token(string, "STRN", "SINGLE_QUOTE"));
|
385
|
-
return true;
|
386
|
-
}
|
387
|
-
else {
|
388
|
-
string += stream.next();
|
389
|
-
}
|
390
|
-
}
|
391
|
-
}
|
392
|
-
return false; // error! unterminated string
|
393
|
-
}
|
394
|
-
TokenReader.prototype.read_numb = function(stream, tokens) {
|
395
|
-
if (stream.look() === "0" && stream.look(1) == "x") {
|
396
|
-
return this.read_hex(stream, tokens);
|
397
|
-
}
|
398
|
-
|
399
|
-
var found = "";
|
400
|
-
|
401
|
-
while (!stream.look().eof && TOKN.NUMB.test(found+stream.look())){
|
402
|
-
found += stream.next();
|
403
|
-
}
|
404
|
-
|
405
|
-
if (found === "") {
|
406
|
-
return false;
|
407
|
-
}
|
408
|
-
else {
|
409
|
-
if (/^0[0-7]/.test(found)) tokens.push(new Token(found, "NUMB", "OCTAL"));
|
410
|
-
else tokens.push(new Token(found, "NUMB", "DECIMAL"));
|
411
|
-
return true;
|
412
|
-
}
|
413
|
-
}
|
414
|
-
TokenReader.prototype.read_hex = function(stream, tokens) {
|
415
|
-
var found = stream.next(2);
|
416
|
-
|
417
|
-
while (!stream.look().eof) {
|
418
|
-
if (TOKN.HEX_DEC.test(found) && !TOKN.HEX_DEC.test(found+stream.look())) { // done
|
419
|
-
tokens.push(new Token(found, "NUMB", "HEX_DEC"));
|
420
|
-
return true;
|
421
|
-
}
|
422
|
-
else {
|
423
|
-
found += stream.next();
|
424
|
-
}
|
425
|
-
}
|
426
|
-
return false;
|
427
|
-
}
|
428
|
-
TokenReader.prototype.read_regx = function(stream, tokens) {
|
429
|
-
if (
|
430
|
-
stream.look() == "/"
|
431
|
-
&&
|
432
|
-
(
|
433
|
-
!tokens.last()
|
434
|
-
||
|
435
|
-
(
|
436
|
-
!tokens.last().is("NUMB")
|
437
|
-
&& !tokens.last().is("NAME")
|
438
|
-
&& !tokens.last().is("RIGHT_PAREN")
|
439
|
-
&& !tokens.last().is("RIGHT_BRACKET")
|
440
|
-
)
|
441
|
-
)
|
442
|
-
) {
|
443
|
-
var regex = stream.next();
|
444
|
-
|
445
|
-
while (!stream.look().eof) {
|
446
|
-
if (stream.look() == "\\") { // escape sequence
|
447
|
-
regex += stream.next(2);
|
448
|
-
}
|
449
|
-
else if (stream.look() == "/") {
|
450
|
-
regex += stream.next();
|
451
|
-
|
452
|
-
while (/[gmi]/.test(stream.look())) {
|
453
|
-
regex += stream.next();
|
454
|
-
}
|
455
|
-
|
456
|
-
tokens.push(new Token(regex, "REGX", "REGX"));
|
457
|
-
return true;
|
458
|
-
}
|
459
|
-
else {
|
460
|
-
regex += stream.next();
|
461
|
-
}
|
462
|
-
}
|
463
|
-
// error: unterminated regex
|
464
|
-
}
|
465
|
-
return false;
|
466
|
-
}
|
467
|
-
|
468
|
-
/**
|
469
|
-
* @class Like a array that you can easily move forward and backward through.
|
470
|
-
* @constructor
|
471
|
-
* @param {List} array The list of tokens to use.
|
472
|
-
*/
|
473
|
-
function TokenStream(tokens) {
|
474
|
-
this.tokens = (tokens || []);
|
475
|
-
this.cursor = -1;
|
476
|
-
}
|
477
|
-
|
478
|
-
/**
|
479
|
-
* Return the token n places away from the current position.
|
480
|
-
* @param {integer} n Positive or negative (defaults to zero), where to look relative to the current cursor position.
|
481
|
-
* @param {boolean} considerWhitespace If whitespace is in the tokenStream they will normally be ignored here, but set this to true if you want to consider whitespace.
|
482
|
-
*/
|
483
|
-
TokenStream.prototype.look = function(n, considerWhitespace) {
|
484
|
-
if (typeof n == "undefined") n = 0;
|
485
|
-
|
486
|
-
if (considerWhitespace == true) {
|
487
|
-
if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {};
|
488
|
-
return this.tokens[this.cursor+n];
|
489
|
-
}
|
490
|
-
else {
|
491
|
-
var count = 0;
|
492
|
-
var i = this.cursor;
|
493
|
-
var voidToken = {is: function(){return false;}}
|
494
|
-
while (true) {
|
495
|
-
if (i < 0 || i > this.tokens.length) return voidToken;
|
496
|
-
if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("SPACE") || this.tokens[i].is("NEWLINE"))) {
|
497
|
-
if (n < 0) i--; else i++;
|
498
|
-
continue;
|
499
|
-
}
|
500
|
-
|
501
|
-
if (count == Math.abs(n)) {
|
502
|
-
return this.tokens[i];
|
503
|
-
}
|
504
|
-
count++;
|
505
|
-
(n < 0)? i-- : i++;
|
506
|
-
}
|
507
|
-
return voidToken; // because null isn't an object and caller always expects an object
|
508
|
-
}
|
509
|
-
};
|
510
|
-
|
511
|
-
/**
|
512
|
-
* Get the next n tokens from the stream relative to the current cursor position, and advance the cursor to the new position.
|
513
|
-
* @param {integer} howMany Positive (defaults to one), how many tokens to return.
|
514
|
-
*/
|
515
|
-
TokenStream.prototype.next = function(howMany) {
|
516
|
-
if (typeof howMany == "undefined") howMany = 1;
|
517
|
-
if (howMany < 1) return null;
|
518
|
-
var got = [];
|
519
|
-
|
520
|
-
for (var i = 1; i <= howMany; i++) {
|
521
|
-
if (this.cursor+i >= this.tokens.length) {
|
522
|
-
return null;
|
523
|
-
}
|
524
|
-
got.push(this.tokens[this.cursor+i]);
|
525
|
-
}
|
526
|
-
this.cursor += howMany;
|
527
|
-
|
528
|
-
if (howMany == 1) {
|
529
|
-
return got[0];
|
530
|
-
}
|
531
|
-
else return got;
|
532
|
-
};
|
533
|
-
|
534
|
-
/**
|
535
|
-
* Get all the tokens between a starting token and the stop token. The stop token will be found considering its balance with
|
536
|
-
* the start token. That is, it must be the one that closes the start token, not necessarily the first stop token.
|
537
|
-
* @param {TOKN} start The token to start collecting on, must be present somewhere in the stream ahead of the cursor.
|
538
|
-
* @param {TOKN} [stop] The token to stop collecting on, must be present somewhere in the stream ahead of the cursor and after the start token.
|
539
|
-
* If this is not given, the matching token to start will be used if it exists. Like ( and ) or { and }.
|
540
|
-
*/
|
541
|
-
TokenStream.prototype.balance = function(start, stop) {
|
542
|
-
if (!stop) stop = TOKN.MATCHING[start];
|
543
|
-
|
544
|
-
var depth = 0;
|
545
|
-
var got = [];
|
546
|
-
var started = false;
|
547
|
-
|
548
|
-
while ((token = this.look())) {
|
549
|
-
if (token.is(start)) {
|
550
|
-
depth++;
|
551
|
-
started = true;
|
552
|
-
}
|
553
|
-
|
554
|
-
if (started) {
|
555
|
-
got.push(token);
|
556
|
-
}
|
557
|
-
|
558
|
-
if (token.is(stop)) {
|
559
|
-
depth--;
|
560
|
-
if (depth == 0) return got;
|
561
|
-
}
|
562
|
-
if (!this.next()) break;
|
563
|
-
}
|
564
|
-
};
|