[29] | 1 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 2 | /// \file regex_constants.hpp |
---|
| 3 | /// Contains definitions for the syntax_option_type, match_flag_type and |
---|
| 4 | /// error_type enumerations. |
---|
| 5 | // |
---|
| 6 | // Copyright 2004 Eric Niebler. Distributed under the Boost |
---|
| 7 | // Software License, Version 1.0. (See accompanying file |
---|
| 8 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
| 9 | |
---|
| 10 | #ifndef BOOST_XPRESSIVE_REGEX_CONSTANTS_HPP_EAN_10_04_2005 |
---|
| 11 | #define BOOST_XPRESSIVE_REGEX_CONSTANTS_HPP_EAN_10_04_2005 |
---|
| 12 | |
---|
| 13 | // MS compatible compilers support #pragma once |
---|
| 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
---|
| 15 | # pragma once |
---|
| 16 | #endif |
---|
| 17 | |
---|
| 18 | #include <boost/mpl/identity.hpp> |
---|
| 19 | |
---|
| 20 | #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED |
---|
| 21 | # define icase icase_ |
---|
| 22 | #endif |
---|
| 23 | |
---|
| 24 | namespace boost { namespace xpressive { namespace regex_constants |
---|
| 25 | { |
---|
| 26 | |
---|
| 27 | /// Flags used to customize the regex syntax |
---|
| 28 | /// |
---|
| 29 | enum syntax_option_type |
---|
| 30 | { |
---|
| 31 | // these flags are required: |
---|
| 32 | |
---|
| 33 | ECMAScript = 0, ///< Specifies that the grammar recognized by the regular expression |
---|
| 34 | ///< engine uses its normal semantics: that is the same as that given |
---|
| 35 | ///< in the ECMA-262, ECMAScript Language Specification, Chapter 15 |
---|
| 36 | ///< part 10, RegExp (Regular Expression) Objects (FWD.1). |
---|
| 37 | ///< |
---|
| 38 | icase = 1 << 1, ///< Specifies that matching of regular expressions against a character |
---|
| 39 | ///< container sequence shall be performed without regard to case. |
---|
| 40 | ///< |
---|
| 41 | nosubs = 1 << 2, ///< Specifies that when a regular expression is matched against a |
---|
| 42 | ///< character container sequence, then no sub-expression matches are to |
---|
| 43 | ///< be stored in the supplied match_results structure. |
---|
| 44 | ///< |
---|
| 45 | optimize = 1 << 3, ///< Specifies that the regular expression engine should pay more |
---|
| 46 | ///< attention to the speed with which regular expressions are matched, |
---|
| 47 | ///< and less to the speed with which regular expression objects are |
---|
| 48 | ///< constructed. Otherwise it has no detectable effect on the program |
---|
| 49 | ///< output. |
---|
| 50 | ///< |
---|
| 51 | collate = 1 << 4, ///< Specifies that character ranges of the form "[a-b]" should be |
---|
| 52 | ///< locale sensitive. |
---|
| 53 | ///< |
---|
| 54 | |
---|
| 55 | // These flags are optional. If the functionality is supported |
---|
| 56 | // then the flags shall take these names. |
---|
| 57 | |
---|
| 58 | //basic = 1 << 5, ///< Specifies that the grammar recognized by the regular expression |
---|
| 59 | // ///< engine is the same as that used by POSIX basic regular expressions |
---|
| 60 | // ///< in IEEE Std 1003.1-2001, Portable Operating System Interface |
---|
| 61 | // ///< (POSIX), Base Definitions and Headers, Section 9, Regular |
---|
| 62 | // ///< Expressions (FWD.1). |
---|
| 63 | // ///< |
---|
| 64 | //extended = 1 << 6, ///< Specifies that the grammar recognized by the regular expression |
---|
| 65 | // ///< engine is the same as that used by POSIX extended regular |
---|
| 66 | // ///< expressions in IEEE Std 1003.1-2001, Portable Operating System |
---|
| 67 | // ///< Interface (POSIX), Base Definitions and Headers, Section 9, |
---|
| 68 | // ///< Regular Expressions (FWD.1). |
---|
| 69 | // ///< |
---|
| 70 | //awk = 1 << 7, ///< Specifies that the grammar recognized by the regular expression |
---|
| 71 | // ///< engine is the same as that used by POSIX utility awk in IEEE Std |
---|
| 72 | // ///< 1003.1-2001, Portable Operating System Interface (POSIX), Shells |
---|
| 73 | // ///< and Utilities, Section 4, awk (FWD.1). |
---|
| 74 | // ///< |
---|
| 75 | //grep = 1 << 8, ///< Specifies that the grammar recognized by the regular expression |
---|
| 76 | // ///< engine is the same as that used by POSIX utility grep in IEEE Std |
---|
| 77 | // ///< 1003.1-2001, Portable Operating System Interface (POSIX), |
---|
| 78 | // ///< Shells and Utilities, Section 4, Utilities, grep (FWD.1). |
---|
| 79 | // ///< |
---|
| 80 | //egrep = 1 << 9, ///< Specifies that the grammar recognized by the regular expression |
---|
| 81 | // ///< engine is the same as that used by POSIX utility grep when given |
---|
| 82 | // ///< the -E option in IEEE Std 1003.1-2001, Portable Operating System |
---|
| 83 | // ///< Interface (POSIX), Shells and Utilities, Section 4, Utilities, |
---|
| 84 | // ///< grep (FWD.1). |
---|
| 85 | // ///< |
---|
| 86 | |
---|
| 87 | // these flags are specific to xpressive, and they help with perl compliance. |
---|
| 88 | |
---|
| 89 | single_line = 1 << 10, ///< Specifies that the ^ and \$ metacharacters DO NOT match at |
---|
| 90 | ///< internal line breaks. Note that this is the opposite of the |
---|
| 91 | ///< perl default. It is the inverse of perl's /m (multi-line) |
---|
| 92 | ///< modifier. |
---|
| 93 | ///< |
---|
| 94 | not_dot_null = 1 << 11, ///< Specifies that the . metacharacter does not match the null |
---|
| 95 | ///< character \\0. |
---|
| 96 | ///< |
---|
| 97 | not_dot_newline = 1 << 12, ///< Specifies that the . metacharacter does not match the |
---|
| 98 | ///< newline character \\n. |
---|
| 99 | ///< |
---|
| 100 | ignore_white_space = 1 << 13 ///< Specifies that non-escaped white-space is not significant. |
---|
| 101 | ///< |
---|
| 102 | }; |
---|
| 103 | |
---|
| 104 | /// Flags used to customize the behavior of the regex algorithms |
---|
| 105 | /// |
---|
| 106 | enum match_flag_type |
---|
| 107 | { |
---|
| 108 | match_default = 0, ///< Specifies that matching of regular expressions proceeds |
---|
| 109 | ///< without any modification of the normal rules used in |
---|
| 110 | ///< ECMA-262, ECMAScript Language Specification, Chapter 15 |
---|
| 111 | ///< part 10, RegExp (Regular Expression) Objects (FWD.1) |
---|
| 112 | ///< |
---|
| 113 | match_not_bol = 1 << 1, ///< Specifies that the expression "^" should not be matched |
---|
| 114 | ///< against the sub-sequence [first,first). |
---|
| 115 | ///< |
---|
| 116 | match_not_eol = 1 << 2, ///< Specifies that the expression "\$" should not be |
---|
| 117 | ///< matched against the sub-sequence [last,last). |
---|
| 118 | ///< |
---|
| 119 | match_not_bow = 1 << 3, ///< Specifies that the expression "\\b" should not be |
---|
| 120 | ///< matched against the sub-sequence [first,first). |
---|
| 121 | ///< |
---|
| 122 | match_not_eow = 1 << 4, ///< Specifies that the expression "\\b" should not be |
---|
| 123 | ///< matched against the sub-sequence [last,last). |
---|
| 124 | ///< |
---|
| 125 | match_any = 1 << 7, ///< Specifies that if more than one match is possible then |
---|
| 126 | ///< any match is an acceptable result. |
---|
| 127 | ///< |
---|
| 128 | match_not_null = 1 << 8, ///< Specifies that the expression can not be matched |
---|
| 129 | ///< against an empty sequence. |
---|
| 130 | ///< |
---|
| 131 | match_continuous = 1 << 10, ///< Specifies that the expression must match a sub-sequence |
---|
| 132 | ///< that begins at first. |
---|
| 133 | ///< |
---|
| 134 | match_partial = 1 << 11, ///< Specifies that if no match can be found, then it is |
---|
| 135 | ///< acceptable to return a match [from, last) where |
---|
| 136 | ///< from!=last, if there exists some sequence of characters |
---|
| 137 | ///< [from,to) of which [from,last) is a prefix, and which |
---|
| 138 | ///< would result in a full match. |
---|
| 139 | ///< |
---|
| 140 | match_prev_avail = 1 << 12, ///< Specifies that --first is a valid iterator position, |
---|
| 141 | ///< when this flag is set then the flags match_not_bol |
---|
| 142 | ///< and match_not_bow are ignored by the regular expression |
---|
| 143 | ///< algorithms (RE.7) and iterators (RE.8). |
---|
| 144 | ///< |
---|
| 145 | format_default = 0, ///< Specifies that when a regular expression match is to be |
---|
| 146 | ///< replaced by a new string, that the new string is |
---|
| 147 | ///< constructed using the rules used by the ECMAScript |
---|
| 148 | ///< replace function in ECMA-262, ECMAScript Language |
---|
| 149 | ///< Specification, Chapter 15 part 5.4.11 |
---|
| 150 | ///< String.prototype.replace. (FWD.1). In addition during |
---|
| 151 | ///< search and replace operations then all non-overlapping |
---|
| 152 | ///< occurrences of the regular expression are located and |
---|
| 153 | ///< replaced, and sections of the input that did not match |
---|
| 154 | ///< the expression, are copied unchanged to the output |
---|
| 155 | ///< string. |
---|
| 156 | ///< |
---|
| 157 | //format_sed = 1 << 13, ///< Specifies that when a regular expression match is to be |
---|
| 158 | // ///< replaced by a new string, that the new string is |
---|
| 159 | // ///< constructed using the rules used by the Unix sed |
---|
| 160 | // ///< utility in IEEE Std 1003.1-2001, Portable Operating |
---|
| 161 | // ///< SystemInterface (POSIX), Shells and Utilities. |
---|
| 162 | // ///< |
---|
| 163 | //format_perl = 1 << 14, ///< Specifies that when a regular expression match is to be |
---|
| 164 | // ///< replaced by a new string, that the new string is |
---|
| 165 | // ///< constructed using an implementation defined superset |
---|
| 166 | // ///< of the rules used by the ECMAScript replace function in |
---|
| 167 | // ///< ECMA-262, ECMAScript Language Specification, Chapter 15 |
---|
| 168 | // ///< part 5.4.11 String.prototype.replace (FWD.1). |
---|
| 169 | // ///< |
---|
| 170 | format_no_copy = 1 << 15, ///< When specified during a search and replace operation, |
---|
| 171 | ///< then sections of the character container sequence being |
---|
| 172 | ///< searched that do match the regular expression, are not |
---|
| 173 | ///< copied to the output string. |
---|
| 174 | ///< |
---|
| 175 | format_first_only = 1 << 16, ///< When specified during a search and replace operation, |
---|
| 176 | ///< then only the first occurrence of the regular |
---|
| 177 | ///< expression is replaced. |
---|
| 178 | ///< |
---|
| 179 | format_literal = 1 << 17 ///< Treat the format string as a literal. |
---|
| 180 | ///< |
---|
| 181 | }; |
---|
| 182 | |
---|
| 183 | /// Error codes used by the regex_error type |
---|
| 184 | /// |
---|
| 185 | enum error_type |
---|
| 186 | { |
---|
| 187 | error_collate, ///< The expression contained an invalid collating element name. |
---|
| 188 | ///< |
---|
| 189 | error_ctype, ///< The expression contained an invalid character class name. |
---|
| 190 | ///< |
---|
| 191 | error_escape, ///< The expression contained an invalid escaped character, |
---|
| 192 | ///< or a trailing escape. |
---|
| 193 | ///< |
---|
| 194 | error_subreg, ///< The expression contained an invalid back-reference. |
---|
| 195 | ///< |
---|
| 196 | error_brack, ///< The expression contained mismatched [ and ]. |
---|
| 197 | ///< |
---|
| 198 | error_paren, ///< The expression contained mismatched (and). |
---|
| 199 | ///< |
---|
| 200 | error_brace, ///< The expression contained mismatched { and } |
---|
| 201 | ///< |
---|
| 202 | error_badbrace, ///< The expression contained an invalid range in a {} expression. |
---|
| 203 | ///< |
---|
| 204 | error_range, ///< The expression contained an invalid character range, for |
---|
| 205 | ///< example [b-a]. |
---|
| 206 | ///< |
---|
| 207 | error_space, ///< There was insufficient memory to convert the expression into a |
---|
| 208 | ///< finite state machine. |
---|
| 209 | ///< |
---|
| 210 | error_badrepeat, ///< One of *?+{ was not preceded by a valid regular expression. |
---|
| 211 | ///< |
---|
| 212 | error_complexity, ///< The complexity of an attempted match against a regular |
---|
| 213 | ///< expression exceeded a pre-set level. |
---|
| 214 | ///< |
---|
| 215 | error_stack, ///< There was insufficient memory to determine whether the regular |
---|
| 216 | ///< expression could match the specified character sequence. |
---|
| 217 | ///< |
---|
| 218 | error_badref, ///< An nested regex is uninitialized. |
---|
| 219 | ///< |
---|
| 220 | error_badlookbehind, ///< An attempt to create a variable-width look-behind assertion |
---|
| 221 | ///< was detected. |
---|
| 222 | ///< |
---|
| 223 | error_internal ///< An internal error has occured. |
---|
| 224 | ///< |
---|
| 225 | }; |
---|
| 226 | |
---|
| 227 | /// INTERNAL ONLY |
---|
| 228 | inline syntax_option_type operator &(syntax_option_type b1, syntax_option_type b2) |
---|
| 229 | { |
---|
| 230 | return static_cast<syntax_option_type>( |
---|
| 231 | static_cast<int>(b1) & static_cast<int>(b2)); |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | /// INTERNAL ONLY |
---|
| 235 | inline syntax_option_type operator |(syntax_option_type b1, syntax_option_type b2) |
---|
| 236 | { |
---|
| 237 | return static_cast<syntax_option_type>(static_cast<int>(b1) | static_cast<int>(b2)); |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | /// INTERNAL ONLY |
---|
| 241 | inline syntax_option_type operator ^(syntax_option_type b1, syntax_option_type b2) |
---|
| 242 | { |
---|
| 243 | return static_cast<syntax_option_type>(static_cast<int>(b1) ^ static_cast<int>(b2)); |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | /// INTERNAL ONLY |
---|
| 247 | inline syntax_option_type operator ~(syntax_option_type b) |
---|
| 248 | { |
---|
| 249 | return static_cast<syntax_option_type>(~static_cast<int>(b)); |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | /// INTERNAL ONLY |
---|
| 253 | inline match_flag_type operator &(match_flag_type b1, match_flag_type b2) |
---|
| 254 | { |
---|
| 255 | return static_cast<match_flag_type>(static_cast<int>(b1) & static_cast<int>(b2)); |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | /// INTERNAL ONLY |
---|
| 259 | inline match_flag_type operator |(match_flag_type b1, match_flag_type b2) |
---|
| 260 | { |
---|
| 261 | return static_cast<match_flag_type>(static_cast<int>(b1) | static_cast<int>(b2)); |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | /// INTERNAL ONLY |
---|
| 265 | inline match_flag_type operator ^(match_flag_type b1, match_flag_type b2) |
---|
| 266 | { |
---|
| 267 | return static_cast<match_flag_type>(static_cast<int>(b1) ^ static_cast<int>(b2)); |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | /// INTERNAL ONLY |
---|
| 271 | inline match_flag_type operator ~(match_flag_type b) |
---|
| 272 | { |
---|
| 273 | return static_cast<match_flag_type>(~static_cast<int>(b)); |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | }}} // namespace boost::xpressive::regex_constants |
---|
| 277 | |
---|
| 278 | #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED |
---|
| 279 | # undef icase |
---|
| 280 | #endif |
---|
| 281 | |
---|
| 282 | #endif |
---|