1 Clazz.declarePackage ("com.stevesoft.pat");
\r
2 Clazz.load (null, "com.stevesoft.pat.Skip", ["com.stevesoft.pat.CaseMgr", "$.Or", "$.Skipped", "$.oneChar", "java.lang.StringBuffer"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
10 Clazz.instantialize (this, arguments);
\r
11 }, com.stevesoft.pat, "Skip");
\r
12 c$.mkmask = Clazz.defineMethod (c$, "mkmask",
\r
14 var x = String.fromCharCode (c);
\r
15 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));
\r
17 c$.string = Clazz.defineMethod (c$, "string",
\r
19 return r.skipper == null ? null : r.skipper.src;
\r
20 }, "com.stevesoft.pat.Regex");
\r
21 c$.offset = Clazz.defineMethod (c$, "offset",
\r
23 return r.skipper == null ? -1 : r.skipper.$offset;
\r
24 }, "com.stevesoft.pat.Regex");
\r
25 Clazz.makeConstructor (c$,
\r
26 function (s, ign, o) {
\r
28 this.c = s.charCodeAt (0);
\r
30 this.mask = com.stevesoft.pat.Skip.mkmask (this.c);
\r
35 this.m1 = (s.length == 1);
\r
37 Clazz.defineMethod (c$, "find",
\r
39 return this.find (s, 0, s.length ());
\r
40 }, "com.stevesoft.pat.StringLike");
\r
41 c$.min = Clazz.defineMethod (c$, "min",
\r
43 return a < b ? a : b;
\r
45 Clazz.defineMethod (c$, "find",
\r
46 function (s, start, end) {
\r
49 }start += this.$offset;
\r
50 var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.$offset);
\r
51 if (this.mask != this.c) {
\r
52 for (var i = start; i <= vend; i++) {
\r
53 if (0 == (s.charCodeAt (i) & this.mask)) {
\r
54 if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) {
\r
55 return i - this.$offset;
\r
58 for (var i = start; i <= vend; i++) {
\r
59 if (this.c == s.charCodeAt (i)) {
\r
60 if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) {
\r
61 return i - this.$offset;
\r
64 }, "com.stevesoft.pat.StringLike,~N,~N");
\r
65 c$.findSkipRegex = Clazz.defineMethod (c$, "findSkipRegex",
\r
67 return com.stevesoft.pat.Skip.findSkip (r.thePattern, r.ignoreCase, !r.dontMatchInQuotes);
\r
68 }, "com.stevesoft.pat.Regex");
\r
69 c$.findSkip = Clazz.defineMethod (c$, "findSkip",
\r
70 function (p, ignoreCase, trnc) {
\r
71 var sb = new StringBuffer ();
\r
76 for (; p != null; p = p.next) {
\r
77 if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) {
\r
78 skipc = ((p).c).charCodeAt (0);
\r
80 }if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) {
\r
83 while (Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) {
\r
84 sb.append ((p.next).c);
\r
87 var st = sb.toString ();
\r
89 if (st.length > 2) {
\r
90 sk = new com.stevesoft.pat.SkipBMH (st, ignoreCase, offset);
\r
92 sk = new com.stevesoft.pat.Skip2 (st, ignoreCase, offset);
\r
93 }if (trnc && st.length > 2) {
\r
94 psav.next = new com.stevesoft.pat.Skipped (st.substring (1));
\r
95 psav.next.next = p.next;
\r
96 psav.next.parent = p.parent;
\r
98 } 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))) {
\r
99 subsk.$offset += offset;
\r
101 } else if (p.minChars ().equals (p.maxChars ())) {
\r
102 offset += p.minChars ().intValue ();
\r
104 return skipc < 0 ? null : new com.stevesoft.pat.Skip ("" + String.fromCharCode (skipc), ignoreCase, skipoff);
\r
107 }, "com.stevesoft.pat.Pattern,~B,~B");
\r