Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file regex_constants.hpp Chris@16: /// Contains definitions for the syntax_option_type, match_flag_type and Chris@16: /// error_type enumerations. Chris@16: // Chris@16: // Copyright 2008 Eric Niebler. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_XPRESSIVE_REGEX_CONSTANTS_HPP_EAN_10_04_2005 Chris@16: #define BOOST_XPRESSIVE_REGEX_CONSTANTS_HPP_EAN_10_04_2005 Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: Chris@16: #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED Chris@16: # define icase icase_ Chris@16: #endif Chris@16: Chris@16: namespace boost { namespace xpressive { namespace regex_constants Chris@16: { Chris@16: Chris@16: /// Flags used to customize the regex syntax Chris@16: /// Chris@16: enum syntax_option_type Chris@16: { Chris@16: // these flags are required: Chris@16: Chris@16: ECMAScript = 0, ///< Specifies that the grammar recognized by the regular expression Chris@16: ///< engine uses its normal semantics: that is the same as that given Chris@16: ///< in the ECMA-262, ECMAScript Language Specification, Chapter 15 Chris@16: ///< part 10, RegExp (Regular Expression) Objects (FWD.1). Chris@16: ///< Chris@16: icase = 1 << 1, ///< Specifies that matching of regular expressions against a character Chris@16: ///< container sequence shall be performed without regard to case. Chris@16: ///< Chris@16: nosubs = 1 << 2, ///< Specifies that when a regular expression is matched against a Chris@16: ///< character container sequence, then no sub-expression matches are to Chris@16: ///< be stored in the supplied match_results structure. Chris@16: ///< Chris@16: optimize = 1 << 3, ///< Specifies that the regular expression engine should pay more Chris@16: ///< attention to the speed with which regular expressions are matched, Chris@16: ///< and less to the speed with which regular expression objects are Chris@16: ///< constructed. Otherwise it has no detectable effect on the program Chris@16: ///< output. Chris@16: ///< Chris@16: collate = 1 << 4, ///< Specifies that character ranges of the form "[a-b]" should be Chris@16: ///< locale sensitive. Chris@16: ///< Chris@16: Chris@16: // These flags are optional. If the functionality is supported Chris@16: // then the flags shall take these names. Chris@16: Chris@16: //basic = 1 << 5, ///< Specifies that the grammar recognized by the regular expression Chris@16: // ///< engine is the same as that used by POSIX basic regular expressions Chris@16: // ///< in IEEE Std 1003.1-2001, Portable Operating System Interface Chris@16: // ///< (POSIX), Base Definitions and Headers, Section 9, Regular Chris@16: // ///< Expressions (FWD.1). Chris@16: // ///< Chris@16: //extended = 1 << 6, ///< Specifies that the grammar recognized by the regular expression Chris@16: // ///< engine is the same as that used by POSIX extended regular Chris@16: // ///< expressions in IEEE Std 1003.1-2001, Portable Operating System Chris@16: // ///< Interface (POSIX), Base Definitions and Headers, Section 9, Chris@16: // ///< Regular Expressions (FWD.1). Chris@16: // ///< Chris@16: //awk = 1 << 7, ///< Specifies that the grammar recognized by the regular expression Chris@16: // ///< engine is the same as that used by POSIX utility awk in IEEE Std Chris@16: // ///< 1003.1-2001, Portable Operating System Interface (POSIX), Shells Chris@16: // ///< and Utilities, Section 4, awk (FWD.1). Chris@16: // ///< Chris@16: //grep = 1 << 8, ///< Specifies that the grammar recognized by the regular expression Chris@16: // ///< engine is the same as that used by POSIX utility grep in IEEE Std Chris@16: // ///< 1003.1-2001, Portable Operating System Interface (POSIX), Chris@16: // ///< Shells and Utilities, Section 4, Utilities, grep (FWD.1). Chris@16: // ///< Chris@16: //egrep = 1 << 9, ///< Specifies that the grammar recognized by the regular expression Chris@16: // ///< engine is the same as that used by POSIX utility grep when given Chris@16: // ///< the -E option in IEEE Std 1003.1-2001, Portable Operating System Chris@16: // ///< Interface (POSIX), Shells and Utilities, Section 4, Utilities, Chris@16: // ///< grep (FWD.1). Chris@16: // ///< Chris@16: Chris@16: // these flags are specific to xpressive, and they help with perl compliance. Chris@16: Chris@16: single_line = 1 << 10, ///< Specifies that the ^ and \$ metacharacters DO NOT match at Chris@16: ///< internal line breaks. Note that this is the opposite of the Chris@16: ///< perl default. It is the inverse of perl's /m (multi-line) Chris@16: ///< modifier. Chris@16: ///< Chris@16: not_dot_null = 1 << 11, ///< Specifies that the . metacharacter does not match the null Chris@16: ///< character \\0. Chris@16: ///< Chris@16: not_dot_newline = 1 << 12, ///< Specifies that the . metacharacter does not match the Chris@16: ///< newline character \\n. Chris@16: ///< Chris@16: ignore_white_space = 1 << 13 ///< Specifies that non-escaped white-space is not significant. Chris@16: ///< Chris@16: }; Chris@16: Chris@16: /// Flags used to customize the behavior of the regex algorithms Chris@16: /// Chris@16: enum match_flag_type Chris@16: { Chris@16: match_default = 0, ///< Specifies that matching of regular expressions proceeds Chris@16: ///< without any modification of the normal rules used in Chris@16: ///< ECMA-262, ECMAScript Language Specification, Chapter 15 Chris@16: ///< part 10, RegExp (Regular Expression) Objects (FWD.1) Chris@16: ///< Chris@16: match_not_bol = 1 << 1, ///< Specifies that the expression "^" should not be matched Chris@16: ///< against the sub-sequence [first,first). Chris@16: ///< Chris@16: match_not_eol = 1 << 2, ///< Specifies that the expression "\$" should not be Chris@16: ///< matched against the sub-sequence [last,last). Chris@16: ///< Chris@16: match_not_bow = 1 << 3, ///< Specifies that the expression "\\b" should not be Chris@16: ///< matched against the sub-sequence [first,first). Chris@16: ///< Chris@16: match_not_eow = 1 << 4, ///< Specifies that the expression "\\b" should not be Chris@16: ///< matched against the sub-sequence [last,last). Chris@16: ///< Chris@16: match_any = 1 << 7, ///< Specifies that if more than one match is possible then Chris@16: ///< any match is an acceptable result. Chris@16: ///< Chris@16: match_not_null = 1 << 8, ///< Specifies that the expression can not be matched Chris@16: ///< against an empty sequence. Chris@16: ///< Chris@16: match_continuous = 1 << 10, ///< Specifies that the expression must match a sub-sequence Chris@16: ///< that begins at first. Chris@16: ///< Chris@16: match_partial = 1 << 11, ///< Specifies that if no match can be found, then it is Chris@16: ///< acceptable to return a match [from, last) where Chris@16: ///< from != last, if there exists some sequence of characters Chris@16: ///< [from,to) of which [from,last) is a prefix, and which Chris@16: ///< would result in a full match. Chris@16: ///< Chris@16: match_prev_avail = 1 << 12, ///< Specifies that --first is a valid iterator position, Chris@16: ///< when this flag is set then the flags match_not_bol Chris@16: ///< and match_not_bow are ignored by the regular expression Chris@16: ///< algorithms (RE.7) and iterators (RE.8). Chris@16: ///< Chris@16: format_default = 0, ///< Specifies that when a regular expression match is to be Chris@16: ///< replaced by a new string, that the new string is Chris@16: ///< constructed using the rules used by the ECMAScript Chris@16: ///< replace function in ECMA-262, ECMAScript Language Chris@16: ///< Specification, Chapter 15 part 5.4.11 Chris@16: ///< String.prototype.replace. (FWD.1). In addition during Chris@16: ///< search and replace operations then all non-overlapping Chris@16: ///< occurrences of the regular expression are located and Chris@16: ///< replaced, and sections of the input that did not match Chris@16: ///< the expression, are copied unchanged to the output Chris@16: ///< string. Chris@16: ///< Chris@16: format_sed = 1 << 13, ///< Specifies that when a regular expression match is to be Chris@16: ///< replaced by a new string, that the new string is Chris@16: ///< constructed using the rules used by the Unix sed Chris@16: ///< utility in IEEE Std 1003.1-2001, Portable Operating Chris@16: ///< SystemInterface (POSIX), Shells and Utilities. Chris@16: ///< Chris@16: format_perl = 1 << 14, ///< Specifies that when a regular expression match is to be Chris@16: ///< replaced by a new string, that the new string is Chris@16: ///< constructed using an implementation defined superset Chris@16: ///< of the rules used by the ECMAScript replace function in Chris@16: ///< ECMA-262, ECMAScript Language Specification, Chapter 15 Chris@16: ///< part 5.4.11 String.prototype.replace (FWD.1). Chris@16: ///< Chris@16: format_no_copy = 1 << 15, ///< When specified during a search and replace operation, Chris@16: ///< then sections of the character container sequence being Chris@16: ///< searched that do match the regular expression, are not Chris@16: ///< copied to the output string. Chris@16: ///< Chris@16: format_first_only = 1 << 16, ///< When specified during a search and replace operation, Chris@16: ///< then only the first occurrence of the regular Chris@16: ///< expression is replaced. Chris@16: ///< Chris@16: format_literal = 1 << 17, ///< Treat the format string as a literal. Chris@16: ///< Chris@16: format_all = 1 << 18 ///< Specifies that all syntax extensions are enabled, Chris@16: ///< including conditional (?ddexpression1:expression2) Chris@16: ///< replacements. Chris@16: ///< Chris@16: }; Chris@16: Chris@16: /// Error codes used by the regex_error type Chris@16: /// Chris@16: enum error_type Chris@16: { Chris@16: error_collate, ///< The expression contained an invalid collating element name. Chris@16: ///< Chris@16: error_ctype, ///< The expression contained an invalid character class name. Chris@16: ///< Chris@16: error_escape, ///< The expression contained an invalid escaped character, Chris@16: ///< or a trailing escape. Chris@16: ///< Chris@16: error_subreg, ///< The expression contained an invalid back-reference. Chris@16: ///< Chris@16: error_brack, ///< The expression contained mismatched [ and ]. Chris@16: ///< Chris@16: error_paren, ///< The expression contained mismatched ( and ). Chris@16: ///< Chris@16: error_brace, ///< The expression contained mismatched { and }. Chris@16: ///< Chris@16: error_badbrace, ///< The expression contained an invalid range in a {} expression. Chris@16: ///< Chris@16: error_range, ///< The expression contained an invalid character range, for Chris@16: ///< example [b-a]. Chris@16: ///< Chris@16: error_space, ///< There was insufficient memory to convert the expression into a Chris@16: ///< finite state machine. Chris@16: ///< Chris@16: error_badrepeat, ///< One of *?+{ was not preceded by a valid regular expression. Chris@16: ///< Chris@16: error_complexity, ///< The complexity of an attempted match against a regular Chris@16: ///< expression exceeded a pre-set level. Chris@16: ///< Chris@16: error_stack, ///< There was insufficient memory to determine whether the regular Chris@16: ///< expression could match the specified character sequence. Chris@16: ///< Chris@16: error_badref, ///< An nested regex is uninitialized. Chris@16: ///< Chris@16: error_badmark, ///< An invalid use of a named capture. Chris@16: ///< Chris@16: error_badlookbehind, ///< An attempt to create a variable-width look-behind assertion Chris@16: ///< was detected. Chris@16: ///< Chris@16: error_badrule, ///< An invalid use of a rule was detected. Chris@16: ///< Chris@16: error_badarg, ///< An argument to an action was unbound. Chris@16: ///< Chris@16: error_badattr, ///< Tried to read from an uninitialized attribute. Chris@16: ///< Chris@16: error_internal ///< An internal error has occurred. Chris@16: ///< Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: inline syntax_option_type operator &(syntax_option_type b1, syntax_option_type b2) Chris@16: { Chris@16: return static_cast( Chris@16: static_cast(b1) & static_cast(b2)); Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: inline syntax_option_type operator |(syntax_option_type b1, syntax_option_type b2) Chris@16: { Chris@16: return static_cast(static_cast(b1) | static_cast(b2)); Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: inline syntax_option_type operator ^(syntax_option_type b1, syntax_option_type b2) Chris@16: { Chris@16: return static_cast(static_cast(b1) ^ static_cast(b2)); Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: inline syntax_option_type operator ~(syntax_option_type b) Chris@16: { Chris@16: return static_cast(~static_cast(b)); Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: inline match_flag_type operator &(match_flag_type b1, match_flag_type b2) Chris@16: { Chris@16: return static_cast(static_cast(b1) & static_cast(b2)); Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: inline match_flag_type operator |(match_flag_type b1, match_flag_type b2) Chris@16: { Chris@16: return static_cast(static_cast(b1) | static_cast(b2)); Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: inline match_flag_type operator ^(match_flag_type b1, match_flag_type b2) Chris@16: { Chris@16: return static_cast(static_cast(b1) ^ static_cast(b2)); Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: inline match_flag_type operator ~(match_flag_type b) Chris@16: { Chris@16: return static_cast(~static_cast(b)); Chris@16: } Chris@16: Chris@16: }}} // namespace boost::xpressive::regex_constants Chris@16: Chris@16: #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED Chris@16: # undef icase Chris@16: #endif Chris@16: Chris@16: #endif