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");
118 res_->labelset()->conv(*
rs_.labelset(),
142 e.sub()->accept(*
this);
161 e.sub()->accept(*
this);
165 res_->set_weight(t,
ws_.mul(w,
res_->weight_of(t)));
170 e.sub()->accept(*
this);
180 std::vector<state_t> finals_;
186 finals_.push_back(
final_);
194 for (
auto s: finals_)
206 std::vector<state_t> state_stack;
209 for (
auto i = 0; i < e.size() - 1; ++i)
210 state_stack.push_back(
res_->new_state());
212 e.head()->accept(*
this);
223 state_t final = automaton_t::element_type::null_state();
225 initial = state_stack.back();
226 state_stack.pop_back();
229 for (
auto t: e.tail())
233 final =
res_->new_state();
236 auto cst_e =
res_->get_final_weight(initial_e);
240 res_->unset_final(initial_e);
244 res_->set_final(initial,
ws_.mul(cst_e, cst_f));
251 if (!state_stack.empty())
253 initial = state_stack.back();
254 state_stack.pop_back();
266 e.head()->accept(*
this);
275 for (
auto c: e.tail())
295 e.head()->accept(*
this);
304 for (
auto t: e.tail())
309 auto cst_e =
res_->get_final_weight(initial_e);
313 res_->unset_final(initial_e);
317 res_->set_final(initial,
ws_.mul(cst_e, cst_f));
347 template <Automaton Aut,
typename ExpSet>
351 const typename ExpSet::value_t&
r,
352 const std::string& algo =
"auto")
361 {
"auto", std::string(
"regular")},
379 template <
typename ExpSet,
typename String>
389 using ctx_t = decltype(ctx);
391 return ::vcsn::zpc<automaton_t>(
ctx, e.valueset(), e.value(), algo);
zpc_visitor(const context_t &ctx, const expressionset_t &rs, bool compact)
Build an automaton of context ctx.
std::shared_ptr< detail::mutable_automaton_impl< Context > > mutable_automaton
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
state_t_of< automaton_t > state_t
void prod_compact(const mul_t &e)
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
nullableset_context_t< context< LabelSet, WeightSet > > make_nullableset_context(const context< LabelSet, WeightSet > &ctx)
The nullableset context of a context.
SharedPtr make_shared_ptr(Args &&... args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
static constexpr const char * me()
Name of this algorithm, for error messages.
An inner node with multiple children.
Build a ZPC automaton from an expression.
VCSN_RAT_VISIT(rweight, e)
label_t_of< automaton_t > label_t
const expressionset_t & rs_
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
An inner node to name the subexpression.
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
typename detail::context_t_of_impl< base_t< ValueSet > >::type context_t_of
context_t_of< automaton_t > context_t
void visit(const tuple_t &, std::true_type) override
Provide a variadic mul on top of a binary mul(), and one().
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.
typename super_t::tuple_t tuple_t
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
void prod_regular(const mul_t &e)
weightset_t_of< expressionset_t > weightset_t
VCSN_RAT_VISIT(lweight, e)
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
const bool compact_
Whether to build the "compact" version of the ZPC automaton.
zpc_visitor(const expressionset_t &rs, bool compact)
std::string to_string(identities i)
Wrapper around operator<<.
An inner node implementing a weight.
static dyn::context ctx(const driver &d)
Get the context of the driver.
void add_compact(const add_t &e)
A mapping from strings to Values.
value_impl< detail::expression_tag > expression
weight_t_of< expressionset_t > weight_t
automaton_t operator()(const typename expressionset_t::value_t &v)
typename expressionset_t::const_visitor super_t
#define VCSN_RAT_UNSUPPORTED(Type)
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
void add_regular(const add_t &e)