From 7aa1cbb3d04c0d8bffd52e0ff5fe725bab8702a2 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Wed, 30 Aug 2017 21:59:14 +0200 Subject: [PATCH] add stringApi specialisation for UnboundedRegExp --- alib2str/src/regexp/RegExpFromStringParser.cpp | 6 +++++- alib2str/src/regexp/RegExpFromStringParser.h | 1 + alib2str/src/regexp/RegExpStringApi.cpp | 8 ++++++++ alib2str/src/regexp/RegExpStringApi.hpp | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/alib2str/src/regexp/RegExpFromStringParser.cpp b/alib2str/src/regexp/RegExpFromStringParser.cpp index c6a2062ff6..691e9b3eb3 100644 --- a/alib2str/src/regexp/RegExpFromStringParser.cpp +++ b/alib2str/src/regexp/RegExpFromStringParser.cpp @@ -21,13 +21,17 @@ RegExp RegExpFromStringParser::parseRegExp(std::istream& input) { return parseRegExp(input, ext::set<FEATURES>({FEATURES::FORMAL, FEATURES::UNBOUNDED})); } +UnboundedRegExp < DefaultSymbolType > RegExpFromStringParser::parseUnboundedRegExp(std::istream& input) { + return UnboundedRegExp < DefaultSymbolType > { RegExpFromStringParser::parseUnboundedRegExpStructure ( input ) }; +} + UnboundedRegExpStructure < DefaultSymbolType > RegExpFromStringParser::parseUnboundedRegExpStructure(std::istream& input) { ext::rvalue_ref < UnboundedRegExpElement < DefaultSymbolType > > element = alternation(input); return regexp::UnboundedRegExpStructure < DefaultSymbolType >(std::move(element)); } RegExp RegExpFromStringParser::parseRegExp(std::istream& input, const ext::set<FEATURES>& features) { - UnboundedRegExp < > regexp { RegExpFromStringParser::parseUnboundedRegExpStructure ( input ) }; + UnboundedRegExp < > regexp = RegExpFromStringParser::parseUnboundedRegExp ( input ); if(features.count(FEATURES::UNBOUNDED)) return RegExp { std::move ( regexp ) }; diff --git a/alib2str/src/regexp/RegExpFromStringParser.h b/alib2str/src/regexp/RegExpFromStringParser.h index b22cacc128..c28a71c718 100644 --- a/alib2str/src/regexp/RegExpFromStringParser.h +++ b/alib2str/src/regexp/RegExpFromStringParser.h @@ -31,6 +31,7 @@ class RegExpFromStringParser { public: static UnboundedRegExpStructure < DefaultSymbolType > parseUnboundedRegExpStructure(std::istream& input); + static UnboundedRegExp < DefaultSymbolType > parseUnboundedRegExp(std::istream& input); static RegExp parseRegExp(std::istream& input); static RegExp parseRegExp(std::istream& input, const ext::set<FEATURES>& features); }; diff --git a/alib2str/src/regexp/RegExpStringApi.cpp b/alib2str/src/regexp/RegExpStringApi.cpp index e896ad537d..c42703b1b7 100644 --- a/alib2str/src/regexp/RegExpStringApi.cpp +++ b/alib2str/src/regexp/RegExpStringApi.cpp @@ -19,6 +19,14 @@ void stringApi < regexp::RegExp >::compose ( std::ostream & output, const regexp return regexp::RegExpToStringComposer::compose ( output, data ); } +regexp::UnboundedRegExp < DefaultSymbolType > stringApi < regexp::UnboundedRegExp < DefaultSymbolType > >::parse ( std::istream & input ) { + return regexp::RegExpFromStringParser::parseUnboundedRegExp ( input ); +} + +void stringApi < regexp::UnboundedRegExp < DefaultSymbolType > >::compose ( std::ostream & output, const regexp::UnboundedRegExp < DefaultSymbolType > & data ) { + return regexp::RegExpToStringComposer::compose ( output, data ); +} + regexp::UnboundedRegExpStructure < DefaultSymbolType > stringApi < regexp::UnboundedRegExpStructure < DefaultSymbolType > >::parse ( std::istream & input ) { return regexp::RegExpFromStringParser::parseUnboundedRegExpStructure ( input ); } diff --git a/alib2str/src/regexp/RegExpStringApi.hpp b/alib2str/src/regexp/RegExpStringApi.hpp index 82f054ccb2..71ce68c25e 100644 --- a/alib2str/src/regexp/RegExpStringApi.hpp +++ b/alib2str/src/regexp/RegExpStringApi.hpp @@ -20,6 +20,12 @@ struct stringApi < regexp::RegExp > { static void compose ( std::ostream & output, const regexp::RegExp & data ); }; +template < > +struct stringApi < regexp::UnboundedRegExp < DefaultSymbolType > > { + static regexp::UnboundedRegExp < DefaultSymbolType > parse ( std::istream & input ); + static void compose ( std::ostream & output, const regexp::UnboundedRegExp < DefaultSymbolType > & data ); +}; + template < > struct stringApi < regexp::UnboundedRegExpStructure < DefaultSymbolType > > { static regexp::UnboundedRegExpStructure < DefaultSymbolType > parse ( std::istream & input ); -- GitLab