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

some more cppcheck issues

parent 35ecea47
No related branches found
No related tags found
1 merge request!111Merge jt
......@@ -131,7 +131,6 @@ automaton::NFTA < SymbolType, unsigned > RandomTreeAutomatonFactory::LeslieConne
 
ext::deque<bool> VStates;
ext::deque<unsigned> Q;
size_t unvisited;
 
automaton::NFTA < SymbolType, unsigned > automaton;
 
......@@ -149,16 +148,16 @@ automaton::NFTA < SymbolType, unsigned > RandomTreeAutomatonFactory::LeslieConne
} else if( n == 1 ) {
automaton.addTransition( nullaryAlphabet[ ext::random_devices::semirandom() % nullaryAlphabet.size( ) ], ext::vector < unsigned > { }, Q[ 0 ] );
 
unvisited = 0;
VStates[ 0 ] = true;
} else {
unsigned x = ext::random_devices::semirandom() % n;
automaton.addTransition( nullaryAlphabet[ ext::random_devices::semirandom() % nullaryAlphabet.size( ) ], ext::vector < unsigned > { }, Q[ x ] );
unvisited = n - 1;
 
VStates[ x ] = true;
}
 
size_t unvisited = n - 1;
while( unvisited != 0 ) {
int c = ext::random_devices::semirandom() % alphabet.size( );
ext::vector < unsigned > from;
......
......@@ -82,11 +82,14 @@ ext::set < UnboundedRegExpSymbol < SymbolType > > GlushkovFollow::follow ( const
 
template < class SymbolType >
ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > GlushkovFollow::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpAlternation < SymbolType > & node, const regexp::UnboundedRegExpSymbol < SymbolType > & symbolptr ) {
for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) )
if ( element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbolptr ) )
return element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFollow::Unbounded < SymbolType > > ( symbolptr );
auto iter = std::find_if ( node.getElements ( ).begin ( ), node.getElements ( ).end ( ), [ & ] ( const UnboundedRegExpElement < SymbolType > & element ) {
return element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbolptr );
} );
 
throw exception::CommonException ( "GlushkovFollow::Unbounded < SymbolType >::visit(Alt)" );
if ( iter == node.getElements ( ).end ( ) )
throw exception::CommonException ( "GlushkovFollow::Unbounded < SymbolType >::visit(Alt)" );
return iter->template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFollow::Unbounded < SymbolType > > ( symbolptr );
}
 
template < class SymbolType >
......
......@@ -52,20 +52,16 @@ bool GlushkovPos::pos ( const UnboundedRegExpSymbol < SymbolType > & symbol, con
 
template < class SymbolType >
bool GlushkovPos::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpAlternation < SymbolType > & node, const regexp::UnboundedRegExpSymbol < SymbolType > & symbol ) {
for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) )
if ( element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbol ) )
return true;
return false;
return std::any_of ( node.getElements ( ).begin ( ), node.getElements ( ).end ( ), [ & ] ( const UnboundedRegExpElement < SymbolType > & element ) {
return element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbol );
} );
}
 
template < class SymbolType >
bool GlushkovPos::Unbounded < SymbolType >::visit ( const regexp::UnboundedRegExpConcatenation < SymbolType > & node, const regexp::UnboundedRegExpSymbol < SymbolType > & symbol ) {
for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) )
if ( element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbol ) )
return true;
return false;
return std::any_of ( node.getElements ( ).begin ( ), node.getElements ( ).end ( ), [ & ] ( const UnboundedRegExpElement < SymbolType > & element ) {
return element.template accept < bool, GlushkovPos::Unbounded < SymbolType > > ( symbol );
} );
}
 
template < class SymbolType >
......
......@@ -127,22 +127,16 @@ bool RegExpEmpty::languageIsEmpty(const regexp::UnboundedRegExp < SymbolType > &
 
template < class SymbolType >
bool RegExpEmpty::Unbounded< SymbolType >::visit(const regexp::UnboundedRegExpAlternation < SymbolType > & alternation) {
for(const UnboundedRegExpElement < SymbolType > & element : alternation.getElements()) {
if(! element.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( ) ) {
return false;
}
}
return true;
return std::all_of ( alternation.getElements ( ).begin ( ), alternation.getElements ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & element ) {
return element.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( );
} );
}
 
template < class SymbolType >
bool RegExpEmpty::Unbounded< SymbolType >::visit(const regexp::UnboundedRegExpConcatenation < SymbolType > & concatenation) {
for(const UnboundedRegExpElement < SymbolType > & element : concatenation.getElements()) {
if( element.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( ) ) {
return true;
}
}
return false;
return std::any_of ( concatenation.getElements ( ).begin ( ), concatenation.getElements ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & element ) {
return element.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( );
} );
}
 
template < class SymbolType >
......
......@@ -126,20 +126,16 @@ bool RegExpEpsilon::languageContainsEpsilon(const regexp::UnboundedRegExp < Symb
 
template < class SymbolType >
bool RegExpEpsilon::Unbounded < SymbolType >::visit(const regexp::UnboundedRegExpAlternation < SymbolType > & alternation) {
for ( const UnboundedRegExpElement < SymbolType > & element : alternation.getElements ( ) )
if ( element.template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( ) )
return true;
return false;
return std::any_of ( alternation.getElements ( ).begin ( ), alternation.getElements ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & element ) {
return element.template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( );
} );
}
 
template < class SymbolType >
bool RegExpEpsilon::Unbounded < SymbolType >::visit(const regexp::UnboundedRegExpConcatenation < SymbolType > & concatenation) {
for ( const UnboundedRegExpElement < SymbolType > & element : concatenation.getElements ( ) )
if ( ! element.template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( ) )
return false;
return true;
return std::all_of ( concatenation.getElements ( ).begin ( ), concatenation.getElements ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & element ) {
return element.template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( );
} );
}
 
template < class SymbolType >
......
......@@ -59,11 +59,9 @@ template < class SymbolType >
bool GlushkovPos::Formal < SymbolType >::visit ( const rte::FormalRTESymbolAlphabet < SymbolType > & node, const common::ranked_symbol < SymbolType > & symbolF ) {
if ( symbolF == node.getSymbol ( ) ) return true;
 
for ( const rte::FormalRTEElement < SymbolType > & element : node.getElements ( ) )
if ( element.template accept < bool, GlushkovPos::Formal < SymbolType > > ( symbolF ) )
return true;
return false;
return std::any_of ( node.getElements ( ).begin ( ), node.getElements ( ).end ( ), [ & ] ( const rte::FormalRTEElement < SymbolType > & element ) {
return element.template accept < bool, GlushkovPos::Formal < SymbolType > > ( symbolF );
} );
}
 
template < class SymbolType >
......
......@@ -53,11 +53,14 @@ std::shared_ptr < abstraction::OperationAbstraction > XmlContainerParserRegistry
if ( group == getEntries ( ).end ( ) )
throw exception::CommonException ( "Entry " + container + " not available" );
 
for ( const ext::pair < std::string, std::unique_ptr < Entry > > & entry : group->second )
if ( ext::is_same_type ( type, ext::erase_template_info ( entry.first ) ) )
return entry.second->getAbstraction ( );
auto iter = std::find_if ( group->second.begin ( ), group->second.end ( ), [ & ] ( const ext::pair < std::string, std::unique_ptr < Entry > > & entry ) {
return ext::is_same_type ( type, ext::erase_template_info ( entry.first ) );
} );
if ( iter == group->second.end ( ) )
throw exception::CommonException ( "Entry for " + container + " parametrized with " + type + " not available." );
 
throw exception::CommonException ( "Entry for " + container + " parametrized with " + type + " not available." );
return iter->second->getAbstraction ( );
}
 
ext::set < std::string > XmlContainerParserRegistry::listOverloads ( const std::string & container ) {
......
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