Permalink
Browse files

move from _pcre to _ctre suffix

  • Loading branch information...
Hana Dusíková
Hana Dusíková committed Oct 6, 2018
1 parent 251c5bf commit 9357f66ee0baf47de8876cdb2dcbacffacdf9080
Showing with 3,361 additions and 3,391 deletions.
  1. +6 −36 include/ctre/literals.hpp
  2. +1 −1 result.cpp
  3. +1 −1 test.cpp
  4. +84 −84 tests/generating.cpp
  5. +3,000 −3,000 tests/many-of-same-proto.cpp
  6. +157 −157 tests/matching2.cpp
  7. +112 −112 tests/parsing.cpp
View
@@ -19,36 +19,6 @@ template <typename CharT, CharT... input> static inline constexpr auto _fixed_st
#endif
namespace literals {
#if !__cpp_nontype_template_parameter_class
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_fixed_pcre() noexcept {
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
#else
template <basic_fixed_string input> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_fixed_pcre() noexcept {
#endif
using tmp = typename ctll::parser<ctre::pcre, input, ctre::pcre_actions>::template output<pcre_context<>>;
static_assert(tmp(), "Regular Expression contains syntax error.");
using re = decltype(front(typename tmp::output_type::stack_type()));
return ctre::regular_expression(re());
}
// add this when we will have concepts
// requires ctll::parser<ctre::pcre, _fixed_string_reference<CharT, charpack...>, ctre::pcre_actions>::template correct_with<pcre_context<>>
#if !__cpp_nontype_template_parameter_class
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_pcre() noexcept {
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
#else
template <basic_fixed_string input> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_pcre() noexcept {
#endif
using tmp = typename ctll::parser<ctre::pcre, input, ctre::pcre_actions>::template output<pcre_context<>>;
static_assert(tmp(), "Regular Expression contains syntax error.");
using re = decltype(front(typename tmp::output_type::stack_type()));
return ctre::regular_expression(re());
}
// duplicate for _ctre
// add this when we will have concepts
// requires ctll::parser<ctre::pcre, _fixed_string_reference<CharT, charpack...>, ctre::pcre_actions>::template correct_with<pcre_context<>>
@@ -77,19 +47,19 @@ template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr
namespace test_literals {
#if !__cpp_nontype_template_parameter_class
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr inline auto operator""_pcre_test() noexcept {
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr inline auto operator""_ctre_test() noexcept {
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
#else
template <basic_fixed_string input> __attribute__((flatten)) constexpr inline auto operator""_pcre_test() noexcept {
template <basic_fixed_string input> __attribute__((flatten)) constexpr inline auto operator""_ctre_test() noexcept {
#endif
return ctll::parser<ctre::pcre, input>::correct;
}
#if !__cpp_nontype_template_parameter_class
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr inline auto operator""_pcre_gen() noexcept {
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr inline auto operator""_ctre_gen() noexcept {
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
#else
template <basic_fixed_string input> __attribute__((flatten)) constexpr inline auto operator""_pcre_gen() noexcept {
template <basic_fixed_string input> __attribute__((flatten)) constexpr inline auto operator""_ctre_gen() noexcept {
#endif
using tmp = typename ctll::parser<ctre::pcre, input, ctre::pcre_actions>::template output<pcre_context<>>;
static_assert(tmp(), "Regular Expression contains syntax error.");
@@ -98,10 +68,10 @@ template <basic_fixed_string input> __attribute__((flatten)) constexpr inline au
#if !__cpp_nontype_template_parameter_class
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_pcre_syntax() noexcept {
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_ctre_syntax() noexcept {
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
#else
template <basic_fixed_string input> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_pcre_syntax() noexcept {
template <basic_fixed_string input> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_ctre_syntax() noexcept {
#endif
return ctll::parser<ctre::pcre, input, ctre::pcre_actions>::template correct_with<pcre_context<>>;
}
View
@@ -13,7 +13,7 @@ enum class type {
std::pair<type, std::string_view> match(std::string_view subject) {
using namespace ctre::literals;
if (auto [matched, identifier, number] = "(?:([a-z]++)|([0-9]++))"_pcre.match(subject); matched) {
if (auto [matched, identifier, number] = "(?:([a-z]++)|([0-9]++))"_ctre.match(subject); matched) {
if (identifier) return {type::identifier, std::string_view{identifier}};
else if (number) return {type::number, std::string_view{number}};
else return {type::matched, std::string_view{matched}};
View
@@ -7,7 +7,7 @@
void match(std::string_view subject) {
using namespace ctre::literals;
if (auto [matched, inner] = "^([0-9]+?[a-z]++)+"_pcre.match(subject); matched) {
if (auto [matched, inner] = "^([0-9]+?[a-z]++)+"_ctre.match(subject); matched) {
std::cout << "matched = " << matched.to_view() << "\n";
if (inner) {
std::cout << " inner = " << inner.to_view() << "\n";
Oops, something went wrong.

0 comments on commit 9357f66

Please sign in to comment.