1 //<script type="text/javscript">
2 imports['Object.js'].load(Object);
4 JSDOC = imports['JSDOC.js'].JSDOC;
5 console = imports['console.js'].console;
7 // make sure parent is loaded..
8 TokenStream = imports['JSDOC/TokenStream.js'].TokenStream;
11 * base class for parsing segments of token array..
14 * We want to make parsing the whole thing easy..
16 * so we do various tricks:
19 * a) white space collased
22 * { } - collapse into first element.
23 ( ) - collapse into first element.
24 [ ] - collapse into first element.
25 * c) items = , seperation within the above..
34 Collapse = Object.define(
38 Collapse.superclass.constructor.call(this, ar);
41 var ar = this.collapse(this.tokens);
51 spaces : function () {
57 for (var i = 0; i < this.tokens.length; i ++) {
59 if (tok.is("COMM") || tok.is("WHIT")) {
65 Roo.each(pref, function(e) {
80 collapse : function(ar) {
82 var st = new TokenStream(ar);
86 var tok = st.look(1,true);
87 if (!tok || !tok.is) {
88 // Seed.print(TokenStream.toString(ret));
91 // console.log(tok.data);
101 ret.push(st.next(1));
110 var start = st.cursor;
112 var add = st.balance(tok.name);
115 console.dump(start + '...' + st.cursor);
116 console.dump(st.tokens);
122 //Seed.print(TokenStream.toString(aa));
125 var toks = add ? this.collapse(add) : [];
129 if (tok.data != '{') {
130 // paramters or array elements..
131 tok.items = this.toItems(toks, [',']);
133 // check for types.. it could be a list of statements.. or object
135 var ost = new TokenStream(toks);
136 //console.dump(ost.look(2,true) );
137 if (ost.look(2,true) && ost.look(2,true).data == ":") {
138 tok.props = this.toProps(toks);
140 // list of statemetns..
141 tok.items = this.toItems(toks,[ ';', '{'] );;
153 //Seed.print(" ADD : " + add.length + " ITEMS: " + tok.items.length);
160 ret.push(st.next(1));
181 toItems : function(ar,sep)
186 for (var i = 0; i < ar.length; i ++) {
187 if (sep.indexOf(ar[i].data) < 0) {
203 toProps : function(ar)
208 var g = { key : '', val: [] }
213 for (var i = 0; i < ar.length; i ++) {
222 state =2; // should be ':'
226 if (ar[i].data != ',') {
230 g = { key : '', val: [] }