-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Add support for converting multiple NFAs into one DFA. #7
Conversation
accept: Vec<State>, | ||
states: HashSet<State>, | ||
transitions: HashMap<State, HashMap<char, Transition>>, // from_state -> symbol -> to_state | ||
dfa_to_accepted_nfa_state_mapping: Option<HashMap<State, Vec<(usize, crate::nfa::nfa::State)>>>, // to determine which NFA gets matched |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why cargo fmt
doesn't work, but this line exceeds the 100-char limit, right? Can we put the comment in a separate line before this line? (It's hard to navigate long lines without using mouse, lol)
|
||
// Helper functions for converting multiple NFAs to a single DFA | ||
impl DFA { | ||
fn epsilon_closure( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Shouldn't this be a part of NFA?
use std::process::id; | ||
|
||
#[derive(Clone, Debug, Eq, Hash, PartialEq)] | ||
struct State(String); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the state to be a string?
); | ||
} | ||
|
||
fn simulate(&self, input: &str) -> (Option<HashSet<usize>>, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a different API that takes char by char since the lexer emits chars as tokens, we don't know the size of string in advance.
In this way, we might also need an API to reset the current simulation state.
src/dfa/dfa.rs
Outdated
start: State, | ||
accept: Vec<State>, | ||
states: HashSet<State>, | ||
transitions: HashMap<State, HashMap<char, Transition>>, // from_state -> symbol -> to_state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, there's a performance concern in this part; shall we add a TODO to keep track of the issue?
Description
Validation performed