Commit 77750ffe authored by Ing. Jan Trávníček's avatar Ing. Jan Trávníček

common: remove not needed casts add missing virtual destructors

parent ab479290
......@@ -19,6 +19,8 @@ namespace equations {
template < class TerminalSymbolType, class VariableSymbolType >
class RegularEquationSolver {
public:
virtual ~RegularEquationSolver ( ) noexcept = default;
/**
* Adds nonterminal symbol into system.
*
......
......@@ -108,7 +108,7 @@ struct Node {
Node * nextChild = child;
for ( size_t i = 0; i < rank; i++ ) {
children.emplace_back ( ext::tree < DefaultSymbolType > ( nextChild->createUnrankedNode ( ) ) );
children.emplace_back ( nextChild->createUnrankedNode ( ) );
nextChild = nextChild->right;
}
......@@ -123,7 +123,7 @@ struct Node {
Node * nextChild = child;
for ( size_t i = 0; i < rank; i++ ) {
children.emplace_back ( ext::tree < DefaultSymbolType > ( nextChild->createUnrankedPatternNode ( ) ) );
children.emplace_back ( nextChild->createUnrankedPatternNode ( ) );
nextChild = nextChild->right;
}
......@@ -136,7 +136,7 @@ struct Node {
Node * nextChild = child;
for ( size_t i = 0; i < rank; i++ ) {
children.emplace_back ( ext::tree < common::ranked_symbol < > > ( nextChild->createRankedNode ( ) ) );
children.emplace_back ( nextChild->createRankedNode ( ) );
nextChild = nextChild->right;
}
......@@ -151,7 +151,7 @@ struct Node {
Node * nextChild = child;
for ( size_t i = 0; i < rank; i++ ) {
children.emplace_back ( ext::tree < common::ranked_symbol < > > ( nextChild->createRankedPatternNode ( ) ) );
children.emplace_back ( nextChild->createRankedPatternNode ( ) );
nextChild = nextChild->right;
}
......@@ -170,7 +170,7 @@ struct Node {
Node * nextChild = child;
for ( size_t i = 0; i < rank; i++ ) {
children.emplace_back ( ext::tree < common::ranked_symbol < > > ( nextChild->createRankedNonlinearPatternNode ( singleNonlinearVariable ) ) );
children.emplace_back ( nextChild->createRankedNonlinearPatternNode ( singleNonlinearVariable ) );
nextChild = nextChild->right;
}
......
......@@ -63,10 +63,10 @@ TEST_CASE ( "Automata Concatenation", "[unit][algo][automaton][transform]" ) {
m3.addTransition(q0b, b, q0b);
m3.setFinalStates({q2b});
auto u11 = automaton::transform::AutomataConcatenationEpsilonTransition::concatenation(automaton::NFA<>(automaton::DFA<>(m1)), automaton::NFA < > (m2));
auto u12 = automaton::transform::AutomataConcatenationEpsilonTransition::concatenation(automaton::DFA<>(m1), automaton::DFA<>(m2));
auto u21 = automaton::transform::AutomataConcatenation::concatenation(automaton::NFA<>(automaton::DFA<>(m1)), automaton::NFA < > (m2));
auto u22 = automaton::transform::AutomataConcatenation::concatenation(automaton::DFA<>(m1), automaton::DFA<>(m2));
auto u11 = automaton::transform::AutomataConcatenationEpsilonTransition::concatenation(automaton::NFA<>(m1), automaton::NFA < > (m2));
auto u12 = automaton::transform::AutomataConcatenationEpsilonTransition::concatenation(m1, m2);
auto u21 = automaton::transform::AutomataConcatenation::concatenation(automaton::NFA<>(m1), automaton::NFA < > (m2));
auto u22 = automaton::transform::AutomataConcatenation::concatenation(m1, m2);
automaton::DFA < DefaultSymbolType, unsigned > umdfa (automaton::simplify::Normalize::normalize(automaton::simplify::Trim::trim(automaton::simplify::MinimizeBrzozowski::minimize(automaton::simplify::EpsilonRemoverIncoming::remove(m3)))));
automaton::DFA < DefaultSymbolType, unsigned > umdfa11(automaton::simplify::Normalize::normalize(automaton::simplify::Trim::trim(automaton::simplify::MinimizeBrzozowski::minimize(automaton::simplify::EpsilonRemoverIncoming::remove(u11)))));
......
......@@ -19,7 +19,7 @@ public:
CommandResult run ( Environment & environment ) const override {
std::shared_ptr < abstraction::Value > value = m_expr->translateAndEval ( environment );
if ( value->getType ( ) == std::string ( ext::to_string < void > ( ) ) )
if ( value->getType ( ) == ext::to_string < void > ( ) )
throw std::invalid_argument ( "Printing void is not allowed." );
std::shared_ptr < abstraction::OperationAbstraction > res = abstraction::Registry::getValuePrinterAbstraction ( value->getType ( ) );
......
......@@ -61,6 +61,7 @@ protected:
*/
class Visitor {
public:
virtual ~Visitor ( ) noexcept = default;
virtual void visit ( const FormalRegExpAlternation < SymbolType > & ) = 0;
virtual void visit ( const FormalRegExpConcatenation < SymbolType > & ) = 0;
virtual void visit ( const FormalRegExpIteration < SymbolType > & ) = 0;
......
......@@ -61,6 +61,7 @@ protected:
*/
class Visitor {
public:
virtual ~Visitor ( ) noexcept = default;
virtual void visit ( const UnboundedRegExpAlternation < SymbolType > & ) = 0;
virtual void visit ( const UnboundedRegExpConcatenation < SymbolType > & ) = 0;
virtual void visit ( const UnboundedRegExpIteration < SymbolType > & ) = 0;
......@@ -74,6 +75,7 @@ protected:
*/
class RvalueVisitor {
public:
virtual ~RvalueVisitor ( ) noexcept = default;
virtual void visit ( UnboundedRegExpAlternation < SymbolType > && ) = 0;
virtual void visit ( UnboundedRegExpConcatenation < SymbolType > && ) = 0;
virtual void visit ( UnboundedRegExpIteration < SymbolType > && ) = 0;
......
......@@ -53,6 +53,7 @@ protected:
*/
class ConstVisitor {
public:
virtual ~ConstVisitor ( ) noexcept = default;
virtual void visit ( const FormalRTEAlternation < SymbolType > & alternation ) = 0;
virtual void visit ( const FormalRTEIteration < SymbolType > & iteration ) = 0;
virtual void visit ( const FormalRTESubstitution < SymbolType > & substitution ) = 0;
......@@ -63,6 +64,7 @@ protected:
class Visitor {
public:
virtual ~Visitor ( ) noexcept = default;
virtual void visit ( FormalRTEAlternation < SymbolType > & alternation ) = 0;
virtual void visit ( FormalRTEIteration < SymbolType > & iteration ) = 0;
virtual void visit ( FormalRTESubstitution < SymbolType > & substitution ) = 0;
......
......@@ -208,7 +208,7 @@ SECTION ( "Extended NFA Alphabet" ) {
goodConcat2.appendElement(regexp::UnboundedRegExpSymbol < char > ('b'));
badConcat.appendElement(regexp::UnboundedRegExpSymbol < char > ('b'));
badConcat.appendElement(regexp::UnboundedRegExpSymbol < char > (char('d')));
badConcat.appendElement(regexp::UnboundedRegExpSymbol < char > ('d'));
CHECK_THROWS_AS(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (badConcat), 1), automaton::AutomatonException);
CHECK_NOTHROW(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (goodConcat1), 1));
......
......@@ -78,7 +78,7 @@ TEST_CASE ( "Trees test", "[unit][data][tree]" ) {
ext::tree < common::ranked_symbol < > > node = prefixToNode(s, itmp);
ext::set<common::ranked_symbol < >> al;
for ( unsigned i = 0; i < s.length ( ); i += 2 )
al.insert ( common::ranked_symbol < > ( DefaultSymbolType ( s [ i ] ), static_cast < int > ( s [ i + 1 ] - '0' ) ) );
al.insert ( common::ranked_symbol < > ( DefaultSymbolType ( s [ i ] ), s [ i + 1 ] - '0' ) );
tree::RankedTree < > t(al, std::move(node));
INFO ( factory::XmlDataFactory::toString(t) );
......
#include "string.hpp"
#include <sstream>
#include <exception>
#include <limits>
namespace ext {
......@@ -77,7 +79,11 @@ long long from_string ( const std::string & value ) {
template < >
unsigned from_string ( const std::string & value ) {
return std::stoul ( value );
unsigned long result = std::stoul ( value );
if ( result > std::numeric_limits < unsigned >::max ( ) ) {
throw std::out_of_range ( "stou" );
}
return static_cast < unsigned > ( result );
}
template < >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment