static Pire::CountingScanner Do(const Patterns& patterns, bool /*surround*/) { Pire::CountingScanner sc; for (Patterns::const_iterator i = patterns.begin(), ie = patterns.end(); i != ie; ++i) { Pire::CountingScanner tsc = Pire::CountingScanner( Pire::Lexer(*i).Parse(), Pire::Lexer(".*").Parse()); if (i == patterns.begin()) tsc.Swap(sc); else { sc = Pire::CountingScanner::Glue(sc, tsc); if (sc.Empty()) { std::ostringstream msg; msg << "Scanner gluing failed at regexp " << *i << " - pattern too complicated"; throw std::runtime_error(msg.str()); } } } return sc; }
static Pire::Impl::Scanner<Relocation, Shortcutting> Do(const Patterns& patterns, bool surround) { typedef Pire::Impl::Scanner<Relocation, Shortcutting> Sc; Sc sc; for (Patterns::const_iterator i = patterns.begin(), ie = patterns.end(); i != ie; ++i) { Pire::Fsm fsm = Pire::Lexer(*i).Parse(); if (surround) fsm.Surround(); Sc tsc = fsm.Compile<Sc>(); if (i == patterns.begin()) tsc.Swap(sc); else { sc = Sc::Glue(sc, tsc); if (sc.Empty()) { std::ostringstream msg; msg << "Scanner gluing failed at regexp " << *i << " - pattern too complicated"; throw std::runtime_error(msg.str()); } } } return sc; }