Skip to content

Commit

Permalink
SA updates
Browse files Browse the repository at this point in the history
  • Loading branch information
BenHanson committed Mar 1, 2024
1 parent 3097246 commit fcf7b25
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
4 changes: 2 additions & 2 deletions include/lexertl/parser/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ namespace lexertl
}

void insert_range(const string_token& token_,
const string_token& token2_, string_token_vector data_[2])
const string_token& token2_, string_token_vector data_[2]) const
{
auto iter_ = std::find_if(data_[0].cbegin(), data_[0].cend(),
[&token_](const std::unique_ptr<string_token>& rhs_)
Expand Down Expand Up @@ -648,7 +648,7 @@ namespace lexertl

void insert_range(const string_token& token_,
const string_token& token2_, const string_token& token3_,
string_token_vector data_[3])
string_token_vector data_[3]) const
{
auto iter_ = data_[0].cbegin();
auto end_ = data_[0].cend();
Expand Down
38 changes: 20 additions & 18 deletions include/lexertl/parser/tokeniser/re_tokeniser_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ namespace lexertl
static void alnum_alpha(state_type& state_, string_token& token_,
const bool negate_)
{
enum { unknown, alnum, alpha };
std::size_t type_ = unknown;
enum class type { unknown, alnum, alpha };
type type_ = type::unknown;

state_.increment();

Expand All @@ -527,7 +527,7 @@ namespace lexertl
if (!state_.eos() && *state_._curr == 'm')
{
state_.increment();
type_ = alnum;
type_ = type::alnum;
}
}
}
Expand All @@ -542,14 +542,14 @@ namespace lexertl
if (!state_.eos() && *state_._curr == 'a')
{
state_.increment();
type_ = alpha;
type_ = type::alpha;
}
}
}
}
}

if (type_ == unknown)
if (type_ == type::unknown)
{
unknown_posix(state_);
}
Expand All @@ -559,7 +559,7 @@ namespace lexertl

check_posix_termination(state_);

if (type_ == alnum)
if (type_ == type::alnum)
{
// alnum
str_ = sizeof(input_char_type) == 1 ?
Expand All @@ -578,7 +578,7 @@ namespace lexertl
}
}

static std::string make_alnum(std::locale& locale_)
static std::string make_alnum(const std::locale& locale_)
{
std::string str_(1, '[');

Expand All @@ -595,7 +595,7 @@ namespace lexertl
return str_;
}

static std::string make_alpha(std::locale& locale_)
static std::string make_alpha(const std::locale& locale_)
{
std::string str_(1, '[');

Expand Down Expand Up @@ -768,7 +768,7 @@ namespace lexertl
}
}

static std::string create_lower(std::locale& locale_)
static std::string create_lower(const std::locale& locale_)
{
std::string str_(1, '[');

Expand All @@ -789,8 +789,8 @@ namespace lexertl
static void print_punct(state_type& state_, string_token& token_,
const bool negate_)
{
enum { unknown, print, punct };
std::size_t type_ = unknown;
enum class type { unknown, print, punct };
type type_ = type::unknown;

state_.increment();

Expand All @@ -811,7 +811,7 @@ namespace lexertl
if (!state_.eos() && *state_._curr == 't')
{
state_.increment();
type_ = print;
type_ = type::print;
}
}
}
Expand All @@ -831,14 +831,14 @@ namespace lexertl
if (!state_.eos() && *state_._curr == 't')
{
state_.increment();
type_ = punct;
type_ = type::punct;
}
}
}
}
}

if (type_ == unknown)
if (type_ == type::unknown)
{
unknown_posix(state_);
}
Expand All @@ -848,7 +848,7 @@ namespace lexertl

check_posix_termination(state_);

if (type_ == print)
if (type_ == type::print)
{
// print
str_ = sizeof(input_char_type) == 1 ?
Expand Down Expand Up @@ -929,7 +929,7 @@ namespace lexertl
}
}

static std::string create_upper(std::locale& locale_)
static std::string create_upper(const std::locale& locale_)
{
std::string str_(1, '[');

Expand Down Expand Up @@ -1082,6 +1082,8 @@ namespace lexertl
case 'W':
str_ = "[^_0-9A-Za-z]";
break;
default:
break;
}

if (str_)
Expand Down Expand Up @@ -1344,9 +1346,9 @@ namespace lexertl
ch_ = *state_._curr;

// Don't consume invalid chars!
if (((ch_ >= '0' && ch_ <= '9') ||
if ((ch_ >= '0' && ch_ <= '9') ||
(ch_ >= 'a' && ch_ <= 'f') ||
(ch_ >= 'A' && ch_ <= 'F')))
(ch_ >= 'A' && ch_ <= 'F'))
{
state_.increment();
}
Expand Down
2 changes: 1 addition & 1 deletion include/lexertl/partition/equivset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace lexertl
}

private:
void process_greedy(basic_equivset& rhs_, basic_equivset& overlap_)
void process_greedy(basic_equivset& rhs_, basic_equivset& overlap_) const
{
if (_greedy)
overlap_._greedy = true;
Expand Down
4 changes: 3 additions & 1 deletion include/lexertl/rules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ namespace lexertl
case '+':
lhs_->_str.insert(rhs_._str);
break;
default:
break;
}

diff_ = 0;
Expand Down Expand Up @@ -738,7 +740,7 @@ namespace lexertl
}
}

void reverse(token_vector& vector_)
void reverse(token_vector& vector_) const
{
token_vector new_vector_(vector_.size(), token());
auto iter_ = vector_.rbegin();
Expand Down

0 comments on commit fcf7b25

Please sign in to comment.