JSDOC/TokenStream.js
[gnome.introspection-doc-generator] / JSDOC / TokenStream.js
index 26f03c4..d42164d 100644 (file)
@@ -114,11 +114,14 @@ TokenStream = XObject.define(
                // print(i);
                 if (i < 0) {
                     if (n > -1) {
-                        i = 0; continue;
+                        i = 0; 
+                        continue;
                     }
-                    return   new Token("", "VOID", "END_OF_STREAM");
+                    return  new Token("", "VOID", "END_OF_STREAM");
+                }
+                else if (i > this.tokens.length)  {
+                    return  new Token("", "VOID", "END_OF_STREAM");
                 }
-                else if (i > this.tokens.length) return  new Token("", "VOID", "END_OF_STREAM");
 
                 if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("WHIT") || this.tokens[i].is("COMM"))) {
                     if (n < 0) i--; else i++;
@@ -185,18 +188,19 @@ TokenStream = XObject.define(
          */
         balance : function(/**String*/start, /**String*/stop) {
             
-            start = typeof(Lang.matching(start)) == 'undefined' ? Lang.punc(start) : start;
+            
+            start = typeof(Lang.punc(start)) == 'undefined' ? start : Lang.punc(start);
             
             if (!stop) stop = Lang.matching(start);
             
             var depth = 0;
             var got = [];
             var started = false;
-            Seed.print("START:" + start);
-            Seed.print("STOP:" + stop);
+            //Seed.print("START:" + start);
+            //Seed.print("STOP:" + stop);
             while ((token = this.look())) {
                 if (token.is(start)) {
-                   // Seed.print("balance: START : " + depth + " " + token.data);
+              //      Seed.print("balance: START : " + depth + " " + token.data);
                     depth++;
                     started = true;
                 }
@@ -207,8 +211,8 @@ TokenStream = XObject.define(
                 
                 if (token.is(stop)) {
                     depth--;
-                   // Seed.print("balance: STOP: "  + depth + " " + token.data);
-                    if (depth < 0) return got;
+                //    Seed.print("balance: STOP: "  + depth + " " + token.data);
+                    if (depth < 1) return got;
                 }
                 if (!this.next()) break;
             }