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

index 3ffbe29..09d7212 100644 (file)
@@ -459,7 +459,7 @@ ScopeParser.prototype = {
         var parensNesting = 0;
 
         var isObjectLitAr = [ false ];
-        while (token = this.ts.lookT()) {
+        while (token = this.ts.look()) {
      
 
             
@@ -467,10 +467,10 @@ ScopeParser.prototype = {
             
             //println("<i>"+token.data+"</i>");
             
-            switch (token.type) {
+            switch (token.data.toUpperCase()) {
 
-                case 'semicolon':
-                case 'comma':
+                case ';':
+                case ',':
                     if (this.braceNesting == expressionBraceNesting &&
                             bracketNesting == 0 &&
                             parensNesting == 0) {
@@ -478,43 +478,43 @@ ScopeParser.prototype = {
                     }
                     break;
 
-                case 'function':
+                case 'FUNCTION':
                     this.parseFunctionDeclaration();
                     break;
 
-                case 'lbrace': //Token.LC:
+                case '{': //Token.LC:
                     isObjectLitAr.push(false);
                     
                     this.braceNesting++;
                     break;
 
-                case 'rbrace': //Token.RC:
+                case '}': //Token.RC:
                     this.braceNesting--;
                     isObjectLitAr.pop();
                     
                    // assert braceNesting >= expressionBraceNesting;
                     break;
 
-                case 'lbracket': //Token.LB:
+                case '[': //Token.LB:
                     bracketNesting++;
                     break;
 
-                case 'rbracket': //Token.RB:
+                case ']': //Token.RB:
                     bracketNesting--;
                     break;
 
-                case 'lparen': //Token.LP:
+                case '(': //Token.LP:
                     parensNesting++;
                     break;
 
-                case 'rparen': //Token.RP:
+                case ')': //Token.RP:
                     parensNesting--;
                     break;
-                    
-                    
+            }
+            switch(token.type) {
                    
-                case 'string': // used for object lit detection..
-                    if (this.ts.lookT(-1).isType('lbrace') && this.ts.lookT(1).isType('colon')) {
+                case 'STRN': // used for object lit detection..
+                    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);
@@ -523,8 +523,8 @@ ScopeParser.prototype = {
                     
                      
                     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..
                         var str = token.data.substring(1,token.data.length-1);
@@ -548,20 +548,21 @@ ScopeParser.prototype = {
                     }
                     break;
                 */
-                case 'identifier':
+                case 'NAME':
+                case 'KEYW':
                     symbol = token.data;
-                    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);
                         break;
                     }
                     var isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
-                    if (isInObjectLitAr && this.ts.lookT(-1).isType('comma') && this.ts.lookT(1).isType('colon')) {
+                    if (isInObjectLitAr && this.ts.look(-1).data == "," && this.ts.look(1).data == ":") {
                         break;
                     }
                     
-                    if (this.ts.lookT(-1).isType('dot')) {
+                    if (this.ts.look(-1).data == ".") {
                         //skip '.'
                         break;
                     }
@@ -700,7 +701,7 @@ ScopeParser.prototype = {
         
         // Parse function arguments.
         var argpos = 0;
-        while (!this.ts.lookT().isType('rparen')) { //(token = consumeToken()).getType() != Token.RP) {
+        while (!this.ts.look().isType('rparen')) { //(token = consumeToken()).getType() != Token.RP) {
             token = this.ts.nextT();
            
             //assert token.getType() == Token.NAME ||
@@ -721,7 +722,7 @@ ScopeParser.prototype = {
         this.braceNesting++;
 
         token = this.ts.nextT();
-        if (token.isType('string') && this.ts.lookT(1).isType('semicolon')) {
+        if (token.isType('string') && this.ts.look(1).isType('semicolon')) {
             /*
             
             NOT SUPPORTED YET!?!!?!