00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <cstring>
00027 #include <mpcl/text/codegen/defs.hh>
00028
00029
00031 namespace mpcl
00032 {
00033
00035 namespace text
00036 {
00037
00039 namespace codegen
00040 {
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 const char* pkcCommentTagPattern = "[[:space:]]*<!--%t-->[[:space:]]*";
00054
00055
00056
00057
00058 const char* pkcDOCTYPE_TagPattern_1 = "[[:space:]]*<!doctype"
00059 "[[:space:]]+cdml[[:space:]]*>";
00060 const char* pkcDOCTYPE_TagPattern_2 = "[[:space:]]*<!doctype"
00061 "[[:space:]]+cdml[[:space:]]+system[[:space:]]*>";
00062 const char* pkcDOCTYPE_TagPattern_3 = "[[:space:]]*<!doctype"
00063 "[[:space:]]+cdml[[:space:]]+system"
00064 "[[:space:]]+%q[[:space:]]*>";
00065 const char* pkcDOCTYPE_TagPattern_4 = "[[:space:]]*<!doctype"
00066 "[[:space:]]+cdml[[:space:]]+public"
00067 "[[:space:]]+%q[[:space:]]*>";
00068
00069
00070
00071 const char* pkcCDML_TagPattern_1 = "[[:space:]]*<cdml"
00072 "[[:space:]]+target[[:space:]]*="
00073 "[[:space:]]*%q"
00074 "[[:space:]]*>[[:blank:]]*\n?";
00075 const char* pkcCDML_TagPattern_2 = "[[:space:]]*<cdml"
00076 "[[:space:]]+target[[:space:]]*="
00077 "[[:space:]]*%q"
00078 "[[:space:]]+inherit[[:space:]]*="
00079 "[[:space:]]*%q"
00080 "[[:space:]]*>[[:blank:]]*\n?";
00081 const char* pkcCDML_TagPattern_3 = "[[:space:]]*<cdml"
00082 "[[:space:]]+inherit[[:space:]]*="
00083 "[[:space:]]*%q"
00084 "[[:space:]]+target[[:space:]]*="
00085 "[[:space:]]*%q"
00086 "[[:space:]]*>[[:blank:]]*\n?";
00087 const char* pkcCDML_EndTagPattern = "[[:space:]]*</cdml[[:space:]]*>";
00088
00089
00090
00091
00092 const char* pkcDESC_ElementPattern = "[[:space:]]*<desc"
00093 "[[:space:]]*>[[:blank:]]*\n?"
00094 "%t[[:blank:]]*\n?</desc[[:space:]]*>";
00095
00096
00097
00098
00099 const char* pkcDECLARE_TagPattern = "[[:space:]]*<declare[[:space:]]*>[[:blank:]]*\n?";
00100 const char* pkcDECLARE_EndTagPattern = "[[:space:]]*</declare[[:space:]]*>";
00101
00102
00103
00104
00105 const char* pkcINSTRUCT_TagPattern = "[[:space:]]*<instruct[[:space:]]+"
00106 "name[[:space:]]*=[[:space:]]*"
00107 "%q[[:space:]]*>";
00108 const char* pkcINSTRUCT_EndTagPattern = "[[:space:]]*</instruct[[:space:]]*>";
00109
00110
00111
00112
00113 const char* pkcVARIABLE_ElementPattern_1 = "[[:space:]]*<variable"
00114 "[[:space:]]+name[[:space:]]*=[[:space:]]*%q"
00115 "[[:space:]]*>%t</variable[[:space:]]*>";
00116 const char* pkcVARIABLE_ElementPattern_2 = "[[:space:]]*<variable"
00117 "[[:space:]]+name[[:space:]]*=[[:space:]]*%q"
00118 "[[:space:]]+type[[:space:]]*=[[:space:]]*%q"
00119 "[[:space:]]*>%t</variable[[:space:]]*>";
00120 const char* pkcVARIABLE_ElementPattern_3 = "[[:space:]]*<variable"
00121 "[[:space:]]+type[[:space:]]*=[[:space:]]*%q"
00122 "[[:space:]]+name[[:space:]]*=[[:space:]]*%q"
00123 "[[:space:]]*>%t</variable[[:space:]]*>";
00124
00125
00126
00127
00128 const char* pkcCLAUSE_TagBegin = "[[:space:]]*<clause";
00129 const char* pkcCLAUSE_TagNameAttr = "[[:space:]]+name[[:space:]]*=[[:space:]]*%q";
00130 const char* pkcCLAUSE_TagTargetAttr = "[[:space:]]+target[[:space:]]*=[[:space:]]*%q";
00131 const char* pkcCLAUSE_TagNoCheckAttr = "[[:space:]]+nocheck";
00132 const char* pkcCLAUSE_TagEnd = "[[:space:]]*>[[:blank:]]*\n?";
00133 const char* pkcCLAUSE_BodyPattern = "%t[[:blank:]]*</clause[[:space:]]*>";
00134
00135
00136
00137
00138 const char* pkcEntityPrefix = "&";
00139 const char* pkcGT_EntityPattern = ">";
00140 const char* pkcGT_EntityValue = ">";
00141 const char* pkcLT_EntityPattern = "<";
00142 const char* pkcLT_EntityValue = "<";
00143 const char* pkcNL_EntityPattern = "&nl;";
00144 const char* pkcNL_EntityValue = "\n";
00145 const char* pkcEOC_EntityPattern = "&eoc;";
00146 const char* pkcAMP_EntityPattern = "&";
00147 const char* pkcAMP_EntityValue = "&";
00148
00149
00150
00151
00152 size_t zEntityPrefixLength = std::strlen (pkcEntityPrefix);
00153 size_t zGT_EntityPatternLength = std::strlen (pkcGT_EntityPattern);
00154 size_t zGT_EntityValueLength = std::strlen (pkcGT_EntityValue);
00155 size_t zLT_EntityPatternLength = std::strlen (pkcLT_EntityPattern);
00156 size_t zLT_EntityValueLength = std::strlen (pkcLT_EntityValue);
00157 size_t zNL_EntityPatternLength = std::strlen (pkcNL_EntityPattern);
00158 size_t zNL_EntityValueLength = std::strlen (pkcNL_EntityValue);
00159 size_t zEOC_EntityPatternLength = std::strlen (pkcEOC_EntityPattern);
00160 size_t zAMP_EntityPatternLength = std::strlen (pkcAMP_EntityPattern);
00161 size_t zAMP_EntityValueLength = std::strlen (pkcAMP_EntityValue);
00162
00163
00164
00165
00166
00167 const char* pkcTargetSeparator = "::";
00168
00169 }
00170
00171 }
00172
00173 }
00174
00175
00176
00177
00178
00179
00180 void mpcl::text::codegen::
00181 InstantiateEntities (TString& ryTARGET_STRING)
00182 {
00183
00184 using std::strncmp;
00185
00186 const char* pkcBase;
00187 size_t zOffset = 0;
00188
00189
00190
00191
00192 while ( TString::npos != (zOffset = ryTARGET_STRING.find (pkcEntityPrefix, zOffset)) )
00193 {
00194 pkcBase = ryTARGET_STRING.c_str() + zOffset;
00195 if ( !strncmp (pkcBase, pkcGT_EntityPattern, zGT_EntityPatternLength) )
00196 {
00197 ryTARGET_STRING.replace (zOffset, zGT_EntityPatternLength, pkcGT_EntityValue);
00198 zOffset += zGT_EntityValueLength;
00199 }
00200 else if ( !strncmp (pkcBase, pkcLT_EntityPattern, zLT_EntityPatternLength) )
00201 {
00202 ryTARGET_STRING.replace (zOffset, zLT_EntityPatternLength, pkcLT_EntityValue);
00203 zOffset += zLT_EntityValueLength;
00204 }
00205 else if ( !strncmp (pkcBase, pkcNL_EntityPattern, zNL_EntityPatternLength) )
00206 {
00207 ryTARGET_STRING.replace (zOffset, zNL_EntityPatternLength, pkcNL_EntityValue);
00208 zOffset += zNL_EntityValueLength;
00209 }
00210 else if ( !strncmp (pkcBase, pkcEOC_EntityPattern, zEOC_EntityPatternLength) )
00211 {
00212 ryTARGET_STRING.erase (zOffset);
00213 break;
00214 }
00215 else if ( !strncmp (pkcBase, pkcAMP_EntityPattern, zAMP_EntityPatternLength) )
00216 {
00217 ryTARGET_STRING.replace (zOffset, zAMP_EntityPatternLength, pkcAMP_EntityValue);
00218 zOffset += zAMP_EntityValueLength;
00219 }
00220 else
00221 {
00222 zOffset += zEntityPrefixLength;
00223 }
00224 }
00225
00226 }