X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fcom%2Fstevesoft%2Fpat%2FRegexTokenizer.js;h=c5774f3b051e5e5d626e2008bffee75047ba40c5;hp=08cc754db94af9556cbfbb550e0bc9bb0b9ae609;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/com/stevesoft/pat/RegexTokenizer.js b/bin/com/stevesoft/pat/RegexTokenizer.js index 08cc754..c5774f3 100644 --- a/bin/com/stevesoft/pat/RegexTokenizer.js +++ b/bin/com/stevesoft/pat/RegexTokenizer.js @@ -1,104 +1,104 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.util.Enumeration", "$.Vector"], "com.stevesoft.pat.RegexTokenizer", ["com.stevesoft.pat.Regex"], function () { -c$ = Clazz.decorateAsClass (function () { -this.toParse = null; -this.r = null; -this.count = 0; -this.v = null; -this.vi = null; -this.pos = 0; -this.offset = 1; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RegexTokenizer", null, java.util.Enumeration); -Clazz.prepareFields (c$, function () { -this.v = new java.util.Vector (); -this.vi = new java.util.Vector (); -}); -Clazz.defineMethod (c$, "getMore", -function () { -var s = this.r.right (); -if (this.r.searchFrom (this.toParse, this.pos)) { -this.v.addElement (this.r.left ().substring (this.pos)); -this.vi.addElement ( new Integer (this.r.matchFrom () + this.r.charsMatched ())); -for (var i = 0; i < this.r.numSubs (); i++) { -if (this.r.substring () != null) { -this.v.addElement (this.r.substringI (i + this.offset)); -this.vi.addElement ( new Integer (this.r.matchFromI (i + this.offset) + this.r.charsMatchedI (i + this.offset))); -}} -this.pos = this.r.matchFrom () + this.r.charsMatched (); -} else if (s != null) { -this.v.addElement (s); -}}); -Clazz.makeConstructor (c$, -function (txt, ptrn) { -this.toParse = txt; -this.r = new com.stevesoft.pat.Regex (ptrn, ""); -this.offset = com.stevesoft.pat.Regex.BackRefOffset; -this.getMore (); -}, "~S,~S"); -Clazz.makeConstructor (c$, -function (txt, r) { -this.toParse = txt; -this.r = r; -this.offset = com.stevesoft.pat.Regex.BackRefOffset; -this.getMore (); -}, "~S,com.stevesoft.pat.Regex"); -Clazz.overrideMethod (c$, "nextElement", -function () { -if (this.count >= this.v.size ()) { -this.getMore (); -}return this.v.elementAt (this.count++); -}); -Clazz.defineMethod (c$, "nextToken", -function () { -return this.nextElement (); -}); -Clazz.defineMethod (c$, "nextToken", -function (newpat) { -try { -this.r.compile (newpat); -} catch (r_) { -if (Clazz.exceptionOf (r_, com.stevesoft.pat.RegSyntax)) { -} else { -throw r_; -} -} -return this.nextToken (this.r); -}, "~S"); -Clazz.defineMethod (c$, "nextToken", -function (nr) { -this.r = nr; -if (this.vi.size () > this.count) { -this.pos = (this.vi.elementAt (this.count)).intValue (); -this.v.setSize (this.count); -this.vi.setSize (this.count); -}this.getMore (); -return this.nextToken (); -}, "com.stevesoft.pat.Regex"); -Clazz.overrideMethod (c$, "hasMoreElements", -function () { -if (this.count >= this.v.size ()) { -this.getMore (); -}return this.count < this.v.size (); -}); -Clazz.defineMethod (c$, "hasMoreTokens", -function () { -return this.hasMoreElements (); -}); -Clazz.defineMethod (c$, "countTokens", -function () { -var _count = this.count; -while (this.hasMoreTokens ()) { -this.nextToken (); -} -this.count = _count; -return this.v.size () - this.count; -}); -Clazz.defineMethod (c$, "allTokens", -function () { -this.countTokens (); -var ret = new Array (this.v.size ()); -this.v.copyInto (ret); -return ret; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.util.Enumeration", "$.Vector"], "com.stevesoft.pat.RegexTokenizer", ["com.stevesoft.pat.Regex"], function () { +c$ = Clazz.decorateAsClass (function () { +this.toParse = null; +this.r = null; +this.count = 0; +this.v = null; +this.vi = null; +this.pos = 0; +this.offset = 1; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RegexTokenizer", null, java.util.Enumeration); +Clazz.prepareFields (c$, function () { +this.v = new java.util.Vector (); +this.vi = new java.util.Vector (); +}); +Clazz.defineMethod (c$, "getMore", +function () { +var s = this.r.right (); +if (this.r.searchFrom (this.toParse, this.pos)) { +this.v.addElement (this.r.left ().substring (this.pos)); +this.vi.addElement ( new Integer (this.r.matchFrom () + this.r.charsMatched ())); +for (var i = 0; i < this.r.numSubs (); i++) { +if (this.r.substring () != null) { +this.v.addElement (this.r.substringI (i + this.offset)); +this.vi.addElement ( new Integer (this.r.matchFromI (i + this.offset) + this.r.charsMatchedI (i + this.offset))); +}} +this.pos = this.r.matchFrom () + this.r.charsMatched (); +} else if (s != null) { +this.v.addElement (s); +}}); +Clazz.makeConstructor (c$, +function (txt, ptrn) { +this.toParse = txt; +this.r = new com.stevesoft.pat.Regex (ptrn, ""); +this.offset = com.stevesoft.pat.Regex.BackRefOffset; +this.getMore (); +}, "~S,~S"); +Clazz.makeConstructor (c$, +function (txt, r) { +this.toParse = txt; +this.r = r; +this.offset = com.stevesoft.pat.Regex.BackRefOffset; +this.getMore (); +}, "~S,com.stevesoft.pat.Regex"); +Clazz.overrideMethod (c$, "nextElement", +function () { +if (this.count >= this.v.size ()) { +this.getMore (); +}return this.v.elementAt (this.count++); +}); +Clazz.defineMethod (c$, "nextToken", +function () { +return this.nextElement (); +}); +Clazz.defineMethod (c$, "nextToken", +function (newpat) { +try { +this.r.compile (newpat); +} catch (r_) { +if (Clazz.exceptionOf (r_, com.stevesoft.pat.RegSyntax)) { +} else { +throw r_; +} +} +return this.nextToken (this.r); +}, "~S"); +Clazz.defineMethod (c$, "nextToken", +function (nr) { +this.r = nr; +if (this.vi.size () > this.count) { +this.pos = (this.vi.elementAt (this.count)).intValue (); +this.v.setSize (this.count); +this.vi.setSize (this.count); +}this.getMore (); +return this.nextToken (); +}, "com.stevesoft.pat.Regex"); +Clazz.overrideMethod (c$, "hasMoreElements", +function () { +if (this.count >= this.v.size ()) { +this.getMore (); +}return this.count < this.v.size (); +}); +Clazz.defineMethod (c$, "hasMoreTokens", +function () { +return this.hasMoreElements (); +}); +Clazz.defineMethod (c$, "countTokens", +function () { +var _count = this.count; +while (this.hasMoreTokens ()) { +this.nextToken (); +} +this.count = _count; +return this.v.size () - this.count; +}); +Clazz.defineMethod (c$, "allTokens", +function () { +this.countTokens (); +var ret = new Array (this.v.size ()); +this.v.copyInto (ret); +return ret; +}); +});