Skip to content

Makefile parsing library for Go

License

Notifications You must be signed in to change notification settings

unmango/go-make

Repository files navigation

Go Make

Makefile parsing and utilities in Go

Usage

At present the scanning utilities are the most tested.

Using make.ScanTokens with a bufio.Scanner

f := os.Open("Makefile")
s := bufio.NewScanner(f)
s.Split(make.ScanTokens)

for s.Scan() {
  s.Bytes() // The current token byte slice i.e. []byte(":=")
  s.Text() // The current token as a string i.e. ":="
}

Using make.Scanner

f := os.Open("Makefile")
s := make.NewScanner(f)

for s.Scan() {
  s.Token() // The current token.Token i.e. token.SIMPLE_ASSIGN
  s.Literal() // Literal tokens as a string i.e. "identifier"
}

if err := s.Err(); err != nil {
  fmt.Println(err)
}

Future

  • make.Parser
  • make.Parse(file)

About

Makefile parsing library for Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published