32 if (lbl.get().empty())
33 return labelset_type::empty;
34 else if (lbl ==
"\\e")
35 return labelset_type::lan;
36 else if (1 < lbl.get().size())
37 return labelset_type::law;
39 return labelset_type::lal;
46 case labelset_type::empty:
return {};
47 case labelset_type::lal:
return "lal_char()";
48 case labelset_type::lan:
return "lan<lal_char()>";
49 case labelset_type::law:
return "law_char()";
64 if (!lbl2.get().empty())
67 lbl1 =
"(" + lbl1.get() +
"," + lbl2.get() +
")";
71 if (!weight.get().empty())
75 && weight.get().find(
'.') != std::string::npos)
116 edit->add_transition(std::get<0>(t), std::get<1>(t),
117 std::get<2>(t), std::get<3>(t));
120 edit->add_initial(p.first, p.second);
123 edit->add_final(p.first, p.second);
124 return edit->result();
143 return detail::make_automaton_editor_registry().call(ctx);
context make_context(const std::string &name)
Build a context from its name.
std::vector< std::pair< string_t, string_t > > initial_states_
The collected initial states: (State, Weight).
bool open(bool o)
Whether unknown letters should be added, or rejected.
automaton_editor::string_t string_t
A hash-cons'ed string type.
std::shared_ptr< detail::automaton_base > automaton
bool real_
Whether we saw a period in a the weight.
void reset()
Get ready to build another automaton.
labelset_type input_type_
Labelset type for input tape.
std::shared_ptr< const detail::weight_base > weight
void add_initial(string_t s, string_t w=string_t{})
Add s as an initial state.
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.
void add_final(string_t s, string_t w=string_t{})
Add s as a final state.
labelset_type output_type_
Labelset type for output tape.
std::vector< std::pair< string_t, string_t > > final_states_
The collected final states: (State, Weight).
automaton_editor * make_automaton_editor(const context &ctx)
Build an automatonset from its context.
dyn::automaton result()
Return the built automaton.
Abstract Builder (the design pattern) for automata.
bool weighted_
Whether we saw a non-empty weight.
std::shared_ptr< const detail::context_base > context
std::vector< std::tuple< string_t, string_t, string_t, string_t > > transitions_
The collected transitions: (Source, Destination, Label, Weight).
labelset_type
Labelset types, increasing generality.
#define BUILTIN_UNREACHABLE()
bool open_
Whether the labelset is open.
std::string to_string(direction d)
Conversion to string.