From 520763007373a2eb4c93210ff3280adfce425857 Mon Sep 17 00:00:00 2001
From: Tomas Pecka <peckato1@fit.cvut.cz>
Date: Thu, 21 Jul 2016 20:32:43 +0200
Subject: [PATCH] RTE: Compute min. alphabet bug

---
 alib2data/src/rte/common/RTEFromXMLParser.cpp        | 4 ++++
 alib2data/src/rte/formal/FormalRTESymbolAlphabet.cpp | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/alib2data/src/rte/common/RTEFromXMLParser.cpp b/alib2data/src/rte/common/RTEFromXMLParser.cpp
index 9254a8615f..118259457e 100644
--- a/alib2data/src/rte/common/RTEFromXMLParser.cpp
+++ b/alib2data/src/rte/common/RTEFromXMLParser.cpp
@@ -67,6 +67,7 @@ std::rvalue_ref < FormalRTEAlternation > RTEFromXMLParser::parseFormalRTEAlterna
 std::rvalue_ref < FormalRTESubstitution > RTEFromXMLParser::parseFormalRTESubstitution ( std::deque < sax::Token >::iterator & input ) {
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "substitution" );
 
+	 // TODO: Check alphabet membership
 	std::rvalue_ref < FormalRTESymbolSubst > ssymb ( new FormalRTESymbolSubst ( alib::xmlApi < alphabet::RankedSymbol >::parse ( input ) ) );
 	std::rvalue_ref < FormalRTEElement > element1 = parseFormalRTEElement ( input );
 	std::rvalue_ref < FormalRTEElement > element2 = parseFormalRTEElement ( input );
@@ -80,6 +81,7 @@ std::rvalue_ref < FormalRTESubstitution > RTEFromXMLParser::parseFormalRTESubsti
 std::rvalue_ref < FormalRTEIteration > RTEFromXMLParser::parseFormalRTEIteration ( std::deque < sax::Token >::iterator & input ) {
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "iteration" );
 
+	 // TODO: Check alphabet membership
 	std::rvalue_ref < FormalRTESymbolSubst > ssymb ( new FormalRTESymbolSubst ( alib::xmlApi < alphabet::RankedSymbol >::parse ( input ) ) );
 	std::rvalue_ref < FormalRTEElement > element = parseFormalRTEElement ( input );
 	std::rvalue_ref < FormalRTEIteration > iteration ( new FormalRTEIteration ( std::move ( element ), std::move ( ssymb ) ) );
@@ -112,6 +114,7 @@ std::rvalue_ref < FormalRTESymbolAlphabet > RTEFromXMLParser::parseFormalRTESymb
 	alphabet::RankedSymbol symbol = alib::xmlApi < alphabet::RankedSymbol >::parse ( input );
 	std::vector < std::rvalue_ref < FormalRTESymbol > > elements;
 
+	 // TODO: Check alphabet membership
 	std::rvalue_ref < FormalRTESymbolAlphabet > ret ( new FormalRTESymbolAlphabet ( symbol ) );
 
 	while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) )
@@ -129,6 +132,7 @@ std::rvalue_ref < FormalRTESymbolSubst > RTEFromXMLParser::parseFormalRTESymbolS
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "substSymbol" );
 	alphabet::RankedSymbol symbol = alib::xmlApi < alphabet::RankedSymbol >::parse ( input );
 
+	 // TODO: Check alphabet membership
 	std::rvalue_ref < FormalRTESymbolSubst > ret ( new FormalRTESymbolSubst ( symbol ) );
 
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "substSymbol" );
diff --git a/alib2data/src/rte/formal/FormalRTESymbolAlphabet.cpp b/alib2data/src/rte/formal/FormalRTESymbolAlphabet.cpp
index 1c0ac404a8..9759db6dd4 100644
--- a/alib2data/src/rte/formal/FormalRTESymbolAlphabet.cpp
+++ b/alib2data/src/rte/formal/FormalRTESymbolAlphabet.cpp
@@ -94,8 +94,11 @@ bool FormalRTESymbolAlphabet::attachRTE ( const FormalRTE * regexp ) {
 	return this->parentRTE->getAlphabet ( ).find ( this->symbol ) != this->parentRTE->getAlphabet ( ).end ( ) || this->parentRTE->getConstantAlphabet ( ).find ( this->symbol ) == this->parentRTE->getConstantAlphabet ( ).end ( );
 }
 
-void FormalRTESymbolAlphabet::computeMinimalAlphabet ( std::set < alphabet::RankedSymbol > & alphabetF, std::set < alphabet::RankedSymbol > & /* alphabetK */ ) const {
+void FormalRTESymbolAlphabet::computeMinimalAlphabet ( std::set < alphabet::RankedSymbol > & alphabetF, std::set < alphabet::RankedSymbol > & alphabetK ) const {
 	alphabetF.insert ( this->symbol );
+
+	for ( const auto & child : elements )
+		child->computeMinimalAlphabet ( alphabetF, alphabetK );
 }
 
 FormalRTESymbolAlphabet::operator std::string ( ) const {
-- 
GitLab