Rudimentary matching works

This commit is contained in:
2024-10-22 16:25:49 -04:00
parent 9f9de2234f
commit d191686168
2 changed files with 63 additions and 5 deletions

16
main.go
View File

@@ -2,6 +2,7 @@ package main
import (
"fmt"
"os"
"slices"
)
@@ -157,13 +158,18 @@ func thompson(re string) State {
}
func main() {
if len(os.Args) < 3 {
fmt.Println("ERROR: Missing cmdline args")
}
var re string
// fmt.Scanln(&re)
re = "abab|abbb"
re = os.Args[1]
re_postfix := shuntingYard(re)
fmt.Println(re_postfix)
start := thompson(re_postfix)
UNUSED(start)
s, e, matched := match(&start, os.Args[2])
if matched {
fmt.Printf("Matched from %d to %d\n", s, e)
} else {
fmt.Printf("No match found.\n")
}
}
func UNUSED[T any](val T) {}