Skip to content

Commit 643f82b

Browse files
author
Hana Dusíková
committed
fixed issue #69: the optimizer for greedy => possesive cycle transformation didn't support shorthands for word_chars and others
1 parent 86c4089 commit 643f82b

File tree

3 files changed

+39
-33
lines changed

3 files changed

+39
-33
lines changed

include/ctre/atoms_characters.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@ template <auto A, auto B> struct char_range {
5353
}
5454
};
5555

56-
struct word_chars : set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'>, character<'_'> > { };
56+
using word_chars = set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'>, character<'_'> >;
5757

58-
struct space_chars : enumeration<' ', '\t', '\n', '\v', '\f', '\r'> {};
58+
using space_chars = enumeration<' ', '\t', '\n', '\v', '\f', '\r'>;
5959

60-
struct alphanum_chars : set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'> > { };
60+
using alphanum_chars = set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'> >;
6161

62-
struct alpha_chars : set<char_range<'A','Z'>, char_range<'a','z'> > { };
62+
using alpha_chars = set<char_range<'A','Z'>, char_range<'a','z'> >;
6363

64-
struct xdigit_chars : set<char_range<'A','F'>, char_range<'a','f'>, char_range<'0','9'> > { };
64+
using xdigit_chars = set<char_range<'A','F'>, char_range<'a','f'>, char_range<'0','9'> >;
6565

66-
struct punct_chars
67-
: enumeration<'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', ',', '-',
66+
using punct_chars
67+
= enumeration<'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', ',', '-',
6868
'.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']',
69-
'^', '_', '`', '{', '|', '}', '~'> {};
69+
'^', '_', '`', '{', '|', '}', '~'>;
7070

71-
struct digit_chars : char_range<'0','9'> { };
71+
using digit_chars = char_range<'0','9'>;
7272

73-
struct ascii_chars : char_range<'\x00','\x7F'> { };
73+
using ascii_chars = char_range<'\x00','\x7F'>;
7474

7575

7676
}

include/ctre/first.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ template <typename... Content> constexpr size_t calculate_size_of_first(ctll::li
266266
return (calculate_size_of_first(Content{}) + ... + 0);
267267
}
268268

269+
template <typename... Content> constexpr size_t calculate_size_of_first(ctre::set<Content...>) {
270+
return (calculate_size_of_first(Content{}) + ... + 0);
271+
}
272+
269273
template <auto A, typename CB> constexpr int64_t negative_helper(ctre::character<A>, CB & cb, int64_t start) {
270274
if (A != std::numeric_limits<int64_t>::min()) {
271275
if (start < A) {
@@ -436,6 +440,9 @@ template <size_t Capacity> class point_set {
436440
template <typename... Content> constexpr bool check(ctll::list<Content...>) {
437441
return (check(Content{}) || ... || false);
438442
}
443+
template <typename... Content> constexpr bool check(ctre::set<Content...>) {
444+
return (check(Content{}) || ... || false);
445+
}
439446

440447

441448
template <auto V> constexpr void populate(ctre::character<V>) {
@@ -452,8 +459,8 @@ template <size_t Capacity> class point_set {
452459
this->insert(low, high);
453460
});
454461
}
455-
template <auto... V> constexpr void populate(ctre::enumeration<V...>) {
456-
return (insert(V,V), ...);
462+
template <typename... Content> constexpr void populate(ctre::set<Content...>) {
463+
(populate(Content{}), ...);
457464
}
458465
template <typename... Content> constexpr void populate(ctll::list<Content...>) {
459466
(populate(Content{}), ...);

single-header/ctre.hpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,24 +1385,24 @@ template <auto A, auto B> struct char_range {
13851385
}
13861386
};
13871387

1388-
struct word_chars : set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'>, character<'_'> > { };
1388+
using word_chars = set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'>, character<'_'> >;
13891389

1390-
struct space_chars : enumeration<' ', '\t', '\n', '\v', '\f', '\r'> {};
1390+
using space_chars = enumeration<' ', '\t', '\n', '\v', '\f', '\r'>;
13911391

1392-
struct alphanum_chars : set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'> > { };
1392+
using alphanum_chars = set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'> >;
13931393

1394-
struct alpha_chars : set<char_range<'A','Z'>, char_range<'a','z'> > { };
1394+
using alpha_chars = set<char_range<'A','Z'>, char_range<'a','z'> >;
13951395

1396-
struct xdigit_chars : set<char_range<'A','F'>, char_range<'a','f'>, char_range<'0','9'> > { };
1396+
using xdigit_chars = set<char_range<'A','F'>, char_range<'a','f'>, char_range<'0','9'> >;
13971397

1398-
struct punct_chars
1399-
: enumeration<'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', ',', '-',
1398+
using punct_chars
1399+
= enumeration<'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', ',', '-',
14001400
'.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']',
1401-
'^', '_', '`', '{', '|', '}', '~'> {};
1401+
'^', '_', '`', '{', '|', '}', '~'>;
14021402

1403-
struct digit_chars : char_range<'0','9'> { };
1403+
using digit_chars = char_range<'0','9'>;
14041404

1405-
struct ascii_chars : char_range<'\x00','\x7F'> { };
1405+
using ascii_chars = char_range<'\x00','\x7F'>;
14061406

14071407
}
14081408

@@ -2427,14 +2427,6 @@ template <typename Iterator, typename... Captures> class regex_results {
24272427
return bool(_captures.template select<0>());
24282428
}
24292429

2430-
constexpr CTRE_FORCE_INLINE auto operator*() const noexcept {
2431-
return *this;
2432-
}
2433-
2434-
constexpr CTRE_FORCE_INLINE auto operator*() noexcept {
2435-
return *this;
2436-
}
2437-
24382430
constexpr CTRE_FORCE_INLINE operator std::basic_string_view<char_type>() const noexcept {
24392431
return to_view();
24402432
}
@@ -2874,6 +2866,10 @@ template <typename... Content> constexpr size_t calculate_size_of_first(ctll::li
28742866
return (calculate_size_of_first(Content{}) + ... + 0);
28752867
}
28762868

2869+
template <typename... Content> constexpr size_t calculate_size_of_first(ctre::set<Content...>) {
2870+
return (calculate_size_of_first(Content{}) + ... + 0);
2871+
}
2872+
28772873
template <auto A, typename CB> constexpr int64_t negative_helper(ctre::character<A>, CB & cb, int64_t start) {
28782874
if (A != std::numeric_limits<int64_t>::min()) {
28792875
if (start < A) {
@@ -3044,6 +3040,9 @@ template <size_t Capacity> class point_set {
30443040
template <typename... Content> constexpr bool check(ctll::list<Content...>) {
30453041
return (check(Content{}) || ... || false);
30463042
}
3043+
template <typename... Content> constexpr bool check(ctre::set<Content...>) {
3044+
return (check(Content{}) || ... || false);
3045+
}
30473046

30483047

30493048
template <auto V> constexpr void populate(ctre::character<V>) {
@@ -3060,8 +3059,8 @@ template <size_t Capacity> class point_set {
30603059
this->insert(low, high);
30613060
});
30623061
}
3063-
template <auto... V> constexpr void populate(ctre::enumeration<V...>) {
3064-
return (insert(V,V), ...);
3062+
template <typename... Content> constexpr void populate(ctre::set<Content...>) {
3063+
(populate(Content{}), ...);
30653064
}
30663065
template <typename... Content> constexpr void populate(ctll::list<Content...>) {
30673066
(populate(Content{}), ...);
@@ -3447,7 +3446,7 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
34473446

34483447
// backreference support (match agains content of iterators)
34493448
template <typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE string_match_result<Iterator> match_against_range(Iterator current, const EndIterator end, Iterator range_current, const Iterator range_end) noexcept {
3450-
while (current != end && range_current != range_end) {
3449+
while (end != current && range_end != range_current) {
34513450
if (*current == *range_current) {
34523451
current++;
34533452
range_current++;

0 commit comments

Comments
 (0)