X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=JSDOC%2FTokenStream.js;h=7b3328f3eefe541c02d2d850d23810080890d27e;hp=5cead7a9df1c50ea3652cd8881dfc8569d5c8be1;hb=759466942f163998373b165f409fd9cfaaa9910f;hpb=6ce22f0aa9c91333c6b954de5b31a3fa56b51186 diff --git a/JSDOC/TokenStream.js b/JSDOC/TokenStream.js index 5cead7a..7b3328f 100644 --- a/JSDOC/TokenStream.js +++ b/JSDOC/TokenStream.js @@ -137,8 +137,11 @@ TokenStream = XObject.define( }, /** - @type JSDOC.Token|JSDOC.Token[]| null! - */ + * @return {Token|null} + * next token (with white space) + */ + + next : function(/**Number*/howMany) { if (typeof howMany == "undefined") howMany = 1; if (howMany < 1) return null; @@ -183,16 +186,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); while ((token = this.look())) { if (token.is(start)) { + // Seed.print("balance: START : " + depth + " " + token.data); depth++; started = true; } @@ -203,7 +209,8 @@ TokenStream = XObject.define( if (token.is(stop)) { depth--; - if (depth == 0) return got; + // Seed.print("balance: STOP: " + depth + " " + token.data); + if (depth < 1) return got; } if (!this.next()) break; } @@ -256,11 +263,16 @@ 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].outData == false) ? this.tokens[i].data : this.tokens[i].outData; + }; + print(out); } }); \ No newline at end of file