17 template <
typename Context>
18 mutable_automaton<Context>
21 const auto& ls = *ctx.labelset();
22 const auto& gens = ls.generators();
23 size_t sz = boost::distance(gens);
24 require(2 <= sz,
"de_bruijn: the alphabet needs at least 2 letters");
25 using context_t = Context;
27 automaton_t res = make_shared_ptr<automaton_t>(
ctx);
29 auto init = res->new_state();
30 res->set_initial(init);
32 res->new_transition(init, init, ls.value(l));
34 auto prev = res->new_state();
35 res->new_transition(init, prev, ls.value(
detail::front(gens)));
39 auto next = res->new_state();
41 res->new_transition(prev, next, ls.value(l));
57 template <
typename Ctx,
typename Un
signed>
61 const auto& c = ctx->as<Ctx>();
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
mutable_automaton< Context > de_bruijn(const Context &ctx, unsigned n)
std::shared_ptr< const detail::context_base > context
A dyn::context.
std::shared_ptr< detail::automaton_base > automaton
automaton de_bruijn(const dyn::context &ctx, unsigned n)
Bridge.
static dyn::context ctx(const driver &d)
Get the context of the driver.
Container::value_type front(const Container &container)
The first member of this Container.