// make sure parent is loaded..
TokenStream = imports.TokenStream.TokenStream;
-
+
/**
- *
- */
-
-/**
- * @namespace JSDOC
+ * @scope JSDOC
* @class Collapse
- * @extends TokenStream
+ * @extends JSDOC.TokenStream
* base class for parsing segments of token array..
*
*
( ) - collapse into first element.
[ ] - collapse into first element.
* c) items = , seperation within the above..
- *
+ * d) props = for { xx: ... , yy: ....}
*
*
* usage:
Collapse = XObject.define(
- function (ar, scrFile)
+ function (cfg)
{
Collapse.superclass.constructor.call(this, cfg);
-
+ this.allJSDOC = [];
// console.dump(ar);
},
* @type {Array} top level statements
*/
statements : false,
+
+ /**
+ * @cfg {Boolean} createJSDOC create .jsdoc properties on tokens.
+ */
+ createJSDOC : false,
+
+ /**
+ * @type {Array} allJSDOC if createJSDOC is set, then all the files JSDOC comments
+ * are stored here, in theory to verify that all have been used up..
+ */
+ allJSDOC : false,
+
+ /**
+ * collapse the token array
+ * if collapseTop is set, then statments is set to the array statements (which is an array of tokens)
+ * otherwise this.tokens is set..
+ */
+ collapse : function(ar) {
+
+ ar = ar || this.tokens ;
+ this.rewind();
+ ar = this.spaces(ar);
+ ar = this._collapse(ar);
+
+ if (this.collapseTop) {
+ //print(JSON.stringify(ar, null,4));
+
+ return this.toItems(ar, [ ';', '{'] );
+
+ }
+ return ar;
+ },
+
/**
* Add all the comments to the closed token.
* adds :
*
*
*/
- spaces : function () {
+ spaces : function (toks)
+ {
+ this.tokens = toks;
+ this.rewind();
var ar = [];
var pref = [];
var tok;
+ var jsdoc;
+ var _this = this;
for (var i = 0; i < this.tokens.length; i ++) {
tok = this.tokens[i];
+ if (this.createJSDOC) {
+ tok.jsdoc = false;
+ }
+
if (tok.is("COMM") || tok.is("WHIT")) {
pref.push(tok);
continue;
}
if (e.name == "JSDOC") {
tok.comment = e.data;
+ if (_this.createJSDOC) {
+ tok.jsdoc = new imports.DocComment.DocComment(tok.comment);
+ _this.allJSDOC.push(tok.jsdoc);
+ }
}
// kludge for private..
if (e.is("COMM") && e.data.match(/\/\/\s+private/)) {
tok.comment = '/** @private */';
+ if (_this.createJSDOC) {
+ tok.jsdoc = new imports.DocComment.DocComment(tok.comment);
+ _this.allJSDOC.push(tok.jsdoc);
+ }
}
tok.prefix += e.data;
pref= [];
}
- this.tokens = ar;
+ return ar;
},
- collapse : function() {
- this.spaces();
- var nar = this._collapse(this.tokens);
- this.tokens = nar;
- }
- collapse : function(ar, depth) {
+
+
+ _collapse : function(ar, depth) {
depth = depth || 0;
- var st = new TokenStream(ar);
+ var st = new TokenStream({ tokens : ar });
var ret = [];
while (true) {
if (tok.data != '{') {
// paramters or array elements..
tok.items = this.toItems(toks, [',']);
+ tok.args = [];
+ tok.items.forEach(function(tar) {
+ if (tar[0].is('NAME')) {
+ tok.args.push(tar[0].data);
+ }
+ });
- } else {
- // check for types.. it could be a list of statements.. or object
+
+ ret.push(tok);
- var ost = new TokenStream(toks);
- //console.dump(ost.look(2,true) );
- if (ost.look(2,true) && ost.look(2,true).data == ":") {
- tok.props = this.toProps(toks);
- } else {
- // list of statemetns..
- tok.items = this.toItems(toks,[ ';', '{'] );;
- }
+ continue;
+ }
+ // check for types.. it could be a list of statements.. or object
+
+ var ost = new TokenStream({tokens : toks});
+ //console.dump(ost.look(2,true) );
+ if (ost.look(2,true) && ost.look(2,true).data == ":") {
+ tok.props = this.toProps(toks);
+ } else {
+ // list of statemetns..
+ tok.items = this.toItems(toks,[ ';', '{'] );
}
-
-
-
-
-
+
//Seed.print(" ADD : " + add.length + " ITEMS: " + tok.items.length);
toProps : function(ar)
{
- var ret = { }
+ var ret = { };
- var g = { key : '', val: [] }
+ var g = { key : '', val: [] };
var k = '';