grammar/src/util.hpp
// Counts all occurrences but every char in the string can only be used once to
// match any infix
Counts all occurrences but every char in the string can only be used once to
match any infix
Counts all occurrences but every char in the string can only be used once to match any infix
static inline size_t countInOrder(const string &who,
                                  const vector<string> &infix) {
    size_t c = 0;
    for (size_t i = 0; i < who.size(); i++) {
        for (const auto &inf : infix) {
            if (inf.size() <= who.size() - i) {
                if (who.substr(i, inf.size()) == inf) {
                    c++;
                    i += inf.size() -
                         1; 
                    break;
                }
            }
        }
    }
    return c;
}
static inline size_t countInOrder ( const string & who , const vector < string > & infix ) { size_t c = 0 ; for ( size_t i = 0 ; i < who . size ( ) ; i ++ ) { for ( const auto & inf : infix ) { if ( inf . size ( ) <= who . size ( ) - i ) { if ( who . substr ( i , inf . size ( ) ) == inf ) { c ++ ; i += inf . size ( ) - 1 ; break ; } } } } return c ; }
Counts all occurrences but every char in the string can only be used once to
match any infix
Counts all occurrences but every char in the string can only be used once to match any infix
// The one is incremented in the loop header