22 std::string read_id(std::istream& is)
27 while ((c = is.get()) != EOF && !isspace(c))
60 bool is_transducer =
false;
62 std::string line, state;
65 std::getline(is, line,
'\n');
66 std::istringstream ss{line};
73 is_transducer = state ==
"@Transducer";
74 is_dfa = state ==
"@DFA";
75 if (!is_transducer && !is_dfa && state !=
"@NFA")
76 raise(
"fado: bad automaton kind in first line: ", state);
78 while (!(state = read_id(ss)).empty())
82 else if (state ==
"*")
84 require(!is_dfa,
"fado: invalid \"*\" for DFA" 86 require(!init,
"fado: multiple \"*\" in first line");
106 edit.add_initial(s1);
109 if (l1 ==
"@epsilon")
111 require(!is_dfa,
"fado: unexpected \"@epsilon\" in DFA, in: ",
113 l2, s2.get().empty() ?
"" :
" ",
119 if (l2 ==
"@epsilon")
121 edit.add_transition(s1, s2, l1, l2,
string_t{});
126 "fado: unexpected trailing characters after: ", s1,
128 edit.add_transition(s1, l2, l1);
132 return edit.result();
void skip_space(std::istream &is)
Ignore spaces.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
automaton read_fado(std::istream &is, const location &)
Build an automaton with unknown context.
bool open(bool o)
Whether unknown letters should be added, or rejected.
void require(Bool b, Args &&... args)
If b is not verified, raise an error with args as message.