JSDOC/ScopeParser.js
authoralan <alan@alanfast.akbkhome.com>
Mon, 19 Apr 2010 04:33:25 +0000 (12:33 +0800)
committeralan <alan@alanfast.akbkhome.com>
Mon, 19 Apr 2010 04:33:25 +0000 (12:33 +0800)
JSDOC/ScopeParser.js

index 6a95bb7..7a40d46 100644 (file)
@@ -201,27 +201,27 @@ ScopeParser.prototype = {
         var isObjectLitAr = [ false ];
         
         this.scopes.push(scope);
-        token = this.ts.lookT();
+        token = this.ts.lookTok();
         while (token) {
           //  this.timerPrint("parseScope AFTER lookT: " + token.toString()); 
              
             //println("START<i>"+token.data+"</i>");
-            switch(token.tokN) {
-                case Script.TOKvar:
-                case Script.TOKconst:
+            switch(token.type + '.' token.name) {
+                case "KEYW.VAR":
+                case "KEYW.CONST": // not really relivant as it's only mozzy that does this.
                     
                     //this.log("parseScope GOT VAR/CONST : " + token.toString()); 
                     while (true) {
-                        token = this.ts.nextT();
+                        token = this.ts.next();
                         
-                        if (token.tokN == Script.TOKvar) { // kludge..
+                        if (token.name == "var") { // kludge..
                             continue;
                         }
                         if (!token) { // can return false at EOF!
                             break;
                         }
                         //this.logR("parseScope GOT VAR  : <B>" + token.toString() + "</B>"); 
-                        if (!token.isType('identifier')) {
+                        if (!token.type =="NAME") {
                             println(token.toString());
                             throw "var without ident";
                         }
@@ -231,45 +231,45 @@ ScopeParser.prototype = {
                             identifier = scope.getIdentifier(token.data) ;
                             
                             if (identifier == false) {
-                                scope.declareIdentifier(token.data,token);
+                                scope.declareIdentifier(token.data, token);
                             } else {
                                 token.identifier = identifier;
                                 this.warn("The variable " + symbol + " has already been declared in the same scope...");
                             }
                         }
 
-                        token = this.ts.nextT();
+                        token = this.ts.next();
                         /*
                         assert token.getType() == Token.SEMI ||
                                 token.getType() == Token.ASSIGN ||
                                 token.getType() == Token.COMMA ||
                                 token.getType() == Token.IN;
                         */
-                        if (token.isType('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.lookT(0).isType('semicolon')) {
+                            if (this.ts.look(0).data == ';') {
                                 break;
                             }
                         }
                     }
                     break;
-                case Script.TOKfunction:
+                case "KEYW.FUNCTION":
                     //println("<i>"+token.data+"</i>");
                     this.parseFunctionDeclaration();
                     break;
 
-                case Script.TOKlbrace: // {
+                case "KEYW.LEFT_CURLY": // {
                     //println("<i>"+token.data+"</i>");
                     isObjectLitAr.push(false);
                     this.braceNesting++;
                     break;
 
-                case Script.TOKrbrace: // }
+                case "KEYW.RIGHT_CURLY": // }
                     //println("<i>"+token.data+"</i>");
                     this.braceNesting--;
                     isObjectLitAr.pop();
@@ -281,7 +281,7 @@ ScopeParser.prototype = {
                     }
                     break;
 
-                case Script.TOKwith:
+                case "KEYW.WITH":
                     //println("<i>"+token.data+"</i>");   
                     if (this.mode == "BUILDING_SYMBOL_TREE") {
                         // Inside a 'with' block, it is impossible to figure out
@@ -294,7 +294,7 @@ ScopeParser.prototype = {
                     }
                     break;
 
-                case Script.TOKcatch:
+                case "KEYW.CATCH":
                     //println("<i>"+token.data+"</i>");
                     this.parseCatch();
                     break;
@@ -307,16 +307,18 @@ ScopeParser.prototype = {
                         break;
                 */
                 
-                case Script.TOKstring: // used for object lit detection..
+                case "STRN.DOUBLE_QUOTE": // used for object lit detection..
+                case "STRN.SINGLE_QUOTE":
                     //println("<i>"+token.data+"</i>");
-                    if (this.ts.lookT(-1).isType('lbrace') && this.ts.lookT(1).isType('colon')) {
+                    if (this.ts.look(-1).data == '{' && this.ts.look(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.lookT(1).isType('colon') &&
-                        ( this.ts.lookT(-11).isType('lbrace') ||  this.ts.lookT(-1).isType('comma'))) {
+                    
+                    if (isInObjectLitAr &&  this.ts.look(1).data == ':' &&
+                        ( this.ts.look(-1).data == '{'  ||  this.ts.look(-1).data == ':' )) {
                         // see if we can replace..
                         // remove the quotes..
                         // should do a bit more checking!!!! (what about wierd char's in the string..
@@ -334,11 +336,14 @@ ScopeParser.prototype = {
                     break;
                 
                 
-                
-                case Script.TOKidentifier:
+                default: 
+                    if (token.type != "NAME") {
+                        break;
+                    }
+                    // got identifier..
                     
                     // look for  { ** : <- indicates obj literal.. ** this could occur with numbers ..
-                    if ((this.ts.lookT(-1).tokN ==Script.TOKlbrace) && (this.ts.lookT(1).tokN == Script.TOKcolon)) {
+                    if ((this.ts.look(-1).data == "{") && (this.ts.look(1).data == ":")) {
                         isObjectLitAr.pop();
                         isObjectLitAr.push(true);
                         //println("<i>"+token.data+"</i>");
@@ -346,7 +351,7 @@ ScopeParser.prototype = {
                     }
                     var isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
                     
-                    if (isInObjectLitAr && (this.ts.lookT(1).tokN == Script.TOKcolon) && (this.ts.lookT(-1).tokN == Script.TOKcomma)) {
+                    if (isInObjectLitAr && (this.ts.look(1).data == ":") && (this.ts.look(-1).data == ",")) {
                         // skip, it's an object lit key..
                         //println("<i>"+token.data+"</i>");
                         break;
@@ -355,7 +360,7 @@ ScopeParser.prototype = {
                     
                     // skip anyting with "." before it..!!
                     
-                    if (this.ts.lookT(-1).isType('dot')) {
+                    if (this.ts.look(-1).data(".")) {
                         // skip, it's an object prop.
                         //println("<i>"+token.data+"</i>");
                         break;