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

arename main reimplementation + fixes

parent e57699a4
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
   
int main(int argc, char** argv) { int main(int argc, char** argv) {
try { try {
TCLAP::CmdLine cmd("Regexp derivative compute binary", ' ', "0.01"); TCLAP::CmdLine cmd("Cat binary", ' ', "0.01");
   
TCLAP::UnlabeledValueArg<std::string> input( "input", "Input to cat", false, "-", "file"); TCLAP::UnlabeledValueArg<std::string> input( "input", "Input to cat", false, "-", "file");
cmd.add( input ); cmd.add( input );
......
//============================================================================ /*
// Name : anormalize.cpp * arename.cpp
// Author : Jan Travnicek *
//============================================================================ * Created on: 24. 2. 2014
* Author: Jan Travnicek
*/
   
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <set> #include <set>
#include <tclap/CmdLine.h>
   
#include "exception/AlibException.h" #include "exception/AlibException.h"
#include "factory/DataFactory.hpp" #include "factory/DataFactory.hpp"
...@@ -14,22 +17,33 @@ ...@@ -14,22 +17,33 @@
int main(int argc, char** argv) { int main(int argc, char** argv) {
   
try { try {
if (argc == 2 && std::string("-h").compare(argv[1]) == 0) { TCLAP::CmdLine cmd("Automaton rename binary", ' ', "0.01");
std::cout << "Automaton rename." << std::endl << "Usage: arename automaton.xml" << std::endl;
return -1; TCLAP::ValueArg<std::string> input( "a", "automaton", "Automaton to rename", false, "-", "file");
} else if (argc == 1 || (argc == 2 && std::string("--").compare(argv[1]) == 0)) { cmd.add( input );
alib::DataFactory::toStdout(automaton::simplify::Rename::rename(alib::DataFactory::fromStdin<automaton::Automaton>()));
} else if (argc == 2) { cmd.parse(argc, argv);
alib::DataFactory::toStdout(automaton::simplify::Rename::rename(alib::DataFactory::fromFile<automaton::Automaton>(argv[1])));
std::list<sax::Token> tokens;
if(input.isSet()) {
if(input.getValue() == "-") {
sax::SaxParseInterface::parseStdin(tokens);
} else {
sax::SaxParseInterface::parseFile(input.getValue(), tokens);
}
} else { } else {
std::cout << "Automaton rename require deterministic automaton" << std::endl; sax::SaxParseInterface::parseStdin(tokens);
return 1;
} }
alib::DataFactory::toStdout(automaton::simplify::Rename::rename(alib::DataFactory::fromTokens<automaton::Automaton>(tokens)));
return 0; return 0;
   
} catch (const exception::AlibException& exception) { } catch (const exception::AlibException& exception) {
alib::DataFactory::toStdout(exception); alib::DataFactory::toStdout(exception);
return 1; return 1;
} catch(const TCLAP::ArgException& exception) {
std::cout << exception.error() << std::endl;
return 2;
} catch(...) { } catch(...) {
return 127; return 127;
} }
......
...@@ -70,7 +70,8 @@ function runTest2 { ...@@ -70,7 +70,8 @@ function runTest2 {
fi fi
   
log "$1" $RET "$(cat $TMPNFA)" "$OUT" log "$1" $RET "$(cat $TMPNFA)" "$OUT"
rm $TMPNFA
if [ $RET == 124 ]; then # timeout if [ $RET == 124 ]; then # timeout
return 2 return 2
elif [ $RET -ge 124 ]; then #segv elif [ $RET -ge 124 ]; then #segv
......
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