--- /dev/null
+//\r
+// This software is now distributed according to\r
+// the Lesser Gnu Public License. Please see\r
+// http://www.gnu.org/copyleft/lesser.txt for\r
+// the details.\r
+// -- Happy Computing!\r
+//\r
+package com.stevesoft.pat;\r
+import java.util.Hashtable;\r
+\r
+//class AddToEnd extends RegSyntax {};\r
+\r
+/** Compiles the '$' or the '\Z' Pattern. It is\r
+ an error to have further Pattern elements after\r
+ '\Z'. It is the end of the String. */\r
+class End extends Pattern {\r
+ boolean retIsEnd;\r
+ End(boolean b) { retIsEnd = b; }\r
+ public int matchInternal(int pos,Pthings pt) {\r
+ if(retIsEnd && pt.mFlag && pos < pt.src.length()) {\r
+ if(pt.src.charAt(pos)=='\n') {\r
+ return nextMatch(pos,pt);\r
+ }\r
+ }\r
+ if(pt.src.length() == pos)\r
+ return nextMatch(pos,pt);\r
+ else if(pos<pt.src.length())\r
+ // Access the next character...\r
+ // this is crucial to making \r
+ // RegexReader work.\r
+ pt.src.charAt(pos);\r
+ return -1;\r
+ }\r
+ public String toString() {\r
+ if(retIsEnd)\r
+ return "$";\r
+ else\r
+ return "\\Z";\r
+ }\r
+ public patInt maxChars() { return new patInt(1); }\r
+ public Pattern clone1(Hashtable h) { return new End(retIsEnd); }\r
+};\r