diff --git a/Makefile b/Makefile index 3445247..2c97b5d 100644 --- a/Makefile +++ b/Makefile @@ -2,22 +2,13 @@ TEST?=./... default: test -fmt: hcl/y.go json/y.go +fmt: generate go fmt ./... -test: hcl/y.go json/y.go +test: generate go test $(TEST) $(TESTARGS) -hcl/y.go: hcl/parse.y - cd hcl && \ - go tool yacc -p "hcl" parse.y +generate: + go generate ./... -json/y.go: json/parse.y - cd json/ && \ - go tool yacc -p "json" parse.y - -clean: - rm -f hcl/y.go - rm -f json/y.go - -.PHONY: default test +.PHONY: default generate test diff --git a/hcl/lex.go b/hcl/lex.go index e0c96b1..825b7da 100644 --- a/hcl/lex.go +++ b/hcl/lex.go @@ -8,6 +8,8 @@ import ( "unicode/utf8" ) +//go:generate go tool yacc -p "hcl" parse.y + // The parser expects the lexer to return 0 on EOF. const lexEOF = 0 diff --git a/json/lex.go b/json/lex.go index 0c1299c..0b07e36 100644 --- a/json/lex.go +++ b/json/lex.go @@ -8,6 +8,8 @@ import ( "unicode/utf8" ) +//go:generate go tool yacc -p "json" parse.y + // This marks the end of the lexer const lexEOF = 0