JSDOC/ScopeParser.js
[gnome.introspection-doc-generator] / JSDOC / ScopeParser.js
index 6786600..6922034 100644 (file)
@@ -201,12 +201,12 @@ ScopeParser.prototype = {
         var isObjectLitAr = [ false ];
         
         this.scopes.push(scope);
-        token = this.ts.lookTok();
+        token = this.ts.lookTok(1);
         while (token) {
           //  this.timerPrint("parseScope AFTER lookT: " + token.toString()); 
              
-            //println("START<i>"+token.data+"</i>");
-            switch(token.type + '.' token.name) {
+            print(token.type + '.' + token.name+ ":" + token.data);
+            switch(token.type + '.' token.name) {
                 case "KEYW.VAR":
                 case "KEYW.CONST": // not really relivant as it's only mozzy that does this.
                     
@@ -245,14 +245,14 @@ ScopeParser.prototype = {
                                 token.getType() == Token.COMMA ||
                                 token.getType() == Token.IN;
                         */
-                        if (token.name == "IN")) {
+                        if (token.name == "IN") {
                             break;
                         } else {
                             this.parseExpression();
                             //this.logR("parseScope DONE  : <B>ParseExpression</B> - tok is:" + this.ts.lookT(0).toString()); 
                             
                             
-                            if (this.ts.look(0).data == ';') {
+                            if (this.ts.lookTok(0).data == ';') {
                                 break;
                             }
                         }
@@ -310,15 +310,15 @@ ScopeParser.prototype = {
                 case "STRN.DOUBLE_QUOTE": // used for object lit detection..
                 case "STRN.SINGLE_QUOTE":
                     //println("<i>"+token.data+"</i>");
-                    if (this.ts.look(-1).data == '{' && this.ts.look(1).data == ':') {
+                    if (this.ts.lookTok(-1).data == '{' && this.ts.lookTok(1).data == ':') {
                         // then we are in an object lit.. -> we need to flag the brace as such...
                         isObjectLitAr.pop();
                         isObjectLitAr.push(true);
                     }
                     var isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
                     
-                    if (isInObjectLitAr &&  this.ts.look(1).data == ':' &&
-                        ( this.ts.look(-1).data == '{'  ||  this.ts.look(-1).data == ':' )) {
+                    if (isInObjectLitAr &&  this.ts.lookTok(1).data == ':' &&
+                        ( this.ts.lookTok(-1).data == '{'  ||  this.ts.lookTok(-1).data == ':' )) {
                         // see if we can replace..
                         // remove the quotes..
                         // should do a bit more checking!!!! (what about wierd char's in the string..
@@ -337,21 +337,23 @@ ScopeParser.prototype = {
                 
                 
                 default: 
-                    if ((token.type != "NAME") && (token.type != "KEYW"){
+                    if ((token.type != "NAME") && (token.type != "KEYW")){
                         break;
                     }
+                    print("DEAL WITH NAME:");
                     // got identifier..
                     
                     // look for  { ** : <- indicates obj literal.. ** this could occur with numbers ..
-                    if ((this.ts.look(-1).data == "{") && (this.ts.look(1).data == ":")) {
+                    if ((this.ts.lookTok(-1).data == "{") && (this.ts.lookTok(1).data == ":")) {
                         isObjectLitAr.pop();
                         isObjectLitAr.push(true);
                         //println("<i>"+token.data+"</i>");
                         break;
                     }
+                    print("DEAL WITH obj lit:");
                     var isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
                     
-                    if (isInObjectLitAr && (this.ts.look(1).data == ":") && (this.ts.look(-1).data == ",")) {
+                    if (isInObjectLitAr && (this.ts.lookTok(1).data == ":") && (this.ts.lookTok(-1).data == ",")) {
                         // skip, it's an object lit key..
                         //println("<i>"+token.data+"</i>");
                         break;
@@ -359,8 +361,8 @@ ScopeParser.prototype = {
                     
                     
                     // skip anyting with "." before it..!!
-                    
-                    if (this.ts.look(-1).data(".")) {
+                     
+                    if (this.ts.lookTok(-1).data == ".") {
                         // skip, it's an object prop.
                         //println("<i>"+token.data+"</i>");
                         break;
@@ -368,7 +370,7 @@ ScopeParser.prototype = {
                     
                     //println("<B>SID</B>");
                    
-                
+                    print("Check eval:");
                 
                     symbol = token.data;
                     
@@ -459,7 +461,7 @@ ScopeParser.prototype = {
         var parensNesting = 0;
 
         var isObjectLitAr = [ false ];
-        while (token = this.ts.look()) {
+        while (token = this.ts.lookTok()) {
      
 
             
@@ -514,7 +516,7 @@ ScopeParser.prototype = {
             switch(token.type) {
                    
                 case 'STRN': // used for object lit detection..
-                    if (this.ts.look(-1).data == "{" && this.ts.look(1).data == ":" ) {
+                    if (this.ts.lookTok(-1).data == "{" && this.ts.lookTok(1).data == ":" ) {
                         // then we are in an object lit.. -> we need to flag the brace as such...
                         isObjectLitAr.pop();
                         isObjectLitAr.push(true);
@@ -523,8 +525,8 @@ ScopeParser.prototype = {
                     
                      
                     var isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
-                    if (isInObjectLitAr &&  this.ts.look(1).data = ":"  &&
-                        ( this.ts.look(-1).data == "{"  ||  this.ts.look(-1).data == "," )) {
+                    if (isInObjectLitAr &&  this.ts.lookTok(1).data == ":"  &&
+                        ( this.ts.lookTok(-1).data == "{"  ||  this.ts.lookTok(-1).data == "," )) {
                         // see if we can replace..
                         // remove the quotes..
                         var str = token.data.substring(1,token.data.length-1);
@@ -551,18 +553,18 @@ ScopeParser.prototype = {
                 case 'NAME':
                 case 'KEYW':
                     symbol = token.data;
-                    if (this.ts.look(-1).data == "{"  && this.ts.look(1).data == ":") {
+                    if (this.ts.lookTok(-1).data == "{"  && this.ts.lookTok(1).data == ":") {
                         // then we are in an object lit.. -> we need to flag the brace as such...
                         isObjectLitAr.pop();
                         isObjectLitAr.push(true);
                         break;
                     }
                     var isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
-                    if (isInObjectLitAr && this.ts.look(-1).data == "," && this.ts.look(1).data == ":") {
+                    if (isInObjectLitAr && this.ts.lookTok(-1).data == "," && this.ts.lookTok(1).data == ":") {
                         break;
                     }
                     
-                    if (this.ts.look(-1).data == ".") {
+                    if (this.ts.lookTok(-1).data == ".") {
                         //skip '.'
                         break;
                     }
@@ -658,7 +660,7 @@ ScopeParser.prototype = {
             identifier.refcount++;
         }
 
-        token = this.ts.nextT();
+        token = this.ts.nextTok();
         //assert token.getType() == Token.RP; // )
     },
     
@@ -666,15 +668,15 @@ ScopeParser.prototype = {
     {
 
         var symbol;
-        var  token;
+        var token;
         var currentScope  = false; 
         var fnScope = false;
         var identifier;
         //this.logR("<B>PARSING FUNCTION</B>");
         currentScope = this.scopes[this.scopes.length-1];
 
-        token = this.ts.nextT();
-        if (token.isType('identifier')) {
+        token = this.ts.nextTok();
+        if (token.type == "NAME") {
             if (this.mode == 'BUILDING_SYMBOL_TREE') {
                 // Get the name of the function and declare it in the current scope.
                 symbol = token.data;
@@ -683,7 +685,7 @@ ScopeParser.prototype = {
                 }
                 currentScope.declareIdentifier(symbol,token);
             }
-            token =  this.ts.nextT();
+            token =  this.ts.nextTok();
         }
 
         //assert token.getType() == Token.LP;
@@ -701,12 +703,12 @@ ScopeParser.prototype = {
         
         // Parse function arguments.
         var argpos = 0;
-        while (!this.ts.look().isType('rparen')) { //(token = consumeToken()).getType() != Token.RP) {
-            token = this.ts.nextT();
+        while (!this.ts.lookTok().data == ')') { //(token = consumeToken()).getType() != Token.RP) {
+            token = this.ts.nextTok();
            
             //assert token.getType() == Token.NAME ||
             //        token.getType() == Token.COMMA;
-            if (token.isType('identifier') && this.mode == 'BUILDING_SYMBOL_TREE') {
+            if (token.type == 'NAME' && this.mode == 'BUILDING_SYMBOL_TREE') {
                 symbol = token.data;
                 identifier = fnScope.declareIdentifier(symbol,token);
                 if (symbol == "$super" && argpos == 0) {
@@ -717,12 +719,12 @@ ScopeParser.prototype = {
             }
         }
 
-        token = this.ts.nextT();
+        token = this.ts.nextTok();
         // assert token.getType() == Token.LC;
         this.braceNesting++;
 
-        token = this.ts.nextT();
-        if (token.isType('string') && this.ts.look(1).isType('semicolon')) {
+        token = this.ts.nextTok();
+        if (token.type == "STRN" && this.ts.lookTok(1).data == ';') {
             /*
             
             NOT SUPPORTED YET!?!!?!
@@ -807,4 +809,4 @@ ScopeParser.prototype = {
         }
         return false;
     }
-});
\ No newline at end of file
+};
\ No newline at end of file