JSDOC/ScopeParser.vala
[gnome.introspection-doc-generator] / JSDOC / ScopeParser.vala
index 7a8a1e6..a6c181b 100644 (file)
@@ -24,7 +24,7 @@ namespace JSDOC {
     Gee.HashMap<int,Scope> indexedScopes;
     bool munge =  true;
 
-       
+    int expN =  0;     
        
        public ScopeParser(TokenStream ts) {
                this.ts = ts; // {TokenStream}
@@ -252,7 +252,7 @@ namespace JSDOC {
                         //this.logR("parseScope GOT VAR  : <B>" + token.toString() + "</B>"); 
                         if (token.type != "NAME") {
                                
-                            for(var i = Int.max(this.ts.cursor-10,0); i < this.ts.cursor+1; i++) {
+                            for(var i = int.max(this.ts.cursor-10,0); i < this.ts.cursor+1; i++) {
                                 print(this.ts.tokens[i].toString());
                             }
                             
@@ -427,13 +427,14 @@ namespace JSDOC {
                     }
                     isInObjectLitAr = isObjectLitAr.get(isObjectLitAr.size-1);
                     
-                    if (isInObjectLitAr &&  this.ts.lookTok(1).data == ':' &&
-                        ( this.ts.lookTok(-1).data == '{'  ||  this.ts.lookTok(-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..
                         var str = token.data.substring(1,token.data.length-1);
-                        if (/^[a-z_]+$/i.test(str) && ScopeParser.idents.indexOf(str) < 0) {
+                        
+                        if (Regex.match_simple ("^[a-z_]+$", str) && this.idents.index_of(str) < 0) {
                             token.outData = str;
                         }
                         
@@ -458,10 +459,11 @@ namespace JSDOC {
                     //print("SYMBOL: " + token.toString());
                     
                     symbol = token.data;
-                    if (symbol == 'this') {
+                    if (symbol == "this") {
                         break;
                     }
-                    if (this.mode == 'PASS2_SYMBOL_TREE') {
+                    
+                    if (this.mode == ScopeParserMode.PASS2_SYMBOL_TREE) {
                         
                         //println("GOT IDENT: -2 : " + this.ts.lookT(-2).toString() + " <BR> ..... -1 :  " +  this.ts.lookT(-1).toString() + " <BR> "); 
                         
@@ -480,7 +482,7 @@ namespace JSDOC {
                                 // We don't need to declare longer symbols since they won't cause
                                 // any conflict with other munged symbols.
                                 this.globalScope.declareIdentifier(symbol, token);
-                                this.warn("Found an undeclared symbol: " + symbol + ' (line:' + token.line + ')', true);
+                                this.warn("Found an undeclared symbol: " + symbol + " (line:" + token.line + ")", true);
                             }
                             
                             //println("GOT IDENT IGNORE(3): <B>" + symbol + "</B><BR/>");
@@ -493,7 +495,7 @@ namespace JSDOC {
                     break;
                     //println("<B>SID</B>");
                 default:
-                    if (token.type != 'KEYW') {
+                    if (token.type != "KEYW") {
                         break;
                     }
                     //print('SCOPE-KEYW:' + token.toString());
@@ -501,7 +503,7 @@ namespace JSDOC {
                 
                     symbol = token.data;
                     
-                     if (this.mode == 'BUILDING_SYMBOL_TREE') {
+                     if (this.mode == ScopeParserMode.BUILDING_SYMBOL_TREE) {
 
                         if (token.name == "EVAL") {
                             
@@ -512,6 +514,8 @@ namespace JSDOC {
                                 // look for eval:var:noreplace\n
                                 //print("MATCH!?");
                                 var _t = this;
+                                
+                                
                                 token.prefix.replace(/eval:var:([a-z_]+)/ig, function(m, a) {
                                     //print("GOT: " + a);
                                     var hi = _t.getIdentifier(a, scope, token);
@@ -548,38 +552,37 @@ namespace JSDOC {
         }
         //print("<<< EXIT SCOPE");
         //print("<<<<<<<EXIT SCOPE ERR?" +this.scopes.length);
-    },
+    }
+
 
-    expN : 0,
-    parseExpression : function(scope) {
+    
+    void parseExpression(Scope scope) 
+    {
 
         // Parse the expression until we encounter a comma or a semi-colon
         // in the same brace nesting, bracket nesting and paren nesting.
         // Parse functions if any...
         //println("<i>EXP</i><BR/>");
-        !this.debug || print("PARSE EXPR");
+        //!this.debug || print("PARSE EXPR");
         this.expN++;
          
         // for printing stuff..
        
         
         
-        var symbol;
-        var token;
-        
-        var identifier;
 
         var expressionBraceNesting = this.braceNesting + 0;
         var bracketNesting = 0;
         var parensNesting = 0;
         var isInObjectLitAr;
-        var isObjectLitAr = [ false ];
+        var isObjectLitAr = new Gee.ArrayList<boolean>();
+        isObjectLitAr.add( false);
         
         
             
         
         //print(scopeIndent + ">> ENTER EXPRESSION" + this.expN);
-        while ((token = this.ts.nextTok())) {
+        while (null != (token = this.ts.nextTok())) {
      
         
             
@@ -600,23 +603,23 @@ namespace JSDOC {
             //println("<i>"+token.data+"</i>");
             //this.log("EXP:" + token.data);
             switch (token.type) {
-                case 'PUNC':
+                case "PUNC":
                     //print("EXPR-PUNC:" + token.toString());
                     
                     switch(token.data) {
                          
-                        case ';':
+                        case ";":
                             //print("<< EXIT EXPRESSION");
                             break;
 
-                        case ',':
+                        case ",":
                             
                             break;
 
                        
-                        case '(': //Token.LP:
-                        case '{': //Token.LC:
-                        case '[': //Token.LB:
+                        case "(": //Token.LP:
+                        case "{": //Token.LC:
+                        case "[": //Token.LB:
                             //print('SCOPE-CURLY/PAREN/BRACE:' + token.toString());
                            // print('SCOPE-CURLY/PAREN/BRACE:' + JSON.stringify(token, null,4));
                             //println("<i>"+token.data+"</i>");