From 7b90a14b811e7d787afa5ffde75baac2ae1e17d2 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 7 Jul 2010 07:39:45 +0800 Subject: [PATCH] JSDOC/DocTag.js --- JSDOC/DocTag.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/JSDOC/DocTag.js b/JSDOC/DocTag.js index d9fa27b..296eea8 100644 --- a/JSDOC/DocTag.js +++ b/JSDOC/DocTag.js @@ -13,6 +13,12 @@ Options = imports.Options.Options; DocTag = XObject.define( + +/** + * @constructor + * @arg {String} src + */ + function(src) { this.title = ""; this.type = ""; @@ -164,6 +170,29 @@ DocTag = XObject.define( return src; } + + balance : function(str, open, close) { + var i = 0; + while (str.charAt(i) != open) { + if (i == str.length) return [-1, -1]; + i++; + } + + var j = i+1; + var balance = 1; + while (j < str.length) { + if (str.charAt(j) == open) balance++; + if (str.charAt(j) == close) balance--; + if (balance == 0) break; + j++; + if (j == str.length) return [-1, -1]; + } + + return [i, j]; +} + + + }); // cached support? -- 2.39.2