X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fcom%2Fstevesoft%2Fpat%2FFastMulti.js;h=16ffec1a910864e6930204c1cf8cdb6e67527d90;hp=898aa9e2676a65d66ab7bac9387e88670e006d58;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/site/j2s/com/stevesoft/pat/FastMulti.js b/site/j2s/com/stevesoft/pat/FastMulti.js index 898aa9e..16ffec1 100644 --- a/site/j2s/com/stevesoft/pat/FastMulti.js +++ b/site/j2s/com/stevesoft/pat/FastMulti.js @@ -1,108 +1,108 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.FastMulti", ["com.stevesoft.pat.RegSyntaxError", "$.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fewestMatches = null; -this.mostMatches = null; -this.matchFewest = false; -this.step = -1; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "FastMulti", com.stevesoft.pat.PatternSub); -Clazz.overrideMethod (c$, "minChars", -function () { -return this.sub.countMinChars ().mul (this.fewestMatches); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return this.sub.countMaxChars ().mul (this.mostMatches); -}); -Clazz.makeConstructor (c$, -function (a, b, p) { -Clazz.superConstructor (this, com.stevesoft.pat.FastMulti, []); -if (p == null) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Null length pattern followed by *, +, or other Multi."); -}this.fewestMatches = a; -this.mostMatches = b; -this.sub = p; -this.step = p.countMinChars ().intValue (); -this.sub.setParent (null); -}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); -Clazz.defineMethod (c$, "toString", -function () { -return this.sub.toString () + "{" + this.fewestMatches + "," + this.mostMatches + "}" + (this.matchFewest ? "?" : "") + "(?# <= fast multi)" + this.nextString (); -}); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -var m = -1; -var i = pos; -var endstr = pt.src.length () - this.step; -var matches = new com.stevesoft.pat.patInt (0); -if (this.matchFewest) { -if (this.fewestMatches.lessEq (matches)) { -var ii = this.nextMatch (i, pt); -if (ii >= 0) { -return ii; -}}while (i >= 0 && i <= endstr) { -i = this.sub.matchInternal (i, pt); -if (i >= 0) { -matches.inc (); -if (this.fewestMatches.lessEq (matches)) { -var ii = this.nextMatch (i, pt); -if (ii >= 0) { -return ii; -}}if (matches.equals (this.mostMatches)) { -return -1; -}}} -return -1; -}var nMatches = 0; -while (this.fewestMatches.intValue () > nMatches) { -i = this.sub.matchInternal (i, pt); -if (i >= 0) { -nMatches++; -} else { -return -1; -}} -m = i; -if (this.mostMatches.finite ()) { -while (nMatches < this.mostMatches.intValue ()) { -i = this.sub.matchInternal (i, pt); -if (i >= 0) { -m = i; -nMatches++; -} else { -break; -}} -} else { -while (true) { -i = this.sub.matchInternal (i, pt); -if (i >= 0) { -m = i; -nMatches++; -} else { -break; -}} -}while (m >= pos) { -var r = this.nextMatch (m, pt); -if (r >= 0) { -return r; -}m -= this.step; -nMatches--; -if (nMatches < this.fewestMatches.intValue ()) { -return -1; -}} -return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -try { -var fm = new com.stevesoft.pat.FastMulti (this.fewestMatches, this.mostMatches, this.sub.clone (h)); -fm.matchFewest = this.matchFewest; -return fm; -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -return null; -} else { -throw rs; -} -} -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.FastMulti", ["com.stevesoft.pat.RegSyntaxError", "$.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fewestMatches = null; +this.mostMatches = null; +this.matchFewest = false; +this.step = -1; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "FastMulti", com.stevesoft.pat.PatternSub); +Clazz.overrideMethod (c$, "minChars", +function () { +return this.sub.countMinChars ().mul (this.fewestMatches); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return this.sub.countMaxChars ().mul (this.mostMatches); +}); +Clazz.makeConstructor (c$, +function (a, b, p) { +Clazz.superConstructor (this, com.stevesoft.pat.FastMulti, []); +if (p == null) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Null length pattern followed by *, +, or other Multi."); +}this.fewestMatches = a; +this.mostMatches = b; +this.sub = p; +this.step = p.countMinChars ().intValue (); +this.sub.setParent (null); +}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); +Clazz.defineMethod (c$, "toString", +function () { +return this.sub.toString () + "{" + this.fewestMatches + "," + this.mostMatches + "}" + (this.matchFewest ? "?" : "") + "(?# <= fast multi)" + this.nextString (); +}); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +var m = -1; +var i = pos; +var endstr = pt.src.length () - this.step; +var matches = new com.stevesoft.pat.patInt (0); +if (this.matchFewest) { +if (this.fewestMatches.lessEq (matches)) { +var ii = this.nextMatch (i, pt); +if (ii >= 0) { +return ii; +}}while (i >= 0 && i <= endstr) { +i = this.sub.matchInternal (i, pt); +if (i >= 0) { +matches.inc (); +if (this.fewestMatches.lessEq (matches)) { +var ii = this.nextMatch (i, pt); +if (ii >= 0) { +return ii; +}}if (matches.equals (this.mostMatches)) { +return -1; +}}} +return -1; +}var nMatches = 0; +while (this.fewestMatches.intValue () > nMatches) { +i = this.sub.matchInternal (i, pt); +if (i >= 0) { +nMatches++; +} else { +return -1; +}} +m = i; +if (this.mostMatches.finite ()) { +while (nMatches < this.mostMatches.intValue ()) { +i = this.sub.matchInternal (i, pt); +if (i >= 0) { +m = i; +nMatches++; +} else { +break; +}} +} else { +while (true) { +i = this.sub.matchInternal (i, pt); +if (i >= 0) { +m = i; +nMatches++; +} else { +break; +}} +}while (m >= pos) { +var r = this.nextMatch (m, pt); +if (r >= 0) { +return r; +}m -= this.step; +nMatches--; +if (nMatches < this.fewestMatches.intValue ()) { +return -1; +}} +return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +try { +var fm = new com.stevesoft.pat.FastMulti (this.fewestMatches, this.mostMatches, this.sub.clone (h)); +fm.matchFewest = this.matchFewest; +return fm; +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +return null; +} else { +throw rs; +} +} +}, "java.util.Hashtable"); +});