25 :
public ExpSet::const_visitor
28 "zpc: requires nullable labels");
38 using super_t =
typename expressionset_t::const_visitor;
41 constexpr
static const char*
me() {
return "zpc"; }
66 return std::move(
res_);
77 virtual
void visit(const tuple_t&,
std::true_type)
override
79 raise(
me(),
": tuple is not supported");
103 res_->labelset()->conv(*
rs_.labelset(),
127 e.sub()->accept(*
this);
146 e.sub()->accept(*
this);
150 res_->set_weight(t,
ws_.mul(w,
res_->weight_of(t)));
155 e.sub()->accept(*
this);
165 std::vector<state_t> finals_;
171 finals_.push_back(
final_);
179 for (
auto s: finals_)
191 std::vector<state_t> state_stack;
194 for (
auto i = 0; i < e.size() - 1; ++i)
195 state_stack.push_back(
res_->new_state());
197 e.head()->accept(*
this);
208 state_t final = automaton_t::element_type::null_state();
210 initial = state_stack.back();
211 state_stack.pop_back();
214 for (
auto t: e.tail())
218 final =
res_->new_state();
221 auto cst_e =
res_->get_final_weight(initial_e);
225 res_->unset_final(initial_e);
229 res_->set_final(initial,
ws_.mul(cst_e, cst_f));
236 if (!state_stack.empty())
238 initial = state_stack.back();
239 state_stack.pop_back();
251 e.head()->accept(*
this);
260 for (
auto c: e.tail())
280 e.head()->accept(*
this);
289 for (
auto t: e.tail())
294 auto cst_e =
res_->get_final_weight(initial_e);
298 res_->unset_final(initial_e);
302 res_->set_final(initial,
ws_.mul(cst_e, cst_f));
332 template <Automaton Aut,
typename ExpSet>
336 const typename ExpSet::value_t&
r,
337 const std::string& algo =
"auto")
346 {
"auto", std::string(
"regular")},
364 template <
typename ExpSet,
typename String>
370 using expressionset_t = ExpSet;
371 const auto& e = exp->as<expressionset_t>();
374 using ctx_t = decltype(ctx);
automaton_t operator()(const typename expressionset_t::value_t &v)
VCSN_RAT_VISIT(rweight, e)
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
typename super_t::tuple_t tuple_t
#define VCSN_RAT_UNSUPPORTED(Type)
state_t_of< automaton_t > state_t
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
const expressionset_t & rs_
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
zpc_visitor(const expressionset_t &rs, bool compact)
automaton zpc(const expression &exp, const std::string &algo)
Bridge.
void prod_regular(const prod_t &e)
void prod_compact(const prod_t &e)
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_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...
virtual void visit(const tuple_t &, std::true_type) override
Provide a variadic mul on top of a binary mul(), and one().
An inner node with multiple children.
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
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.
A mapping from strings to Values.
label_t_of< automaton_t > label_t
static constexpr const char * me()
Name of this algorithm, for error messages.
void sum_regular(const sum_t &e)
nullableset_context_t< context< LabelSet, WeightSet > > make_nullableset_context(const context< LabelSet, WeightSet > &ctx)
The nullableset context of a context.
std::shared_ptr< detail::automaton_base > automaton
const bool compact_
Whether to build the "compact" version of the ZPC automaton.
Build a ZPC automaton from an expression.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
static dyn::context ctx(const driver &d)
Get the context of the driver.
An inner node implementing a weight.
zpc_visitor(const context_t &ctx, const expressionset_t &rs, bool compact)
Build an automaton of context ctx.
std::shared_ptr< detail::expression_base > expression
VCSN_RAT_VISIT(lweight, e)
context_t_of< automaton_t > context_t
weightset_t_of< expressionset_t > weightset_t
typename expressionset_t::const_visitor super_t
weight_t_of< expressionset_t > weight_t
void sum_compact(const sum_t &e)