Makefile 889 B

123456789101112131415161718192021222324252627282930
  1. .PHONY: all parser clean
  2. all: fmt parser
  3. test: fmt parser
  4. sh test.sh
  5. parser: parser.go hintparser.go
  6. %arser.go: prefix = $(@:parser.go=)
  7. %arser.go: %arser.y bin/goyacc
  8. @echo "bin/goyacc -o $@ -p yy$(prefix) -t $(prefix)Parser $<"
  9. @bin/goyacc -o $@ -p yy$(prefix) -t $(prefix)Parser $< || ( rm -f $@ && echo 'Please check y.output for more information' && exit 1 )
  10. @rm -f y.output
  11. %arser_golden.y: %arser.y
  12. @bin/goyacc -fmt -fmtout $@ $<
  13. @(git diff --no-index --exit-code $< $@ && rm $@) || (mv $@ $< && >&2 echo "formatted $<" && exit 1)
  14. bin/goyacc: goyacc/main.go goyacc/format_yacc.go
  15. GO111MODULE=on go build -o bin/goyacc goyacc/main.go goyacc/format_yacc.go
  16. fmt: bin/goyacc parser_golden.y hintparser_golden.y
  17. @echo "gofmt (simplify)"
  18. @gofmt -s -l -w . 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
  19. clean:
  20. go clean -i ./...
  21. rm -rf *.out
  22. rm -f parser.go hintparser.go