Skip to content

Commit

Permalink
Make determinization deterministic by sorting on NFA state id.
Browse files Browse the repository at this point in the history
  • Loading branch information
SharafMohamed committed Jan 30, 2025
1 parent 57cf69b commit ab9c875
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class DetermizationConfiguration {
m_lookahead{std::move(tag_lookahead)} {}

auto operator<(DetermizationConfiguration const& rhs) const -> bool {
if (m_nfa_state != rhs.m_nfa_state) {
return m_nfa_state < rhs.m_nfa_state;
if (m_nfa_state->get_id() != rhs.m_nfa_state->get_id()) {
return m_nfa_state->get_id() < rhs.m_nfa_state->get_id();
}
if (m_tag_id_to_reg_ids != rhs.m_tag_id_to_reg_ids) {
return m_tag_id_to_reg_ids < rhs.m_tag_id_to_reg_ids;
Expand Down
2 changes: 2 additions & 0 deletions src/log_surgeon/finite_automata/NfaState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class NfaState {

[[nodiscard]] auto is_accepting() const -> bool const& { return m_accepting; }

[[nodiscard]] auto get_id() const -> state_id_t { return m_id; }

[[nodiscard]] auto get_matching_variable_id() const -> uint32_t {
return m_matching_variable_id;
}
Expand Down
4 changes: 0 additions & 4 deletions src/log_surgeon/finite_automata/SpontaneousTransition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class SpontaneousTransition {
: m_tag_ops{std::move(tag_ops)},
m_dest_state{dest_state} {}

auto operator<(SpontaneousTransition const& rhs) const -> bool {
return std::tie(m_tag_ops, m_dest_state) < std::tie(rhs.m_tag_ops, rhs.m_dest_state);
}

[[nodiscard]] auto get_tag_ops() const -> std::vector<TagOperation> { return m_tag_ops; }

[[nodiscard]] auto get_dest_state() const -> TypedNfaState const* { return m_dest_state; }
Expand Down

0 comments on commit ab9c875

Please sign in to comment.