1
Fork 0
mirror of https://github.com/Jaxan/hybrid-ads.git synced 2025-04-27 15:07:45 +02:00
hybrid-ads/lib/read_mealy.hpp
2015-05-20 12:23:13 +02:00

42 lines
1.6 KiB
C++

#pragma once
#include "types.hpp"
#include <iosfwd>
#include <map>
#include <utility>
struct mealy;
struct translation;
/// \brief reads a mealy machine from plain txt file as provided by A. T. Endo
/// States, inputs and outputs in these files are already integral, so no need for translation
mealy read_mealy_from_txt(std::istream & in);
mealy read_mealy_from_txt(std::string const & filename);
/// \brief reads a mealy machine from dot files as generated by learnlib
/// Here we need a translation, which is extended during parsing
mealy read_mealy_from_dot(std::istream & in, translation & t);
mealy read_mealy_from_dot(std::string const & filename, translation & t);
/// \brief reads a mealy machine from dot files as generated by learnlib
/// Here the translation starts out empty and is returned in the end
std::pair<mealy, translation> read_mealy_from_dot(std::istream & in);
std::pair<mealy, translation> read_mealy_from_dot(std::string const & filename);
/// \brief For non-integral formats we use a translation to integers
struct translation {
std::map<std::string, input> input_indices;
input max_input = 0;
std::map<std::string, output> output_indices;
output max_output = 0;
};
/// \brief inverts the input_indices and output_indices maps
std::vector<std::string> create_reverse_map(std::map<std::string, input> const & indices);
std::vector<std::string> create_reverse_map(std::map<std::string, output> const & indices);
/// \brief defines trivial translation (the string represent integers directly)
translation create_translation_for_mealy(mealy const & m);