Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add regex-engine feature to expose NFA and DFA APIs. #17

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions src/dfa/dfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Debug for Transition {
}
}

pub(crate) struct DFA {
pub struct DFA {
start: State,
accept: Vec<State>,
states: Vec<State>,
Expand Down Expand Up @@ -79,7 +79,7 @@ impl Debug for DFA {
}
}

pub(crate) struct DfaSimulator {
pub struct DfaSimulator {
dfa: Rc<DFA>,
current_state: State,
}
Expand Down
11 changes: 7 additions & 4 deletions src/dfa/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
mod dfa;
pub(crate) mod dfa;

pub(crate) use dfa::DfaSimulator;
pub(crate) use dfa::State;
pub(crate) use dfa::DFA;
#[cfg(feature = "regex-engine")]
pub use dfa::DfaSimulator;
#[cfg(feature = "regex-engine")]
pub use dfa::State;
#[cfg(feature = "regex-engine")]
pub use dfa::DFA;
2 changes: 1 addition & 1 deletion src/lexer/lexer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::dfa::{State, DFA};
use crate::dfa::dfa::{State, DFA};
use crate::error_handling::Error::{LexerInputStreamNotSet, LexerInternalErr, LexerStateUnknown};
use crate::error_handling::Result;
use crate::lexer::LexerStream;
Expand Down
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
mod dfa;
pub mod error_handling;
pub mod lexer;
pub mod log_parser;
mod nfa;
pub mod parser;

#[cfg(feature = "regex-engine")]
pub mod dfa;
#[cfg(feature = "regex-engine")]
pub mod nfa;

#[cfg(not(feature = "regex-engine"))]
mod dfa;
#[cfg(not(feature = "regex-engine"))]
mod nfa;

const VERSION: &str = "0.0.1";

pub fn version() -> &'static str {
Expand Down
11 changes: 10 additions & 1 deletion src/nfa/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
pub mod nfa;
pub(crate) mod nfa;

#[cfg(feature = "regex-engine")]
pub use crate::nfa::nfa::State;

#[cfg(feature = "regex-engine")]
pub use crate::nfa::nfa::NFA;

#[cfg(feature = "regex-engine")]
pub use crate::nfa::nfa::Transition;
4 changes: 2 additions & 2 deletions src/nfa/nfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const EPSILON_TRANSITION: u128 = 0x0;
const DOT_TRANSITION: u128 = !EPSILON_TRANSITION;

#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub(crate) struct State(pub usize);
pub struct State(pub usize);

pub struct Transition {
from: State,
Expand Down Expand Up @@ -115,7 +115,7 @@ impl Transition {
}
}

pub(crate) struct NFA {
pub struct NFA {
start: State,
accept: State,
states: Vec<State>,
Expand Down
Loading