Skip to content
Snippets Groups Projects
Commit 6129736c authored by Jan Trávníček's avatar Jan Trávníček
Browse files

tclap in more binary files

parent c84f8c2b
No related branches found
No related tags found
No related merge requests found
//============================================================================
// Name : aepislon.cpp
// Author : Tomas Pecka
//============================================================================
/*
* aepsilon.cpp
*
* Created on: 24. 2. 2014
* Author: Jan Travnicek
*/
 
#include <iostream>
#include <tclap/CmdLine.h>
 
#include <factory/DataFactory.hpp>
#include <exception/AlibException.h>
......@@ -13,23 +16,33 @@
int main(int argc, char** argv) {
 
try {
if (argc == 2 && std::string("-h").compare(argv[1]) == 0) {
std::cout << "Remove epsilon transitions from automaton." << std::endl << "Usage: aepsilon [automaton.xml]" << std::endl;
return -1;
} else if (argc == 1 || (argc == 2 && std::string("--").compare(argv[1]) == 0)) {
alib::DataFactory::toStdout(automaton::simplify::EpsilonRemover::remove(alib::DataFactory::fromStdin<automaton::Automaton>()));
} else if (argc == 2) {
alib::DataFactory::toStdout(automaton::simplify::EpsilonRemover::remove(alib::DataFactory::fromFile<automaton::Automaton>(argv[1])));
TCLAP::CmdLine cmd("Automaton rename binary", ' ', "0.01");
TCLAP::ValueArg<std::string> input( "a", "automaton", "Automaton where to remove epsilon transitions", false, "-", "file");
cmd.add( input );
cmd.parse(argc, argv);
std::list<sax::Token> tokens;
if(input.isSet()) {
if(input.getValue() == "-") {
sax::SaxParseInterface::parseStdin(tokens);
} else {
sax::SaxParseInterface::parseFile(input.getValue(), tokens);
}
} else {
std::cout << "Automaton minimize require deterministic finite automaton" << std::endl;
return 1;
sax::SaxParseInterface::parseStdin(tokens);
}
 
alib::DataFactory::toStdout(automaton::simplify::EpsilonRemover::remove(alib::DataFactory::fromTokens<automaton::Automaton>(tokens)));
return 0;
 
} catch (const exception::AlibException& exception) {
alib::DataFactory::toStdout(exception);
return 1;
} catch(const TCLAP::ArgException& exception) {
std::cout << exception.error() << std::endl;
return 2;
} catch(...) {
return 127;
}
......
//============================================================================
// Name : aminimize.cpp
// Author : Jan Travnicek
//============================================================================
/*
* aminimize.cpp
*
* Created on: 24. 2. 2014
* Author: Jan Travnicek
*/
 
#include <iostream>
#include <tclap/CmdLine.h>
 
#include <exception/AlibException.h>
#include <factory/DataFactory.hpp>
......@@ -13,23 +16,33 @@
int main(int argc, char** argv) {
 
try {
if (argc == 2 && std::string("-h").compare(argv[1]) == 0) {
std::cout << "Automaton minimize." << std::endl << "Usage: aminimize automaton.xml" << std::endl;
return -1;
} else if (argc == 1 || (argc == 2 && std::string("--").compare(argv[1]) == 0)) {
alib::DataFactory::toStdout(automaton::simplify::Minimize::minimize(alib::DataFactory::fromStdin<automaton::Automaton>()));
} else if (argc == 2) {
alib::DataFactory::toStdout(automaton::simplify::Minimize::minimize(alib::DataFactory::fromFile<automaton::Automaton>(argv[1])));
TCLAP::CmdLine cmd("Automaton minimize binary", ' ', "0.01");
TCLAP::ValueArg<std::string> input( "a", "automaton", "Automaton to minimize", false, "-", "file");
cmd.add( input );
cmd.parse(argc, argv);
std::list<sax::Token> tokens;
if(input.isSet()) {
if(input.getValue() == "-") {
sax::SaxParseInterface::parseStdin(tokens);
} else {
sax::SaxParseInterface::parseFile(input.getValue(), tokens);
}
} else {
std::cout << "Automaton minimize require deterministic finite automaton" << std::endl;
return 1;
sax::SaxParseInterface::parseStdin(tokens);
}
 
alib::DataFactory::toStdout(automaton::simplify::Minimize::minimize(alib::DataFactory::fromTokens<automaton::Automaton>(tokens)));
return 0;
 
} catch (const exception::AlibException& exception) {
alib::DataFactory::toStdout(exception);
return 1;
} catch(const TCLAP::ArgException& exception) {
std::cout << exception.error() << std::endl;
return 2;
} catch(...) {
return 127;
}
......
//============================================================================
// Name : anormalize.cpp
// Author : Jan Travnicek
//============================================================================
/*
* anormalize.cpp
*
* Created on: 24. 2. 2014
* Author: Jan Travnicek
*/
 
#include <iostream>
#include <string>
#include <set>
#include <tclap/CmdLine.h>
 
#include "exception/AlibException.h"
#include "factory/DataFactory.hpp"
......@@ -14,22 +15,33 @@
int main(int argc, char** argv) {
 
try {
if (argc == 2 && std::string("-h").compare(argv[1]) == 0) {
std::cout << "Automaton normalize." << std::endl << "Usage: anormalize automaton.xml" << std::endl;
return -1;
} else if (argc == 1 || (argc == 2 && std::string("--").compare(argv[1]) == 0)) {
alib::DataFactory::toStdout(automaton::simplify::Normalize::normalize(alib::DataFactory::fromStdin<automaton::Automaton>()));
} else if (argc == 2) {
alib::DataFactory::toStdout(automaton::simplify::Normalize::normalize(alib::DataFactory::fromFile<automaton::Automaton>(argv[1])));
TCLAP::CmdLine cmd("Automaton normalize binary", ' ', "0.01");
TCLAP::ValueArg<std::string> input( "a", "automaton", "Automaton to normalize", false, "-", "file");
cmd.add( input );
cmd.parse(argc, argv);
std::list<sax::Token> tokens;
if(input.isSet()) {
if(input.getValue() == "-") {
sax::SaxParseInterface::parseStdin(tokens);
} else {
sax::SaxParseInterface::parseFile(input.getValue(), tokens);
}
} else {
std::cout << "Automaton normalize require deterministic automaton" << std::endl;
return 1;
sax::SaxParseInterface::parseStdin(tokens);
}
alib::DataFactory::toStdout(automaton::simplify::Normalize::normalize(alib::DataFactory::fromTokens<automaton::Automaton>(tokens)));
return 0;
 
} catch (const exception::AlibException& exception) {
alib::DataFactory::toStdout(exception);
return 1;
} catch(const TCLAP::ArgException& exception) {
std::cout << exception.error() << std::endl;
return 2;
} catch(...) {
return 127;
}
......
......@@ -6,8 +6,6 @@
*/
 
#include <iostream>
#include <string>
#include <set>
#include <tclap/CmdLine.h>
 
#include "exception/AlibException.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment