12 #include <vcsn/dyn/registries.hh> 20 const auto pos = is.tellg();
22 "cannot keep file position while guessing automaton file format");
25 const static auto probes = std::multimap<std::string, std::regex>
27 {
"daut",
r{
"^\\s*context *="}},
28 {
"daut",
r{
"^\\s*(\\$|\\w+|\".*?\")\\s*->\\s*(\\$|\\w+|\".*?\")"}},
29 {
"dot",
r{
"^\\s*digraph"}},
30 {
"efsm",
r{
"^#! /bin/sh"}},
31 {
"fado",
r{
"^@([DN]FA|Transducer) "}},
32 {
"grail",
r{
"\\(START\\)"}},
34 const auto daut = std::regex();
38 std::getline(is, line,
'\n');
39 for (
const auto& p: probes)
40 if (std::regex_search(line, p.second))
43 require(is.good(),
"cannot rewind automaton file");
47 raise(
"cannot guess automaton format: ", is);
58 automaton read_auto(std::istream& is,
const location& loc)
63 automaton read_dot(std::istream& is,
const location&)
77 "automaton input format",
87 auto res = map[f](is, loc);
97 std::istream& is,
const std::string& f,
104 "expression input format",
108 std::istream& is,
const location& loc) {
113 return map[f](
ctx,
ids, is, loc);
123 const std::string& f)
127 "label input format",
136 bool is_quoted = map[f];
137 return detail::read_label_registry().call(ctx, is, is_quoted);
vcsn::rat::location location
Pairs of positions in a file/stream.
automaton strip(const automaton &a)
The automaton in a with its metadata layers removed.
automaton read_daut(std::istream &is, const location &l)
A mapping from strings to Values.
std::ostream & daut(const Aut &aut, std::ostream &out=std::cout)
Print an automaton in Daut format.
State and public interface for Dot parsing.
label read_label(const context &ctx, std::istream &is, const std::string &format="default")
Read a label from a stream.
expression read_expression(const context &ctx, identities ids, std::istream &is, const std::string &format="default", const location &loc=location{})
Read an expression from a stream.
automaton read_automaton(std::istream &is, const std::string &format="default", bool strip=true, const location &loc=location{})
Read an automaton from a stream.
dyn::expression read(const dyn::context &ctx, rat::identities ids, std::istream &is, const location &l)
The expression in stream is.
Template-less root for contexts.
void require(Bool b, Args &&... args)
If b is not verified, raise an error with args as message.
dyn::automaton parse(std::istream &is, const location_t &l=location_t{})
Parse this stream.
static identities ids(const driver &d)
Get the identities of the driver.
::vcsn::rat::identities identities
Sets of identities on expressions.
An expressionset can implement several different sets of identities on expressions.
Provide a variadic mul on top of a binary mul(), and one().
automaton read_efsm(std::istream &is, const location &)
std::string guess_automaton_format(std::istream &is)
Guess the format of an automaton file.
automaton read_fado(std::istream &is, const location &)