regen/Lexer.hpp
/**
     * reads a string containing a regular expression
     * and creates a token list that can be used with the parser
     * 
     * @param str string to read
     * 
     * @return list of tokens in the string
     */
reads a string containing a regular expression
and creates a token list that can be used with the parser

@param str string to read

@return list of tokens in the string
reads a string containing a regular expression and creates a token list that can be used with the parser @param str string to read @return list of tokens in the string
inline TokenList lexer( const std::string& str )
    {
        static const std::set<char> charClassesSet = { 'w', 'd', 's', 't', 'r', 'n', 'v', 'f' };
        TokenList res;
        std::size_t i = 0;
        std::size_t startOfChar = std::string::npos;
        while( i < str.size() )
        {
            if( str[i] == '\\' && i+1 < str.size() )
            {
                ++i;
                if( charClassesSet.count( str[i] ) )
                    res.push_back( Token{Token::CHARCLASS, str[i]} );
                else if( str[i] == 'x' )
                    res.push_back( Token{Token::CHAR, readHexChar(str.substr(i, 3))} );
                else
                    res.push_back( Token{Token::CHAR, str[i]} );
                ++i;
                continue;
            }
            auto tokenType = charToToken( str[i] );
            res.push_back( Token{tokenType, str[i]} );
            ++i;
        }
        return res;
    }
inline TokenList lexer ( const std :: string & str ) { static const std :: set < char > charClassesSet = { ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' } ; TokenList res ; std :: size_t i = 0 ; std :: size_t startOfChar = std :: string :: npos ; while ( i < str . size ( ) ) { if ( str [ i ] == ' \\ ' && i + 1 < str . size ( ) ) { ++ i ; if ( charClassesSet . count ( str [ i ] ) ) res . push_back ( Token { Token :: CHARCLASS , str [ i ] } ) ; else if ( str [ i ] == ' ' ) res . push_back ( Token { Token :: CHAR , readHexChar ( str . substr ( i , 3 ) ) } ) ; else res . push_back ( Token { Token :: CHAR , str [ i ] } ) ; ++ i ; continue ; } auto tokenType = charToToken ( str [ i ] ) ; res . push_back ( Token { tokenType , str [ i ] } ) ; ++ i ; } return res ; }
reads a string containing a regular expression
 and creates a token list that can be used with the parser
reads a string containing a regular expression and creates a token list that can be used with the parser