8 #include <vcsn/dyn/registries.hh>
20 if (lbl.get().empty())
21 return labelset_type::empty;
22 else if (lbl ==
"\\e")
23 return labelset_type::lan;
24 else if (1 < lbl.get().size())
25 return labelset_type::law;
27 return labelset_type::lal;
34 case labelset_type::empty:
return {};
35 case labelset_type::lal:
return "lal<char>";
36 case labelset_type::lan:
return "lan<char>";
37 case labelset_type::law:
return "law<char>";
46 || s.get().size() == 1 && std::isalnum(s.get()[0]))
51 static auto re = std::regex{
"['\\\\]"};
53 + std::regex_replace(s.get(), re,
"\\$&")
71 && w.get().find(
'.') != std::string::npos)
102 if (lbl2.get().empty())
162 res += (
real_ ?
"rmin"
177 edit->add_transition(std::get<0>(t), std::get<1>(t),
178 std::get<2>(t), std::get<3>(t));
181 edit->add_initial(p.first, p.second);
184 edit->add_final(p.first, p.second);
185 return edit->result();
bool weighted_
Whether we saw a non-empty weight.
automaton_editor::string_t string_t
A hash-cons'ed string type.
std::vector< transition_t > transitions_
std::shared_ptr< const detail::weight_base > weight
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.
std::string to_string(direction d)
Conversion to string.
bool open(bool o)
Whether unknown letters should be added, or rejected.
std::string type(const automaton &a)
The implementation type of a.
std::vector< std::pair< string_t, string_t > > final_states_
The collected final states: (State, Weight).
weightset_type weightset_type_
The weightset scale.
#define BUILTIN_UNREACHABLE()
void reset()
Get ready to build another automaton.
dyn::automaton result(const std::string &ctx={})
Return the built automaton.
std::string result_context() const
Return the context that was inferred.
labelset_type
Labelset types, increasing generality.
bool real_
Whether we saw a period in a the weight.
labelset_type input_type_
Labelset type for input tape.
std::shared_ptr< detail::automaton_base > automaton
automaton_editor * make_automaton_editor(const context &ctx)
Build an automatonset from its context.
void register_weight_(string_t w)
Record that this weight was seen.
context make_context(const std::string &name)
Build a context from its name.
static dyn::context ctx(const driver &d)
Get the context of the driver.
bool open_
Whether the labelset is open.
labelset_type output_type_
Labelset type for output tape.
void add_final(string_t s, string_t w=string_t{})
Add s as a final state.
std::string quote(const std::string &s)
Turn a label into a parsable label: escape special characters.
void add_initial(string_t s, string_t w=string_t{})
Add s as an initial state.
std::vector< std::pair< string_t, string_t > > initial_states_
The collected initial states: (State, Weight).