Home

Awesome

RE2EPSNFA: A tranform function to translate RE to Epsilon-NFA (Epsilon-Nondeterministic finite automaton)

GitHub license GoDoc Build Status

image

What is this package

re2epsnfa (Regular Expression to Eplison-NFA) will help you to convert regular expression string to epsilon-NFA object.

####The convert rule base on three simple rule:

image

union: ex: A union B

image

concatenation: ex: A concatenation B

image

closure: ex: Closure(A)

What is Epsilon-Nondeterministic finite automaton

ε-NFA: Epsilon-Nondeterministic finite automaton (so call:Nondeterministic finite automaton with ε-moves)

In the automata theory, a nondeterministic finite automaton with ε-moves (NFA-ε)(also known as NFA-λ) is an extension of nondeterministic finite automaton(NFA), which allows a transformation to a new state without consuming any input symbols. The transitions without consuming an input symbol are called ε-transitions or λ-transitions. In the state diagrams, they are usually labeled with the Greek letter ε or λ.

(sited from here)

Installation and Usage

Install

go get github.com/kkdai/re2epsnfa

Usage

Following is sample code to implement a epsilon-NFA automata diagram as follow:


package main

import (
    "github.com/kkdai/re2epsnfa"
)

func main() {

	trans := NewRe2EpsNFA("(0+1.0)*.(e+1)")
	trans.StartParse()
	enfa := trans.GetEpsNFA()
	enfa.PrintTransitionTable()

}

Inspired By

Project52

It is one of my project 52.

License

This package is licensed under MIT license. See LICENSE for details.