1.0.7 • Published 8 years ago

nfa-to-dfa v1.0.7

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

NFA to DFA

logo

npm travis

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

sample.nfa

nfa : Title

q0 {
    start
    loop c
    goto q2 e
}

q1 {
    loop a
    goto q0 a
}

q2 {
    end
    loop y
    goto q1 b
}

Sublime Text Syntax Highlight

nfa.tmLanguage

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago