From 2b27de55e29cfb711fd0923af4f70e35a599e417 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sun, 15 Nov 2015 13:59:47 +0100
Subject: [PATCH] format code

---
 anormalize2/src/anormalize.cpp | 240 +++++++++++++++++----------------
 1 file changed, 123 insertions(+), 117 deletions(-)

diff --git a/anormalize2/src/anormalize.cpp b/anormalize2/src/anormalize.cpp
index b9b20a21b8..d233ca8a0a 100644
--- a/anormalize2/src/anormalize.cpp
+++ b/anormalize2/src/anormalize.cpp
@@ -19,189 +19,195 @@
 #include "grammar/simplify/ToGNF.h"
 #include "grammar/parsing/DeterministicLL1Grammar.h"
 
-int main(int argc, char** argv) {
+int main ( int argc, char * * argv ) {
 
 	try {
-		TCLAP::CmdLine cmd("Automaton normalize binary", ' ', "0.01");
+		TCLAP::CmdLine cmd ( "Automaton normalize binary", ' ', "0.01" );
 
-		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to normalize",		false,	"-",	"file");
-		cmd.add( input );
+		TCLAP::ValueArg < std::string > input ( "i", "input", "Input to normalize", false, "-", "file" );
+		cmd.add ( input );
 
-		std::vector<std::string> forms {"leftRG", "rightRG", "singleInitialState", "CNF", "GNF", "LL1" };
-		TCLAP::ValuesConstraint<std::string> formVals( forms );
+		std::vector < std::string > forms {
+			"leftRG", "rightRG", "singleInitialState", "CNF", "GNF", "LL1"
+		};
+		TCLAP::ValuesConstraint < std::string > formVals ( forms );
 
-		TCLAP::ValueArg<std::string> form(	"f",	"form",		"Convert to different form",	false,	"",	&formVals);
-		cmd.add( form );
+		TCLAP::ValueArg < std::string > form ( "f", "form", "Convert to different form", false, "", & formVals );
+		cmd.add ( form );
 
-		std::vector<std::string> inputTypes {"automaton", "grammar"};
-		TCLAP::ValuesConstraint<std::string> inputTypeVals( inputTypes );
+		std::vector < std::string > inputTypes {
+			"automaton", "grammar"
+		};
+		TCLAP::ValuesConstraint < std::string > inputTypeVals ( inputTypes );
 
-		TCLAP::ValueArg<std::string> labels(	"l",	"labels",	"Normalize labels",		false,	"",	&inputTypeVals);
-		cmd.add( labels );
+		TCLAP::ValueArg < std::string > labels ( "l", "labels", "Normalize labels", false, "", & inputTypeVals );
+		cmd.add ( labels );
 
-		std::vector<std::string> inputTypes2 {"string"};
-		TCLAP::ValuesConstraint<std::string> inputTypeVals2( inputTypes2 );
+		std::vector < std::string > inputTypes2 {
+			"string"
+		};
+		TCLAP::ValuesConstraint < std::string > inputTypeVals2 ( inputTypes2 );
 
-		TCLAP::ValueArg<std::string> alphabet(	"a",	"alphabet",	"Normalize alphabet",		false,	"",	&inputTypeVals2);
-		cmd.add( alphabet );
+		TCLAP::ValueArg < std::string > alphabet ( "a", "alphabet", "Normalize alphabet", false, "", & inputTypeVals2 );
+		cmd.add ( alphabet );
 
-		TCLAP::SwitchArg measure(		"m",	"measure",	"Measure times",		false);
-		cmd.add( measure );
+		TCLAP::SwitchArg measure ( "m", "measure", "Measure times", false );
+		cmd.add ( measure );
 
-		TCLAP::SwitchArg verbose(		"v",	"verbose",	"Be verbose",			false);
-		cmd.add( verbose );
+		TCLAP::SwitchArg verbose ( "v", "verbose", "Be verbose", false );
+		cmd.add ( verbose );
 
-		cmd.parse(argc, argv);
+		cmd.parse ( argc, argv );
 
-		if(verbose.isSet())
+		if ( verbose.isSet ( ) )
 			common::GlobalData::verbose = true;
-		if(measure.isSet())
+
+		if ( measure.isSet ( ) )
 			common::GlobalData::measure = true;
 
-		std::chrono::measurements::start("Overal", std::chrono::measurements::Type::OVERALL);
-		std::chrono::measurements::start("Input read", std::chrono::measurements::Type::AUXILARY);
+		std::chrono::measurements::start ( "Overal", std::chrono::measurements::Type::OVERALL );
+		std::chrono::measurements::start ( "Input read", std::chrono::measurements::Type::AUXILARY );
+
+		std::deque < sax::Token > tokens;
 
-		std::deque<sax::Token> tokens;
-		if(input.isSet()) {
-			if(input.getValue() == "-") {
-				sax::SaxParseInterface::parseStdin(tokens);
-			} else {
-				sax::SaxParseInterface::parseFile(input.getValue(), tokens);
-			}
+		if ( input.isSet ( ) ) {
+			if ( input.getValue ( ) == "-" )
+				sax::SaxParseInterface::parseStdin ( tokens );
+			else
+				sax::SaxParseInterface::parseFile ( input.getValue ( ), tokens );
 		} else {
-			sax::SaxParseInterface::parseStdin(tokens);
+			sax::SaxParseInterface::parseStdin ( tokens );
 		}
 
-		if(labels.getValue() == "automaton") {
-			automaton::Automaton automaton = alib::XmlDataFactory::fromTokens<automaton::Automaton>(tokens);
+		if ( labels.getValue ( ) == "automaton" ) {
+			automaton::Automaton automaton = alib::XmlDataFactory::fromTokens < automaton::Automaton > ( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-			automaton::Automaton res = automaton::simplify::Normalize::normalize(automaton);
+			automaton::Automaton res = automaton::simplify::Normalize::normalize ( automaton );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-			alib::XmlDataFactory::toStdout(res);
-		} else if(labels.getValue() == "grammar") {
-//			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens<grammar::Grammar>( tokens );
+			alib::XmlDataFactory::toStdout ( res );
+		} else if ( labels.getValue ( ) == "grammar" ) {
+			// grammar::Grammar grammar = alib::XmlDataFactory::fromTokens<grammar::Grammar>( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-//			grammar::Grammar res = grammar::simplify::Normalize::normalize(grammar);
+			// grammar::Grammar res = grammar::simplify::Normalize::normalize(grammar);
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-//			alib::XmlDataFactory::toStdout(res);
-		} else if(alphabet.getValue() == "string") {
-			string::String string = alib::XmlDataFactory::fromTokens<string::String>(tokens);
+			// alib::XmlDataFactory::toStdout(res);
+		} else if ( alphabet.getValue ( ) == "string" ) {
+			string::String string = alib::XmlDataFactory::fromTokens < string::String > ( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-			string::String res = string::simplify::NormalizeAlphabet::normalize(string);
+			string::String res = string::simplify::NormalizeAlphabet::normalize ( string );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-			alib::XmlDataFactory::toStdout(res);
-		} else if(form.getValue() == "leftRG") {
-			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens<grammar::Grammar>( tokens );
+			alib::XmlDataFactory::toStdout ( res );
+		} else if ( form.getValue ( ) == "leftRG" ) {
+			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens < grammar::Grammar > ( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-			grammar::LeftRG res = grammar::convert::ToGrammarLeftRG::convert(grammar);
+			grammar::LeftRG res = grammar::convert::ToGrammarLeftRG::convert ( grammar );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-			alib::XmlDataFactory::toStdout(res);
-		} else if(form.getValue() == "rightRG") {
-			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens<grammar::Grammar>( tokens );
+			alib::XmlDataFactory::toStdout ( res );
+		} else if ( form.getValue ( ) == "rightRG" ) {
+			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens < grammar::Grammar > ( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-			grammar::RightRG res = grammar::convert::ToGrammarRightRG::convert(grammar);
+			grammar::RightRG res = grammar::convert::ToGrammarRightRG::convert ( grammar );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-			alib::XmlDataFactory::toStdout(res);
-		} else if(form.getValue() == "singleInitialState") {
-			automaton::Automaton automaton = alib::XmlDataFactory::fromTokens<automaton::Automaton>(tokens);
+			alib::XmlDataFactory::toStdout ( res );
+		} else if ( form.getValue ( ) == "singleInitialState" ) {
+			automaton::Automaton automaton = alib::XmlDataFactory::fromTokens < automaton::Automaton > ( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-			automaton::Automaton res = automaton::simplify::SingleInitialState::convert(automaton);
+			automaton::Automaton res = automaton::simplify::SingleInitialState::convert ( automaton );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-			alib::XmlDataFactory::toStdout(res);
-		} else if(form.getValue() == "CNF") {
-			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens<grammar::Grammar>( tokens );
+			alib::XmlDataFactory::toStdout ( res );
+		} else if ( form.getValue ( ) == "CNF" ) {
+			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens < grammar::Grammar > ( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-			grammar::Grammar res = grammar::simplify::ToCNF::convert(grammar);
+			grammar::Grammar res = grammar::simplify::ToCNF::convert ( grammar );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-			alib::XmlDataFactory::toStdout(res);
-		} else if(form.getValue() == "GNF") {
-			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens<grammar::Grammar>( tokens );
+			alib::XmlDataFactory::toStdout ( res );
+		} else if ( form.getValue ( ) == "GNF" ) {
+			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens < grammar::Grammar > ( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-			grammar::Grammar res = grammar::simplify::ToGNF::convert(grammar);
+			grammar::Grammar res = grammar::simplify::ToGNF::convert ( grammar );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-			alib::XmlDataFactory::toStdout(res);
-		} else if(form.getValue() == "LL1") {
-			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens<grammar::Grammar>( tokens );
+			alib::XmlDataFactory::toStdout ( res );
+		} else if ( form.getValue ( ) == "LL1" ) {
+			grammar::Grammar grammar = alib::XmlDataFactory::fromTokens < grammar::Grammar > ( tokens );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Algorithm", std::chrono::measurements::Type::MAIN);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Algorithm", std::chrono::measurements::Type::MAIN );
 
-			grammar::Grammar res = grammar::parsing::DeterministicLL1Grammar::convert(grammar);
+			grammar::Grammar res = grammar::parsing::DeterministicLL1Grammar::convert ( grammar );
 
-			std::chrono::measurements::end();
-			std::chrono::measurements::start("Output write", std::chrono::measurements::Type::AUXILARY);
+			std::chrono::measurements::end ( );
+			std::chrono::measurements::start ( "Output write", std::chrono::measurements::Type::AUXILARY );
 
-			alib::XmlDataFactory::toStdout(res);
+			alib::XmlDataFactory::toStdout ( res );
 		} else {
-			throw exception::AlibException("Invalid normalize command");
+			throw exception::AlibException ( "Invalid normalize command" );
 		}
 
-		std::chrono::measurements::end();
-		std::chrono::measurements::end();
+		std::chrono::measurements::end ( );
+		std::chrono::measurements::end ( );
 
-		if(measure.getValue()) std::clog << std::chrono::measurements::results() << std::endl;
+		if ( measure.getValue ( ) ) std::clog << std::chrono::measurements::results ( ) << std::endl;
 
 		return 0;
-	} catch (const exception::AlibException& exception) {
-		alib::XmlDataFactory::toStdout(exception);
+	} catch ( const exception::AlibException & exception ) {
+		alib::XmlDataFactory::toStdout ( exception );
 		return 1;
-	} catch(const TCLAP::ArgException& exception) {
-		std::cout << exception.error() << std::endl;
+	} catch ( const TCLAP::ArgException & exception ) {
+		std::cout << exception.error ( ) << std::endl;
 		return 2;
-	} catch (const std::exception& exception) {
-		std::cerr << "Exception caught: " << exception.what() << std::endl;
+	} catch ( const std::exception & exception ) {
+		std::cerr << "Exception caught: " << exception.what ( ) << std::endl;
 		return 3;
-	} catch(...) {
+	} catch ( ... ) {
 		std::cerr << "Unknown exception caught." << std::endl;
 		return 127;
 	}
 }
-
-- 
GitLab