From b69935776208ec1d57e169b3a0e699232fe69e3c Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Fri, 8 Feb 2019 16:04:43 +0100 Subject: [PATCH] user documentation of regexp properties and simplify --- .../src/regexp/properties/RegExpEmpty.cpp | 13 ++++++-- alib2algo/src/regexp/properties/RegExpEmpty.h | 30 ++++++++++++++++++- .../src/regexp/properties/RegExpEpsilon.cpp | 13 ++++++-- .../src/regexp/properties/RegExpEpsilon.h | 30 ++++++++++++++++++- .../src/regexp/simplify/RegExpOptimize.cpp | 13 ++++++-- .../src/regexp/simplify/RegExpOptimize.h | 26 ++++++++++++++++ 6 files changed, 117 insertions(+), 8 deletions(-) diff --git a/alib2algo/src/regexp/properties/RegExpEmpty.cpp b/alib2algo/src/regexp/properties/RegExpEmpty.cpp index b06c4eace9..2302c6909b 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 33351c4713..d10f297836 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 f51e8dc78d..149b288fa9 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 95c26996c5..a5852a74fd 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 05dc9167f2..6b895f084d 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 a6f768a9e2..2debe089ca 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 ); -- GitLab