X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fcom%2Fstevesoft%2Fpat%2FSkip.js;h=6dd2756f0252ad10ea8401b30338f04838d58555;hp=bdf02e4f2d3530fbe8a9983905202163e1e37508;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/com/stevesoft/pat/Skip.js b/bin/com/stevesoft/pat/Skip.js index bdf02e4..6dd2756 100644 --- a/bin/com/stevesoft/pat/Skip.js +++ b/bin/com/stevesoft/pat/Skip.js @@ -1,108 +1,108 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.Skip", ["com.stevesoft.pat.CaseMgr", "$.Or", "$.Skipped", "$.oneChar", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.src = null; -this.c = 0; -this.mask = 0; -this.$offset = 0; -this.ign = false; -this.m1 = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Skip"); -c$.mkmask = Clazz.defineMethod (c$, "mkmask", -function (c) { -var x = String.fromCharCode (c); -return ~((com.stevesoft.pat.CaseMgr.toUpperCaseC (x)).charCodeAt (0) | (com.stevesoft.pat.CaseMgr.toLowerCaseC (x)).charCodeAt (0) | (com.stevesoft.pat.CaseMgr.toTitleCaseC (x)).charCodeAt (0)); -}, "~N"); -c$.string = Clazz.defineMethod (c$, "string", -function (r) { -return r.skipper == null ? null : r.skipper.src; -}, "com.stevesoft.pat.Regex"); -c$.offset = Clazz.defineMethod (c$, "offset", -function (r) { -return r.skipper == null ? -1 : r.skipper.$offset; -}, "com.stevesoft.pat.Regex"); -Clazz.makeConstructor (c$, -function (s, ign, o) { -this.src = s; -this.c = s.charCodeAt (0); -if (ign) { -this.mask = com.stevesoft.pat.Skip.mkmask (this.c); -} else { -this.mask = 0; -}this.$offset = o; -this.ign = ign; -this.m1 = (s.length == 1); -}, "~S,~B,~N"); -Clazz.defineMethod (c$, "find", -function (s) { -return this.find (s, 0, s.length ()); -}, "com.stevesoft.pat.StringLike"); -c$.min = Clazz.defineMethod (c$, "min", -function (a, b) { -return a < b ? a : b; -}, "~N,~N"); -Clazz.defineMethod (c$, "find", -function (s, start, end) { -if (start > end) { -return -1; -}start += this.$offset; -var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.$offset); -if (this.mask != this.c) { -for (var i = start; i <= vend; i++) { -if (0 == (s.charCodeAt (i) & this.mask)) { -if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { -return i - this.$offset; -}}} -} else { -for (var i = start; i <= vend; i++) { -if (this.c == s.charCodeAt (i)) { -if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { -return i - this.$offset; -}}} -}return -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$.findSkipRegex = Clazz.defineMethod (c$, "findSkipRegex", -function (r) { -return com.stevesoft.pat.Skip.findSkip (r.thePattern, r.ignoreCase, !r.dontMatchInQuotes); -}, "com.stevesoft.pat.Regex"); -c$.findSkip = Clazz.defineMethod (c$, "findSkip", -function (p, ignoreCase, trnc) { -var sb = new StringBuffer (); -var subsk = null; -var offset = 0; -var skipc = -1; -var skipoff = 0; -for (; p != null; p = p.next) { -if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) { -skipc = ((p).c).charCodeAt (0); -skipoff = offset; -}if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) { -var psav = p; -sb.append ((p).c); -while (Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) { -sb.append ((p.next).c); -p = p.next; -} -var st = sb.toString (); -var sk = null; -if (st.length > 2) { -sk = new com.stevesoft.pat.SkipBMH (st, ignoreCase, offset); -} else { -sk = new com.stevesoft.pat.Skip2 (st, ignoreCase, offset); -}if (trnc && st.length > 2) { -psav.next = new com.stevesoft.pat.Skipped (st.substring (1)); -psav.next.next = p.next; -psav.next.parent = p.parent; -}return sk; -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or) && (p).v.size () == 1 && !(p).leftForm ().equals ("(?!") && null != (subsk = com.stevesoft.pat.Skip.findSkip ((p).v.elementAt (0), ignoreCase, trnc))) { -subsk.$offset += offset; -return subsk; -} else if (p.minChars ().equals (p.maxChars ())) { -offset += p.minChars ().intValue (); -} else { -return skipc < 0 ? null : new com.stevesoft.pat.Skip ("" + String.fromCharCode (skipc), ignoreCase, skipoff); -}} -return null; -}, "com.stevesoft.pat.Pattern,~B,~B"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.Skip", ["com.stevesoft.pat.CaseMgr", "$.Or", "$.Skipped", "$.oneChar", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.src = null; +this.c = 0; +this.mask = 0; +this.$offset = 0; +this.ign = false; +this.m1 = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Skip"); +c$.mkmask = Clazz.defineMethod (c$, "mkmask", +function (c) { +var x = String.fromCharCode (c); +return ~((com.stevesoft.pat.CaseMgr.toUpperCaseC (x)).charCodeAt (0) | (com.stevesoft.pat.CaseMgr.toLowerCaseC (x)).charCodeAt (0) | (com.stevesoft.pat.CaseMgr.toTitleCaseC (x)).charCodeAt (0)); +}, "~N"); +c$.string = Clazz.defineMethod (c$, "string", +function (r) { +return r.skipper == null ? null : r.skipper.src; +}, "com.stevesoft.pat.Regex"); +c$.offset = Clazz.defineMethod (c$, "offset", +function (r) { +return r.skipper == null ? -1 : r.skipper.$offset; +}, "com.stevesoft.pat.Regex"); +Clazz.makeConstructor (c$, +function (s, ign, o) { +this.src = s; +this.c = s.charCodeAt (0); +if (ign) { +this.mask = com.stevesoft.pat.Skip.mkmask (this.c); +} else { +this.mask = 0; +}this.$offset = o; +this.ign = ign; +this.m1 = (s.length == 1); +}, "~S,~B,~N"); +Clazz.defineMethod (c$, "find", +function (s) { +return this.find (s, 0, s.length ()); +}, "com.stevesoft.pat.StringLike"); +c$.min = Clazz.defineMethod (c$, "min", +function (a, b) { +return a < b ? a : b; +}, "~N,~N"); +Clazz.defineMethod (c$, "find", +function (s, start, end) { +if (start > end) { +return -1; +}start += this.$offset; +var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.$offset); +if (this.mask != this.c) { +for (var i = start; i <= vend; i++) { +if (0 == (s.charCodeAt (i) & this.mask)) { +if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { +return i - this.$offset; +}}} +} else { +for (var i = start; i <= vend; i++) { +if (this.c == s.charCodeAt (i)) { +if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { +return i - this.$offset; +}}} +}return -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$.findSkipRegex = Clazz.defineMethod (c$, "findSkipRegex", +function (r) { +return com.stevesoft.pat.Skip.findSkip (r.thePattern, r.ignoreCase, !r.dontMatchInQuotes); +}, "com.stevesoft.pat.Regex"); +c$.findSkip = Clazz.defineMethod (c$, "findSkip", +function (p, ignoreCase, trnc) { +var sb = new StringBuffer (); +var subsk = null; +var offset = 0; +var skipc = -1; +var skipoff = 0; +for (; p != null; p = p.next) { +if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) { +skipc = ((p).c).charCodeAt (0); +skipoff = offset; +}if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) { +var psav = p; +sb.append ((p).c); +while (Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) { +sb.append ((p.next).c); +p = p.next; +} +var st = sb.toString (); +var sk = null; +if (st.length > 2) { +sk = new com.stevesoft.pat.SkipBMH (st, ignoreCase, offset); +} else { +sk = new com.stevesoft.pat.Skip2 (st, ignoreCase, offset); +}if (trnc && st.length > 2) { +psav.next = new com.stevesoft.pat.Skipped (st.substring (1)); +psav.next.next = p.next; +psav.next.parent = p.parent; +}return sk; +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or) && (p).v.size () == 1 && !(p).leftForm ().equals ("(?!") && null != (subsk = com.stevesoft.pat.Skip.findSkip ((p).v.elementAt (0), ignoreCase, trnc))) { +subsk.$offset += offset; +return subsk; +} else if (p.minChars ().equals (p.maxChars ())) { +offset += p.minChars ().intValue (); +} else { +return skipc < 0 ? null : new com.stevesoft.pat.Skip ("" + String.fromCharCode (skipc), ignoreCase, skipoff); +}} +return null; +}, "com.stevesoft.pat.Pattern,~B,~B"); +});