Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ad30714
Change concept of tagged transitions to spontaenous transitions.
SharafMohamed Feb 13, 2025
8d8e5ee
Fix typo.
SharafMohamed Feb 13, 2025
5c01aa3
Return by reference; Fix docstring.
SharafMohamed Feb 13, 2025
f695c56
Rename method to new_state_from_negative_captures for clarity.
SharafMohamed Feb 13, 2025
fc1ef67
Update docstring of new_state_from_negative_captures.
SharafMohamed Feb 13, 2025
dbd6d2c
Rename to new_start_and_end_states_from_positive_capture.
SharafMohamed Feb 13, 2025
cd7e3a9
Update spontaneous doc strings.
SharafMohamed Feb 13, 2025
43c1764
Update Nfa::Serialize docstring.
SharafMohamed Feb 13, 2025
f42e341
Clean up NfaState; Fix double declaration of tag_id_t.
SharafMohamed Feb 13, 2025
563a619
Clean up Nfa.hpp.
SharafMohamed Feb 13, 2025
c55b5b3
Remove overload of add_spontaneous_transitions; Fix compiler errors t…
SharafMohamed Feb 13, 2025
eb10e95
Use uniform initialization.
SharafMohamed Feb 13, 2025
ad23402
Clang-tidy.
SharafMohamed Feb 13, 2025
452b6b4
Add const.
SharafMohamed Feb 13, 2025
04a65c2
Fix typo.
SharafMohamed Feb 13, 2025
abc1006
Add noexcept; Add None case.
SharafMohamed Feb 13, 2025
7967082
Fix docstring.
SharafMohamed Feb 13, 2025
9cafc39
Remove noexcept.
SharafMohamed Feb 13, 2025
01b4698
Rename to NfaSpontaneousTransition.hpp.
SharafMohamed Feb 14, 2025
2a0d573
Removing unused constructor.
SharafMohamed Feb 14, 2025
a454838
Add ticks for var in return field.
SharafMohamed Feb 14, 2025
472b674
Add [nodiscard] to comparator methods.
SharafMohamed Feb 14, 2025
35fbcbd
Refactor serialize.
SharafMohamed Feb 14, 2025
8a1fe9e
Remove None from TagOperationType; Add default case.
SharafMohamed Feb 14, 2025
3f8e6fb
Change find to at.
SharafMohamed Feb 14, 2025
3c611ef
Fix at call.
SharafMohamed Feb 14, 2025
9ccd118
Fix cmake order.
SharafMohamed Feb 14, 2025
c9464ab
Clang tidy fixes for TDFA related files.
SharafMohamed Feb 14, 2025
3c5de6a
Merge branch 'main' into raii-accepting-state
SharafMohamed Feb 16, 2025
6535d53
Update src/log_surgeon/finite_automata/Nfa.hpp
SharafMohamed Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/log_surgeon/LexicalRule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ class LexicalRule {

template <typename TypedNfaState>
void LexicalRule<TypedNfaState>::add_to_nfa(finite_automata::Nfa<TypedNfaState>* nfa) const {
auto* end_state = nfa->new_state();
end_state->set_accepting(true);
end_state->set_matching_variable_id(m_variable_id);
auto* end_state = nfa->new_accepting_state(m_variable_id);
m_regex->add_to_nfa_with_negative_captures(nfa, end_state);
}
} // namespace log_surgeon
Expand Down
13 changes: 13 additions & 0 deletions src/log_surgeon/finite_automata/Nfa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class Nfa {
*/
[[nodiscard]] auto new_state() -> TypedNfaState*;

/*
* @param matching_variable_id The id for the variable matched by this state.
* @return A pointer to the newly created accepting NFA state.
*/
[[nodiscard]] auto new_accepting_state(uint32_t matching_variable_id) -> TypedNfaState*;

/**
* @param captures A vector containing the captures of all alternate paths.
* @param dest_state The destination state to arrive at after negating the captures.
Expand Down Expand Up @@ -137,6 +143,13 @@ auto Nfa<TypedNfaState>::new_state() -> TypedNfaState* {
return m_states.back().get();
}

template <typename TypedNfaState>
auto Nfa<TypedNfaState>::new_accepting_state(uint32_t const matching_variable_id
) -> TypedNfaState* {
m_states.emplace_back(std::make_unique<TypedNfaState>(matching_variable_id));
return m_states.back().get();
}

template <typename TypedNfaState>
auto Nfa<TypedNfaState>::new_state_from_negative_captures(
std::vector<Capture const*> const& captures,
Expand Down
12 changes: 5 additions & 7 deletions src/log_surgeon/finite_automata/NfaState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ class NfaState {
public:
using Tree = UnicodeIntervalTree<NfaState*>;

NfaState() = default;
explicit NfaState() {}

NfaState(uint32_t const matching_variable_id)
: m_accepting{true},
m_matching_variable_id{matching_variable_id} {}

NfaState(
TagOperationType const op_type,
Expand All @@ -47,12 +51,6 @@ class NfaState {
add_spontaneous_transition(op_type, tag_ids, dest_state);
}

auto set_accepting(bool const accepting) -> void { m_accepting = accepting; }

auto set_matching_variable_id(uint32_t const variable_id) -> void {
m_matching_variable_id = variable_id;
}

auto add_spontaneous_transition(NfaState const* dest_state) -> void {
m_spontaneous_transitions.emplace_back(std::vector<TagOperation>{}, dest_state);
}
Expand Down
Loading