4 #include <boost/algorithm/string/predicate.hpp> 
    5 #include <boost/algorithm/string/trim.hpp> 
   25       std::string read_context(std::string& line)
 
   28         static auto re = std::regex(
"^[ \t]*(?:vcsn_)?(?:context|ctx)[ \t]*=" 
   29                                     "[ \t]*(\"?)(.*?)\\1[ \t]*(?://.*)?$");
 
   31         static auto sub = std::regex(
"\\\\\\\\");
 
   33         if (std::regex_match(line, m, re))
 
   35           std::string 
res = m[2];
 
   37             res = std::regex_replace(res, sub, 
"\\");
 
   45       std::string read_quotes(std::istream& is)
 
   49         while ((c = is.peek()) != EOF && c != 
'"')
 
   52           raise(
"invalid daut file: missing '\"' after '" + res + 
"'");
 
   59       bool is_comment(std::istream& is, 
char c)
 
   61         if (c == 
'/' && is.peek() == 
'/')
 
   72       std::string read_state(std::istream& is)
 
   77         while ((c = is.get()) != EOF)
 
   81               if ((c = is.get()) != EOF)
 
   86               return read_quotes(is);
 
   87             if (isspace(c) || is_comment(is, c))
 
   91         boost::algorithm::trim_right(res);
 
   97       std::string read_entry(std::istream& is)
 
  102         while ((c = is.get()) != EOF)
 
  104             if (isspace(c) && res.empty())
 
  106             if (is_comment(is, c))
 
  117         res->set_separator(
',');
 
  128       std::shared_ptr<vcsn::automaton_editor> edit = 
nullptr;
 
  134           std::getline(is, line, 
'\n');
 
  136           boost::algorithm::trim_right(line);
 
  137           if (line.empty() || boost::starts_with(line, 
"//"))
 
  142               auto ctx = read_context(line);
 
  143               edit.reset(make_editor(ctx));
 
  149           std::istringstream ss{line};
 
  160                   "invalid daut file: expected destination after: ", s);
 
  161           auto entry = 
string_t{read_entry(ss)};
 
  164               edit->add_entry(s == 
"$" ? 
string_t{
"$pre"} : s,
 
  165                               d == 
"$" ? 
string_t{
"$post"} : d, entry);
 
  167           catch (
const std::runtime_error& e)
 
  169               raise(e, 
"  while adding transitions: (", s, 
", ", entry, 
", ",
 
  175         edit.reset(make_editor(
""));
 
  176       return edit->result();
 
Abstract Builder (the design pattern) for automata. 
 
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message. 
 
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string. 
 
context make_context(const std::string &name)
Build a context from its name. 
 
void skip_space(std::istream &is)
Ignore spaces. 
 
automaton read_daut(std::istream &is)
 
char get_char(std::istream &i)
Read a single char, with possible -escape support. 
 
automaton_editor * make_automaton_editor(const context &ctx)
Build an automatonset from its context.