Use go generate to generate parsers
This commit is contained in:
parent
e37b5bd61b
commit
3c3a30a1e5
19
Makefile
19
Makefile
@ -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
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user