3
3
#define CPP2REGEX_H_CPP2
4
4
5
5
6
+ // === Cpp1 type definitions and function declarations ====================================================
7
+
8
+ #line 1 "cpp2regex.h2"
9
+
10
+ // Copyright 2022-2024 Herb Sutter
11
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
12
+ //
13
+ // Part of the Cppfront Project, under the Apache License v2.0 with LLVM Exceptions.
14
+ // See https://github.com/hsutter/cppfront/blob/main/LICENSE for license information.
15
+
16
+
17
+ // ===========================================================================
18
+ // Regex support
19
+ // ===========================================================================
20
+
21
+ #ifndef CPP2_CPP2REGEX_H
22
+ #define CPP2_CPP2REGEX_H
23
+
24
+ template <typename matcher_wrapper, typename Iter, typename CharT>
25
+ using matcher_wrapper_type = typename matcher_wrapper::template wrap<Iter, CharT>;
26
+
27
+ template <typename matcher>
28
+ using matcher_context_type = typename matcher::context;
29
+ #line 758 "cpp2regex.h2"
30
+ #endif
31
+
6
32
// === Cpp2 type declarations ====================================================
7
33
8
34
@@ -15,6 +41,9 @@ namespace cpp2 {
15
41
16
42
namespace regex {
17
43
44
+ template <typename CharT> using bstring = std::basic_string<CharT>;
45
+ template <typename CharT> using bview = std::basic_string_view<CharT>;
46
+
18
47
#line 38 "cpp2regex.h2"
19
48
template <typename Iter> class match_group ;
20
49
@@ -54,12 +83,59 @@ template<typename CharT, typename Inner> class negated_class_entry;
54
83
#line 211 "cpp2regex.h2"
55
84
template <typename CharT, string_util::fixed_string Name, typename Inner> class shorthand_class_entry ;
56
85
86
+ #line 220 "cpp2regex.h2"
87
+ template <typename CharT> using digits_class = named_class_entry<CharT," digits" ,range_class_entry<CharT,' 0' ,' 9' >>;
88
+ template <typename CharT> using lower_class = named_class_entry<CharT," lower" ,range_class_entry<CharT,' a' ,' z' >>;
89
+ template <typename CharT> using upper_class = named_class_entry<CharT," upper" ,range_class_entry<CharT,' A' ,' Z' >>;
90
+
91
+ #line 226 "cpp2regex.h2"
92
+ template <typename CharT> using alnum_class = named_class_entry<CharT," alnum" ,combined_class_entry<CharT,lower_class<CharT>,upper_class<CharT>,digits_class<CharT>>>;
93
+ template <typename CharT> using alpha_class = named_class_entry<CharT," alpha" ,combined_class_entry<CharT,lower_class<CharT>,upper_class<CharT>>>;
94
+ template <typename CharT> using ascii_class = named_class_entry<CharT," ascii" ,range_class_entry<CharT,' \x00 ' ,' \x7F ' >>;
95
+ template <typename CharT> using blank_class = named_class_entry<CharT," blank" ,list_class_entry<CharT,' ' ,' \t ' >>;
96
+ template <typename CharT> using cntrl_class = named_class_entry<CharT," cntrl" ,combined_class_entry<CharT,range_class_entry<CharT,' \x00 ' ,' \x1F ' >,single_class_entry<CharT,' \x7F ' >>>;
97
+ template <typename CharT> using graph_class = named_class_entry<CharT," graph" ,range_class_entry<CharT,' \x21 ' ,' \x7E ' >>;
98
+ template <typename CharT> using hor_space_class = named_class_entry<CharT," hspace" ,list_class_entry<CharT,' \t ' ,' ' >>;
99
+ template <typename CharT> using print_class = named_class_entry<CharT," print" ,range_class_entry<CharT,' \x20 ' ,' \x7E ' >>;
100
+ template <typename CharT> using punct_class = named_class_entry<CharT," punct" ,list_class_entry<CharT,' [' ,' !' ,' "' ,' #' ,' $' ,' %' ,' &' ,' \' ' ,' (' ,' )' ,' *' ,' +' ,' ,' ,' -' ,' .' ,' /' ,' :' ,' ;' ,' <' ,' =' ,' >' ,' ?' ,' @' ,' [' ,' \\ ' ,' ]' ,' ^' ,' _' ,' `' ,' {' ,' |' ,' }' ,' ~' ,' ]' >>;
101
+ template <typename CharT> using space_class = named_class_entry<CharT," space" ,list_class_entry<CharT,' ' ,' \t ' ,' \r ' ,' \n ' ,' \v ' ,' \f ' >>;
102
+ template <typename CharT> using ver_space_class = named_class_entry<CharT," vspace" ,list_class_entry<CharT,' \n ' ,' \v ' ,' \f ' ,' \r ' >>;
103
+ template <typename CharT> using word_class = named_class_entry<CharT," word" ,combined_class_entry<CharT,alnum_class<CharT>,single_class_entry<CharT,' _' >>>;
104
+ template <typename CharT> using xdigit_class = named_class_entry<CharT," xdigit" ,combined_class_entry<CharT,range_class_entry<CharT,' A' ,' F' >,range_class_entry<CharT,' a' ,' f' >,digits_class<CharT>>>;
105
+
106
+ #line 242 "cpp2regex.h2"
107
+ template <typename CharT> using short_digits_class = shorthand_class_entry<CharT," \\ d" ,digits_class<CharT>>;
108
+ template <typename CharT> using short_hor_space_class = shorthand_class_entry<CharT," \\ h" ,hor_space_class<CharT>>;
109
+ template <typename CharT> using short_space_class = shorthand_class_entry<CharT," \\ s" ,space_class<CharT>>;
110
+ template <typename CharT> using short_vert_space_class = shorthand_class_entry<CharT," \\ v" ,ver_space_class<CharT>>;
111
+ template <typename CharT> using short_word_class = shorthand_class_entry<CharT," \\ w" ,word_class<CharT>>;
112
+
113
+ template <typename CharT> using short_not_digits_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ D" ,digits_class<CharT>>>;
114
+ template <typename CharT> using short_not_hor_space_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ H" ,hor_space_class<CharT>>>;
115
+ template <typename CharT> using short_not_space_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ S" ,space_class<CharT>>>;
116
+ template <typename CharT> using short_not_vert_space_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ V" ,ver_space_class<CharT>>>;
117
+ template <typename CharT> using short_not_word_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ W" ,word_class<CharT>>>;
118
+
57
119
#line 259 "cpp2regex.h2"
58
120
template <typename CharT> class alternative_token_matcher ;
59
121
60
122
#line 337 "cpp2regex.h2"
61
123
template <typename CharT, bool negate, bool case_insensitive, typename ...List> class class_token_matcher ;
62
124
125
+ #line 397 "cpp2regex.h2"
126
+ template <typename CharT, bool case_insensitive> using named_class_no_new_line = class_token_matcher<CharT,true ,case_insensitive,single_class_entry<CharT,' \n ' >>;
127
+ template <typename CharT, bool case_insensitive> using named_class_digits = class_token_matcher<CharT,false ,case_insensitive,digits_class<CharT>>;
128
+ template <typename CharT, bool case_insensitive> using named_class_hor_space = class_token_matcher<CharT,false ,case_insensitive,hor_space_class<CharT>>;
129
+ template <typename CharT, bool case_insensitive> using named_class_space = class_token_matcher<CharT,false ,case_insensitive,space_class<CharT>>;
130
+ template <typename CharT, bool case_insensitive> using named_class_ver_space = class_token_matcher<CharT,false ,case_insensitive,ver_space_class<CharT>>;
131
+ template <typename CharT, bool case_insensitive> using named_class_word = class_token_matcher<CharT,false ,case_insensitive,word_class<CharT>>;
132
+
133
+ template <typename CharT, bool case_insensitive> using named_class_not_digits = class_token_matcher<CharT,true ,case_insensitive,digits_class<CharT>>;
134
+ template <typename CharT, bool case_insensitive> using named_class_not_hor_space = class_token_matcher<CharT,true ,case_insensitive,hor_space_class<CharT>>;
135
+ template <typename CharT, bool case_insensitive> using named_class_not_space = class_token_matcher<CharT,true ,case_insensitive,space_class<CharT>>;
136
+ template <typename CharT, bool case_insensitive> using named_class_not_ver_space = class_token_matcher<CharT,true ,case_insensitive,ver_space_class<CharT>>;
137
+ template <typename CharT, bool case_insensitive> using named_class_not_word = class_token_matcher<CharT,true ,case_insensitive,word_class<CharT>>;
138
+
63
139
#line 492 "cpp2regex.h2"
64
140
class range_flags ;
65
141
@@ -79,34 +155,12 @@ template<typename CharT, typename matcher_wrapper> class regular_expression;
79
155
80
156
#line 1 "cpp2regex.h2"
81
157
82
- // Copyright 2022-2024 Herb Sutter
83
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
84
- //
85
- // Part of the Cppfront Project, under the Apache License v2.0 with LLVM Exceptions.
86
- // See https://github.com/hsutter/cppfront/blob/main/LICENSE for license information.
87
-
88
-
89
- // ===========================================================================
90
- // Regex support
91
- // ===========================================================================
92
-
93
- #ifndef CPP2_CPP2REGEX_H
94
- #define CPP2_CPP2REGEX_H
95
-
96
- template <typename matcher_wrapper, typename Iter, typename CharT>
97
- using matcher_wrapper_type = typename matcher_wrapper::template wrap<Iter, CharT>;
98
-
99
- template <typename matcher>
100
- using matcher_context_type = typename matcher::context;
101
-
102
158
#line 22 "cpp2regex.h2"
103
159
namespace cpp2 {
104
160
105
161
namespace regex {
106
162
107
- template <typename CharT> using bstring = std::basic_string<CharT>;
108
- template <typename CharT> using bview = std::basic_string_view<CharT>;
109
-
163
+ #line 29 "cpp2regex.h2"
110
164
// -----------------------------------------------------------------------
111
165
//
112
166
// Helper structures for the expression matching.
@@ -335,39 +389,14 @@ template<typename CharT, string_util::fixed_string Name, typename Inner> class s
335
389
#line 218 "cpp2regex.h2"
336
390
// Named basic character classes
337
391
//
338
- template <typename CharT> using digits_class = named_class_entry<CharT," digits" ,range_class_entry<CharT,' 0' ,' 9' >>;
339
- template <typename CharT> using lower_class = named_class_entry<CharT," lower" ,range_class_entry<CharT,' a' ,' z' >>;
340
- template <typename CharT> using upper_class = named_class_entry<CharT," upper" ,range_class_entry<CharT,' A' ,' Z' >>;
341
392
393
+ #line 224 "cpp2regex.h2"
342
394
// Named other classes
343
395
//
344
- template <typename CharT> using alnum_class = named_class_entry<CharT," alnum" ,combined_class_entry<CharT,lower_class<CharT>,upper_class<CharT>,digits_class<CharT>>>;
345
- template <typename CharT> using alpha_class = named_class_entry<CharT," alpha" ,combined_class_entry<CharT,lower_class<CharT>,upper_class<CharT>>>;
346
- template <typename CharT> using ascii_class = named_class_entry<CharT," ascii" ,range_class_entry<CharT,' \x00 ' ,' \x7F ' >>;
347
- template <typename CharT> using blank_class = named_class_entry<CharT," blank" ,list_class_entry<CharT,' ' ,' \t ' >>;
348
- template <typename CharT> using cntrl_class = named_class_entry<CharT," cntrl" ,combined_class_entry<CharT,range_class_entry<CharT,' \x00 ' ,' \x1F ' >,single_class_entry<CharT,' \x7F ' >>>;
349
- template <typename CharT> using graph_class = named_class_entry<CharT," graph" ,range_class_entry<CharT,' \x21 ' ,' \x7E ' >>;
350
- template <typename CharT> using hor_space_class = named_class_entry<CharT," hspace" ,list_class_entry<CharT,' \t ' ,' ' >>;
351
- template <typename CharT> using print_class = named_class_entry<CharT," print" ,range_class_entry<CharT,' \x20 ' ,' \x7E ' >>;
352
- template <typename CharT> using punct_class = named_class_entry<CharT," punct" ,list_class_entry<CharT,' [' ,' !' ,' "' ,' #' ,' $' ,' %' ,' &' ,' \' ' ,' (' ,' )' ,' *' ,' +' ,' ,' ,' -' ,' .' ,' /' ,' :' ,' ;' ,' <' ,' =' ,' >' ,' ?' ,' @' ,' [' ,' \\ ' ,' ]' ,' ^' ,' _' ,' `' ,' {' ,' |' ,' }' ,' ~' ,' ]' >>;
353
- template <typename CharT> using space_class = named_class_entry<CharT," space" ,list_class_entry<CharT,' ' ,' \t ' ,' \r ' ,' \n ' ,' \v ' ,' \f ' >>;
354
- template <typename CharT> using ver_space_class = named_class_entry<CharT," vspace" ,list_class_entry<CharT,' \n ' ,' \v ' ,' \f ' ,' \r ' >>;
355
- template <typename CharT> using word_class = named_class_entry<CharT," word" ,combined_class_entry<CharT,alnum_class<CharT>,single_class_entry<CharT,' _' >>>;
356
- template <typename CharT> using xdigit_class = named_class_entry<CharT," xdigit" ,combined_class_entry<CharT,range_class_entry<CharT,' A' ,' F' >,range_class_entry<CharT,' a' ,' f' >,digits_class<CharT>>>;
357
396
397
+ #line 240 "cpp2regex.h2"
358
398
// Shorthand class entries
359
399
//
360
- template <typename CharT> using short_digits_class = shorthand_class_entry<CharT," \\ d" ,digits_class<CharT>>;
361
- template <typename CharT> using short_hor_space_class = shorthand_class_entry<CharT," \\ h" ,hor_space_class<CharT>>;
362
- template <typename CharT> using short_space_class = shorthand_class_entry<CharT," \\ s" ,space_class<CharT>>;
363
- template <typename CharT> using short_vert_space_class = shorthand_class_entry<CharT," \\ v" ,ver_space_class<CharT>>;
364
- template <typename CharT> using short_word_class = shorthand_class_entry<CharT," \\ w" ,word_class<CharT>>;
365
-
366
- template <typename CharT> using short_not_digits_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ D" ,digits_class<CharT>>>;
367
- template <typename CharT> using short_not_hor_space_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ H" ,hor_space_class<CharT>>>;
368
- template <typename CharT> using short_not_space_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ S" ,space_class<CharT>>>;
369
- template <typename CharT> using short_not_vert_space_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ V" ,ver_space_class<CharT>>>;
370
- template <typename CharT> using short_not_word_class = negated_class_entry<CharT,shorthand_class_entry<CharT," \\ W" ,word_class<CharT>>>;
371
400
372
401
#line 255 "cpp2regex.h2"
373
402
// Regex syntax: | Example: ab|ba
@@ -459,18 +488,6 @@ template<typename CharT, bool negate, bool case_insensitive, typename ...List> c
459
488
#line 395 "cpp2regex.h2"
460
489
// Named short classes
461
490
//
462
- template <typename CharT, bool case_insensitive> using named_class_no_new_line = class_token_matcher<CharT,true ,case_insensitive,single_class_entry<CharT,' \n ' >>;
463
- template <typename CharT, bool case_insensitive> using named_class_digits = class_token_matcher<CharT,false ,case_insensitive,digits_class<CharT>>;
464
- template <typename CharT, bool case_insensitive> using named_class_hor_space = class_token_matcher<CharT,false ,case_insensitive,hor_space_class<CharT>>;
465
- template <typename CharT, bool case_insensitive> using named_class_space = class_token_matcher<CharT,false ,case_insensitive,space_class<CharT>>;
466
- template <typename CharT, bool case_insensitive> using named_class_ver_space = class_token_matcher<CharT,false ,case_insensitive,ver_space_class<CharT>>;
467
- template <typename CharT, bool case_insensitive> using named_class_word = class_token_matcher<CharT,false ,case_insensitive,word_class<CharT>>;
468
-
469
- template <typename CharT, bool case_insensitive> using named_class_not_digits = class_token_matcher<CharT,true ,case_insensitive,digits_class<CharT>>;
470
- template <typename CharT, bool case_insensitive> using named_class_not_hor_space = class_token_matcher<CharT,true ,case_insensitive,hor_space_class<CharT>>;
471
- template <typename CharT, bool case_insensitive> using named_class_not_space = class_token_matcher<CharT,true ,case_insensitive,space_class<CharT>>;
472
- template <typename CharT, bool case_insensitive> using named_class_not_ver_space = class_token_matcher<CharT,true ,case_insensitive,ver_space_class<CharT>>;
473
- template <typename CharT, bool case_insensitive> using named_class_not_word = class_token_matcher<CharT,true ,case_insensitive,word_class<CharT>>;
474
491
475
492
#line 411 "cpp2regex.h2"
476
493
// Regex syntax: \<number> Example: \1
@@ -624,7 +641,6 @@ template<typename CharT, typename matcher_wrapper> class regular_expression
624
641
625
642
}
626
643
}
627
- #endif
628
644
629
645
630
646
// === Cpp2 function definitions =================================================
0 commit comments