From b3a2685394e0a2d7f8e50b95de7d73f237136bbd Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Mon, 29 Sep 2014 21:33:35 +0200
Subject: [PATCH] Trim RegExp

---
 atrim2/src/atrim.cpp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/atrim2/src/atrim.cpp b/atrim2/src/atrim.cpp
index 59561d3fc7..5d2e016a53 100644
--- a/atrim2/src/atrim.cpp
+++ b/atrim2/src/atrim.cpp
@@ -11,12 +11,12 @@
 void help( void ) {
 	std::cout << "atrim 0.01" << std::endl;
 	std::cout << "Removes unreachable and useless states from FSM, productive and unreachable nonterminals from CFG. Simplifies representation of RE" << std::endl;
-	std::cout << "Usage: atrim [-u] [-r]" << std::endl << std::endl;
+	std::cout << "Usage: atrim [-u] [-r] [-s] [-h]" << std::endl << std::endl;
 	std::cout << "If neither --useless nor --unreachable option is used, both useless and unreachable states (or symbols) are removed." << std::endl;
 	std::cout << std::endl;
-	std::cout << " -u, --useless \t Removes useless states. (works with FSM only)" << std::endl;
-	std::cout << " -r, --unreachable \t Removes unreachable states. (works with FSM or CFG)" << std::endl;
-	std::cout << " -s, --simplify \t Simplifies representation. (works with RE)" << std::endl;
+	std::cout << " -u, --useless \t Removes useless states (or symbols). (works with FSM or CFG)" << std::endl;
+	std::cout << " -r, --unreachable \t Removes unreachable states (or symbols). (works with FSM or CFG)" << std::endl;
+	std::cout << " -s, --simplify \t Simplifies representation. (works with RE only)" << std::endl;
 	std::cout << " -h, --help \t shows this." << std::endl;
 	std::cout << std::endl;
 }
@@ -182,6 +182,13 @@ int main(int argc, char* argv[]) {
 
 			grammar::Grammar res = trimGrammar(grammar, del_unreachables, del_useless );
 
+			alib::DataFactory::toStdout( res );
+			return 0;
+		} else if( alib::FromXMLParsers::regexpParser.first(tokens)) {
+			regexp::RegExp regexp = alib::DataFactory::fromTokens<regexp::RegExp>(tokens);
+
+			regexp::RegExp res = optimizeRegExp(regexp );
+
 			alib::DataFactory::toStdout( res );
 			return 0;
 		} else {
-- 
GitLab