Rudimentary matching works
This commit is contained in:
16
main.go
16
main.go
@@ -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) {}
|
||||
|
Reference in New Issue
Block a user