Skip to content

Commit

Permalink
Merge branch 'use-auto' into refactor-nfa-to-dfa
Browse files Browse the repository at this point in the history
  • Loading branch information
SharafMohamed committed Jan 9, 2025
2 parents 25237a2 + fd394af commit 7fe39db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/log_surgeon/Lalr1Parser.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ auto Lalr1Parser<TypedNfaState, TypedDfaState>::generate_first_sets() -> void {
for (uint32_t const& s : m_terminals) {
m_firsts.insert(std::pair<uint32_t, std::set<uint32_t>>(s, {s}));
}
auto changed = true;
bool changed = true;
while (changed) {
changed = false;
for (auto const& p : m_productions) {
Expand Down Expand Up @@ -329,7 +329,7 @@ auto Lalr1Parser<TypedNfaState, TypedDfaState>::generate_lr1_item_sets() -> void
}
}
}
auto changed = true;
bool changed = true;
while (changed) {
changed = false;
for (auto& kv : m_propagate_map) {
Expand Down Expand Up @@ -405,7 +405,7 @@ auto Lalr1Parser<TypedNfaState, TypedDfaState>::generate_lr1_closure(ItemSet* it
lookaheads.push_back(item.m_lookahead);
}
for (auto* const p : m_non_terminals.at(next_symbol)) {
for (auto const& l : lookaheads) {
for (auto const l : lookaheads) {
queue.emplace_back(p, 0, l);
}
}
Expand Down Expand Up @@ -514,9 +514,9 @@ auto Lalr1Parser<TypedNfaState, TypedDfaState>::get_input_after_last_newline(
std::stack<MatchedSymbol>& parse_stack_matches
) -> std::string {
std::string error_message_reversed;
auto done = false;
bool done = false;
while (!parse_stack_matches.empty() && !done) {
auto top_symbol = std::move(parse_stack_matches.top());
MatchedSymbol top_symbol{std::move(parse_stack_matches.top())};
parse_stack_matches.pop();
std::visit(
Overloaded{
Expand Down Expand Up @@ -552,8 +552,8 @@ template <typename TypedNfaState, typename TypedDfaState>
auto Lalr1Parser<TypedNfaState, TypedDfaState>::get_input_until_next_newline(Token* error_token
) -> std::string {
std::string rest_of_line;
auto next_is_end_token = (error_token->m_type_ids_ptr->at(0) == (uint32_t)SymbolId::TokenEnd);
auto next_has_newline = (error_token->to_string().find('\n') != std::string::npos)
bool next_is_end_token = (error_token->m_type_ids_ptr->at(0) == (uint32_t)SymbolId::TokenEnd);
bool next_has_newline = (error_token->to_string().find('\n') != std::string::npos)
|| (error_token->to_string().find('\r') != std::string::npos);
while (!next_has_newline && !next_is_end_token) {
auto token = get_next_symbol();
Expand All @@ -572,7 +572,7 @@ template <typename TypedNfaState, typename TypedDfaState>
auto Lalr1Parser<TypedNfaState, TypedDfaState>::report_error() -> std::string {
assert(m_next_token == std::nullopt);
assert(!m_parse_stack_matches.empty());
auto top_symbol = std::move(m_parse_stack_matches.top());
MatchedSymbol top_symbol{std::move(m_parse_stack_matches.top())};
m_parse_stack_matches.pop();
auto line_num = get_line_num(top_symbol);
auto token = std::get<Token>(top_symbol);
Expand Down Expand Up @@ -623,7 +623,7 @@ template <typename TypedNfaState, typename TypedDfaState>
auto Lalr1Parser<TypedNfaState, TypedDfaState>::parse(Reader& reader) -> NonTerminal {
reset();
m_parse_stack_states.push(m_root_item_set_ptr);
auto accept = false;
bool accept = false;
while (true) {
m_input_buffer.read_if_safe(reader);
auto next_terminal = get_next_symbol();
Expand All @@ -635,7 +635,7 @@ auto Lalr1Parser<TypedNfaState, TypedDfaState>::parse(Reader& reader) -> NonTerm
throw std::runtime_error(report_error());
}
assert(!m_parse_stack_matches.empty());
auto m = std::move(m_parse_stack_matches.top());
MatchedSymbol m{std::move(m_parse_stack_matches.top())};
m_parse_stack_matches.pop();
assert(m_parse_stack_matches.empty());
return std::move(std::get<NonTerminal>(m));
Expand Down
2 changes: 1 addition & 1 deletion src/log_surgeon/Lexer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ template <typename TypedNfaState, typename TypedDfaState>
auto Lexer<TypedNfaState, TypedDfaState>::increase_buffer_capacity(ParserInputBuffer& input_buffer
) -> void {
uint32_t old_storage_size{0};
auto flipped_static_buffer{false};
bool flipped_static_buffer{false};
input_buffer.increase_capacity(old_storage_size, flipped_static_buffer);
if (old_storage_size < input_buffer.storage().size()) {
if (flipped_static_buffer) {
Expand Down

0 comments on commit 7fe39db

Please sign in to comment.