// -- Happy Computing!\r
//\r
package com.stevesoft.pat;\r
-import java.util.Hashtable;\r
+\r
+import java.util.*;\r
\r
/** Matches any number of instances of sub Pattern\r
this was the hardest method to write. It implements\r
@see pat.Multi_stage2\r
@see pat.MultiMin\r
*/\r
-class Multi extends PatternSub {\r
- patInt a,b;\r
- public patInt minChars() { return a.mul(p.countMinChars()); }\r
- public patInt maxChars() { return b.mul(p.countMaxChars()); }\r
- Pattern p;\r
- Multi_stage2 st2;\r
- public boolean matchFewest = false;\r
- /**\r
- @param a The fewest number of times the sub pattern can match.\r
- @param b The maximum number of times the sub pattern can match.\r
- @param p The sub pattern.\r
- @see Multi_stage2\r
- @see MultiMin\r
- */\r
- public Multi(patInt a,patInt b,Pattern p) throws RegSyntax {\r
- this.a = a;\r
- this.b = b;\r
- this.p = p;\r
- st2 = new Multi_stage2(a,b,p);\r
- st2.parent = this;\r
- sub = st2.sub;\r
- }\r
- public String toString() {\r
- st2.matchFewest = matchFewest;\r
- return st2.toString();\r
+class Multi\r
+ extends PatternSub\r
+{\r
+ patInt a, b;\r
+ public patInt minChars()\r
+ {\r
+ return a.mul(p.countMinChars());\r
+ }\r
+\r
+ public patInt maxChars()\r
+ {\r
+ return b.mul(p.countMaxChars());\r
+ }\r
+\r
+ Pattern p;\r
+ Multi_stage2 st2;\r
+ public boolean matchFewest = false;\r
+ /**\r
+ @param a The fewest number of times the sub pattern can match.\r
+ @param b The maximum number of times the sub pattern can match.\r
+ @param p The sub pattern.\r
+ @see Multi_stage2\r
+ @see MultiMin\r
+ */\r
+ public Multi(patInt a, patInt b, Pattern p)\r
+ throws RegSyntax\r
+ {\r
+ this.a = a;\r
+ this.b = b;\r
+ this.p = p;\r
+ st2 = new Multi_stage2(a, b, p);\r
+ st2.parent = this;\r
+ sub = st2.sub;\r
+ }\r
+\r
+ public String toString()\r
+ {\r
+ st2.matchFewest = matchFewest;\r
+ return st2.toString();\r
+ }\r
+\r
+ public int matchInternal(int pos, Pthings pt)\r
+ {\r
+ try\r
+ {\r
+ st2 = new Multi_stage2(a, b, p);\r
}\r
- public int matchInternal(int pos,Pthings pt) {\r
- try {\r
- st2 = new Multi_stage2(a,b,p);\r
- } catch(RegSyntax r__) {}\r
- st2.matchFewest = matchFewest;\r
- st2.parent = this;\r
- return st2.matchInternal(pos,pt);\r
+ catch (RegSyntax r__)\r
+ {}\r
+ st2.matchFewest = matchFewest;\r
+ st2.parent = this;\r
+ return st2.matchInternal(pos, pt);\r
+ }\r
+\r
+ public Pattern clone1(Hashtable h)\r
+ {\r
+ try\r
+ {\r
+ Multi m = new Multi(a, b, ( (Pattern) p).clone(h));\r
+ m.matchFewest = matchFewest;\r
+ return m;\r
}\r
- public Pattern clone1(Hashtable h) {\r
- try {\r
- Multi m = new Multi(a,b,((Pattern)p).clone(h));\r
- m.matchFewest = matchFewest;\r
- return m;\r
- } catch(RegSyntax rs) {\r
- return null;\r
- }\r
+ catch (RegSyntax rs)\r
+ {\r
+ return null;\r
}\r
+ }\r
};\r