1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file regex_constants.hpp
3 /// Contains definitions for the syntax_option_type, match_flag_type and
4 /// error_type enumerations.
6 // Copyright 2008 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)
10 #ifndef BOOST_XPRESSIVE_REGEX_CONSTANTS_HPP_EAN_10_04_2005
11 #define BOOST_XPRESSIVE_REGEX_CONSTANTS_HPP_EAN_10_04_2005
13 // MS compatible compilers support #pragma once
14 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
18 #include <boost/mpl/identity.hpp>
20 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
24 namespace boost
{ namespace xpressive
{ namespace regex_constants
27 /// Flags used to customize the regex syntax
29 enum syntax_option_type
31 // these flags are required:
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).
38 icase
= 1 << 1, ///< Specifies that matching of regular expressions against a character
39 ///< container sequence shall be performed without regard to case.
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.
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
51 collate
= 1 << 4, ///< Specifies that character ranges of the form "[a-b]" should be
52 ///< locale sensitive.
55 // These flags are optional. If the functionality is supported
56 // then the flags shall take these names.
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).
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).
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).
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).
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,
87 // these flags are specific to xpressive, and they help with perl compliance.
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)
94 not_dot_null
= 1 << 11, ///< Specifies that the . metacharacter does not match the null
97 not_dot_newline
= 1 << 12, ///< Specifies that the . metacharacter does not match the
98 ///< newline character \\n.
100 ignore_white_space
= 1 << 13 ///< Specifies that non-escaped white-space is not significant.
104 /// Flags used to customize the behavior of the regex algorithms
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)
113 match_not_bol
= 1 << 1, ///< Specifies that the expression "^" should not be matched
114 ///< against the sub-sequence [first,first).
116 match_not_eol
= 1 << 2, ///< Specifies that the expression "\$" should not be
117 ///< matched against the sub-sequence [last,last).
119 match_not_bow
= 1 << 3, ///< Specifies that the expression "\\b" should not be
120 ///< matched against the sub-sequence [first,first).
122 match_not_eow
= 1 << 4, ///< Specifies that the expression "\\b" should not be
123 ///< matched against the sub-sequence [last,last).
125 match_any
= 1 << 7, ///< Specifies that if more than one match is possible then
126 ///< any match is an acceptable result.
128 match_not_null
= 1 << 8, ///< Specifies that the expression can not be matched
129 ///< against an empty sequence.
131 match_continuous
= 1 << 10, ///< Specifies that the expression must match a sub-sequence
132 ///< that begins at first.
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.
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).
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
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.
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).
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.
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.
179 format_literal
= 1 << 17, ///< Treat the format string as a literal.
181 format_all
= 1 << 18 ///< Specifies that all syntax extensions are enabled,
182 ///< including conditional (?ddexpression1:expression2)
187 /// Error codes used by the regex_error type
191 error_collate
, ///< The expression contained an invalid collating element name.
193 error_ctype
, ///< The expression contained an invalid character class name.
195 error_escape
, ///< The expression contained an invalid escaped character,
196 ///< or a trailing escape.
198 error_subreg
, ///< The expression contained an invalid back-reference.
200 error_brack
, ///< The expression contained mismatched [ and ].
202 error_paren
, ///< The expression contained mismatched ( and ).
204 error_brace
, ///< The expression contained mismatched { and }.
206 error_badbrace
, ///< The expression contained an invalid range in a {} expression.
208 error_range
, ///< The expression contained an invalid character range, for
211 error_space
, ///< There was insufficient memory to convert the expression into a
212 ///< finite state machine.
214 error_badrepeat
, ///< One of *?+{ was not preceded by a valid regular expression.
216 error_complexity
, ///< The complexity of an attempted match against a regular
217 ///< expression exceeded a pre-set level.
219 error_stack
, ///< There was insufficient memory to determine whether the regular
220 ///< expression could match the specified character sequence.
222 error_badref
, ///< An nested regex is uninitialized.
224 error_badmark
, ///< An invalid use of a named capture.
226 error_badlookbehind
, ///< An attempt to create a variable-width look-behind assertion
229 error_badrule
, ///< An invalid use of a rule was detected.
231 error_badarg
, ///< An argument to an action was unbound.
233 error_badattr
, ///< Tried to read from an uninitialized attribute.
235 error_internal
///< An internal error has occured.
240 inline syntax_option_type
operator &(syntax_option_type b1
, syntax_option_type b2
)
242 return static_cast<syntax_option_type
>(
243 static_cast<int>(b1
) & static_cast<int>(b2
));
247 inline syntax_option_type
operator |(syntax_option_type b1
, syntax_option_type b2
)
249 return static_cast<syntax_option_type
>(static_cast<int>(b1
) | static_cast<int>(b2
));
253 inline syntax_option_type
operator ^(syntax_option_type b1
, syntax_option_type b2
)
255 return static_cast<syntax_option_type
>(static_cast<int>(b1
) ^ static_cast<int>(b2
));
259 inline syntax_option_type
operator ~(syntax_option_type b
)
261 return static_cast<syntax_option_type
>(~static_cast<int>(b
));
265 inline match_flag_type
operator &(match_flag_type b1
, match_flag_type b2
)
267 return static_cast<match_flag_type
>(static_cast<int>(b1
) & static_cast<int>(b2
));
271 inline match_flag_type
operator |(match_flag_type b1
, match_flag_type b2
)
273 return static_cast<match_flag_type
>(static_cast<int>(b1
) | static_cast<int>(b2
));
277 inline match_flag_type
operator ^(match_flag_type b1
, match_flag_type b2
)
279 return static_cast<match_flag_type
>(static_cast<int>(b1
) ^ static_cast<int>(b2
));
283 inline match_flag_type
operator ~(match_flag_type b
)
285 return static_cast<match_flag_type
>(~static_cast<int>(b
));
288 }}} // namespace boost::xpressive::regex_constants
290 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED