diff --git a/aconvert/src/aconvert.cpp b/aconvert/src/aconvert.cpp index 682f5759d25f9ab0a8b6ced3d00c559f59645b79..c327c151234408be790be749ae23b06f92b60a7d 100644 --- a/aconvert/src/aconvert.cpp +++ b/aconvert/src/aconvert.cpp @@ -8,36 +8,41 @@ #include <iostream> +#include "automaton/AutomatonParser.h" #include "automaton/UnknownAutomaton.h" #include "AutomatonFactory.h" #include "AlibException.h" +#include "sax/SaxInterface.h" + +#include "DotConverter.h" using namespace std; using namespace automaton; +using namespace sax; using namespace alib; -#include "DotConverter.h" - int main(int argc, char** argv) { - - UnknownAutomaton automaton; - + list<Token> tokens; try { if (argc > 1) { if (string("-h").compare(argv[1]) == 0) { - cout << "Automaton parsing.\nUsage: catPDA [automaton.xml]\n"; + cout + << "Automaton converting tool. Supports only dot format at the moment.\nUsage: aconvert [automaton.xml]\n"; return -1; } - automaton = AutomatonFactory::fromFile(argv[1]); + SaxInterface::parseFile(argv[1], tokens); } else { - string input(istreambuf_iterator<char>(cin), (istreambuf_iterator<char>())); - automaton = AutomatonFactory::fromString(input); + string input(istreambuf_iterator<char>(cin), + (istreambuf_iterator<char>())); + SaxInterface::parseMemory(input, tokens); } - Automaton* knownAutomaton = AutomatonFactory::buildAutomaton(&automaton); - DotConverter::convert(*knownAutomaton,cout); + UnknownAutomaton unknownAutomaton = AutomatonParser::parse(tokens); + Automaton* automaton = AutomatonFactory::buildAutomaton(unknownAutomaton); + DotConverter::convert(*automaton, cout); + } catch (AlibException& e) { cout << e.what() << endl; return 0;