OLD | NEW |
1 // Copyright 2006 The RE2 Authors. All Rights Reserved. | 1 // Copyright 2006 The RE2 Authors. All Rights Reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Helper class for traversing Regexps without recursion. | 5 // Helper class for traversing Regexps without recursion. |
6 // Clients should declare their own subclasses that override | 6 // Clients should declare their own subclasses that override |
7 // the PreVisit and PostVisit methods, which are called before | 7 // the PreVisit and PostVisit methods, which are called before |
8 // and after visiting the subexpressions. | 8 // and after visiting the subexpressions. |
9 | 9 |
10 // Not quite the Visitor pattern, because (among other things) | 10 // Not quite the Visitor pattern, because (among other things) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 bool stopped_early() { return stopped_early_; } | 85 bool stopped_early() { return stopped_early_; } |
86 | 86 |
87 private: | 87 private: |
88 // Walk state for the entire traversal. | 88 // Walk state for the entire traversal. |
89 stack<WalkState<T> >* stack_; | 89 stack<WalkState<T> >* stack_; |
90 bool stopped_early_; | 90 bool stopped_early_; |
91 int max_visits_; | 91 int max_visits_; |
92 | 92 |
93 T WalkInternal(Regexp* re, T top_arg, bool use_copy); | 93 T WalkInternal(Regexp* re, T top_arg, bool use_copy); |
94 | 94 |
95 DISALLOW_EVIL_CONSTRUCTORS(Walker); | 95 DISALLOW_COPY_AND_ASSIGN(Walker); |
96 }; | 96 }; |
97 | 97 |
98 template<typename T> T Regexp::Walker<T>::PreVisit(Regexp* re, | 98 template<typename T> T Regexp::Walker<T>::PreVisit(Regexp* re, |
99 T parent_arg, | 99 T parent_arg, |
100 bool* stop) { | 100 bool* stop) { |
101 return parent_arg; | 101 return parent_arg; |
102 } | 102 } |
103 | 103 |
104 template<typename T> T Regexp::Walker<T>::PostVisit(Regexp* re, | 104 template<typename T> T Regexp::Walker<T>::PostVisit(Regexp* re, |
105 T parent_arg, | 105 T parent_arg, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 template<typename T> T Regexp::Walker<T>::WalkExponential(Regexp* re, T top_arg, | 236 template<typename T> T Regexp::Walker<T>::WalkExponential(Regexp* re, T top_arg, |
237 int max_visits) { | 237 int max_visits) { |
238 max_visits_ = max_visits; | 238 max_visits_ = max_visits; |
239 return WalkInternal(re, top_arg, false); | 239 return WalkInternal(re, top_arg, false); |
240 } | 240 } |
241 | 241 |
242 } // namespace re2 | 242 } // namespace re2 |
243 | 243 |
244 #endif // RE2_WALKER_INL_H__ | 244 #endif // RE2_WALKER_INL_H__ |
OLD | NEW |