Skip to content

Commit

Permalink
honour some CppCheck remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed May 10, 2023
1 parent 41baac2 commit aec47dd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
28 changes: 14 additions & 14 deletions include/frog/mbma_brackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class BaseBracket {
virtual bool isglue() const { return false; };
virtual icu::UnicodeString put( bool = false ) const;
virtual BaseBracket *append( BaseBracket * ){ abort(); };
virtual bool isNested() { return false; };
virtual bool isNested() const { return false; };
virtual void resolveGlue(){ abort(); };
virtual void resolveLead(){ abort(); };
virtual void resolveTail(){ abort(); };
Expand All @@ -111,7 +111,7 @@ class BaseBracket {
icu::UnicodeString&,
int& ) const = 0;
virtual Compound::Type compound() const { return Compound::Type::NONE; };
virtual Compound::Type getCompoundType() { return compound(); };
virtual Compound::Type speculateCompoundType() { return compound(); };
CLEX::Type tag() const { return cls; };
void setTag( CLEX::Type t ) { cls = t; };
std::vector<CLEX::Type> RightHand;
Expand All @@ -129,24 +129,24 @@ class BracketLeaf: public BaseBracket {
BracketLeaf( const RulePart&, int, TiCC::LogStream& );
BracketLeaf( CLEX::Type, const icu::UnicodeString&, int, TiCC::LogStream& );
~BracketLeaf();
icu::UnicodeString put( bool = false ) const;
icu::UnicodeString morpheme() const {
icu::UnicodeString put( bool = false ) const override;
icu::UnicodeString morpheme() const override {
/// return the value of the morpheme
return morph;
};
icu::UnicodeString inflection() const {
icu::UnicodeString inflection() const override {
/// return the value of the inflexion (if any)
return inflect;
};
icu::UnicodeString original() const {
icu::UnicodeString original() const override {
/// return the original value before processing started
return orig;
};
int infixpos() const {
int infixpos() const override {
/// return the position of an infix
return ifpos;
};
bool isglue() const {
bool isglue() const override {
/// return tre if this is a glue tag
return glue;
};
Expand All @@ -170,23 +170,23 @@ class BracketLeaf: public BaseBracket {
class BracketNest: public BaseBracket {
public:
BracketNest( CLEX::Type, Compound::Type, int, TiCC::LogStream& );
BaseBracket *append( BaseBracket * );
BaseBracket *append( BaseBracket * ) override ;
~BracketNest();
bool isNested() { return true; };
icu::UnicodeString put( bool = false ) const;
bool isNested() const override { return true; };
icu::UnicodeString put( bool = false ) const override;
bool testMatch( std::list<BaseBracket*>& result,
const std::list<BaseBracket*>::iterator& rpos,
std::list<BaseBracket*>::iterator& bpos );
std::list<BaseBracket*>::iterator& bpos ) const;
std::list<BaseBracket*>::iterator glue( std::list<BaseBracket*>&,
const std::list<BaseBracket*>::iterator& );
const std::list<BaseBracket*>::iterator& ) const;
std::list<BaseBracket*>::iterator resolveAffix( std::list<BaseBracket*>&,
const std::list<BaseBracket*>::iterator& );
void resolveGlue();
void resolveNouns();
void resolveLead();
void resolveTail();
void resolveMiddle();
Compound::Type getCompoundType();
Compound::Type speculateCompoundType();
CLEX::Type getFinalTag();
folia::Morpheme *createMorpheme( folia::Document *,
const std::string& ) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/FrogData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ ostream& operator<<( ostream& os, const frog_record& fr ){
return os;
}

frog_record merge( frog_data& fd, size_t start, size_t finish ){
frog_record merge( const frog_data& fd, size_t start, size_t finish ){
/// merge a range of records of a frog_data structure into a new one
/*!
\param fd the frog_data structure
Expand Down
17 changes: 9 additions & 8 deletions src/mbma_brackets.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ ostream& operator<< ( ostream& os, const BaseBracket *c ){

bool BracketNest::testMatch( list<BaseBracket*>& result,
const list<BaseBracket*>::iterator& rpos,
list<BaseBracket*>::iterator& bpos ){
list<BaseBracket*>::iterator& bpos ) const {
/// test if the rule matches at a certain position
/*!
\param result the current result. A new match will be appended
Expand Down Expand Up @@ -554,10 +554,10 @@ Compound::Type construct( const CLEX::Type tag1, const CLEX::Type tag2 ){
return construct( v );
}

Compound::Type BracketNest::getCompoundType(){
Compound::Type BracketNest::speculateCompoundType() {
/// extract the Compound::Type
/*!
This function uses a lot of heuristics to determine get Compound::Type
This function uses a lot of heuristics to determine the Compound::Type
given the elements in the BracketNest
*/
if ( debugFlag > 5 ){
Expand All @@ -567,7 +567,7 @@ Compound::Type BracketNest::getCompoundType(){
Compound::Type compound = Compound::Type::NONE;
if ( parts.size() == 1 ){
auto part = *parts.begin();
compound = part->getCompoundType();
compound = part->speculateCompoundType();
}
else if ( parts.size() == 2 ){
auto it = parts.begin();
Expand Down Expand Up @@ -1047,7 +1047,8 @@ void display_parts( ostream& os, const list<BaseBracket*>& parts,
int indent=0 ){
int i=1;
for ( const auto& it : parts ){
os << string(indent,' ') << "[" << i++ << "]= " << (void*)it << endl;
os << string(indent,' ') << "[" << i++ << "]= "
<< static_cast<void*>(it) << endl;
if ( it->isNested() ){
display_parts( os, dynamic_cast<BracketNest*>(it)->parts, indent + 4 );
}
Expand Down Expand Up @@ -1098,7 +1099,7 @@ list<BaseBracket*>::iterator BracketNest::resolveAffix( list<BaseBracket*>& resu
if ( debugFlag > 5 ){
LOG << "new node:" << tmp << endl;
}
_compound = tmp->getCompoundType();
_compound = tmp->speculateCompoundType();
result.insert( ++bit, tmp );
return bit;
}
Expand Down Expand Up @@ -1156,7 +1157,7 @@ void BracketNest::resolveNouns( ){
}

list<BaseBracket*>::iterator BracketNest::glue( list<BaseBracket*>& result,
const list<BaseBracket*>::iterator& rpos ){
const list<BaseBracket*>::iterator& rpos ) const {
/// apply a glue rule
if ( debugFlag > 5 ){
LOG << "glue " << endl;
Expand Down Expand Up @@ -1331,7 +1332,7 @@ void BracketNest::resolveMiddle(){
}
}

CLEX::Type BracketNest::getFinalTag() {
CLEX::Type BracketNest::getFinalTag(){
/// get the result tag for this rule
// It is the last tag in the list, except for 'P' tags
//
Expand Down
2 changes: 1 addition & 1 deletion src/mbma_mod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ void Mbma::filterSubTags( const vector<UnicodeString>& feats ){
void Mbma::assign_compounds(){
/// add compound information to the result
for ( auto const& sit : analysis ){
sit->compound = sit->brackets->getCompoundType();
sit->compound = sit->brackets->speculateCompoundType();
}
}

Expand Down

0 comments on commit aec47dd

Please sign in to comment.