Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / com / stevesoft / pat / ReplaceRule.js
index 5694935..c78211d 100644 (file)
-Clazz.declarePackage ("com.stevesoft.pat");\r
-Clazz.load (["java.util.Hashtable"], "com.stevesoft.pat.ReplaceRule", ["com.stevesoft.pat.Ctrl", "$.Regex", "$.Transformer", "java.lang.StringBuffer"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.next = null;\r
-this.name = null;\r
-Clazz.instantialize (this, arguments);\r
-}, com.stevesoft.pat, "ReplaceRule");\r
-Clazz.prepareFields (c$, function () {\r
-this.name = this.getClass ().getName ();\r
-});\r
-Clazz.defineMethod (c$, "clone1", \r
-function () {\r
-return  new com.stevesoft.pat.RuleHolder (this);\r
-});\r
-Clazz.overrideMethod (c$, "clone", \r
-function () {\r
-var x = this.clone1 ();\r
-var xsav = x;\r
-var y = this;\r
-while (y.next != null) {\r
-x.next = y.next.clone1 ();\r
-x.name = y.name;\r
-x = x.next;\r
-y = y.next;\r
-}\r
-return xsav;\r
-});\r
-c$.add = Clazz.defineMethod (c$, "add", \r
-function (head, adding) {\r
-if (head == null) {\r
-return head = adding;\r
-}head.addRule (adding);\r
-return head;\r
-}, "com.stevesoft.pat.ReplaceRule,com.stevesoft.pat.ReplaceRule");\r
-Clazz.defineMethod (c$, "add", \r
-function (adding) {\r
-return com.stevesoft.pat.ReplaceRule.add (this, adding);\r
-}, "com.stevesoft.pat.ReplaceRule");\r
-Clazz.defineMethod (c$, "addRule", \r
-function (r) {\r
-if (this.next == null) {\r
-this.next = r;\r
-} else {\r
-this.next.addRule (r);\r
-}}, "com.stevesoft.pat.ReplaceRule");\r
-c$.getv = Clazz.defineMethod (c$, "getv", \r
- function () {\r
-if (com.stevesoft.pat.ReplaceRule.getvar != null) {\r
-return com.stevesoft.pat.ReplaceRule.getvar.clone ();\r
-}com.stevesoft.pat.ReplaceRule.getvar =  new com.stevesoft.pat.Regex ("(?:\\\\(\\d+)|\\$(?:(\\d+)|(\\w+)|([&\'`])|\\{(?:(\\d+)|([^\n}\\\\]+))})|\\\\([nrbtaef])|\\\\c([\u0000-\uffff])|\\\\x([A-Fa-f0-9]{2})|\\\\([\u0000-\uffff]))", "");\r
-com.stevesoft.pat.ReplaceRule.getvar.optimize ();\r
-return com.stevesoft.pat.ReplaceRule.getvar;\r
-});\r
-c$.perlCode = Clazz.defineMethod (c$, "perlCode", \r
-function (s) {\r
-try {\r
-var mf = 0;\r
-var mt = 0;\r
-var gv = com.stevesoft.pat.ReplaceRule.getv ();\r
-var head = null;\r
-var tmp = null;\r
-while (gv.searchFrom (s, mt)) {\r
-var off = com.stevesoft.pat.Regex.BackRefOffset - 1;\r
-mf = gv.matchedFrom ();\r
-if (mf > mt) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule (s.substring (mt, mf)));\r
-}var $var = null;\r
-if (($var = gv.stringMatchedI (1 + off)) != null || ($var = gv.stringMatchedI (2 + off)) != null || ($var = gv.stringMatchedI (5 + off)) != null) {\r
-var d = 0;\r
-for (var i = 0; i < $var.length; i++) {\r
-d = 8 * d + ($var.charCodeAt (i) - 48);\r
-}\r
-if ($var.length == 1) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.BackRefRule (d));\r
-} else {\r
-head =  new com.stevesoft.pat.StringRule ("" + String.fromCharCode (d));\r
-}} else if (($var = gv.stringMatchedI (10 + off)) != null) {\r
-if ("QELlUu".indexOf ($var) >= 0) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.CodeRule ($var.charAt (0)));\r
-} else {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ($var));\r
-}} else if (($var = gv.stringMatchedI (3 + off)) != null || ($var = gv.stringMatchedI (4 + off)) != null || ($var = gv.stringMatchedI (6 + off)) != null) {\r
-var arg = "";\r
-var pc;\r
-if ((pc = $var.indexOf (':')) > 0) {\r
-arg = $var.substring (pc + 1);\r
-$var = $var.substring (0, pc);\r
-}if ($var.equals ("&") || $var.equals ("MATCH")) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.AmpersandRule ());\r
-} else if ($var.equals ("`") || $var.equals ("PREMATCH")) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.LeftRule ());\r
-} else if ($var.equals ("'") || $var.equals ("POSTMATCH")) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.RightRule ());\r
-} else if ($var.equals ("WANT_MORE_TEXT")) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.WantMoreTextReplaceRule ());\r
-} else if ($var.equals ("POP")) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.PopRule ());\r
-} else if ($var.startsWith ("+") && (tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var.substring (1))) != null) {\r
-if (Clazz.instanceOf (tmp, com.stevesoft.pat.Regex)) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.PushRule ($var.substring (1), tmp));\r
-} else if (Clazz.instanceOf (tmp, com.stevesoft.pat.Transformer)) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.PushRule ($var.substring (1), tmp));\r
-} else {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("${" + $var + "}"));\r
-}} else if ($var.startsWith ("=") && (tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var.substring (1))) != null) {\r
-if (Clazz.instanceOf (tmp, com.stevesoft.pat.Regex)) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.ChangeRule ($var.substring (1), tmp));\r
-} else if (Clazz.instanceOf (tmp, com.stevesoft.pat.Transformer)) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.ChangeRule ($var.substring (1), tmp));\r
-} else {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("${" + $var + "}"));\r
-}} else if ((tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var)) != null) {\r
-if (Clazz.instanceOf (tmp, com.stevesoft.pat.ReplaceRule)) {\r
-var alt = (tmp).arg (arg);\r
-if (alt == null) {\r
-alt = (tmp);\r
-}head = com.stevesoft.pat.ReplaceRule.add (head, (alt.clone ()));\r
-}} else {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("${" + $var + "}"));\r
-}} else if (($var = gv.stringMatchedI (7 + off)) != null) {\r
-var c = $var.charAt (0);\r
-if (c == 'n') {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\n"));\r
-} else if (c == 't') {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\t"));\r
-} else if (c == 'r') {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\r"));\r
-} else if (c == 'b') {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\r"));\r
-} else if (c == 'a') {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\u0007"));\r
-} else if (c == 'e') {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\u001b"));\r
-} else if (c == 'f') {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\f"));\r
-}} else if (($var = gv.stringMatchedI (8 + off)) != null) {\r
-var c = $var.charAt (0);\r
-if (c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) {\r
-c = com.stevesoft.pat.Ctrl.cmap[c.charCodeAt (0)];\r
-}head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("" + c));\r
-} else if (($var = gv.stringMatchedI (9 + off)) != null) {\r
-var d = 16 * com.stevesoft.pat.ReplaceRule.getHexDigit ($var.charAt (0)) + com.stevesoft.pat.ReplaceRule.getHexDigit ($var.charAt (1));\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("" + String.fromCharCode (d)));\r
-}mt = gv.matchedTo ();\r
-}\r
-if (mt <= s.length) {\r
-head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule (s.substring (mt)));\r
-}return head;\r
-} finally {\r
-}\r
-}, "~S");\r
-c$.isDefined = Clazz.defineMethod (c$, "isDefined", \r
-function (s) {\r
-return com.stevesoft.pat.ReplaceRule.defs.get (s) != null;\r
-}, "~S");\r
-c$.define = Clazz.defineMethod (c$, "define", \r
-function (s, r) {\r
-com.stevesoft.pat.ReplaceRule.defs.put (s, r);\r
-}, "~S,com.stevesoft.pat.Regex");\r
-c$.define = Clazz.defineMethod (c$, "define", \r
-function (s, r) {\r
-com.stevesoft.pat.ReplaceRule.defs.put (s, r);\r
-r.name = s;\r
-}, "~S,com.stevesoft.pat.ReplaceRule");\r
-c$.define = Clazz.defineMethod (c$, "define", \r
-function (s, t) {\r
-com.stevesoft.pat.ReplaceRule.defs.put (s, t);\r
-}, "~S,com.stevesoft.pat.Transformer");\r
-c$.undefine = Clazz.defineMethod (c$, "undefine", \r
-function (s) {\r
-com.stevesoft.pat.ReplaceRule.defs.remove (s);\r
-}, "~S");\r
-Clazz.defineMethod (c$, "toString1", \r
-function () {\r
-return "${" + this.name + "}";\r
-});\r
-Clazz.overrideMethod (c$, "toString", \r
-function () {\r
-var sb =  new StringBuffer ();\r
-sb.append (this.toString1 ());\r
-var rr = this.next;\r
-while (rr != null) {\r
-sb.append (rr.toString1 ());\r
-rr = rr.next;\r
-}\r
-return sb.toString ();\r
-});\r
-Clazz.defineMethod (c$, "arg", \r
-function (s) {\r
-return null;\r
-}, "~S");\r
-c$.getHexDigit = Clazz.defineMethod (c$, "getHexDigit", \r
-function (c) {\r
-if (c >= '0' && c <= '9') {\r
-return c.charCodeAt (0) - 48;\r
-}if (c >= 'a' && c <= 'f') {\r
-return c.charCodeAt (0) - 97 + 10;\r
-}return c.charCodeAt (0) - 65 + 10;\r
-}, "~S");\r
-Clazz.defineStatics (c$,\r
-"getvar", null);\r
-c$.defs = c$.prototype.defs =  new java.util.Hashtable ();\r
-});\r
+Clazz.declarePackage ("com.stevesoft.pat");
+Clazz.load (["java.util.Hashtable"], "com.stevesoft.pat.ReplaceRule", ["com.stevesoft.pat.Ctrl", "$.Regex", "$.Transformer", "java.lang.StringBuffer"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.next = null;
+this.name = null;
+Clazz.instantialize (this, arguments);
+}, com.stevesoft.pat, "ReplaceRule");
+Clazz.prepareFields (c$, function () {
+this.name = this.getClass ().getName ();
+});
+Clazz.defineMethod (c$, "clone1", 
+function () {
+return  new com.stevesoft.pat.RuleHolder (this);
+});
+Clazz.overrideMethod (c$, "clone", 
+function () {
+var x = this.clone1 ();
+var xsav = x;
+var y = this;
+while (y.next != null) {
+x.next = y.next.clone1 ();
+x.name = y.name;
+x = x.next;
+y = y.next;
+}
+return xsav;
+});
+c$.add = Clazz.defineMethod (c$, "add", 
+function (head, adding) {
+if (head == null) {
+return head = adding;
+}head.addRule (adding);
+return head;
+}, "com.stevesoft.pat.ReplaceRule,com.stevesoft.pat.ReplaceRule");
+Clazz.defineMethod (c$, "add", 
+function (adding) {
+return com.stevesoft.pat.ReplaceRule.add (this, adding);
+}, "com.stevesoft.pat.ReplaceRule");
+Clazz.defineMethod (c$, "addRule", 
+function (r) {
+if (this.next == null) {
+this.next = r;
+} else {
+this.next.addRule (r);
+}}, "com.stevesoft.pat.ReplaceRule");
+c$.getv = Clazz.defineMethod (c$, "getv", 
+ function () {
+if (com.stevesoft.pat.ReplaceRule.getvar != null) {
+return com.stevesoft.pat.ReplaceRule.getvar.clone ();
+}com.stevesoft.pat.ReplaceRule.getvar =  new com.stevesoft.pat.Regex ("(?:\\\\(\\d+)|\\$(?:(\\d+)|(\\w+)|([&\'`])|\\{(?:(\\d+)|([^\n}\\\\]+))})|\\\\([nrbtaef])|\\\\c([\u0000-\uffff])|\\\\x([A-Fa-f0-9]{2})|\\\\([\u0000-\uffff]))", "");
+com.stevesoft.pat.ReplaceRule.getvar.optimize ();
+return com.stevesoft.pat.ReplaceRule.getvar;
+});
+c$.perlCode = Clazz.defineMethod (c$, "perlCode", 
+function (s) {
+try {
+var mf = 0;
+var mt = 0;
+var gv = com.stevesoft.pat.ReplaceRule.getv ();
+var head = null;
+var tmp = null;
+while (gv.searchFrom (s, mt)) {
+var off = com.stevesoft.pat.Regex.BackRefOffset - 1;
+mf = gv.matchedFrom ();
+if (mf > mt) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule (s.substring (mt, mf)));
+}var $var = null;
+if (($var = gv.stringMatchedI (1 + off)) != null || ($var = gv.stringMatchedI (2 + off)) != null || ($var = gv.stringMatchedI (5 + off)) != null) {
+var d = 0;
+for (var i = 0; i < $var.length; i++) {
+d = 8 * d + ($var.charCodeAt (i) - 48);
+}
+if ($var.length == 1) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.BackRefRule (d));
+} else {
+head =  new com.stevesoft.pat.StringRule ("" + String.fromCharCode (d));
+}} else if (($var = gv.stringMatchedI (10 + off)) != null) {
+if ("QELlUu".indexOf ($var) >= 0) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.CodeRule ($var.charAt (0)));
+} else {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ($var));
+}} else if (($var = gv.stringMatchedI (3 + off)) != null || ($var = gv.stringMatchedI (4 + off)) != null || ($var = gv.stringMatchedI (6 + off)) != null) {
+var arg = "";
+var pc;
+if ((pc = $var.indexOf (':')) > 0) {
+arg = $var.substring (pc + 1);
+$var = $var.substring (0, pc);
+}if ($var.equals ("&") || $var.equals ("MATCH")) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.AmpersandRule ());
+} else if ($var.equals ("`") || $var.equals ("PREMATCH")) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.LeftRule ());
+} else if ($var.equals ("'") || $var.equals ("POSTMATCH")) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.RightRule ());
+} else if ($var.equals ("WANT_MORE_TEXT")) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.WantMoreTextReplaceRule ());
+} else if ($var.equals ("POP")) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.PopRule ());
+} else if ($var.startsWith ("+") && (tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var.substring (1))) != null) {
+if (Clazz.instanceOf (tmp, com.stevesoft.pat.Regex)) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.PushRule ($var.substring (1), tmp));
+} else if (Clazz.instanceOf (tmp, com.stevesoft.pat.Transformer)) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.PushRule ($var.substring (1), tmp));
+} else {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("${" + $var + "}"));
+}} else if ($var.startsWith ("=") && (tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var.substring (1))) != null) {
+if (Clazz.instanceOf (tmp, com.stevesoft.pat.Regex)) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.ChangeRule ($var.substring (1), tmp));
+} else if (Clazz.instanceOf (tmp, com.stevesoft.pat.Transformer)) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.ChangeRule ($var.substring (1), tmp));
+} else {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("${" + $var + "}"));
+}} else if ((tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var)) != null) {
+if (Clazz.instanceOf (tmp, com.stevesoft.pat.ReplaceRule)) {
+var alt = (tmp).arg (arg);
+if (alt == null) {
+alt = (tmp);
+}head = com.stevesoft.pat.ReplaceRule.add (head, (alt.clone ()));
+}} else {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("${" + $var + "}"));
+}} else if (($var = gv.stringMatchedI (7 + off)) != null) {
+var c = $var.charAt (0);
+if (c == 'n') {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\n"));
+} else if (c == 't') {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\t"));
+} else if (c == 'r') {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\r"));
+} else if (c == 'b') {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\r"));
+} else if (c == 'a') {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\u0007"));
+} else if (c == 'e') {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\u001b"));
+} else if (c == 'f') {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("\f"));
+}} else if (($var = gv.stringMatchedI (8 + off)) != null) {
+var c = $var.charAt (0);
+if (c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) {
+c = com.stevesoft.pat.Ctrl.cmap[c.charCodeAt (0)];
+}head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("" + c));
+} else if (($var = gv.stringMatchedI (9 + off)) != null) {
+var d = 16 * com.stevesoft.pat.ReplaceRule.getHexDigit ($var.charAt (0)) + com.stevesoft.pat.ReplaceRule.getHexDigit ($var.charAt (1));
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule ("" + String.fromCharCode (d)));
+}mt = gv.matchedTo ();
+}
+if (mt <= s.length) {
+head = com.stevesoft.pat.ReplaceRule.add (head,  new com.stevesoft.pat.StringRule (s.substring (mt)));
+}return head;
+} finally {
+}
+}, "~S");
+c$.isDefined = Clazz.defineMethod (c$, "isDefined", 
+function (s) {
+return com.stevesoft.pat.ReplaceRule.defs.get (s) != null;
+}, "~S");
+c$.define = Clazz.defineMethod (c$, "define", 
+function (s, r) {
+com.stevesoft.pat.ReplaceRule.defs.put (s, r);
+}, "~S,com.stevesoft.pat.Regex");
+c$.define = Clazz.defineMethod (c$, "define", 
+function (s, r) {
+com.stevesoft.pat.ReplaceRule.defs.put (s, r);
+r.name = s;
+}, "~S,com.stevesoft.pat.ReplaceRule");
+c$.define = Clazz.defineMethod (c$, "define", 
+function (s, t) {
+com.stevesoft.pat.ReplaceRule.defs.put (s, t);
+}, "~S,com.stevesoft.pat.Transformer");
+c$.undefine = Clazz.defineMethod (c$, "undefine", 
+function (s) {
+com.stevesoft.pat.ReplaceRule.defs.remove (s);
+}, "~S");
+Clazz.defineMethod (c$, "toString1", 
+function () {
+return "${" + this.name + "}";
+});
+Clazz.overrideMethod (c$, "toString", 
+function () {
+var sb =  new StringBuffer ();
+sb.append (this.toString1 ());
+var rr = this.next;
+while (rr != null) {
+sb.append (rr.toString1 ());
+rr = rr.next;
+}
+return sb.toString ();
+});
+Clazz.defineMethod (c$, "arg", 
+function (s) {
+return null;
+}, "~S");
+c$.getHexDigit = Clazz.defineMethod (c$, "getHexDigit", 
+function (c) {
+if (c >= '0' && c <= '9') {
+return c.charCodeAt (0) - 48;
+}if (c >= 'a' && c <= 'f') {
+return c.charCodeAt (0) - 97 + 10;
+}return c.charCodeAt (0) - 65 + 10;
+}, "~S");
+Clazz.defineStatics (c$,
+"getvar", null);
+c$.defs = c$.prototype.defs =  new java.util.Hashtable ();
+});