X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fcom%2Fstevesoft%2Fpat%2FFastBracket.js;h=d26c009deb7ee6d9766cdf8fb5bf1cc78562f7a2;hp=0e7d38a4214dc87be2cca4339c4aa883a6a414cf;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/com/stevesoft/pat/FastBracket.js b/bin/com/stevesoft/pat/FastBracket.js index 0e7d38a..d26c009 100644 --- a/bin/com/stevesoft/pat/FastBracket.js +++ b/bin/com/stevesoft/pat/FastBracket.js @@ -1,156 +1,156 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Bracket"], "com.stevesoft.pat.FastBracket", ["com.stevesoft.pat.Range", "$.oneChar", "java.util.BitSet", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.$min = 0; -this.$max = 0; -this.bs = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "FastBracket", com.stevesoft.pat.Bracket); -c$.process = Clazz.defineMethod (c$, "process", -function (b, ignc) { -var v = b.v; -b.pv = null; -try { -var nv = v; -if (ignc) { -nv = new java.util.Vector (); -for (var i = 0; i < v.size (); i++) { -var p = v.elementAt (i); -nv.addElement (p); -if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) { -var oc = p; -nv.addElement ( new com.stevesoft.pat.oneChar (oc.altc)); -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { -var ra = p; -nv.addElement ( new com.stevesoft.pat.Range (ra.altlo, ra.althi)); -}} -}v = nv; -for (var i = 0; i < v.size () - 1; i++) { -for (var j = 0; j < v.size () - 1; j++) { -var c1 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j)); -var c2 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j + 1)); -if (c2 < c1) { -var o = v.elementAt (j); -v.setElementAt (v.elementAt (j + 1), j); -v.setElementAt (o, j + 1); -}} -} -nv = new java.util.Vector (); -var p = v.elementAt (0); -nv.addElement (p); -for (var i = 1; i < v.size (); i++) { -if ((com.stevesoft.pat.FastBracket.geth (p)).charCodeAt (0) + 1 >= (com.stevesoft.pat.FastBracket.getl (v.elementAt (i))).charCodeAt (0)) { -var p2 = v.elementAt (i); -var lo = com.stevesoft.pat.FastBracket.min (com.stevesoft.pat.FastBracket.getl (p), com.stevesoft.pat.FastBracket.getl (p2)); -var hi = com.stevesoft.pat.FastBracket.max (com.stevesoft.pat.FastBracket.geth (p), com.stevesoft.pat.FastBracket.geth (p2)); -nv.setElementAt (p = com.stevesoft.pat.FastBracket.mkelem (lo, hi), nv.size () - 1); -} else { -p = v.elementAt (i); -nv.addElement (p); -}} -b.v = v = nv; -} catch (e) { -if (Clazz.exceptionOf (e, com.stevesoft.pat.RegSyntax)) { -e.printStackTrace (); -} else { -throw e; -} -} -var negv = com.stevesoft.pat.FastBracket.neg (v); -if (v.size () == 1) { -return b; -}if (negv.size () == 1) { -b.v = negv; -b.neg = !b.neg; -return b; -}var fb = com.stevesoft.pat.FastBracket.newbrack (v, b.neg); -if (fb == null) { -fb = com.stevesoft.pat.FastBracket.newbrack (negv, !b.neg); -}if (fb != null) { -fb.parent = b.parent; -fb.next = b.next; -return fb; -}return b; -}, "com.stevesoft.pat.Bracket,~B"); -c$.newbrack = Clazz.defineMethod (c$, "newbrack", -function (v, neg) { -var fb = new com.stevesoft.pat.FastBracket (neg); -fb.v = v; -if (v.size () == 0) { -return null; -}fb.$min = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0); -fb.$max = (com.stevesoft.pat.FastBracket.geth (v.elementAt (v.size () - 1))).charCodeAt (0); -if (fb.$max - fb.$min <= 256) { -fb.bs = new java.util.BitSet (fb.$max - fb.$min + 1); -for (var i = 0; i < v.size (); i++) { -var o = v.elementAt (i); -var min0 = (com.stevesoft.pat.FastBracket.getl (o)).charCodeAt (0) - fb.$min; -var max0 = (com.stevesoft.pat.FastBracket.geth (o)).charCodeAt (0) - fb.$min; -for (var j = min0; j <= max0; j++) { -fb.bs.set (j); -} -} -return fb; -}return null; -}, "java.util.Vector,~B"); -c$.neg = Clazz.defineMethod (c$, "neg", -function (v) { -try { -var nv = new java.util.Vector (); -if (v.size () == 0) { -nv.addElement ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (65535))); -return nv; -}var p0 = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0); -if (p0 != 0) { -nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (0), String.fromCharCode (p0 - 1))); -}for (var i = 0; i < v.size () - 1; i++) { -var hi = (com.stevesoft.pat.FastBracket.getl (v.elementAt (i + 1))).charCodeAt (0) - 1; -var lo = (com.stevesoft.pat.FastBracket.geth (v.elementAt (i))).charCodeAt (0) + 1; -nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (lo), String.fromCharCode (hi))); -} -var pN = (com.stevesoft.pat.FastBracket.geth (v.lastElement ())).charCodeAt (0); -if (pN != 65535) { -nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (pN + 1), String.fromCharCode (65535))); -}return nv; -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -return null; -} else { -throw rs; -} -} -}, "java.util.Vector"); -c$.mkelem = Clazz.defineMethod (c$, "mkelem", -function (lo, hi) { -return lo == hi ? ( new com.stevesoft.pat.oneChar (lo)) : ( new com.stevesoft.pat.Range (lo, hi)); -}, "~S,~S"); -c$.min = Clazz.defineMethod (c$, "min", -function (a, b) { -return a < b ? a : b; -}, "~S,~S"); -c$.max = Clazz.defineMethod (c$, "max", -function (a, b) { -return a > b ? a : b; -}, "~S,~S"); -c$.getl = Clazz.defineMethod (c$, "getl", -function (o) { -var p = o; -if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { -return (p).lo; -}return (p).c; -}, "~O"); -c$.geth = Clazz.defineMethod (c$, "geth", -function (o) { -var p = o; -if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { -return (p).hi; -}return (p).c; -}, "~O"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (pos >= pt.src.length () || this.Masked (pos, pt)) { -return -1; -}var c = pt.src.charAt (pos); -return ( new Boolean (this.neg ^ (c.charCodeAt (0) >= this.$min && c.charCodeAt (0) <= this.$max && this.bs.get (c.charCodeAt (0) - this.$min))).valueOf ()) ? this.nextMatch (pos + 1, pt) : -1; -}, "~N,com.stevesoft.pat.Pthings"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Bracket"], "com.stevesoft.pat.FastBracket", ["com.stevesoft.pat.Range", "$.oneChar", "java.util.BitSet", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.$min = 0; +this.$max = 0; +this.bs = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "FastBracket", com.stevesoft.pat.Bracket); +c$.process = Clazz.defineMethod (c$, "process", +function (b, ignc) { +var v = b.v; +b.pv = null; +try { +var nv = v; +if (ignc) { +nv = new java.util.Vector (); +for (var i = 0; i < v.size (); i++) { +var p = v.elementAt (i); +nv.addElement (p); +if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) { +var oc = p; +nv.addElement ( new com.stevesoft.pat.oneChar (oc.altc)); +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { +var ra = p; +nv.addElement ( new com.stevesoft.pat.Range (ra.altlo, ra.althi)); +}} +}v = nv; +for (var i = 0; i < v.size () - 1; i++) { +for (var j = 0; j < v.size () - 1; j++) { +var c1 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j)); +var c2 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j + 1)); +if (c2 < c1) { +var o = v.elementAt (j); +v.setElementAt (v.elementAt (j + 1), j); +v.setElementAt (o, j + 1); +}} +} +nv = new java.util.Vector (); +var p = v.elementAt (0); +nv.addElement (p); +for (var i = 1; i < v.size (); i++) { +if ((com.stevesoft.pat.FastBracket.geth (p)).charCodeAt (0) + 1 >= (com.stevesoft.pat.FastBracket.getl (v.elementAt (i))).charCodeAt (0)) { +var p2 = v.elementAt (i); +var lo = com.stevesoft.pat.FastBracket.min (com.stevesoft.pat.FastBracket.getl (p), com.stevesoft.pat.FastBracket.getl (p2)); +var hi = com.stevesoft.pat.FastBracket.max (com.stevesoft.pat.FastBracket.geth (p), com.stevesoft.pat.FastBracket.geth (p2)); +nv.setElementAt (p = com.stevesoft.pat.FastBracket.mkelem (lo, hi), nv.size () - 1); +} else { +p = v.elementAt (i); +nv.addElement (p); +}} +b.v = v = nv; +} catch (e) { +if (Clazz.exceptionOf (e, com.stevesoft.pat.RegSyntax)) { +e.printStackTrace (); +} else { +throw e; +} +} +var negv = com.stevesoft.pat.FastBracket.neg (v); +if (v.size () == 1) { +return b; +}if (negv.size () == 1) { +b.v = negv; +b.neg = !b.neg; +return b; +}var fb = com.stevesoft.pat.FastBracket.newbrack (v, b.neg); +if (fb == null) { +fb = com.stevesoft.pat.FastBracket.newbrack (negv, !b.neg); +}if (fb != null) { +fb.parent = b.parent; +fb.next = b.next; +return fb; +}return b; +}, "com.stevesoft.pat.Bracket,~B"); +c$.newbrack = Clazz.defineMethod (c$, "newbrack", +function (v, neg) { +var fb = new com.stevesoft.pat.FastBracket (neg); +fb.v = v; +if (v.size () == 0) { +return null; +}fb.$min = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0); +fb.$max = (com.stevesoft.pat.FastBracket.geth (v.elementAt (v.size () - 1))).charCodeAt (0); +if (fb.$max - fb.$min <= 256) { +fb.bs = new java.util.BitSet (fb.$max - fb.$min + 1); +for (var i = 0; i < v.size (); i++) { +var o = v.elementAt (i); +var min0 = (com.stevesoft.pat.FastBracket.getl (o)).charCodeAt (0) - fb.$min; +var max0 = (com.stevesoft.pat.FastBracket.geth (o)).charCodeAt (0) - fb.$min; +for (var j = min0; j <= max0; j++) { +fb.bs.set (j); +} +} +return fb; +}return null; +}, "java.util.Vector,~B"); +c$.neg = Clazz.defineMethod (c$, "neg", +function (v) { +try { +var nv = new java.util.Vector (); +if (v.size () == 0) { +nv.addElement ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (65535))); +return nv; +}var p0 = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0); +if (p0 != 0) { +nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (0), String.fromCharCode (p0 - 1))); +}for (var i = 0; i < v.size () - 1; i++) { +var hi = (com.stevesoft.pat.FastBracket.getl (v.elementAt (i + 1))).charCodeAt (0) - 1; +var lo = (com.stevesoft.pat.FastBracket.geth (v.elementAt (i))).charCodeAt (0) + 1; +nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (lo), String.fromCharCode (hi))); +} +var pN = (com.stevesoft.pat.FastBracket.geth (v.lastElement ())).charCodeAt (0); +if (pN != 65535) { +nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (pN + 1), String.fromCharCode (65535))); +}return nv; +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +return null; +} else { +throw rs; +} +} +}, "java.util.Vector"); +c$.mkelem = Clazz.defineMethod (c$, "mkelem", +function (lo, hi) { +return lo == hi ? ( new com.stevesoft.pat.oneChar (lo)) : ( new com.stevesoft.pat.Range (lo, hi)); +}, "~S,~S"); +c$.min = Clazz.defineMethod (c$, "min", +function (a, b) { +return a < b ? a : b; +}, "~S,~S"); +c$.max = Clazz.defineMethod (c$, "max", +function (a, b) { +return a > b ? a : b; +}, "~S,~S"); +c$.getl = Clazz.defineMethod (c$, "getl", +function (o) { +var p = o; +if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { +return (p).lo; +}return (p).c; +}, "~O"); +c$.geth = Clazz.defineMethod (c$, "geth", +function (o) { +var p = o; +if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { +return (p).hi; +}return (p).c; +}, "~O"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (pos >= pt.src.length () || this.Masked (pos, pt)) { +return -1; +}var c = pt.src.charAt (pos); +return ( new Boolean (this.neg ^ (c.charCodeAt (0) >= this.$min && c.charCodeAt (0) <= this.$max && this.bs.get (c.charCodeAt (0) - this.$min))).valueOf ()) ? this.nextMatch (pos + 1, pt) : -1; +}, "~N,com.stevesoft.pat.Pthings"); +});