Skip to content
Snippets Groups Projects
Commit 1aad8646 authored by Tomáš Pecka's avatar Tomáš Pecka
Browse files

algo: regexp: namespace for deriv and integral

parent 5e1b3773
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ int main(int argc, char** argv)
regexp::RegExp regexp = alib::DataFactory::fromFile<regexp::RegExp>(argv[1]);
string::LinearString* string = static_cast<string::LinearString*>(std::move(alib::DataFactory::fromFile<string::LinearString>(argv[2])).plunder());
 
RegExpDerivation derive;
regexp::RegExpDerivation derive;
alib::DataFactory::toStdout(derive.derivation(regexp, *string));
 
return 0;
......
......@@ -28,7 +28,7 @@ int main(int argc, char** argv)
regexp::RegExp regexp = alib::DataFactory::fromFile<regexp::RegExp>(argv[1]);
string::LinearString* string = static_cast<string::LinearString*>(std::move(alib::DataFactory::fromFile<string::LinearString>(argv[2])).plunder());
 
RegExpIntegral i;
regexp::RegExpIntegral i;
alib::DataFactory::toStdout(i.integral(regexp, *string));
 
return 0;
......
......@@ -7,6 +7,9 @@
 
#include "RegExpDerivation.h"
 
namespace regexp
{
RegExpDerivation::RegExpDerivation(){}
RegExpDerivation::~RegExpDerivation(){}
 
......@@ -97,13 +100,13 @@ void RegExpDerivation::Visit(void* userData, const regexp::FormalRegExpSymbol& s
}
 
 
void RegExpDerivation::Visit(void* userData, const regexp::FormalRegExpEpsilon& epsilon)
void RegExpDerivation::Visit(void* userData, const regexp::FormalRegExpEpsilon&)
{
std::pair<alphabet::Symbol, regexp::FormalRegExpElement*> &out = *((std::pair<alphabet::Symbol, regexp::FormalRegExpElement*>*) userData);
out.second = new regexp::FormalRegExpEmpty();
}
 
void RegExpDerivation::Visit(void* userData, const regexp::FormalRegExpEmpty& empty)
void RegExpDerivation::Visit(void* userData, const regexp::FormalRegExpEmpty&)
{
std::pair<alphabet::Symbol, regexp::FormalRegExpElement*> &out = *((std::pair<alphabet::Symbol, regexp::FormalRegExpElement*>*) userData);
out.second = new regexp::FormalRegExpEmpty();
......@@ -196,14 +199,16 @@ void RegExpDerivation::Visit(void* userData, const regexp::UnboundedRegExpSymbol
out.second = new regexp::UnboundedRegExpEmpty();
}
 
void RegExpDerivation::Visit(void* userData, const regexp::UnboundedRegExpEpsilon& epsilon)
void RegExpDerivation::Visit(void* userData, const regexp::UnboundedRegExpEpsilon&)
{
std::pair<alphabet::Symbol, regexp::UnboundedRegExpElement*> &out = *((std::pair<alphabet::Symbol, regexp::UnboundedRegExpElement*>*) userData);
out.second = new regexp::UnboundedRegExpEmpty();
}
 
void RegExpDerivation::Visit(void* userData, const regexp::UnboundedRegExpEmpty& empty)
void RegExpDerivation::Visit(void* userData, const regexp::UnboundedRegExpEmpty&)
{
std::pair<alphabet::Symbol, regexp::UnboundedRegExpElement*> &out = *((std::pair<alphabet::Symbol, regexp::UnboundedRegExpElement*>*) userData);
out.second = new regexp::UnboundedRegExpEmpty();
}
} /* namespace regexp */
......@@ -15,6 +15,9 @@
#include <string/LinearString.h>
#include <string/StringBase.h>
 
namespace regexp
{
/**
* Calculates derivation of regular expression.
*
......@@ -48,4 +51,6 @@ private:
void Visit(void*, const regexp::FormalRegExp& empty);
};
 
} /* namespace regexp */
#endif /* REGEXPDERIVATION_H_ */
......@@ -7,6 +7,9 @@
 
#include "RegExpIntegral.h"
 
namespace regexp
{
RegExpIntegral::RegExpIntegral(){}
RegExpIntegral::~RegExpIntegral(){}
 
......@@ -95,14 +98,14 @@ void RegExpIntegral::Visit(void* userData, const regexp::FormalRegExpSymbol& sym
}
 
 
void RegExpIntegral::Visit(void* userData, const regexp::FormalRegExpEpsilon& epsilon)
void RegExpIntegral::Visit(void* userData, const regexp::FormalRegExpEpsilon&)
{
std::pair<alphabet::Symbol, regexp::FormalRegExpElement*> &out = *((std::pair<alphabet::Symbol, regexp::FormalRegExpElement*>*) userData);
regexp::FormalRegExpSymbol* symb = new regexp::FormalRegExpSymbol(out.first);
out.second = symb;
}
 
void RegExpIntegral::Visit(void* userData, const regexp::FormalRegExpEmpty& empty)
void RegExpIntegral::Visit(void* userData, const regexp::FormalRegExpEmpty&)
{
std::pair<alphabet::Symbol, regexp::FormalRegExpElement*> &out = *((std::pair<alphabet::Symbol, regexp::FormalRegExpElement*>*) userData);
out.second = new regexp::FormalRegExpEmpty();
......@@ -192,7 +195,7 @@ void RegExpIntegral::Visit(void* userData, const regexp::UnboundedRegExpSymbol&
out.second = ret;
}
 
void RegExpIntegral::Visit(void* userData, const regexp::UnboundedRegExpEpsilon& epsilon)
void RegExpIntegral::Visit(void* userData, const regexp::UnboundedRegExpEpsilon&)
{
std::pair<alphabet::Symbol, regexp::UnboundedRegExpElement*> &out = *((std::pair<alphabet::Symbol, regexp::UnboundedRegExpElement*>*) userData);
 
......@@ -200,8 +203,10 @@ void RegExpIntegral::Visit(void* userData, const regexp::UnboundedRegExpEpsilon&
out.second = symb;
}
 
void RegExpIntegral::Visit(void* userData, const regexp::UnboundedRegExpEmpty& empty)
void RegExpIntegral::Visit(void* userData, const regexp::UnboundedRegExpEmpty&)
{
std::pair<alphabet::Symbol, regexp::UnboundedRegExpElement*> &out = *((std::pair<alphabet::Symbol, regexp::UnboundedRegExpElement*>*) userData);
out.second = new regexp::UnboundedRegExpEmpty();
}
} /* namespace regexp */
......@@ -15,6 +15,9 @@
#include <string/LinearString.h>
#include <string/StringBase.h>
 
namespace regexp
{
/**
* Calculates integral of regular expression as defined in Melichar 2.93 (chapt. 2.4.4)
*/
......@@ -44,4 +47,6 @@ private:
void Visit(void*, const regexp::FormalRegExp& empty);
};
 
} /* namespace regexp */
#endif /* REGEXPINTEGRAL_H_ */
......@@ -42,7 +42,7 @@ void RegExpDerivationTest::ExecSingleTest(std::string regexp_str, std::string st
string::StringFromStringParser string_parser(string_ss);
string::String string = string_parser.parseValue();
 
RegExpDerivation d;
regexp::RegExpDerivation d;
regexp::RegExpToStringComposer regexp_composer;
 
// TODO
......
......@@ -34,7 +34,7 @@ void RegExpIntegralTest::ExecSingleTest(std::string regexp_str, std::string stri
string::StringFromStringParser string_parser(string_ss);
string::String string = string_parser.parseValue();
 
RegExpIntegral i;
regexp::RegExpIntegral i;
regexp::RegExpToStringComposer regexp_composer;
 
// TODO
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment