| 150 | // Get all instances of 'T' from the pattern |
| 151 | template <typename T> |
| 152 | std::vector<T*> flat_filter(Pattern& pattern) { |
| 153 | std::vector<Pattern*> flattened = pattern.flat([](Pattern const* p) -> bool { |
| 154 | return dynamic_cast<T const*>(p) != nullptr; |
| 155 | }); |
| 156 | |
| 157 | // now, we're guaranteed to have T*'s, so just use static_cast |
| 158 | std::vector<T*> ret; |
| 159 | std::transform(flattened.begin(), flattened.end(), std::back_inserter(ret), [](Pattern* p) { |
| 160 | return static_cast<T*>(p); |
| 161 | }); |
| 162 | return ret; |
| 163 | } |
| 164 | |
| 165 | static std::vector<std::string> parse_section(std::string const& name, std::string const& source) { |
| 166 | // ECMAScript regex only has "?=" for a non-matching lookahead. In order to make sure we always have |