JSDOC/TokenReader.js
[gnome.introspection-doc-generator] / JSDOC / TokenStream.js
index 32ce52f..a9c685d 100644 (file)
@@ -195,6 +195,7 @@ TokenStream = XObject.define(
             //Seed.print("STOP:" + stop);
             while ((token = this.look())) {
                 if (token.is(start)) {
+                   // Seed.print("balance: START : " + depth + " " + token.data);
                     depth++;
                     started = true;
                 }
@@ -205,7 +206,8 @@ TokenStream = XObject.define(
                 
                 if (token.is(stop)) {
                     depth--;
-                    if (depth == 0) return got;
+                   // Seed.print("balance: STOP: "  + depth + " " + token.data);
+                    if (depth < 0) return got;
                 }
                 if (!this.next()) break;
             }
@@ -258,11 +260,15 @@ TokenStream = XObject.define(
             })
             return ret.join('');
         },
-        dump: function()
+        dump: function(start, end)
         {
-            this.tokens.forEach(function(t) {
-                print(t.toString());
-            });
+            start = Math.max(start || 0, 0);
+            end = Math.min(end || this.tokens.length, this.tokens.length);
+            var out='';
+            for (var i =start;i < end; i++) {
+                out += this.tokens[i].data;
+            };
+            print(out);
         }
 });
     
\ No newline at end of file