2010-06-17 02:34:59 +02:00
|
|
|
// -*- C++ -*-
|
2010-09-28 19:19:10 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2010-06-17 02:34:59 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-06-17 02:34:59 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <regex>
|
|
|
|
|
|
|
|
// class regex_error
|
|
|
|
// : public runtime_error
|
|
|
|
// {
|
|
|
|
// public:
|
|
|
|
// explicit regex_error(regex_constants::error_type ecode);
|
|
|
|
// regex_constants::error_type code() const;
|
|
|
|
// };
|
|
|
|
|
|
|
|
#include <regex>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_collate);
|
|
|
|
assert(e.code() == std::regex_constants::error_collate);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained an invalid collating element name."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_ctype);
|
|
|
|
assert(e.code() == std::regex_constants::error_ctype);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained an invalid character class name."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_escape);
|
|
|
|
assert(e.code() == std::regex_constants::error_escape);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained an invalid escaped character, or a "
|
|
|
|
"trailing escape."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_backref);
|
|
|
|
assert(e.code() == std::regex_constants::error_backref);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained an invalid back reference."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_brack);
|
|
|
|
assert(e.code() == std::regex_constants::error_brack);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained mismatched [ and ]."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_paren);
|
|
|
|
assert(e.code() == std::regex_constants::error_paren);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained mismatched ( and )."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_brace);
|
|
|
|
assert(e.code() == std::regex_constants::error_brace);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained mismatched { and }."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_badbrace);
|
|
|
|
assert(e.code() == std::regex_constants::error_badbrace);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained an invalid range in a {} expression."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_range);
|
|
|
|
assert(e.code() == std::regex_constants::error_range);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The expression contained an invalid character range, "
|
|
|
|
"such as [b-a] in most encodings."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_space);
|
|
|
|
assert(e.code() == std::regex_constants::error_space);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("There was insufficient memory to convert the expression into "
|
|
|
|
"a finite state machine."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_badrepeat);
|
|
|
|
assert(e.code() == std::regex_constants::error_badrepeat);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("One of *?+{ was not preceded by a valid regular expression."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_complexity);
|
|
|
|
assert(e.code() == std::regex_constants::error_complexity);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("The complexity of an attempted match against a regular "
|
|
|
|
"expression exceeded a pre-set level."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
std::regex_error e(std::regex_constants::error_stack);
|
|
|
|
assert(e.code() == std::regex_constants::error_stack);
|
2010-06-24 23:28:00 +02:00
|
|
|
assert(e.what() == std::string("There was insufficient memory to determine whether the regular "
|
|
|
|
"expression could match the specified character sequence."));
|
2010-06-17 02:34:59 +02:00
|
|
|
}
|
|
|
|
}
|