1.0.7 • Published 8 years ago
nfa-to-dfa v1.0.7
NFA to DFA
Convert NFA to DFA (json output) from (json input, .nfa file)
Install
npm install nfa-to-dfa
Usage
var nfa = require("nfa-to-dfa");
// create a new NFA with title
nfa.create("Title");
// add state
nfa.addState("Q1")
.loop("c")
.goTo("Q1", "a")
.goTo("Q0", "a");
// get DFA as json
var dfa = nfa.toDfa();
Test
run npm test
(Mocha)
Methods
create(String title)
create NFA
addState(String label)
add a new state
goTo(String state, String character)
add a new transition
loop(String character)
add a loop transition
initial()
set state as "initial"
final()
set state as "final"
readFile(String path)
create an NFA from .nfa file
toString()
return ordered NFA/DFA
toDfa()
return NFA as DFA
Sample .nfa file
nfa : Title
q0 {
start
loop c
goto q2 e
}
q1 {
loop a
goto q0 a
}
q2 {
end
loop y
goto q1 b
}