JSDOC/ScopeParser.js
[gnome.introspection-doc-generator] / JSDOC / ScopeParser.js
index 216b99a..98ca9cf 100644 (file)
@@ -1,7 +1,7 @@
 //<Script type="text/javascript">
 
-Scope = imports['JSDOC/Scope.js'].Scope;
-
+Scope = imports.Scope.Scope;
+TokenStream = imports.TokenStream.TokenStream;
 /**
 * Scope stuff
 * 
@@ -229,7 +229,7 @@ ScopeParser.prototype = {
         //this.scopes.forEach(function() {
         //    scopeIndent += '   '; 
         //});
-        //print(scopeIndent + ">> ENTER SCOPE");
+        print(">> ENTER SCOPE");
         
         
         
@@ -238,7 +238,7 @@ ScopeParser.prototype = {
         while (token) {
           //  this.timerPrint("parseScope AFTER lookT: " + token.toString()); 
             //this.dumpToken(token , this.scopes, this.braceNesting);
-            //print('SCOPE:' + token.toString());
+            print('SCOPE:' + token.toString());
             //this.log(token.data);
             if (token.type == 'NAME') {
             //    print('*' + token.data);
@@ -313,7 +313,7 @@ ScopeParser.prototype = {
                     
                     break;
                 case "KEYW.FUNCTION":
-                    print('SCOPE-FUNC:' + token.toString());
+                    print('SCOPE-FUNC:' + JSON.stringify(token,null,4));
                     //println("<i>"+token.data+"</i>");
                      var bn = this.braceNesting;
                     this.parseFunctionDeclaration();
@@ -321,7 +321,7 @@ ScopeParser.prototype = {
                     break;
 
                 case "PUNC.LEFT_CURLY": // {
-                    print('SCOPE-CURLY:' + JSON.stringify(token,null,4));
+                    
                     //println("<i>"+token.data+"</i>");
                     
                     if (token.props) {
@@ -344,6 +344,7 @@ ScopeParser.prototype = {
                         // the values could be replaced..
                         
                     }
+                    print('SCOPE-CURLY:' + JSON.stringify(token,null,4));
                     print("NOT PROPS"); Seed.quit();
                     
                     isObjectLitAr.push(false);
@@ -851,10 +852,12 @@ ScopeParser.prototype = {
           
         }
         
+        print('FUNC-PARSE:' + JSON.stringify(token,null,4));
         // Parse function arguments.
-        var argpos = 0;
-        while (this.ts.lookTok().data != ')') { //(token = consumeToken()).getType() != Token.RP) {
-            token = this.ts.nextTok();
+        var args = token.items;
+        for (var argpos =0; argpos < args.length; argpos++) {
+             
+            token = args[argpos][0];
            // print ("FUNC ARGS: " + token.toString())
             //assert token.getType() == Token.NAME ||
             //        token.getType() == Token.COMMA;
@@ -868,20 +871,30 @@ ScopeParser.prototype = {
                 argpos++;
             }
         }
-
+        
         token = this.ts.nextTok();
+        print('FUNC-BODY:' + JSON.stringify(token.items,null,4));
+        //Seed.quit();
         //print(token.toString());
         // assert token.getType() == Token.LC;
-        this.braceNesting++;
-
-        token = this.ts.nextTok();
+        //this.braceNesting++;
+        
+        //token = this.ts.nextTok();
         //print(token.toString());
-     
-
-        this.parseScope(fnScope);
+        var outTS = this.ts;
+        var _this = this;
+        token.items.forEach(function(tar) {
+            _this.ts = new TokenStream(tar);
+            _this.parseScope(fnScope);
+            
+        }
+        
+        //print(JSON.stringify(this.ts,null,4));
+        //this.parseScope(fnScope);
+        this.ts = outTS;
         // now pop it off the stack!!!
        
-        this.braceNesting = b4braceNesting;
+        //this.braceNesting = b4braceNesting;
         //print("ENDFN -1: " + this.ts.lookTok(-1).toString());
         //print("ENDFN 0: " + this.ts.lookTok(0).toString());
         //print("ENDFN 1: " + this.ts.lookTok(1).toString());