Skip to content

Commit dcb562b

Browse files
committed
Code cleanup.
1 parent b14879c commit dcb562b

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed

include/cpp2regex.h2

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ match_context: <CharT, Iter, max_groups: int> type =
120120
}
121121
}
122122

123-
// Modifiable state during matching.
123+
// Wrapper of context for reverse matches. Implements only the minimal interface for matching.
124124
//
125125
reverse_match_context: <CharT, Iter, max_groups: int> type =
126126
{
@@ -145,27 +145,6 @@ reverse_match_context: <CharT, Iter, max_groups: int> type =
145145

146146
// Getter and setter for groups
147147
//
148-
//get_group: (in this, group) = groups[group];
149-
150-
// get_group_end: (in this, group) -> int = {
151-
// if group >= max_groups || !groups[group].matched {
152-
// return 0;
153-
// }
154-
// return cpp2::unchecked_narrow<int>( std::distance(begin, groups[group].end) );
155-
// }
156-
// get_group_start: (in this, group) -> int = {
157-
// if group >= max_groups || !groups[group].matched {
158-
// return 0;
159-
// }
160-
// return cpp2::unchecked_narrow<int>( std::distance(begin, groups[group].start) );
161-
// }
162-
// get_group_string: (in this, group) -> std::string = {
163-
// if group >= max_groups || !groups[group].matched {
164-
// return "";
165-
// }
166-
// return std::string(groups[group].start, groups[group].end);
167-
// }
168-
169148
set_group_end: (inout this, group, pos) = {
170149
forward_context*..set_group_end(group, (pos).base());
171150
}
@@ -178,20 +157,14 @@ reverse_match_context: <CharT, Iter, max_groups: int> type =
178157
forward_context*..set_group_start(group, (pos).base());
179158
}
180159

181-
// size: (in this) = max_groups;
182-
183160
// Misc functions
184161
//
185162
fail: (in this) = match_return<ReverseIter>(false, end);
186163
pass: (in this, cur: ReverseIter) = match_return<ReverseIter>(true, cur);
187-
188-
// reset: (inout this) = {
189-
// for groups do (inout g) {
190-
// g.matched = false;
191-
// }
192-
// }
193164
}
194165

166+
// Helpers for creating wrappers of the match context.
167+
//
195168
make_forward_match_context: <CharT, Iter, max_groups: int> (inout ctx: match_context<CharT, Iter, max_groups>) -> forward _ = {
196169
return ctx;
197170
}
@@ -208,6 +181,8 @@ make_reverse_match_context: <CharT, Iter, max_groups: int> (inout ctx: reverse_m
208181
return ctx;
209182
}
210183

184+
// Helpers for creating wrappers of the iterators.
185+
//
211186
make_forward_iterator: <Iter> (pos: Iter) -> _ = pos;
212187
make_forward_iterator: <Iter> (pos: std::reverse_iterator<Iter>) -> _ = pos.base();
213188
make_reverse_iterator: <Iter> (pos: Iter) -> _ = std::make_reverse_iterator(pos);
@@ -857,9 +832,9 @@ regular_expression: <CharT, matcher> type =
857832
find_all: (in this, forward func, str: bview<CharT>, start: int, length : int) = find_all(func, get_iter(str, start), get_iter(str, start + length));
858833
find_all: <Iter> (in this, func, start: Iter, end: Iter) =
859834
{
860-
sr := search_return<Iter>(start, end);
835+
sr := search_return<Iter>(start, end);
861836
cont := true;
862-
cur := start;
837+
cur := start;
863838

864839
while cont {
865840
r := search_with_context(sr.ctx, cur);
@@ -897,7 +872,8 @@ regular_expression: <CharT, matcher> type =
897872
search: (in this, str: bview<CharT>) = search(str..begin(), str..end());
898873
search: (in this, str: bview<CharT>, start) = search(get_iter(str, start), str..end());
899874
search: (in this, str: bview<CharT>, start, length) = search(get_iter(str, start), get_iter(str, start + length));
900-
search: <Iter> (in this, start: Iter, end: Iter) -> search_return<Iter> = {
875+
search: <Iter> (in this, start: Iter, end: Iter) -> search_return<Iter> =
876+
{
901877
ctx: context<Iter> = (start, end);
902878
r := search_with_context(ctx, start);
903879
return search_return<Iter>(r.matched, ctx, r.pos);

0 commit comments

Comments
 (0)