-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
18 changed files
with
9,762 additions
and
8,125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,26 @@ | ||
.PHONY: all parser clean | ||
|
||
ARCH:="`uname -s`" | ||
MAC:="Darwin" | ||
LINUX:="Linux" | ||
all: fmt parser | ||
|
||
all: parser.go fmt | ||
|
||
test: parser.go fmt | ||
test: fmt parser | ||
sh test.sh | ||
|
||
parser.go: parser.y | ||
make parser | ||
|
||
parser: bin/goyacc | ||
bin/goyacc -o /dev/null parser.y | ||
bin/goyacc -o parser.go parser.y 2>&1 | egrep "(shift|reduce)/reduce" | awk '{print} END {if (NR > 0) {print "Find conflict in parser.y. Please check y.output for more information."; exit 1;}}' | ||
rm -f y.output | ||
|
||
@if [ $(ARCH) = $(LINUX) ]; \ | ||
then \ | ||
sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' parser.go; \ | ||
elif [ $(ARCH) = $(MAC) ]; \ | ||
then \ | ||
/usr/bin/sed -i "" 's|//line.*||' parser.go; \ | ||
/usr/bin/sed -i "" 's/yyEofCode/yyEOFCode/' parser.go; \ | ||
fi | ||
parser: parser.go hintparser.go | ||
|
||
@awk 'BEGIN{print "// Code generated by goyacc DO NOT EDIT."} {print $0}' parser.go > tmp_parser.go && mv tmp_parser.go parser.go; | ||
%arser.go: prefix = $(@:parser.go=) | ||
%arser.go: %arser.y bin/goyacc | ||
@echo "bin/goyacc -o $@ -p yy$(prefix) -t $(prefix)Parser $<" | ||
@bin/goyacc -o $@ -p yy$(prefix) -t $(prefix)Parser $< || ( rm -f $@ && echo 'Please check y.output for more information' && exit 1 ) | ||
@rm -f y.output | ||
|
||
bin/goyacc: goyacc/main.go | ||
GO111MODULE=on go build -o bin/goyacc goyacc/main.go | ||
|
||
fmt: | ||
fmt: bin/goyacc | ||
@echo "gofmt (simplify)" | ||
@ gofmt -s -l -w . 2>&1 | awk '{print} END{if(NR>0) {exit 1}}' | ||
@gofmt -s -l -w . 2>&1 | awk '{print} END{if(NR>0) {exit 1}}' | ||
|
||
clean: | ||
go clean -i ./... | ||
rm -rf *.out | ||
rm parser.go | ||
rm -f parser.go hintparser.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.