26 :
public ExpSet::const_visitor
29 "zpc: requires nullable labels");
39 using super_t =
typename expressionset_t::const_visitor;
42 constexpr
static const char*
me() {
return "zpc"; }
69 return std::move(
res_);
71 catch (
const std::runtime_error& e)
74 " while computing ZPC automaton of: ",
to_string(
rs_, v));
87 void visit(const tuple_t&,
std::true_type)
override
89 raise(
me(),
": tuple is not supported");
113 res_->labelset()->conv(*
rs_.labelset(),
137 e.sub()->accept(*
this);
156 e.sub()->accept(*
this);
160 res_->set_weight(t,
ws_.mul(w,
res_->weight_of(t)));
165 e.sub()->accept(*
this);
175 std::vector<state_t> finals_;
181 finals_.push_back(
final_);
189 for (
auto s: finals_)
201 std::vector<state_t> state_stack;
204 for (
auto i = 0; i < e.size() - 1; ++i)
205 state_stack.push_back(
res_->new_state());
207 e.head()->accept(*
this);
218 state_t final = automaton_t::element_type::null_state();
220 initial = state_stack.back();
221 state_stack.pop_back();
224 for (
auto t: e.tail())
228 final =
res_->new_state();
231 auto cst_e =
res_->get_final_weight(initial_e);
235 res_->unset_final(initial_e);
239 res_->set_final(initial,
ws_.mul(cst_e, cst_f));
246 if (!state_stack.empty())
248 initial = state_stack.back();
249 state_stack.pop_back();
261 e.head()->accept(*
this);
270 for (
auto c: e.tail())
290 e.head()->accept(*
this);
299 for (
auto t: e.tail())
304 auto cst_e =
res_->get_final_weight(initial_e);
308 res_->unset_final(initial_e);
312 res_->set_final(initial,
ws_.mul(cst_e, cst_f));
342 template <Automaton Aut,
typename ExpSet>
346 const typename ExpSet::value_t&
r,
347 const std::string& algo =
"auto")
356 {
"auto", std::string(
"regular")},
374 template <
typename ExpSet,
typename String>
380 using expressionset_t = ExpSet;
381 const auto& e = exp->
as<expressionset_t>();
384 using ctx_t = decltype(ctx);
386 return ::vcsn::zpc<automaton_t>(
ctx, e.valueset(), e.value(), algo);
void add_compact(const add_t &e)
static dyn::context ctx(const driver &d)
Get the context of the driver.
Aut zpc(const context_t_of< Aut > &ctx, const ExpSet &rs, const typename ExpSet::value_t &r, const std::string &algo="auto")
Build a ZPC automaton from an expression.
SharedPtr make_shared_ptr(Args &&...args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
void prod_regular(const mul_t &e)
Build a ZPC automaton from an expression.
An inner node implementing a weight.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
Provide a variadic mul on top of a binary mul(), and one().
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
label_t_of< automaton_t > label_t
zpc_visitor(const expressionset_t &rs, bool compact)
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
void add_regular(const add_t &e)
weightset_t_of< expressionset_t > weightset_t
typename expressionset_t::const_visitor super_t
state_t_of< automaton_t > state_t
const bool compact_
Whether to build the "compact" version of the ZPC automaton.
static constexpr const char * me()
Name of this algorithm, for error messages.
#define VCSN_RAT_UNSUPPORTED(Type)
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
VCSN_RAT_VISIT(rweight, e)
An inner node with multiple children.
void visit(const tuple_t &, std::true_type) override
context_t_of< automaton_t > context_t
const expressionset_t & rs_
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
nullableset_context_t< context< LabelSet, WeightSet > > make_nullableset_context(const context< LabelSet, WeightSet > &ctx)
The nullableset context of a context.
A mapping from strings to Values.
value_impl< detail::expression_tag > expression
automaton_t operator()(const typename expressionset_t::value_t &v)
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
void prod_compact(const mul_t &e)
auto & as()
Extract wrapped typed automaton.
VCSN_RAT_VISIT(lweight, e)
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
zpc_visitor(const context_t &ctx, const expressionset_t &rs, bool compact)
Build an automaton of context ctx.
weight_t_of< expressionset_t > weight_t
std::string to_string(identities i)
Wrapper around operator<<.
automaton zpc(const expression &exp, const std::string &algo)
Bridge.
typename super_t::tuple_t tuple_t