From 86ce80224ce00be916e85522105c28cd8e928a03 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Thu, 27 Feb 2014 13:00:44 +0100
Subject: [PATCH] Revert "implementation of y + x = x + y transformation"

This reverts commit 832a57e717cb56e7616889290bd8d65713ab460f.

Conflicts:
	aconversions/src/re2fa/Brzozowski.cpp
	libaregexptree/src/RegExpOptimize.cpp

Conflicts:
	aconversions/src/re2fa/Brzozowski.cpp
	aderivation/src/aderivation.cpp
	aintegral/src/aintegral.cpp
	libaderivation/src/RegExpDerivation.cpp
	libaderivation/src/RegExpDerivation.h
	libaderivation/src/RegExpIntegral.cpp
	libaderivation/src/RegExpIntegral.h
	libaregexptree/src/RegExpOptimize.cpp
---
 aconvert.regexp/src/RegExpParser.cpp | 33 +++++++++++++++-------------
 aconvert.regexp/src/RegExpParser.h   |  4 ++--
 alib/src/RegExpFactory.h             |  2 --
 alib/src/regexp/Alternation.cpp      |  4 ++--
 alib/src/regexp/Alternation.h        |  8 +++----
 alib/src/regexp/Concatenation.cpp    |  4 ++--
 alib/src/regexp/Concatenation.h      |  8 +++----
 alib/src/regexp/Iteration.h          |  1 +
 alib/src/regexp/RegExp.cpp           |  2 ++
 alib/src/regexp/RegExp.h             |  5 +++--
 alib/src/regexp/RegExpParser.cpp     |  2 +-
 alib/src/regexp/RegExpParser.h       |  4 +---
 alib/src/regexp/RegExpPrinter.cpp    |  2 +-
 alib/src/regexp/RegExpPrinter.h      |  2 +-
 14 files changed, 42 insertions(+), 39 deletions(-)

diff --git a/aconvert.regexp/src/RegExpParser.cpp b/aconvert.regexp/src/RegExpParser.cpp
index 8ba459c5c1..cf070c07a5 100644
--- a/aconvert.regexp/src/RegExpParser.cpp
+++ b/aconvert.regexp/src/RegExpParser.cpp
@@ -19,23 +19,25 @@ regexp::RegExpElement* RegExpParser::AlternationCont(regexp::RegExpElement* left
   RegExpLexer::Token token = m_Lexer.token();
   if(token.type == RegExpLexer::PLUS) {
     m_Lexer.next();
-    regexp::Alternation* res = new regexp::Alternation();
-    res->getElements().push_back(left);
-    this->AlternationContCont(res, this->Concatenation());
+    regexp::Alternation* res = this->AlternationContCont(this->Concatenation());
+    res->getElements().push_front(left);
     return res;
   } else {
     return left;
   }
 }
 
-void RegExpParser::AlternationContCont(regexp::Alternation* res, regexp::RegExpElement* left) {
+regexp::Alternation* RegExpParser::AlternationContCont(regexp::RegExpElement* left) {
   RegExpLexer::Token token = m_Lexer.token();
   if(token.type == RegExpLexer::PLUS) {
     m_Lexer.next();
-    res->getElements().push_back(left);
-    this->AlternationContCont(res, this->Concatenation());
+    regexp::Alternation* res = this->AlternationContCont(this->Concatenation());
+    res->getElements().push_front(left);
+    return res;
   } else {
-    res->getElements().push_back(left);
+    regexp::Alternation* res = new regexp::Alternation();
+    res->getElements().push_front(left);
+    return res;
   }
 }
 
@@ -48,24 +50,25 @@ regexp::RegExpElement* RegExpParser::ConcatenationCont(regexp::RegExpElement* le
   RegExpLexer::Token token = m_Lexer.token();
   if(token.type == RegExpLexer::SYMBOL || token.type == RegExpLexer::LPAR || token.type == RegExpLexer::EPS || token.type == RegExpLexer::EMPTY) {
     
-    regexp::Concatenation* res = new regexp::Concatenation();
-    res->getElements().push_back(left);
-    this->ConcatenationContCont(res, this->Factor());
+    regexp::Concatenation* res = this->ConcatenationContCont(this->Factor());
+    res->getElements().push_front(left);
     return res;
   } else {
     return left;
   }
 }
 
-void RegExpParser::ConcatenationContCont(regexp::Concatenation* res, regexp::RegExpElement* left) {
+regexp::Concatenation* RegExpParser::ConcatenationContCont(regexp::RegExpElement* left) {
   RegExpLexer::Token token = m_Lexer.token();
   if(token.type == RegExpLexer::SYMBOL || token.type == RegExpLexer::LPAR || token.type == RegExpLexer::EPS || token.type == RegExpLexer::EMPTY) {
     
-    res->getElements().push_back(left);
-    this->ConcatenationContCont(res, this->Factor());
+    regexp::Concatenation* res = this->ConcatenationContCont(this->Factor());
+    res->getElements().push_front(left);
+    return res;
   } else {
-    
-    res->getElements().push_back(left);
+    regexp::Concatenation* res = new regexp::Concatenation();
+    res->getElements().push_front(left);
+    return res;
   }
 }
 
diff --git a/aconvert.regexp/src/RegExpParser.h b/aconvert.regexp/src/RegExpParser.h
index 0177ccaaaa..37e161181e 100644
--- a/aconvert.regexp/src/RegExpParser.h
+++ b/aconvert.regexp/src/RegExpParser.h
@@ -26,11 +26,11 @@ public:
 private:
   regexp::RegExpElement* Alternation();
   regexp::RegExpElement* AlternationCont(regexp::RegExpElement* left);
-  void AlternationContCont(regexp::Alternation* res, regexp::RegExpElement* left);
+  regexp::Alternation* AlternationContCont(regexp::RegExpElement* left);
   
   regexp::RegExpElement* Concatenation();
   regexp::RegExpElement* ConcatenationCont(regexp::RegExpElement* left);
-  void ConcatenationContCont(regexp::Concatenation* res, regexp::RegExpElement* left);
+  regexp::Concatenation* ConcatenationContCont(regexp::RegExpElement* left);
   
   regexp::RegExpElement* Factor();
   regexp::RegExpElement* Star(regexp::RegExpElement* elem);
diff --git a/alib/src/RegExpFactory.h b/alib/src/RegExpFactory.h
index de6d8f6430..510ddddc1d 100644
--- a/alib/src/RegExpFactory.h
+++ b/alib/src/RegExpFactory.h
@@ -8,8 +8,6 @@
 #ifndef REGEXPFACTORY_H_
 #define REGEXPFACTORY_H_
 
-#include <list>
-
 #include "sax/Token.h"
 #include "regexp/RegExp.h"
 
diff --git a/alib/src/regexp/Alternation.cpp b/alib/src/regexp/Alternation.cpp
index 2bd801d82e..1c557224ef 100644
--- a/alib/src/regexp/Alternation.cpp
+++ b/alib/src/regexp/Alternation.cpp
@@ -42,11 +42,11 @@ Alternation::~Alternation() {
 	elements.clear();
 }
 
-vector<RegExpElement*>& Alternation::getElements() {
+list<RegExpElement*>& Alternation::getElements() {
 	return elements;
 }
 
-const vector<RegExpElement*>& Alternation::getElements() const {
+const list<RegExpElement*>& Alternation::getElements() const {
 	return elements;
 }
 
diff --git a/alib/src/regexp/Alternation.h b/alib/src/regexp/Alternation.h
index 3ce18a9049..52b8f8c184 100644
--- a/alib/src/regexp/Alternation.h
+++ b/alib/src/regexp/Alternation.h
@@ -8,7 +8,7 @@
 #ifndef ALTERNATION_H_
 #define ALTERNATION_H_
 
-#include <vector>
+#include <list>
 #include "RegExpElement.h"
 
 namespace regexp {
@@ -21,7 +21,7 @@ using namespace std;
  */
 class Alternation: public RegExpElement {
 private:
-	vector<RegExpElement*> elements;
+	list<RegExpElement*> elements;
 public:
 	Alternation();
 	Alternation(const Alternation& other);
@@ -31,12 +31,12 @@ public:
 	/**
 	 * @return list of operands
 	 */
-	vector<RegExpElement*>& getElements();
+	list<RegExpElement*>& getElements();
 
 	/**
 	 * @return list of operands
 	 */
-	const vector<RegExpElement*>& getElements() const;
+	const list<RegExpElement*>& getElements() const;
 
 	/**
 	 * @copydoc RegExpElement::clone() const
diff --git a/alib/src/regexp/Concatenation.cpp b/alib/src/regexp/Concatenation.cpp
index 0387d454fb..c43e767dfd 100644
--- a/alib/src/regexp/Concatenation.cpp
+++ b/alib/src/regexp/Concatenation.cpp
@@ -42,11 +42,11 @@ Concatenation::~Concatenation() {
 	elements.clear();
 }
 
-vector<RegExpElement*>& Concatenation::getElements() {
+list<RegExpElement*>& Concatenation::getElements() {
 	return elements;
 }
 
-const vector<RegExpElement*>& Concatenation::getElements() const {
+const list<RegExpElement*>& Concatenation::getElements() const {
 	return elements;
 }
 
diff --git a/alib/src/regexp/Concatenation.h b/alib/src/regexp/Concatenation.h
index 2e4713875f..9fead277d3 100644
--- a/alib/src/regexp/Concatenation.h
+++ b/alib/src/regexp/Concatenation.h
@@ -8,7 +8,7 @@
 #ifndef CONCATENATION_H_
 #define CONCATENATION_H_
 
-#include <vector>
+#include <list>
 #include "RegExpElement.h"
 
 namespace regexp {
@@ -21,7 +21,7 @@ using namespace std;
  */
 class Concatenation: public RegExpElement {
 private:
-	vector<RegExpElement*> elements;
+	list<RegExpElement*> elements;
 public:
 	Concatenation();
 	Concatenation(const Concatenation& other);
@@ -31,12 +31,12 @@ public:
 	/**
 	 * @return list of operands
 	 */
-	vector<RegExpElement*>& getElements();
+	list<RegExpElement*>& getElements();
 
 	/**
 	 * @return list of operands
 	 */
-	const vector<RegExpElement*>& getElements() const;
+	const list<RegExpElement*>& getElements() const;
 
 	/**
 	 * @copydoc RegExpElement::clone() const
diff --git a/alib/src/regexp/Iteration.h b/alib/src/regexp/Iteration.h
index 4bca308eab..7466b2aedc 100644
--- a/alib/src/regexp/Iteration.h
+++ b/alib/src/regexp/Iteration.h
@@ -8,6 +8,7 @@
 #ifndef ITERATION_H_
 #define ITERATION_H_
 
+#include <list>
 #include "RegExpElement.h"
 
 namespace regexp {
diff --git a/alib/src/regexp/RegExp.cpp b/alib/src/regexp/RegExp.cpp
index 27afc0cb91..621b004152 100644
--- a/alib/src/regexp/RegExp.cpp
+++ b/alib/src/regexp/RegExp.cpp
@@ -8,6 +8,8 @@
 #include "RegExp.h"
 #include "RegExpPrinter.h"
 
+#include <iostream>
+
 namespace regexp {
 
 RegExp::RegExp() {
diff --git a/alib/src/regexp/RegExp.h b/alib/src/regexp/RegExp.h
index ef21bad4b5..f16133cc5f 100644
--- a/alib/src/regexp/RegExp.h
+++ b/alib/src/regexp/RegExp.h
@@ -8,8 +8,9 @@
 #ifndef REGEXP_H_
 #define REGEXP_H_
 
-#include <iostream>
-
+#include <vector>
+#include <list>
+#include <string>
 #include "RegExpElement.h"
 #include "RegExpEmpty.h"
 
diff --git a/alib/src/regexp/RegExpParser.cpp b/alib/src/regexp/RegExpParser.cpp
index 81d52a3987..5bcad37145 100644
--- a/alib/src/regexp/RegExpParser.cpp
+++ b/alib/src/regexp/RegExpParser.cpp
@@ -68,7 +68,7 @@ Iteration* RegExpParser::parseIteration(list<Token>& input) {
 	return iteration;
 }
 
-void RegExpParser::parseContent(list<Token>& input, vector<RegExpElement*>& elements) {
+void RegExpParser::parseContent(list<Token>& input, list<RegExpElement*>& elements) {
 	while (true) {
 		RegExpElement* element = parseElement(input);
 		if(!element) return;
diff --git a/alib/src/regexp/RegExpParser.h b/alib/src/regexp/RegExpParser.h
index 808ad17d24..126f20ee5d 100644
--- a/alib/src/regexp/RegExpParser.h
+++ b/alib/src/regexp/RegExpParser.h
@@ -8,8 +8,6 @@
 #ifndef REGEXPPARSER_H_
 #define REGEXPPARSER_H_
 
-#include <list>
-
 #include "RegExp.h"
 #include "../sax/Token.h"
 #include "RegExpSymbol.h"
@@ -29,7 +27,7 @@ using namespace sax;
  */
 class RegExpParser {
 protected:
-	static void parseContent(list<Token>& input, vector<RegExpElement*>& elements);
+	static void parseContent(list<Token>& input, list<RegExpElement*>& elements);
 	static RegExpElement* parseElement(list<Token>& input);
 
 	static RegExpEpsilon* parseEpsilon(list<Token>& input);
diff --git a/alib/src/regexp/RegExpPrinter.cpp b/alib/src/regexp/RegExpPrinter.cpp
index f3757b3025..223ab54691 100644
--- a/alib/src/regexp/RegExpPrinter.cpp
+++ b/alib/src/regexp/RegExpPrinter.cpp
@@ -56,7 +56,7 @@ void RegExpPrinter::printElement(RegExpElement* element, ostream& out, string pr
 
 }
 
-void RegExpPrinter::printContent(vector<RegExpElement*>& content, ostream& out, string prefix) {
+void RegExpPrinter::printContent(list<RegExpElement*>& content, ostream& out, string prefix) {
 	for (auto element : content) {
 		printElement(element, out, prefix);
 	}
diff --git a/alib/src/regexp/RegExpPrinter.h b/alib/src/regexp/RegExpPrinter.h
index 33c21f8da4..49ba46d027 100644
--- a/alib/src/regexp/RegExpPrinter.h
+++ b/alib/src/regexp/RegExpPrinter.h
@@ -28,7 +28,7 @@ class RegExpPrinter {
 protected:
 	static const string INDENTATION;
 	static void printElement(RegExpElement* element, ostream& out, string prefix);
-	static void printContent(vector<RegExpElement*>& content, ostream& out, string prefix);
+	static void printContent(list<RegExpElement*>& content, ostream& out, string prefix);
 	static void printAlternation(Alternation* alternation, ostream& out, string prefix);
 	static void printConcatenation(Concatenation* concatenation, ostream& out, string prefix);
 
-- 
GitLab