JSDOC/Packer.vala
[gnome.introspection-doc-generator] / JSDOC / ScopeParser.js
index 8a3f330..a35790e 100644 (file)
@@ -1,7 +1,7 @@
 //<Script type="text/javascript">
 
-Scope = imports.Scope.Scope;
-TokenStream = imports.TokenStream.TokenStream;
+const Scope = imports.Scope.Scope;
+const TokenStream = imports.TokenStream.TokenStream;
 /**
 * Scope stuff
 * 
@@ -11,7 +11,7 @@ TokenStream = imports.TokenStream.TokenStream;
 * 
 */
 
-ScopeParser = function(ts) {
+const ScopeParser = function(ts) {
     this.ts = ts; // {TokenStream}
     this.warnings = [];
     this.indexedg = {};
@@ -172,7 +172,7 @@ ScopeParser.prototype = {
         
         this.parseScope(this.globalScope);
         
-        this.globalScope.dump();
+        //this.globalScope.dump();
         
         
         this.globalScope.munge();
@@ -226,9 +226,9 @@ ScopeParser.prototype = {
             //this.dumpToken(token , this.scopes, this.braceNesting);
             //print('SCOPE:' + token.toString());
             //this.log(token.data);
-            if (token.type == 'NAME') {
+            //if (token.type == 'NAME') {
             //    print('*' + token.data);
-            }
+            //}
             switch(token.type + '.' + token.name) {
                 case "KEYW.VAR":
                 case "KEYW.CONST": // not really relivant as it's only mozzy that does this.
@@ -239,7 +239,7 @@ ScopeParser.prototype = {
                     while (true) {
                         token = this.ts.nextTok();
                         //!this.debug|| print( token.toString());
-                        //print('SCOPE-VAR-VAL:' + JSON.stringify(token, null, 4));
+                       // print('SCOPE-VAR-VAL:' + JSON.stringify(token, null, 4));
                         if (!token) { // can return false at EOF!
                             break;
                         }
@@ -301,7 +301,8 @@ ScopeParser.prototype = {
                             //this.logR("parseScope DONE  : <B>ParseExpression</B> - tok is:" + this.ts.lookT(0).toString()); 
                             
                             token = this.ts.lookTok(1);
-                            !this.debug|| print("AFTER EXP: " + token.toString());
+                            //!this.debug|| 
+                           // print("AFTER EXP: " + token.toString());
                             if (token.data == ';') {
                                 break;
                             }
@@ -331,6 +332,8 @@ ScopeParser.prototype = {
                     var curTS = this.ts;
                     if (token.props) {
                         
+                        // { a : ... , c : .... }
+                        
                         for (var prop in token.props) {
                             
                             
@@ -356,12 +359,21 @@ ScopeParser.prototype = {
                         break;
                     }
                     
+                    // ( ... ) or { .... } not object literals..
                     
                     var _this = this;
-                    token.items.forEach(function(expr) {
-                          _this.ts = new TokenStream(expr);
-                          _this.parseExpression(scope)
-                    });
+                   for (var xx =0; xx < token.items.length; xx++) {
+                               expr = token.items[xx];
+                    //token.items.forEach(function(expr) {
+                            //print(expr.toString());
+                           _this.ts = new TokenStream(expr);
+                            //if (curTS.data == '(') {
+                                _this.parseScope(scope)
+                            //} else {
+                              //  _this.parseExpression(scope)
+                            //}
+                          
+                    }  
                     this.ts = curTS;
                     //print("NOT PROPS"); Seed.quit();
                     
@@ -560,7 +572,7 @@ ScopeParser.prototype = {
             
         
         //print(scopeIndent + ">> ENTER EXPRESSION" + this.expN);
-        while (token = this.ts.nextTok()) {
+        while ((token = this.ts.nextTok())) {
      
         
             
@@ -575,7 +587,7 @@ ScopeParser.prototype = {
            */ 
            
            //this.dumpToken(token,  this.scopes, this.braceNesting );
-           //print('EXPR' +  token.toString());
+            //print('EXPR' +  token.toString());
             
             
             //println("<i>"+token.data+"</i>");
@@ -737,8 +749,7 @@ ScopeParser.prototype = {
                         break;
                     }
                
-                    
-             
+                     
                     symbol = token.data;
                     if (this.mode == 'BUILDING_SYMBOL_TREE') {
                         
@@ -788,14 +799,16 @@ ScopeParser.prototype = {
 
         var symbol;
         var token;
-        var scope;
+         
         var identifier;
         
         //token = getToken(-1);
         //assert token.getType() == Token.CATCH;
-        token = this.ts.nextTok();
+        token = this.ts.nextTok(1);
+        token = this.ts.nextTok(1);
+        
         
-        //print(JSON.stringify(token,null,4));
+        //print(JSON.stringify(this.ts,null,4));
         //assert token.getType() == Token.LP; (
         //token = this.ts.nextTok();
         //assert token.getType() == Token.NAME;
@@ -814,7 +827,7 @@ ScopeParser.prototype = {
             identifier.refcount++;
         }
         
-        token = this.ts.nextTok();
+        //token = this.ts.nextTok();
         //assert token.getType() == Token.RP; // )
     },
     
@@ -847,11 +860,9 @@ ScopeParser.prototype = {
         
         // return function() {.... 
         while (token.data != "(") {
-            print(token.toString());
+            //print(token.toString());
             token =  this.ts.nextTok();
-            
-            
-            
+             
         }
         
         
@@ -947,4 +958,4 @@ ScopeParser.prototype = {
         }
         return false;
     }
-};
\ No newline at end of file
+};