diff --git a/alib2algo/src/regexp/properties/RegExpEmpty.cpp b/alib2algo/src/regexp/properties/RegExpEmpty.cpp index b06c4eace9293a6e815a93eda369bb2e0c0f4e9f..2302c6909b3e44f650240ad4798ce218d8286530 100644 --- a/alib2algo/src/regexp/properties/RegExpEmpty.cpp +++ b/alib2algo/src/regexp/properties/RegExpEmpty.cpp @@ -14,8 +14,17 @@ namespace regexp { namespace properties { -auto RegExpEmptyFormalRegExp = registration::AbstractRegister < RegExpEmpty, bool, const regexp::FormalRegExp < > & > ( RegExpEmpty::languageIsEmpty ); -auto RegExpEmptyUnboundedRegExp = registration::AbstractRegister < RegExpEmpty, bool, const regexp::UnboundedRegExp < > & > ( RegExpEmpty::languageIsEmpty ); +auto RegExpEmptyFormalRegExp = registration::AbstractRegister < RegExpEmpty, bool, const regexp::FormalRegExp < > & > ( RegExpEmpty::languageIsEmpty, "regexp" ).setDocumentation ( +"Determines whether regular expression is describes an empty language (regexp == \\0)\n\ +\n\ +@param regexp the regexp to test\n\ +@return true of the language described by the regular expression is empty" ); + +auto RegExpEmptyUnboundedRegExp = registration::AbstractRegister < RegExpEmpty, bool, const regexp::UnboundedRegExp < > & > ( RegExpEmpty::languageIsEmpty, "regexp" ).setDocumentation ( +"Determines whether regular expression is describes an empty language (regexp == \\0)\n\ +\n\ +@param regexp the regexp to test\n\ +@return true of the language described by the regular expression is empty" ); } /* namespace properties */ diff --git a/alib2algo/src/regexp/properties/RegExpEmpty.h b/alib2algo/src/regexp/properties/RegExpEmpty.h index 33351c47136e7438898b1beae2abcdf83b44fe9f..d10f29783628e171f9c1e47ead869131500e8143 100644 --- a/alib2algo/src/regexp/properties/RegExpEmpty.h +++ b/alib2algo/src/regexp/properties/RegExpEmpty.h @@ -18,22 +18,50 @@ namespace regexp { namespace properties { /** - * Determines whether regular expression is empty (regexp == \0) + * Determines whether regular expression (or its subtree) describes an empty language (regexp == \0) * */ class RegExpEmpty { public: + /** + * Determines whether regular expression is describes an empty language (regexp == \0) + * + * \tparam SymbolType the type of symbol in the tested regular expression + * + * \param regexp the regexp to test + * + * \return true of the language described by the regular expression is empty + */ template < class SymbolType > static bool languageIsEmpty(const regexp::FormalRegExpElement < SymbolType > & regexp); + + /** + * \override + */ template < class SymbolType > static bool languageIsEmpty(const regexp::FormalRegExpStructure < SymbolType > & regexp); + + /** + * \override + */ template < class SymbolType > static bool languageIsEmpty(const regexp::FormalRegExp < SymbolType > & regexp); + /** + * \override + */ template < class SymbolType > static bool languageIsEmpty(const regexp::UnboundedRegExpElement < SymbolType > & regexp); + + /** + * \override + */ template < class SymbolType > static bool languageIsEmpty(const regexp::UnboundedRegExpStructure < SymbolType > & regexp); + + /** + * \override + */ template < class SymbolType > static bool languageIsEmpty(const regexp::UnboundedRegExp < SymbolType > & regexp); diff --git a/alib2algo/src/regexp/properties/RegExpEpsilon.cpp b/alib2algo/src/regexp/properties/RegExpEpsilon.cpp index f51e8dc78dc9727337c46e42e8ae344df5bcd2fe..149b288fa9bea8dfd0a50d96fc97069a4d28ee7f 100644 --- a/alib2algo/src/regexp/properties/RegExpEpsilon.cpp +++ b/alib2algo/src/regexp/properties/RegExpEpsilon.cpp @@ -14,8 +14,17 @@ namespace regexp { namespace properties { -auto RegExpEpsilonFormalRegExp = registration::AbstractRegister < RegExpEpsilon, bool, const regexp::FormalRegExp < > & > ( RegExpEpsilon::languageContainsEpsilon ); -auto RegExpEpsilonUnboundedRegExp = registration::AbstractRegister < RegExpEpsilon, bool, const regexp::UnboundedRegExp < > & > ( RegExpEpsilon::languageContainsEpsilon ); +auto RegExpEpsilonFormalRegExp = registration::AbstractRegister < RegExpEpsilon, bool, const regexp::FormalRegExp < > & > ( RegExpEpsilon::languageContainsEpsilon, "regexp" ).setDocumentation ( +"Determines whether regular expression describes a language containing epsilon (\\eps \\in h(regexp)).\n\ +\n\ +@param regexp the regexp to test\n\ +@return true of the language described by the regular expression contains epsilon" ); + +auto RegExpEpsilonUnboundedRegExp = registration::AbstractRegister < RegExpEpsilon, bool, const regexp::UnboundedRegExp < > & > ( RegExpEpsilon::languageContainsEpsilon, "regexp" ).setDocumentation ( +"Determines whether regular expression describes a language containing epsilon (\\eps \\in h(regexp)).\n\ +\n\ +@param regexp the regexp to test\n\ +@return true of the language described by the regular expression contains epsilon" ); } /* namespace properties */ diff --git a/alib2algo/src/regexp/properties/RegExpEpsilon.h b/alib2algo/src/regexp/properties/RegExpEpsilon.h index 95c26996c51c67c5604db2018e7ef4a35341336a..a5852a74fd6885211bd618faa85b9724ed879cf5 100644 --- a/alib2algo/src/regexp/properties/RegExpEpsilon.h +++ b/alib2algo/src/regexp/properties/RegExpEpsilon.h @@ -18,22 +18,50 @@ namespace regexp { namespace properties { /** - * Checks, whether regexp (or its subtree) describes epsilon (empty string). + * Determines whether regular expression (or its subtree) describes a language containing epsilon (\eps \in h(regexp)). * */ class RegExpEpsilon { public: + /** + * Determines whether regular expression describes a language containing epsilon (\eps \in h(regexp)). + * + * \tparam SymbolType the type of symbol in the tested regular expression + * + * \param regexp the regexp to test + * + * \return true of the language described by the regular expression contains epsilon + */ template < class SymbolType > static bool languageContainsEpsilon(const regexp::FormalRegExpElement < SymbolType > & regexp); + + /** + * \overload + */ template < class SymbolType > static bool languageContainsEpsilon(const regexp::FormalRegExpStructure < SymbolType > & regexp); + + /** + * \overload + */ template < class SymbolType > static bool languageContainsEpsilon(const regexp::FormalRegExp < SymbolType > & regexp); + /** + * \overload + */ template < class SymbolType > static bool languageContainsEpsilon(const regexp::UnboundedRegExpElement < SymbolType > & regexp); + + /** + * \overload + */ template < class SymbolType > static bool languageContainsEpsilon(const regexp::UnboundedRegExpStructure < SymbolType > & regexp); + + /** + * \overload + */ template < class SymbolType > static bool languageContainsEpsilon(const regexp::UnboundedRegExp < SymbolType > & regexp); diff --git a/alib2algo/src/regexp/simplify/RegExpOptimize.cpp b/alib2algo/src/regexp/simplify/RegExpOptimize.cpp index 05dc9167f2b79c2166204cfda7c2d3cde605f38c..6b895f084d63a6e19073c3b9c01d3f2a39fdbfef 100644 --- a/alib2algo/src/regexp/simplify/RegExpOptimize.cpp +++ b/alib2algo/src/regexp/simplify/RegExpOptimize.cpp @@ -12,8 +12,17 @@ namespace regexp { namespace simplify { -auto RegExpOptimizeFormalRegExp = registration::AbstractRegister < RegExpOptimize, FormalRegExp < >, const FormalRegExp < > & > ( RegExpOptimize::optimize ); -auto RegExpOptimizeUnboundedRegExp = registration::AbstractRegister < RegExpOptimize, UnboundedRegExp < >, const UnboundedRegExp < > & > ( RegExpOptimize::optimize ); +auto RegExpOptimizeFormalRegExp = registration::AbstractRegister < RegExpOptimize, FormalRegExp < >, const FormalRegExp < > & > ( RegExpOptimize::optimize, "regexp" ).setDocumentation ( +"Implements a regexp simplification algorithm that is transforming the regular expression to be smaller.\n\ +\n\ +@param regexp the simplified regexp\n\ +@return the simlified regexp" ); + +auto RegExpOptimizeUnboundedRegExp = registration::AbstractRegister < RegExpOptimize, UnboundedRegExp < >, const UnboundedRegExp < > & > ( RegExpOptimize::optimize, "regexp" ).setDocumentation ( +"Implements a regexp simplification algorithm that is transforming the regular expression to be smaller.\n\ +\n\ +@param regexp the simplified regexp\n\ +@return the simlified regexp" ); } /* namespace regexp */ diff --git a/alib2algo/src/regexp/simplify/RegExpOptimize.h b/alib2algo/src/regexp/simplify/RegExpOptimize.h index a6f768a9e2830bcc90c6046dede277e0221f3f4a..2debe089ca8d07f5bd90f4745387a9a6463591de 100644 --- a/alib2algo/src/regexp/simplify/RegExpOptimize.h +++ b/alib2algo/src/regexp/simplify/RegExpOptimize.h @@ -61,14 +61,40 @@ namespace simplify { */ class RegExpOptimize { public: + + /** + * Implements a regexp simplification algorithm that is transforming the regular expression to be smaller. + * + * \tparam SymbolType the type of symbols in the regular expression + * + * \param regexp the simplified regexp + * + * \return the simlified regexp + */ template < class SymbolType > static regexp::UnboundedRegExp < SymbolType > optimize( const regexp::UnboundedRegExp < SymbolType > & regexp ); + + /** + * \override + */ template < class SymbolType > static regexp::UnboundedRegExpStructure < SymbolType > optimize( const regexp::UnboundedRegExpStructure < SymbolType > & regexp ); + + /** + * \override + */ template < class SymbolType > static void optimize( regexp::UnboundedRegExpAlternation < SymbolType > & regexp ); + + /** + * \override + */ template < class SymbolType > static void optimize( regexp::UnboundedRegExpConcatenation < SymbolType > & regexp ); + + /** + * \override + */ template < class SymbolType > static void optimize( regexp::UnboundedRegExpIteration < SymbolType > & regexp );