1 //<script type="text/javscript">
2 JSDOC = imports['JSDOC.js'].JSDOC;
3 Roo = imports['Roo.js'].Roo;
4 console = imports['console.js'].console;
6 // make sure parent is loaded..
7 TokenStream = imports['JSDOC/TokenStream.js'].TokenStream;
10 * base class for parsing segments of token array..
13 * We want to make parsing the whole thing easy..
15 * so we do various tricks:
18 * a) white space collased
21 * { } - collapse into first element.
22 ( ) - collapse into first element.
23 [ ] - collapse into first element.
24 * c) items = , seperation within the above..
32 Collapse = function (ar)
35 Collapse.superclass.constructor.call(this, ar);
38 var ar = this.collapse(this.tokens);
46 Roo.extend(Collapse, TokenStream, {
48 spaces : function () {
54 for (var i = 0; i < this.tokens.length; i ++) {
56 if (tok.is("COMM") || tok.is("WHIT")) {
62 Roo.each(pref, function(e) {
77 collapse : function(ar) {
79 var st = new TokenStream(ar);
83 var tok = st.look(1,true);
84 if (!tok || !tok.is) {
85 // Seed.print(TokenStream.toString(ret));
88 // console.log(tok.data);
107 var start = st.cursor;
109 var add = st.balance(tok.name);
112 console.dump(start + '...' + st.cursor);
113 console.dump(st.tokens);
119 //Seed.print(TokenStream.toString(aa));
122 var toks = add ? this.collapse(add) : [];
126 if (tok.data != '{') {
127 // paramters or array elements..
128 tok.items = this.toItems(toks, [',']);
130 // check for types.. it could be a list of statements.. or object
132 var ost = new TokenStream(toks);
133 //console.dump(ost.look(2,true) );
134 if (ost.look(2,true) && ost.look(2,true).data == ":") {
135 tok.props = this.toProps(toks);
137 // list of statemetns..
138 tok.items = this.toItems(toks,[ ';', '{'] );;
150 //Seed.print(" ADD : " + add.length + " ITEMS: " + tok.items.length);
157 ret.push(st.next(1));
178 toItems : function(ar,sep)
183 for (var i = 0; i < ar.length; i ++) {
184 if (sep.indexOf(ar[i].data) < 0) {
200 toProps : function(ar)
205 var g = { key : '', val: [] }
210 for (var i = 0; i < ar.length; i ++) {
219 state =2; // should be ':'
223 if (ar[i].data != ',') {
227 g = { key : '', val: [] }