diff --git a/aconversions/makefile b/aconversions/makefile index 61302d97d7a00421ccd1b406744397d5ff7e1e16..84bd798b21aafc46d69348e7488f2f4a04f9e559 100644 --- a/aconversions/makefile +++ b/aconversions/makefile @@ -1,26 +1,20 @@ -BIN_DIR = bin -SRC_DIR = src +CC=g++ +EXECUTABLE=aconversion +CCFLAGS= -std=c++11 -O2 -c -Wall -I../alib/src -I/usr/include/libxml2/ -I../libaderivation/src -I../libaregexptree/src +LDFLAGS= -L../alib/lib -L../libaderivation/lib -L../libaregexptree/lib -lxml2 -laderivation -laregexptree -lalib -Wl,-rpath,. -CONVERSIONS = fa2re fa2rg re2fa re2rg rg2fa rg2re -EXCEPTIONS = exception +SOURCES=$(shell find src/ -name *cpp) +OBJECTS=$(patsubst src/%.cpp, obj/%.o, $(SOURCES)) -SUBDIRS_WITH_MAKE = $(dir $(wildcard */makefile)) +all: $(SOURCES) bin/$(EXECUTABLE) -.PHONY: $(CONVERSIONS) +bin/$(EXECUTABLE): $(OBJECTS) + mkdir -p bin + $(CC) $(OBJECTS) -o $@ $(LDFLAGS) -all: $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS) copy - -$(CONVERSIONS): - $(MAKE) -C $(SRC_DIR)/$@ +obj/%.o: src/%.cpp + mkdir -p $(dir $@) + $(CC) $(CCFLAGS) $< -o $@ clean: - for dir in $(addprefix $(SRC_DIR)/, $(CONVERSIONS)); do \ - $(MAKE) -C $$dir clean; \ - done - -copy: $(CONVERSIONS) - mkdir -p $(BIN_DIR) - rm -rf $(BIN_DIR)/* - for dir in $(addprefix $(SRC_DIR)/, $(CONVERSIONS)); do \ - cp $$dir/bin/* $(BINFOLDER); \ - done + $(RM) -r *.o *.d bin obj diff --git a/aconversions/src/exception/ConversionException.cpp b/aconversions/src/exception/ConversionException.cpp deleted file mode 100644 index 19aa02a96458030e7537029acddd3d67b46bf770..0000000000000000000000000000000000000000 --- a/aconversions/src/exception/ConversionException.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ConversionException.cpp - * - * Created on: 22. 12. 2013 - * Author: tomas - */ - -#include "ConversionException.h" - -using namespace std; -using namespace alib; - - -namespace conversions -{ - -ConversionException::ConversionException( void ) -{ - -} - -ConversionException::ConversionException( const string & cause ) : AlibException( cause ) -{ - -} - -ConversionException::~ConversionException( void ) throw ( ) -{ - -} - -} /* namespace conversions */ diff --git a/aconversions/src/exception/ConversionException.h b/aconversions/src/exception/ConversionException.h deleted file mode 100644 index f8a9ee0fe722389ca3d099ae1091329206600557..0000000000000000000000000000000000000000 --- a/aconversions/src/exception/ConversionException.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ConversionException.h - * - * Created on: 22. 12. 2013 - * Author: tomas - */ - -#ifndef CONVERSIONEXCEPTION_H_ -#define CONVERSIONEXCEPTION_H_ - -#include <AlibException.h> - -namespace conversions -{ - -class ConversionException : public alib::AlibException -{ -public: - ConversionException( void ); - ConversionException( const std::string & cause ); - virtual ~ConversionException( void ) throw (); -}; - -} /* namespace conversions */ - -#endif /* CONVERSIONEXCEPTION_H_ */ diff --git a/aconversions/src/fa2re/AbstractFAtoREConverter.h b/aconversions/src/fa2re/AbstractFAtoREConverter.h index c57bf9b6eedb06c15d57952cc4b9b963b15d81ba..e45fc67ad87e94607081320153c59abd0940ab79 100644 --- a/aconversions/src/fa2re/AbstractFAtoREConverter.h +++ b/aconversions/src/fa2re/AbstractFAtoREConverter.h @@ -3,9 +3,10 @@ #include <automaton/FSM/FSM.h> #include <regexp/RegExp.h> +#include <AlibException.h> +#include "../include/macros.h" #include "../abstract/Conversion.h" -#include "../../utils/ConversionException.h" namespace conversions { diff --git a/aconversions/src/fa2re/BrzozowskiAlgebraic.cpp b/aconversions/src/fa2re/BrzozowskiAlgebraic.cpp index 58b6660910a991a48acc68b32e2df67d86684142..f961f4891ddc086bf47b5739f1a740d19b737ef4 100644 --- a/aconversions/src/fa2re/BrzozowskiAlgebraic.cpp +++ b/aconversions/src/fa2re/BrzozowskiAlgebraic.cpp @@ -7,6 +7,7 @@ #include "BrzozowskiAlgebraic.h" +using namespace alib; using namespace automaton; using namespace regexp; diff --git a/aconversions/src/fa2re/BrzozowskiAlgebraic.h b/aconversions/src/fa2re/BrzozowskiAlgebraic.h index 2444fc6fb46855f61579c855b697d68948183853..f8a7b14138fd1f00a463dd9d9d31868352474b8a 100644 --- a/aconversions/src/fa2re/BrzozowskiAlgebraic.h +++ b/aconversions/src/fa2re/BrzozowskiAlgebraic.h @@ -19,7 +19,6 @@ #include <regexp/RegExpEpsilon.h> #include "AbstractFAtoREConverter.h" -#include "../../utils/utils.h" #include "RegExpOptimize.h" diff --git a/aconversions/src/fa2re/StateElimination.cpp b/aconversions/src/fa2re/StateElimination.cpp index 65ee15485b633ac9f1f016bd512bc416bea3c446..b58f104ed2db02bffd325e6d8dbfac62b2d2249c 100644 --- a/aconversions/src/fa2re/StateElimination.cpp +++ b/aconversions/src/fa2re/StateElimination.cpp @@ -7,6 +7,7 @@ #include "StateElimination.h" +using namespace alib; using namespace automaton; using namespace regexp; using namespace std; @@ -62,7 +63,7 @@ void StateElimination::constructExtendedNFA( void ) for( const auto & transition : m_automaton.getTransitions( ) ) { if( ! isInSet( transition.getFrom( ), m_MR.m_states ) || ! isInSet( transition.getTo( ), m_MR.m_states ) ) - throw ConversionException( "StateElimination::constructExtendedNFA - Transition from/to non-existing state." ); + throw AlibException( "StateElimination::constructExtendedNFA - Transition from/to non-existing state." ); m_MR.m_transitions.insert( TransitionExtendedNFA( transition.getFrom( ), new RegExpSymbol( transition.getInput( ).getSymbol( ) ), transition.getTo( ) ) ); } @@ -189,7 +190,7 @@ const State & StateElimination::ExtendedNFA::createUniqueState( const string & n } } - throw ConversionException( "StateElimination::ExtendedNFA::createUniqueState - could not create unique state." ); + throw AlibException( "StateElimination::ExtendedNFA::createUniqueState - could not create unique state." ); } // ---------------------------------------------------------------------------- diff --git a/aconversions/src/fa2re/StateElimination.h b/aconversions/src/fa2re/StateElimination.h index 2a717183c635fc436cfd3b5c538bfdf3367de1ce..8bb0945a6ba45f31446d1e3e427290901c74e205 100644 --- a/aconversions/src/fa2re/StateElimination.h +++ b/aconversions/src/fa2re/StateElimination.h @@ -21,8 +21,7 @@ #include <regexp/RegExpSymbol.h> #include "AbstractFAtoREConverter.h" -#include "../../utils/utils.h" -#include "../../conversions/re2fa/RegExpComparator.h" +#include "../re2fa/RegExpComparator.h" #include "RegExpOptimize.h" diff --git a/aconversions/src/fa2rg/AbstractFAtoRGConverter.cpp b/aconversions/src/fa2rg/AbstractFAtoRGConverter.cpp index 59bbe64dc3f28c7729d5516f3f187ff38b485221..a8eb28195b03b6d0b03ea2ee6970d511ed56259b 100644 --- a/aconversions/src/fa2rg/AbstractFAtoRGConverter.cpp +++ b/aconversions/src/fa2rg/AbstractFAtoRGConverter.cpp @@ -1,5 +1,6 @@ #include "AbstractFAtoRGConverter.h" +using namespace alib; using namespace automaton; using namespace grammar; @@ -9,7 +10,7 @@ namespace conversions AbstractFAtoRGConverter::AbstractFAtoRGConverter( const FSM & automaton, RegularGrammar * grammar) : m_automaton( automaton ), m_g( grammar ) { if( ! m_automaton.isEpsilonFree( ) ) - throw ConversionException( "FSM has epsilon transitions" ); + throw AlibException( "FSM has epsilon transitions" ); } AbstractFAtoRGConverter::~AbstractFAtoRGConverter( void ) diff --git a/aconversions/src/fa2rg/AbstractFAtoRGConverter.h b/aconversions/src/fa2rg/AbstractFAtoRGConverter.h index eba7f7ce3f38efdf000f3d6aac084710df58c380..4987910011a6a80566a3fa30090b87ba23861f7d 100644 --- a/aconversions/src/fa2rg/AbstractFAtoRGConverter.h +++ b/aconversions/src/fa2rg/AbstractFAtoRGConverter.h @@ -3,9 +3,10 @@ #include <automaton/FSM/FSM.h> #include <grammar/Regular/RegularGrammar.h> +#include <AlibException.h> +#include "../include/macros.h" #include "../abstract/Conversion.h" -#include "../../utils/ConversionException.h" namespace conversions { diff --git a/aconversions/src/fa2rg/FAtoLRGConverter.h b/aconversions/src/fa2rg/FAtoLRGConverter.h index 62701dc5f9111fdd1c0afbc3c8b88b2514b63e12..a878b782e5db289682b3f292e0d6eef6f416bd51 100644 --- a/aconversions/src/fa2rg/FAtoLRGConverter.h +++ b/aconversions/src/fa2rg/FAtoLRGConverter.h @@ -2,11 +2,10 @@ #define __FATOLRGCONVERTER_H__ #include "AbstractFAtoRGConverter.h" + #include <grammar/Regular/LeftRegularGrammar.h> #include <automaton/FSM/FSM.h> -#include "../../utils/utils.h" - namespace conversions { diff --git a/aconversions/src/fa2rg/FAtoRRGConverter.h b/aconversions/src/fa2rg/FAtoRRGConverter.h index 36b711bacbb6d67c43fe0555b554a97421732ef3..0790af83b5e8ed691e69d0aaf4d10ffed65ea8da 100644 --- a/aconversions/src/fa2rg/FAtoRRGConverter.h +++ b/aconversions/src/fa2rg/FAtoRRGConverter.h @@ -1,11 +1,10 @@ #ifndef __FATORRGCONVERTER_H__ #define __FATORRGCONVERTER_H__ -#include "AbstractFAtoRGConverter.h" #include <grammar/Regular/RightRegularGrammar.h> #include <automaton/FSM/FSM.h> -#include "../../utils/utils.h" +#include "AbstractFAtoRGConverter.h" namespace conversions { diff --git a/aconversions/src/macros.h b/aconversions/src/include/macros.h similarity index 100% rename from aconversions/src/macros.h rename to aconversions/src/include/macros.h diff --git a/aconversions/src/re2fa/AbstractREtoFAConverter.h b/aconversions/src/re2fa/AbstractREtoFAConverter.h index 089390e4a850187cab7afbde214eb8379dc0104d..c66284b647b80e4204d7082f4a7c7312d57572b9 100644 --- a/aconversions/src/re2fa/AbstractREtoFAConverter.h +++ b/aconversions/src/re2fa/AbstractREtoFAConverter.h @@ -4,6 +4,9 @@ #include <regexp/RegExp.h> #include <automaton/FSM/FSM.h> +#include <AlibException.h> + +#include "../include/macros.h" #include "../abstract/Conversion.h" namespace conversions diff --git a/aconversions/src/re2fa/Brzozowski.h b/aconversions/src/re2fa/Brzozowski.h index 1cf791f36dd0d52eecccb0f4d1d07649d31b3bda..8ba4e0947fd7c8d4b7bcc8698bc72fd85c23d35b 100644 --- a/aconversions/src/re2fa/Brzozowski.h +++ b/aconversions/src/re2fa/Brzozowski.h @@ -16,7 +16,6 @@ #include "AbstractREtoFAConverter.h" #include "RegExpComparator.h" -#include "../../utils/utils.h" #include "RegExpDerivation.h" #include "RegExpAlphabet.h" diff --git a/aconversions/src/re2fa/Glushkov.cpp b/aconversions/src/re2fa/Glushkov.cpp index 0e2543214794549f919ac84ff98ac4748454423c..da982d3e97e52502f9da7ee53ab00f83b344fb19 100644 --- a/aconversions/src/re2fa/Glushkov.cpp +++ b/aconversions/src/re2fa/Glushkov.cpp @@ -89,7 +89,7 @@ const set<RegExpSymbol*> Glushkov::getLeftmostSymbolsInTree( RegExpElement * nod else if( empty ) return getLeftmostSymbolsInTree( empty ); - throw ConversionException( "Glushkov::getLeftmostSymbolsInTree - invalid RegExpElement node" ); + throw AlibException( "Glushkov::getLeftmostSymbolsInTree - invalid RegExpElement node" ); } const set<RegExpSymbol*> Glushkov::getLeftmostSymbolsInTree( Alternation * node ) const @@ -170,7 +170,7 @@ const set<RegExpSymbol*> Glushkov::getRightmostSymbolsInTree( RegExpElement * no else if( empty ) return getRightmostSymbolsInTree( empty ); - throw ConversionException( "Glushkov::getRightmostSymbolsInTree - invalid RegExpElement node" ); + throw AlibException( "Glushkov::getRightmostSymbolsInTree - invalid RegExpElement node" ); } const set<RegExpSymbol*> Glushkov::getRightmostSymbolsInTree( Alternation * node ) const @@ -255,7 +255,7 @@ const set<pair<const RegExpSymbol*, const RegExpSymbol*>> Glushkov::getNeighbour else if( empty ) return getNeighbours( empty ); - throw ConversionException( "Glushkov::getNeighbours - unknown RegExpElement* " ); + throw AlibException( "Glushkov::getNeighbours - unknown RegExpElement* " ); } const set<pair<const RegExpSymbol*, const RegExpSymbol*>> Glushkov::getNeighbours( Alternation * node ) const @@ -346,7 +346,7 @@ const Glushkov::NumberedSymbol * Glushkov::getNumberedSymbol( const RegExpSymbol if( it->m_regexpSymbol == symbol ) return & ( *it ); - throw ConversionException( "Glushkov::getNumberedSymbol - no symbol found!" ); + throw AlibException( "Glushkov::getNumberedSymbol - no symbol found!" ); } bool Glushkov::NumberedSymbol::operator<( const NumberedSymbol & x ) const diff --git a/aconversions/src/re2fa/Glushkov.h b/aconversions/src/re2fa/Glushkov.h index 096e1f0ae61bc62bf5167b3773b03b6154835308..6fd433892c7249dd681181194ad57bbeb3cbeef9 100644 --- a/aconversions/src/re2fa/Glushkov.h +++ b/aconversions/src/re2fa/Glushkov.h @@ -13,10 +13,8 @@ #include <alphabet/Symbol.h> #include <automaton/State.h> #include <regexp/RegExp.h> -#include <AlibException.h> #include "AbstractREtoFAConverter.h" -#include "../../utils/ConversionException.h" #include "RegExpAlphabet.h" diff --git a/aconversions/src/re2fa/RegExpComparator.cpp b/aconversions/src/re2fa/RegExpComparator.cpp index d5d7d1a727a71d5308b09bbb9c9c1943c9eef622..c693f56753a4acc95184bf5c5c67645d1793aa8e 100644 --- a/aconversions/src/re2fa/RegExpComparator.cpp +++ b/aconversions/src/re2fa/RegExpComparator.cpp @@ -6,8 +6,8 @@ */ #include "RegExpComparator.h" -#include <typeinfo> -#include <iostream> + +using namespace alib; using namespace regexp; namespace conversions @@ -74,7 +74,7 @@ int RegExpComparator::compare( RegExpElement * lhs, RegExpElement * rhs ) const return 0; } - throw ConversionException( "RegExpComparator::compare - Don't know how to compare subtrees." ); + throw AlibException( "RegExpComparator::compare - Don't know how to compare subtrees." ); } int RegExpComparator::compare( Alternation * lhs, Alternation * rhs ) const diff --git a/aconversions/src/re2fa/RegExpComparator.h b/aconversions/src/re2fa/RegExpComparator.h index 787b5d30e1a9b87a953fcda6053a5b88fd30d05a..76e8023d137b4bfdde94d577674aa14e201744c8 100644 --- a/aconversions/src/re2fa/RegExpComparator.h +++ b/aconversions/src/re2fa/RegExpComparator.h @@ -19,8 +19,7 @@ #include <regexp/RegExpSymbol.h> #include <regexp/RegExpEmpty.h> #include <regexp/RegExpEpsilon.h> - -#include "../../utils/ConversionException.h" +#include <AlibException.h> namespace conversions { diff --git a/aconversions/src/re2fa/Thompson.cpp b/aconversions/src/re2fa/Thompson.cpp index 5ef1719f2d738c24d8d5c1812494a94d39736b33..acc9b466a46c3c4ed3277773f3b337043a0cbade 100644 --- a/aconversions/src/re2fa/Thompson.cpp +++ b/aconversions/src/re2fa/Thompson.cpp @@ -6,6 +6,7 @@ */ #include "Thompson.h" +using namespace alib; using namespace automaton; using namespace regexp; @@ -56,7 +57,7 @@ Thompson::SubexpressionTails Thompson::processRegExpNode( RegExpElement * node ) else if( empty ) return processRegExpNode( empty ); - throw ConversionException( "Thompson::process - invalid RegExpElement node." ); + throw AlibException( "Thompson::process - invalid RegExpElement node." ); } Thompson::SubexpressionTails Thompson::processRegExpNode( Iteration * node ) @@ -142,7 +143,7 @@ Thompson::SubexpressionTails::SubexpressionTails( const FSM & fsm, const State & m_itTail = states.find( tail ); if( m_itHead == states.end( ) || m_itTail == states.end( ) ) - throw ConversionException( "Thompson::SubExpressionTails::SubExpressionTails() - invalid automaton state(s) ???" ); + throw AlibException( "Thompson::SubExpressionTails::SubExpressionTails() - invalid automaton state(s) ???" ); } const automaton::State & Thompson::SubexpressionTails::getHead( ) const diff --git a/aconversions/src/re2fa/Thompson.h b/aconversions/src/re2fa/Thompson.h index e8d15d0be84ed00d1b5399f7916c8394f78d899e..4bd41b61a85217b01da142a7d9d142eaa51f51b0 100644 --- a/aconversions/src/re2fa/Thompson.h +++ b/aconversions/src/re2fa/Thompson.h @@ -20,7 +20,6 @@ #include <regexp/RegExpSymbol.h> #include "AbstractREtoFAConverter.h" -#include "../../utils/ConversionException.h" #include "RegExpAlphabet.h" diff --git a/aconversions/src/rg2fa/AbstractRGtoFAConverter.h b/aconversions/src/rg2fa/AbstractRGtoFAConverter.h index 87d13abe9268403a5053e2e669b1131d909c84bf..00b63f256c00998431b6d6186b9f2c7db41ee6ac 100644 --- a/aconversions/src/rg2fa/AbstractRGtoFAConverter.h +++ b/aconversions/src/rg2fa/AbstractRGtoFAConverter.h @@ -4,6 +4,9 @@ #include <automaton/FSM/FSM.h> #include <grammar/Regular/RegularGrammar.h> +#include <AlibException.h> + +#include "../include/macros.h" #include "../abstract/Conversion.h" namespace conversions diff --git a/aconversions/src/rg2fa/LRGtoFAConverter.h b/aconversions/src/rg2fa/LRGtoFAConverter.h index 83a4f4b359d06c11e2ad8e3cb26f71be1fc85b9d..a27e054777b90fa1b5199271c46823c5c3581dfe 100644 --- a/aconversions/src/rg2fa/LRGtoFAConverter.h +++ b/aconversions/src/rg2fa/LRGtoFAConverter.h @@ -4,7 +4,6 @@ #include <automaton/FSM/FSM.h> #include <grammar/Regular/LeftRegularGrammar.h> -#include "../../utils/utils.h" #include "AbstractRGtoFAConverter.h" namespace conversions diff --git a/aconversions/src/rg2fa/RRGtoFAConverter.h b/aconversions/src/rg2fa/RRGtoFAConverter.h index 951a98571b3df661af354e6a22acc6ec0672f2e3..da057899d73ff8498a0d5e19c9c1561b1a4be4db 100644 --- a/aconversions/src/rg2fa/RRGtoFAConverter.h +++ b/aconversions/src/rg2fa/RRGtoFAConverter.h @@ -4,7 +4,6 @@ #include <grammar/Regular/RightRegularGrammar.h> #include <automaton/FSM/FSM.h> -#include "../../utils/utils.h" #include "AbstractRGtoFAConverter.h" namespace conversions