Skip to content
Snippets Groups Projects
Commit 4a9360ba authored by Jan Trávníček's avatar Jan Trávníček
Browse files

remove not needed ranked_symbol wrapper

parent 1c611e20
No related branches found
No related tags found
No related merge requests found
Pipeline #19728 passed
Showing
with 40 additions and 245 deletions
......@@ -144,7 +144,7 @@ int main ( int argc, char * argv[] ) {
}
if ( collection.isSet ( )
&& ( operation.getValue ( ) == "add" || operation.getValue ( ) == "remove" ) && ( treeInput.isSet ( ) ) ) {
parser = cli::Parser ( cli::Lexer ( "execute < :set @ranked_symbol #collection > $argument" ) );
parser = cli::Parser ( cli::Lexer ( "execute < :set @RankedSymbol #collection > $argument" ) );
parser.parse ( )->run ( environment );
}
 
......@@ -155,7 +155,7 @@ int main ( int argc, char * argv[] ) {
parser.parse ( )->run ( environment );
}
if ( element.isSet ( ) && ( operation.getValue ( ) == "add" || operation.getValue ( ) == "remove" ) && ( treeInput.isSet ( ) ) ) {
parser = cli::Parser ( cli::Lexer ( "execute < :ranked_symbol #element > $argument" ) );
parser = cli::Parser ( cli::Lexer ( "execute < :RankedSymbol #element > $argument" ) );
parser.parse ( )->run ( environment );
}
 
......
......@@ -153,7 +153,7 @@ int main ( int argc, char * argv[] ) {
input = subtreeWildcardInput.getValue ( );
 
environment.setBinding ( "inputSubtreeWildcard", input );
cli::Parser parser ( cli::Lexer ( "execute <:ranked_symbol #inputSubtreeWildcard > $subtreeWildcard" ) );
cli::Parser parser ( cli::Lexer ( "execute <:RankedSymbol #inputSubtreeWildcard > $subtreeWildcard" ) );
parser.parse ( )->run ( environment );
}
 
......@@ -165,7 +165,7 @@ int main ( int argc, char * argv[] ) {
input = nonlinearVariablesInput.getValue ( );
 
environment.setBinding ( "inputNonlinearVariables", input );
cli::Parser parser ( cli::Lexer ( "execute <:set @ranked_symbol #inputNonlinearVariables > $nonlinearVariables" ) );
cli::Parser parser ( cli::Lexer ( "execute <:set @RankedSymbol #inputNonlinearVariables > $nonlinearVariables" ) );
parser.parse ( )->run ( environment );
}
 
......@@ -184,7 +184,7 @@ int main ( int argc, char * argv[] ) {
input = variablesBarInput.getValue ( );
 
environment.setBinding ( "inputVariablesBar", input );
cli::Parser parser ( cli::Lexer ( "execute <:ranked_symbol #inputVariablesBar > $variablesBar" ) );
cli::Parser parser ( cli::Lexer ( "execute <:RankedSymbol #inputVariablesBar > $variablesBar" ) );
parser.parse ( )->run ( environment );
}
}
......
......@@ -13,8 +13,6 @@
#include <alib/deque>
#include <alib/foreach>
 
#include <alphabet/RankedSymbol.h>
#include <tree/ranked/RankedTree.h>
#include <tree/ranked/RankedPattern.h>
#include <tree/ranked/RankedNonlinearPattern.h>
......
......@@ -21,8 +21,6 @@
 
#include <registration/AlgoRegistration.hpp>
 
#include <alphabet/RankedSymbol.h>
namespace automaton {
 
namespace convert {
......@@ -31,7 +29,7 @@ automaton::DPDA < > ToPostfixPushdownAutomaton::convert ( const automaton::DFTA
automaton::DPDA < > automaton(label::InitialStateLabel::instance < DefaultStateType > ( ), alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ));
 
for (const auto & rankedSymbol : dfta.getInputAlphabet()) {
automaton.addInputSymbol(DefaultSymbolType ( alphabet::RankedSymbol < > ( rankedSymbol ) ));
automaton.addInputSymbol ( DefaultSymbolType ( rankedSymbol ) );
}
automaton.addInputSymbol(alphabet::EndSymbol::instance < DefaultSymbolType > ( ));
 
......@@ -46,7 +44,7 @@ automaton::DPDA < > ToPostfixPushdownAutomaton::convert ( const automaton::DFTA
pop.push_back(state);
}
ext::vector<DefaultSymbolType> push (1, transition.second);
automaton.addTransition(automaton.getInitialState(), DefaultSymbolType(alphabet::RankedSymbol<>(transition.first.first)), pop, automaton.getInitialState(), push);
automaton.addTransition(automaton.getInitialState(), DefaultSymbolType ( common::ranked_symbol < > ( transition.first.first ) ), pop, automaton.getInitialState(), push);
}
 
auto finalPDAState = label::FinalStateLabel::instance < DefaultStateType > ( );
......@@ -66,7 +64,7 @@ automaton::NPDA < > ToPostfixPushdownAutomaton::convert ( const automaton::NFTA
automaton::NPDA < > automaton(label::InitialStateLabel::instance < DefaultStateType > ( ), alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ));
 
for (const auto & rankedSymbol : nfta.getInputAlphabet()) {
automaton.addInputSymbol(DefaultSymbolType ( alphabet::RankedSymbol < > ( rankedSymbol ) ));
automaton.addInputSymbol ( DefaultSymbolType ( rankedSymbol ) );
}
automaton.addInputSymbol(alphabet::EndSymbol::instance < DefaultSymbolType > ( ));
 
......@@ -82,7 +80,7 @@ automaton::NPDA < > ToPostfixPushdownAutomaton::convert ( const automaton::NFTA
pop.push_back(state);
}
ext::vector <DefaultSymbolType> push(1, toState);
automaton.addTransition(automaton.getInitialState(), DefaultSymbolType(alphabet::RankedSymbol<>(transition.first.first)), pop, automaton.getInitialState(), push);
automaton.addTransition(automaton.getInitialState(), DefaultSymbolType ( common::ranked_symbol < > ( transition.first.first ) ), pop, automaton.getInitialState(), push);
}
}
 
......
......@@ -23,7 +23,7 @@ namespace rte {
namespace convert {
 
ext::vector < DefaultSymbolType > phi ( const ext::vector < common::ranked_symbol < > > & follow ) {
return ext::transform < DefaultSymbolType > ( follow, []( const common::ranked_symbol < > & symbol ) { return DefaultSymbolType ( alphabet::RankedSymbol < > ( symbol ) ); } );
return ext::transform < DefaultSymbolType > ( follow, []( const common::ranked_symbol < > & symbol ) { return DefaultSymbolType ( symbol ); } );
}
 
bool isSubstSymbolPresent ( const ext::set < common::ranked_symbol < > > & container, const ext::set < common::ranked_symbol < > > & substAlphabet ) {
......@@ -73,7 +73,7 @@ automaton::NPDA < > ToPostfixPushdownAutomatonGlushkovNaive::convert ( const rte
 
// step 4; create pushdown store alphabet; it consists of elements of indexed RTE alphabet and BotS symbol
for ( const common::ranked_symbol < > & symb : indexedRTE.getAlphabet ( ) )
automaton.addPushdownStoreSymbol ( DefaultSymbolType ( alphabet::RankedSymbol < > ( symb ) ) );
automaton.addPushdownStoreSymbol ( DefaultSymbolType ( symb ) );
 
/* DEBUG */
if ( common::GlobalData::verbose ) {
......@@ -111,19 +111,19 @@ automaton::NPDA < > ToPostfixPushdownAutomatonGlushkovNaive::convert ( const rte
 
for ( const common::ranked_symbol < > & symb : indexedRTE.getAlphabet ( ) ) {
if ( symb.getRank ( ) == unsigned ( 0 ) )
automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), { }, q, { DefaultSymbolType ( alphabet::RankedSymbol < > ( symb ) ) } );
automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), { }, q, { DefaultSymbolType ( symb ) } );
else
for ( const ext::vector < common::ranked_symbol < > > & follow : followSet[symb] ) {
ext::vector < DefaultSymbolType > fstring = phi ( follow );
std::reverse ( fstring.begin ( ), fstring.end ( ) );
automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), fstring, q, { DefaultSymbolType ( alphabet::RankedSymbol < > ( symb ) ) } );
automaton.addTransition ( q, rte::GlushkovIndexate::getSymbolFromGlushkovPair ( symb ).getSymbol ( ), fstring, q, { DefaultSymbolType ( symb ) } );
}
 
}
 
for ( const common::ranked_symbol < > & symb : firstSet ) {
ext::vector < DefaultSymbolType > pop;
pop.push_back ( DefaultSymbolType ( alphabet::RankedSymbol < > ( symb ) ) );
pop.push_back ( DefaultSymbolType ( symb ) );
pop.push_back ( alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) );
automaton.addTransition ( q, alphabet::EndSymbol::instance < DefaultSymbolType > ( ), pop, f, { } );
}
......
......@@ -8,7 +8,6 @@
#ifndef _ARBOLOGY_BAD_CHARACTER_SHIFT_TABLE_H_
#define _ARBOLOGY_BAD_CHARACTER_SHIFT_TABLE_H_
 
#include <alphabet/RankedSymbol.h>
#include <tree/ranked/PrefixRankedBarPattern.h>
#include <tree/ranked/PrefixRankedBarNonlinearPattern.h>
 
......
......@@ -8,7 +8,6 @@
#ifndef _LAST_VARIABLE_OFFSET_BACK_H_
#define _LAST_VARIABLE_OFFSET_BACK_H_
 
#include <alphabet/RankedSymbol.h>
#include <tree/ranked/PrefixRankedBarPattern.h>
#include <tree/ranked/PrefixRankedBarNonlinearPattern.h>
 
......
......@@ -8,7 +8,6 @@
#ifndef _ARBOLOGY_QUICK_SEARCH_BAD_CHARACTER_SHIFT_TABLE_H_
#define _ARBOLOGY_QUICK_SEARCH_BAD_CHARACTER_SHIFT_TABLE_H_
 
#include <alphabet/RankedSymbol.h>
#include <tree/ranked/PrefixRankedBarPattern.h>
#include <tree/ranked/PrefixRankedBarNonlinearPattern.h>
 
......
......@@ -28,9 +28,8 @@ namespace {
class PrimitiveRegistrator {
public:
PrimitiveRegistrator ( ) {
abstraction::ContainerRegistry::registerSet < common::ranked_symbol < object::Object, unsigned > > ( "ranked_symbol" );
abstraction::XmlContainerParserRegistry::registerSet < common::ranked_symbol < object::Object, unsigned > > ( "ranked_symbol" );
abstraction::XmlParserRegistry::registerXmlParser < common::ranked_symbol < object::Object, unsigned > > ( "ranked_symbol" );
abstraction::ContainerRegistry::registerSet < common::ranked_symbol < object::Object, unsigned > > ( "RankedSymbol" );
abstraction::XmlContainerParserRegistry::registerSet < common::ranked_symbol < object::Object, unsigned > > ( "RankedSymbol" );
abstraction::XmlComposerRegistry::registerXmlComposer < ext::set < common::ranked_symbol < object::Object, unsigned > > > ( );
abstraction::XmlComposerRegistry::registerXmlComposer < common::ranked_symbol < object::Object, unsigned > > ( );
 
......@@ -41,7 +40,6 @@ public:
abstraction::XmlComposerRegistry::registerXmlComposer < ext::set < string::LinearString < > > > ( );
 
core::xmlApi < object::Object >::template registerXmlWriter < ext::set < common::ranked_symbol < object::Object, unsigned > > > ( );
core::xmlApi < object::Object >::template registerXmlWriter < common::ranked_symbol < object::Object, unsigned > > ( );
core::xmlApi < object::Object >::template registerXmlWriter < ext::pair < ext::set < ext::pair < object::Object, object::Object > >, ext::variant < string::Epsilon < object::Object >, object::Object > > > ( );
core::xmlApi < object::Object >::template registerXmlWriter < ext::pair < object::Object, ext::variant < string::Epsilon < object::Object >, object::Object > > > ( );
}
......
/*
* RankedSymbol.cpp
*
* Created on: Apr 10, 2013
* Author: Stepan Plachy
*/
#include "RankedSymbol.h"
#include <registration/ValuePrinterRegistration.hpp>
namespace {
static auto valuePrinter = registration::ValuePrinterRegister < alphabet::RankedSymbol < > > ( );
} /* namespace */
/*
* RankedSymbol.h
*
* This file is part of Algorithms library toolkit.
* Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
* Algorithms library toolkit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Algorithms library toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
*
* Created on: Apr 10, 2013
* Author: Stepan Plachy
*/
#ifndef RANKED_SYMBOL_H_
#define RANKED_SYMBOL_H_
#include "SymbolBase.h"
#include <common/ranked_symbol.hpp>
#include <core/normalize.hpp>
#include <alphabet/common/SymbolNormalize.h>
namespace alphabet {
/**
* \brief
* Represents the adaptor of ranked symbol to class in symbol hierarchy.
*
* \tparam SymbolType used for the symbol part of the ranked symbol
* \tparam RankType used for the rank part of the ranked symbol
*/
template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType >
class RankedSymbol : public SymbolBase, public common::ranked_symbol < SymbolType, RankType > {
public:
/**
* \brief
* The constructors of raw ranked symbol are inherited here
*/
using common::ranked_symbol < SymbolType, RankType >::ranked_symbol;
/**
* \brief
* Creates a new instance of the ranked symbol based on a raw ranked symbol
*/
explicit RankedSymbol ( common::ranked_symbol < SymbolType, RankType > symbol ) : common::ranked_symbol < SymbolType, RankType > ( std::move ( symbol ) ) {
}
/**
* @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
*/
virtual int compare ( const SymbolBase & other ) const override {
if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
}
/**
* The actual compare method
*
* \param other the other instance
*
* \returns the actual relation between two by type same symbols
*/
int compare ( const RankedSymbol & other ) const;
/**
* Print this object as raw representation to ostream.
*
* \param out ostream where to print
* \param instance object to print
*
* \returns modified output stream
*/
friend std::ostream & operator << ( std::ostream & out, const RankedSymbol < SymbolType, RankType > & instance ) {
return out << static_cast < const common::ranked_symbol < SymbolType, RankType > & > ( instance );
}
/**
* Casts this instance to as compact as possible string representation.
*
* \returns string representation of the object
*/
explicit operator std::string ( ) const;
/**
* @copydoc base::CommonBaseMiddle < SymbolBase >::operator ==
*/
using SymbolBase::operator ==;
/**
* @copydoc base::CommonBaseMiddle < SymbolBase >::operator !=
*/
using SymbolBase::operator !=;
/**
* @copydoc base::CommonBaseMiddle < SymbolBase >::operator <
*/
using SymbolBase::operator <;
/**
* @copydoc base::CommonBaseMiddle < SymbolBase >::operator <=
*/
using SymbolBase::operator <=;
/**
* @copydoc base::CommonBaseMiddle < SymbolBase >::operator >
*/
using SymbolBase::operator >;
/**
* @copydoc base::CommonBaseMiddle < SymbolBase >::operator >=
*/
using SymbolBase::operator >=;
};
template < class SymbolType, class RankType >
int RankedSymbol < SymbolType, RankType >::compare(const RankedSymbol& other) const {
return static_cast < const common::ranked_symbol < SymbolType, RankType > & > ( * this ).compare ( static_cast < const common::ranked_symbol < SymbolType, RankType > & > ( other ) );
}
template < class SymbolType, class RankType >
RankedSymbol < SymbolType, RankType >::operator std::string ( ) const {
return ( std::string ) static_cast < const common::ranked_symbol < SymbolType, RankType > & > ( * this );
}
} /* namespace alphabet */
namespace core {
template < class SymbolType, class RankType >
struct normalize < common::ranked_symbol < SymbolType, RankType > > {
static common::ranked_symbol < > eval ( common::ranked_symbol < SymbolType, RankType > && value ) {
return alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( value ) );
}
};
template < class SymbolType, class RankType >
struct normalize < alphabet::RankedSymbol < SymbolType, RankType > > {
static alphabet::RankedSymbol < > eval ( alphabet::RankedSymbol < SymbolType, RankType > && value ) {
return alphabet::RankedSymbol < > ( normalize < common::ranked_symbol < SymbolType, RankType > >::eval ( std::move ( value ) ) );
}
};
} /* namespace core */
#endif /* RANKED_SYMBOL_H_ */
......@@ -25,7 +25,7 @@
#define VARIABLES_BAR_SYMBOL_H_
 
#include "SymbolBase.h"
#include "RankedSymbol.h"
#include <common/ranked_symbol.hpp>
#include <object/Object.h>
 
namespace alphabet {
......@@ -116,11 +116,6 @@ inline common::ranked_symbol < > VariablesBarSymbol::instance < common::ranked_s
return common::ranked_symbol < > ( VariablesBarSymbol::instance < DefaultSymbolType > ( ), DefaultRankType ( 0 ) );
}
 
template < >
inline RankedSymbol < > VariablesBarSymbol::instance < RankedSymbol < > > ( ) {
return RankedSymbol < > ( VariablesBarSymbol::instance < common::ranked_symbol < > > ( ) );
}
} /* namespace alphabet */
 
#endif /* VARIABLES_BAR_SYMBOL_H_ */
......@@ -25,7 +25,7 @@
#define SUBTREE_WILDCARD_SYMBOL_H_
 
#include "SymbolBase.h"
#include "RankedSymbol.h"
#include <common/ranked_symbol.hpp>
#include <object/Object.h>
 
namespace alphabet {
......@@ -116,11 +116,6 @@ inline common::ranked_symbol < > WildcardSymbol::instance < common::ranked_symbo
return common::ranked_symbol < > ( WildcardSymbol::instance < DefaultSymbolType > ( ), DefaultRankType ( 0 ) );
}
 
template < >
inline RankedSymbol < > WildcardSymbol::instance < RankedSymbol < > > ( ) {
return RankedSymbol < > ( WildcardSymbol::instance < common::ranked_symbol < > > ( ) );
}
} /* namespace alphabet */
 
#endif /* SUBTREE_WILDCARD_SYMBOL_H_ */
......@@ -110,4 +110,15 @@ ext::vector < common::ranked_symbol < DefaultSymbolType, DefaultRankType > > Sym
 
} /* namespace alphabet */
 
namespace core {
template < class SymbolType, class RankType >
struct normalize < common::ranked_symbol < SymbolType, RankType > > {
static common::ranked_symbol < > eval ( common::ranked_symbol < SymbolType, RankType > && value ) {
return alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( value ) );
}
};
} /* namespace core */
#endif /* SYMBOL_NORMALIZE_H_ */
......@@ -12,9 +12,9 @@
 
namespace {
 
static auto xmlWrite = registration::XmlWriterRegister < alphabet::RankedSymbol < > > ( );
static auto xmlRead = registration::XmlReaderRegister < alphabet::RankedSymbol < > > ( );
static auto xmlWrite = registration::XmlWriterRegister < common::ranked_symbol < > > ( );
static auto xmlRead = registration::XmlReaderRegister < common::ranked_symbol < > > ( );
 
static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, alphabet::RankedSymbol < > > ( );
static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, common::ranked_symbol < > > ( );
 
} /* namespace */
......@@ -8,7 +8,7 @@
#ifndef _XML_RANKED_SYMBOL_H_
#define _XML_RANKED_SYMBOL_H_
 
#include <alphabet/RankedSymbol.h>
#include <common/ranked_symbol.hpp>
#include <core/xmlApi.hpp>
#include <primitive/xml/Unsigned.h>
 
......@@ -51,34 +51,6 @@ void xmlApi < common::ranked_symbol < T, R > >::compose ( ext::deque < sax::Toke
output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT );
}
 
template < typename T, typename R >
struct xmlApi < alphabet::RankedSymbol < T, R > > {
static alphabet::RankedSymbol < T, R > parse ( ext::deque < sax::Token >::iterator & input );
static bool first ( const ext::deque < sax::Token >::const_iterator & input );
static const std::string & xmlTagName ( );
static void compose ( ext::deque < sax::Token > & output, const alphabet::RankedSymbol < T, R > & data );
};
template < typename T, typename R >
alphabet::RankedSymbol < T, R > xmlApi < alphabet::RankedSymbol < T, R > >::parse ( ext::deque < sax::Token >::iterator & input ) {
return alphabet::RankedSymbol < T, R > ( xmlApi < common::ranked_symbol < T, R > >::parse ( input ) );
}
template < typename T, typename R >
bool xmlApi < alphabet::RankedSymbol < T, R > >::first ( const ext::deque < sax::Token >::const_iterator & input ) {
return xmlApi < common::ranked_symbol < T, R > >::first ( input );
}
template < typename T, typename R >
const std::string & xmlApi < alphabet::RankedSymbol < T, R > >::xmlTagName ( ) {
return xmlApi < common::ranked_symbol < T, R > >::xmlTagName ( );
}
template < typename T, typename R >
void xmlApi < alphabet::RankedSymbol < T, R > >::compose ( ext::deque < sax::Token > & output, const alphabet::RankedSymbol < T, R > & input ) {
xmlApi < common::ranked_symbol < T, R > >::compose ( output, input );
}
} /* namespace core */
 
#endif /* _XML_RANKED_SYMBOL_H_ */
......@@ -8,12 +8,14 @@
#ifndef RAW_RANKED_SYMBOL_H_
#define RAW_RANKED_SYMBOL_H_
 
#include <alib/tuple>
#include <core/normalize.hpp>
#include <sax/FromXMLParserHelper.h>
#include <common/DefaultSymbolType.h>
#include <common/DefaultRankType.h>
 
#include <alib/tuple>
namespace common {
 
/**
......
......@@ -31,7 +31,7 @@
#include <sstream>
 
#include <common/DefaultSymbolType.h>
#include <alphabet/RankedSymbol.h>
#include <common/ranked_symbol.hpp>
 
#include <core/components.hpp>
#include <exception/CommonException.h>
......
......@@ -28,7 +28,7 @@
#include <alib/compare>
#include <sstream>
 
#include <alphabet/RankedSymbol.h>
#include <common/ranked_symbol.hpp>
 
#include <indexes/stringology/PositionHeap.h>
 
......
......@@ -30,7 +30,7 @@
#include <alib/compare>
#include <sstream>
 
#include <alphabet/RankedSymbol.h>
#include <common/ranked_symbol.hpp>
 
#include <core/components.hpp>
#include <exception/CommonException.h>
......
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