4 #include <unordered_map> 
   58     virtual bool open(
bool o) = 0;
 
   64     virtual void reset() = 0;
 
   83   template <
typename Aut>
 
  168               "edit_automaton: invalid transition from pre to post: ",
 
  169               src, 
" -> ", dst, 
" (", entry, 
")");
 
  170       if (s == 
res_->pre() || d == 
res_->post())
 
  172           if (entry.get().empty())
 
  173             res_->add_transition(s, d, 
res_->prepost_label());
 
  185                       "edit_automaton: invalid ",
 
  186                       s == 
res_->pre() ? 
"initial" : 
"final",
 
  187                       " entry: ", entry.get());
 
  188               res_->add_transition(s, d,
 
  197           for (
auto e: p.first->second)
 
  222       const auto& ls = *
res_->labelset();
 
  225         p.first->second = 
conv(ls, l);
 
  226       return p.first->second;
 
  233       const auto& ws = *
res_->weightset();
 
  236         p.first->second = w.get().empty() ? ws.one() : 
conv(ws, w);
 
  237       return p.first->second;
 
  244       return res_->state(k);
 
  253     using entry_map = std::unordered_map<string_t, entry_t>;
 
  256     using label_map = std::unordered_map<string_t, label_t>;
 
  322     using transition_t = std::tuple<string_t, string_t, string_t, string_t>;
 
  347       template <
typename Ctx>
 
  351         const auto& c = ctx->as<Ctx>();
 
bool open_
Whether the labelset is open. 
weightset_type weightset_type_
The weightset scale. 
label_t_of< automaton_t > label_t
dyn::automaton result(const std::string &ctx={})
Return the built automaton. 
state_t state_(string_t k)
Convert a state name to a state handler. 
labelset_type
Labelset types, increasing generality. 
labelset_t_of< automaton_t > labelset_t
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
std::shared_ptr< const detail::label_base > label
void register_weight_(string_t w)
Record that this weight was seen. 
virtual void add_pre(string_t s) overridefinal
Register that state named s is preinitial. 
std::shared_ptr< const detail::context_base > context
A dyn::context. 
void weightset(weightset_type t)
Specify the weightset type. 
virtual bool open(bool o) overridefinal
Whether unknown letters should be added, or rejected. 
auto label_of(const welement< Label, Weight > &m) -> decltype(m.label())
char sep_
The label separator. 
bool weighted_
Whether we saw a non-empty weight. 
virtual void add_post(string_t s)=0
Declare that s denotes the postfinal state in entries. 
labelset_type output_type_
Labelset type for output tape. 
std::unordered_map< string_t, entry_t > entry_map
Memoize entry conversion. 
void add_initial(string_t s, string_t w=string_t{})
Add s as an initial state. 
virtual void add_initial(string_t s, string_t weight=string_t{}) overridefinal
void add_final(string_t s, string_t w=string_t{})
Add s as a final state. 
virtual ~automaton_editor()
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
std::unordered_map< string_t, weight_t > weight_map
Memoize weight conversion. 
labelset_type input_type_
Labelset type for input tape. 
name_automaton< Aut > automaton_t
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 add_final(string_t s, string_t weight=string_t{}) overridefinal
state_t_of< automaton_t > state_t
Build an automaton with unknown context. 
automaton make_automaton(const Aut &aut)
Build a dyn::automaton. 
virtual void reset() overridefinal
Detach the built automaton. 
automaton_editor * make_automaton_editor(const context &ctx)
Bridge. 
typename polynomialset< context_t >::value_t entry_t
static dyn::context ctx(const driver &d)
Get the context of the driver. 
context_t_of< automaton_t > context_t
std::shared_ptr< const detail::weight_base > weight
void reset()
Get ready to build another automaton. 
std::string result_context() const 
Return the context that was inferred. 
std::tuple< string_t, string_t, string_t, string_t > transition_t
The collected transitions: (Source, Destination, Label, Weight). 
virtual void add_state(string_t s) overridefinal
Register the existence of state named s. 
Provide a variadic mul on top of a binary mul(), and one(). 
std::shared_ptr< detail::automaton_base > automaton
void set_separator(char c)
Set the label separator. Defaults to '+'. 
std::vector< transition_t > transitions_
virtual void add_state(string_t s)=0
Register the existence of state named s. 
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
void add_transition(string_t src, string_t dst, string_t lbl, string_t w=string_t{})
Add an acceptor transition from src to dst, labeled by lbl. 
virtual void add_entry(string_t src, string_t dst, string_t entry)=0
Add an entry from src to dst, with value entry. 
auto weight_of(const welement< Label, Weight > &m) -> decltype(m.weight())
virtual void add_transition(string_t src, string_t dst, string_t label, string_t weight=string_t{})=0
Add a transition from src to dst. 
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message. 
std::vector< std::pair< string_t, string_t > > final_states_
The collected final states: (State, Weight). 
virtual dyn::automaton result() overridefinal
Return the built automaton. 
bool open(bool o)
Whether unknown letters should be added, or rejected. 
virtual dyn::automaton result()=0
The final result. 
edit_automaton(const context_t &ctx)
automaton_editor::string_t string_t
A hash-cons'ed string type. 
weight_t weight_(string_t w)
Convert a weight string to its value. 
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string. 
polynomialset< context_t > ps_
Entries handler. 
super_t::string_t string_t
virtual void reset()=0
Forget about the current automaton, but do not free it. 
std::vector< std::pair< string_t, string_t > > initial_states_
The collected initial states: (State, Weight). 
virtual void add_post(string_t s) overridefinal
Register that state named s is postfinal. 
std::unordered_map< string_t, label_t > label_map
Memoize label conversion. 
automaton_t res_
The automaton under construction. 
virtual void add_transition(string_t src, string_t dst, string_t label, string_t weight=string_t{}) overridefinal
Add a transition from src to dst. 
weight_t_of< automaton_t > weight_t
auto conv(const ValueSet &vs, const std::string &str, Args &&...args) -> decltype(vs.conv(std::declval< std::istream & >(), std::forward< Args >(args)...))
Parse str via vs.conv. 
virtual void add_initial(string_t s, string_t w)=0
Concrete Builder (the design pattern) for automata. 
virtual void add_pre(string_t s)=0
Declare that s denotes the preinitial state in entries. 
virtual void add_entry(string_t src, string_t dst, string_t entry) overridefinal
Add transitions from src to dst, labeled by entry. 
virtual void add_final(string_t s, string_t w)=0
std::shared_ptr< detail::name_automaton_impl< Context >> name_automaton
label_t label_(string_t l)
Convert a label string to its value. 
weightset_type
Weightset types. 
Abstract Builder (the design pattern) for automata. 
bool real_
Whether we saw a period in a the weight. 
virtual bool open(bool o)=0
Whether unknown letters should be added, or rejected. 
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of