More Kleene star fixes
This commit is contained in:
8
main.go
8
main.go
@@ -143,7 +143,8 @@ func thompson(re string) *State {
|
||||
s2 := pop(&nfa)
|
||||
s3 := State{}
|
||||
s3.transitions = make(map[int][]*State)
|
||||
s3.output = append(s3.output, s1, s2)
|
||||
s3.output = append(s3.output, s1.output...)
|
||||
s3.output = append(s3.output, s2.output...)
|
||||
s3.transitions[s1.content] = append(s3.transitions[s1.content], s1)
|
||||
s3.transitions[s2.content] = append(s3.transitions[s2.content], s2)
|
||||
s3.content = EPSILON
|
||||
@@ -163,6 +164,11 @@ func thompson(re string) *State {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Process:
|
||||
// 1. Convert regex into postfix notation (Shunting-Yard algorithm)
|
||||
// a. Add explicit concatenation operators to facilitate this
|
||||
// 2. Build NFA from postfix representation (Thompson's algorithm)
|
||||
// 3. Run the string against the NFA
|
||||
if len(os.Args) < 3 {
|
||||
fmt.Println("ERROR: Missing cmdline args")
|
||||
os.Exit(22)
|
||||
|
Reference in New Issue
Block a user