Skip to content

Commit

Permalink
small [dead] code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
christianparpart committed Jun 8, 2018
1 parent bd42676 commit 860ecb4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 114 deletions.
17 changes: 17 additions & 0 deletions src/klex/DFA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,23 @@ void DFA::setInitialState(State* s) {
initialState_ = s;
}

void DFA::renumber() {
std::set<State*> registry;
renumber(initialState_, &registry);
}

void DFA::renumber(State* s, std::set<State*>* registry) {
StateId id = registry->size();
VERIFY_STATE_AVAILABILITY(id, *registry);
s->setId(id);
registry->insert(s);
for (const Edge& transition : s->transitions()) {
if (registry->find(transition.state) == registry->end()) {
renumber(transition.state, registry);
}
}
}

struct TransitionTable { // {{{
struct Input {
int configurationNumber;
Expand Down
3 changes: 3 additions & 0 deletions src/klex/DFA.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ class DFA {
//! Releases ownership of internal data structures to the callers responsibility.
std::tuple<OwnedStateSet, State*> release();

void renumber();

private:
void renumber(State* s, std::set<State*>* registry);
State* createState(StateId expectedId);
void setInitialState(State* state);

Expand Down
89 changes: 0 additions & 89 deletions src/klex/fa.cc

This file was deleted.

24 changes: 0 additions & 24 deletions src/klex/fa.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/mklex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int main(int argc, const char* argv[]) {

if (std::string dotfile = flags.getString("fa-dot"); !dotfile.empty()) {
if (flags.getBool("fa-renumber")) {
// TODO dfa.renumber();
dfa.renumber();
}
if (dotfile == "-") {
std::cout << klex::dot({klex::DotGraph{dfa.initialState(), dfa.ownedStates(), "n", ""}}, "", true);
Expand Down

0 comments on commit 860ecb4

Please sign in to comment.