Skip to content
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.
/ nfa-to-dfa Public archive

Convert NFA to DFA (json output) from (json input, .nfa file)

License

Notifications You must be signed in to change notification settings

fcannizzaro/nfa-to-dfa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NFA to DFA

logo

npm travis

Convert NFA to DFA (json output) from (json input, .nfa file)

npm

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

About

Convert NFA to DFA (json output) from (json input, .nfa file)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published