Re-arrange files, add support for classic JS Documentor, and packer
[gnome.introspection-doc-generator] / JSDOC / Collapse.js
index e75d672..62b3a73 100644 (file)
@@ -1,11 +1,11 @@
 //<script type="text/javscript">
-imports['Object.js'].load(Object);
+XObject = imports.XObject.XObject;
 
-JSDOC       = imports['JSDOC.js'].JSDOC; 
-console     = imports['console.js'].console; 
+console     = imports.console.console; 
 
 // make sure parent is loaded..
-TokenStream = imports['JSDOC/TokenStream.js'].TokenStream;
+TokenStream = imports.TokenStream.TokenStream;
 /**
  * 
  * base class for parsing segments of token array..
@@ -24,14 +24,14 @@ TokenStream = imports['JSDOC/TokenStream.js'].TokenStream;
        [ ] - collapse into first element.
  * c) items = , seperation within the above..
  * 
- * 
+ * usage: x = new Collapse(token_array)
  * 
  * 
  * 
  * 
  */ 
  
-Collapse = Object.define(
+Collapse = XObject.define(
     function (ar)
     {
          
@@ -62,7 +62,7 @@ Collapse = Object.define(
                 }
                 tok.prefix = '';
                 if (pref.length) {
-                    Roo.each(pref, function(e) {
+                    pref.forEach( function(e) {
                         if (!e) {
                             return;
                         }
@@ -88,9 +88,11 @@ Collapse = Object.define(
                   //  Seed.print(TokenStream.toString(ret));
                     return ret;
                 }
-               // console.log(tok.data);
+                // console.log(tok.data);
                 switch(tok.type) {
-                   
+                    case "VOID": 
+                        return ret; //EOF
+                        
                         
                     case "KEYW": 
                     case "TOKN":
@@ -109,7 +111,7 @@ Collapse = Object.define(
                                 
                                 var start = st.cursor;
                                 st.next(1);
-                                var add = st.balance(tok.name);
+                                var add = st.balance(tok.data);
                                 if (!add) {
                                     console.dump(tok);
                                     console.dump(start + '...' + st.cursor);
@@ -119,13 +121,17 @@ Collapse = Object.define(
                                 if (add) {
                                     add.shift();
                                 }
-                                //Seed.print(TokenStream.toString(aa));
+                                //Seed.print("ADD");
+                                //Seed.print(JSON.stringify(add, null,4));
+                                
                                 
                                 
                                 var toks = add ? this.collapse(add) : [];
                                 tok.items = false;
                                 tok.props = false;
                                 
+                                
+                                
                                 if (tok.data != '{') {
                                     // paramters or array elements..
                                     tok.items = this.toItems(toks, [',']);
@@ -163,7 +169,7 @@ Collapse = Object.define(
                         Seed.print("OOPS");
                         continue;
                     default : 
-                        Seed.print("OOPS");
+                        Seed.print("OOPS" + tok.type);
                         continue;
                 }
             }
@@ -233,8 +239,9 @@ Collapse = Object.define(
                    
                 }
             }
-             // last..
-            if (k.length) {
+             // last.. - if g.val.length is 0 then it's a trailing ','...
+             // we should really throw a syntax error in that case..
+            if (k.length && g.val.length) {
                 ret[k] = g;
             }
             return ret;