Compare commits

..

No commits in common. 'master' and 'v0.5.0' have entirely different histories.

3
.gitignore vendored

@ -1 +1,2 @@
kg/kg
re

@ -8,6 +8,6 @@ vet: fmt
buildLib: vet
go build -gcflags="all=-N -l" ./...
buildCmd: buildLib
go build -C kg/ -gcflags="all=-N -l" -o kg ./...
go build -C cmd/ -gcflags="all=-N -l" -o re ./...
test: buildCmd
go test -v ./...

@ -15,7 +15,3 @@ It also includes features not present in regexp, such as lookarounds and backref
The syntax is, for the most part, a superset of Go's regexp. A full overview of the syntax can be found [here](https://pkg.go.dev/gitea.twomorecents.org/Rockingcool/kleingrep/regex#hdr-Syntax).
__For more information, see https://pkg.go.dev/gitea.twomorecents.org/Rockingcool/kleingrep/regex__.
### How it works
I've written about the inner workings of the engine [on my blog](https://twomorecents.org/writing-regex-engine/index.html).

@ -1,11 +1,6 @@
package main
import (
"bufio"
"os"
"slices"
"strings"
)
import "slices"
type character interface {
int | rune
@ -30,23 +25,3 @@ func genRange[T character](start, end T) []T {
}
return toRet
}
// Returns whether or not the given file contains a NULL character
func fileContainsNullChar(filename string) (bool, error) {
file, err := os.Open(filename)
if err != nil {
return true, err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if strings.Contains(line, "\000") {
return true, nil
}
}
if err := scanner.Err(); err != nil {
return true, err
}
return false, nil
}

@ -91,7 +91,6 @@ func main() {
inputFilenames := flag.Args()[1:]
for _, inputFilename := range inputFilenames {
inputFile, err := os.Open(inputFilename)
defer inputFile.Close()
if err != nil {
fmt.Printf("%s: %s: No such file or directory\n", os.Args[0], inputFilename)
} else {
@ -102,15 +101,6 @@ func main() {
} else {
if fileStat.Mode().IsDir() {
fmt.Printf("%s: %s: Is a directory\n", os.Args[0], inputFilename)
} else {
var nullCharPresent bool
if nullCharPresent, err = fileContainsNullChar(inputFilename); nullCharPresent {
if err != nil {
fmt.Printf("%v\n", err)
os.Exit(1)
} else {
fmt.Printf("%s: %s: Is a binary file\n", os.Args[0], inputFilename)
}
} else {
inputFiles = append(inputFiles, inputFile)
}
@ -118,10 +108,6 @@ func main() {
}
}
}
}
if len(inputFiles) == 0 { // No valid files given
os.Exit(2)
}
var test_str string
var err error

Loading…
Cancel
Save