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