RE2EPSNFA: A tranform function to translate RE to Epsilon-NFA (Epsilon-Nondeterministic finite automaton)
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:
union
: ex: A union B
concatenation
: ex: A concatenation B
closure
: ex: Closure(A)
ε-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)
go get github.com/kkdai/re2epsnfa
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()
}
- ε-NFA: Wiki
- Coursera: Automata
- PDA: Constructing �-NFA’s From Regular Expressions
- Youtube: Regular Expression to NFA
It is one of my project 52.
This package is licensed under MIT license. See LICENSE for details.