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);
zpc_visitor(const expressionset_t &rs, bool compact)
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
SharedPtr make_shared_ptr(Args &&...args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
VCSN_RAT_VISIT(rweight, e)
context_t_of< automaton_t > context_t
void add_compact(const add_t &e)
typename super_t::tuple_t tuple_t
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
automaton zpc(const expression &exp, const std::string &algo)
Bridge.
An inner node implementing a weight.
void add_regular(const add_t &e)
weight_t_of< expressionset_t > weight_t
automaton_t operator()(const typename expressionset_t::value_t &v)
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
label_t_of< automaton_t > label_t
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
void prod_compact(const mul_t &e)
const bool compact_
Whether to build the "compact" version of the ZPC automaton.
VCSN_RAT_VISIT(lweight, e)
nullableset_context_t< context< LabelSet, WeightSet > > make_nullableset_context(const context< LabelSet, WeightSet > &ctx)
The nullableset context of a context.
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
void prod_regular(const mul_t &e)
static constexpr const char * me()
Name of this algorithm, for error messages.
std::string to_string(identities i)
Wrapper around operator<<.
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.
weightset_t_of< expressionset_t > weightset_t
zpc_visitor(const context_t &ctx, const expressionset_t &rs, bool compact)
Build an automaton of context ctx.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
auto & as()
Extract wrapped typed automaton.
An inner node with multiple children.
state_t_of< automaton_t > state_t
A mapping from strings to Values.
#define VCSN_RAT_UNSUPPORTED(Type)
Provide a variadic mul on top of a binary mul(), and one().
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
value_impl< detail::expression_tag > expression
Build a ZPC automaton from an expression.
const expressionset_t & rs_
typename expressionset_t::const_visitor super_t
static dyn::context ctx(const driver &d)
Get the context of the driver.
void visit(const tuple_t &, std::true_type) override