Use go generate to generate parsers

This commit is contained in:
Mitchell Hashimoto 2015-01-15 15:11:14 -08:00
parent e37b5bd61b
commit 3c3a30a1e5
3 changed files with 9 additions and 14 deletions

View File

@ -2,22 +2,13 @@ TEST?=./...
default: test default: test
fmt: hcl/y.go json/y.go fmt: generate
go fmt ./... go fmt ./...
test: hcl/y.go json/y.go test: generate
go test $(TEST) $(TESTARGS) go test $(TEST) $(TESTARGS)
hcl/y.go: hcl/parse.y generate:
cd hcl && \ go generate ./...
go tool yacc -p "hcl" parse.y
json/y.go: json/parse.y .PHONY: default generate test
cd json/ && \
go tool yacc -p "json" parse.y
clean:
rm -f hcl/y.go
rm -f json/y.go
.PHONY: default test

View File

@ -8,6 +8,8 @@ import (
"unicode/utf8" "unicode/utf8"
) )
//go:generate go tool yacc -p "hcl" parse.y
// The parser expects the lexer to return 0 on EOF. // The parser expects the lexer to return 0 on EOF.
const lexEOF = 0 const lexEOF = 0

View File

@ -8,6 +8,8 @@ import (
"unicode/utf8" "unicode/utf8"
) )
//go:generate go tool yacc -p "json" parse.y
// This marks the end of the lexer // This marks the end of the lexer
const lexEOF = 0 const lexEOF = 0