cznic / goyacc

github.com/cznic/goyacc has moved to modernc.org/goyacc
https://godoc.org/modernc.org/goyacc
BSD 3-Clause "New" or "Revised" License
207 stars 24 forks source link

How build goyacc tool in GO #23

Open QuestionPython opened 7 years ago

QuestionPython commented 7 years ago

hi How build goyacc tool in GO?

i have goyacc -h package in my system. but want install go tool yacc on go 1.8 how can do this?

$ make

go fmt go test PASS ok github.com/cznic/goyacc 0.002s go install go tool vet -printfuncs "Log:0,Logf:1" *.go golint . make todo make[1]: Entering directory '/home/guest/go/src/github.com/cznic/goyacc' main.go:554: = yyerrok main.go:706: = yypt // guard against "declared and not used" main.go:791: _ = oNoLines //TODO Ignored for now all_test.go:37:func TODO(...interface{}) string { alltest.go:39: return fmt.Sprintf("TODO: %s:%d:\n", path.Base(fn), fl) main.go:791: = oNoLines //TODO Ignored for now make[1]: Leaving directory '/home/guest/go/src/github.com/cznic/goyacc'

cznic commented 7 years ago

I'm not sure if I understand the problem. Anyway, please try issuing

$ go get -u github.com/cznic/goyacc

If that does not work for you, please report back, preferably including the output of

$ go get -u -v github.com/cznic/goyacc

or any other diagnostics you can provide, thank you.

QuestionPython commented 7 years ago

i old work with yacc on go 1.6 or 1.5 or 1.4. but now i have go 1.8 and this have problem i think...

i first delete /home/guest/go/src/github.com/cznic/goyacc folder,

$ go get -u github.com/cznic/goyacc

Done

$ go get -u -v github.com/cznic/goyacc

github.com/cznic/goyacc (download) github.com/cznic/mathutil (download) github.com/cznic/parser (download) github.com/cznic/golex (download) github.com/cznic/strutil (download) github.com/cznic/sortutil (download) github.com/cznic/y (download) github.com/cznic/golex/lex github.com/cznic/mathutil github.com/cznic/strutil github.com/cznic/sortutil github.com/cznic/parser/yacc github.com/cznic/y github.com/cznic/goyacc

$ make

go fmt go test PASS ok github.com/cznic-/goyacc 0.002s go install go tool vet -printfuncs "Log:0,Logf:1" *.go golint . make todo make[1]: Entering directory '/home/guest/go/src/github.com/cznic-/goyacc' main.go:554: = yyerrok main.go:706: = yypt // guard against "declared and not used" main.go:791: _ = oNoLines //TODO Ignored for now all_test.go:37:func TODO(...interface{}) string { alltest.go:39: return fmt.Sprintf("TODO: %s:%d:\n", path.Base(fn), fl) main.go:791: = oNoLines //TODO Ignored for now make[1]: Leaving directory '/home/guest/go/src/github.com/cznic-/goyacc'

cznic commented 7 years ago

Well, the output seems to indicate the installation went smoothly with no problems. You should be now able to find the goyacc binary in $GOPATH/bin, or alternatively, in $GOBIN, if set. Whichever that location is, it has to be listed in your $PATH if you now want to invoke the command goyacc from any working directory.

cznic commented 7 years ago

Here it seems to work as well:

jnml@4670:~$ ls -a $(which goyacc)
/home/jnml/bin/goyacc
jnml@4670:~$ rm /home/jnml/bin/goyacc
jnml@4670:~$ go get -u -v github.com/cznic/goyacc
github.com/cznic/goyacc (download)
github.com/cznic/mathutil (download)
github.com/cznic/parser (download)
github.com/cznic/golex (download)
github.com/cznic/strutil (download)
github.com/cznic/sortutil (download)
github.com/cznic/y (download)
github.com/cznic/goyacc
jnml@4670:~$ ls -la $(which goyacc)
-rwxrwxr-x 1 jnml jnml 3397456 bře  9 20:33 /home/jnml/bin/goyacc
jnml@4670:~$ 
QuestionPython commented 7 years ago

$ls -a $(which goyacc)

/home/guest/go/bin/goyacc

$rm /home/guest/go/bin/goyacc

$go get -u -v github.com/cznic/goyacc

$ls -la $(which goyacc)

-rwxr-xr-x 1 guest guest 3397456 Mar 9 23:17 /home/guest/go/bin/goyacc

cznic commented 7 years ago

That seems okay.

QuestionPython commented 7 years ago

$ make

go fmt go test PASS ok github.com/cznic-/goyacc 0.002s go install go tool vet -printfuncs "Log:0,Logf:1" *.go golint . make todo make[1]: Entering directory '/home/guest/go/src/github.com/cznic-/goyacc' main.go:554: = yyerrok main.go:706: = yypt // guard against "declared and not used" main.go:791: _ = oNoLines //TODO Ignored for now all_test.go:37:func TODO(...interface{}) string { alltest.go:39: return fmt.Sprintf("TODO: %s:%d:\n", path.Base(fn), fl) main.go:791: = oNoLines //TODO Ignored for now make[1]: Leaving directory '/home/guest/go/src/github.com/cznic-/goyacc'

==========

you sure then test goyacc on GO 1.8?

cznic commented 7 years ago

you sure then test goyacc on GO 1.8?

Yes, you should now have the goyacc binary built by you current Go toolchain. For the record, goyacc binary built from a recent source version, but with the older version of the Go toolchain should work just fine.

You don't need to invoke make. go get -u <import-path> or go install <import-path> already produces/updates the binary. make is a goyacc's developer aid only, not required for end-users ;-)

Anyway running make also installs the goyacc command.

QuestionPython commented 7 years ago

$ go install github.com/cznic/goyacc

result of this is empty.!

$ goyacc -h

Usage of goyacc: -c report state closures -cr check all states are reducible -dlval string debug value (runtime yyDebug >= 3) (default "lval") -dlvalf string debug format of -dlval (runtime yyDebug >= 3) (default "%+v") -ex explain how were conflicts resolved -l disable line directives (for compatibility ony - ignored) -la report all lookahead sets -o string parser output (default "y.go") -p string name prefix to use in generated code (default "yy") -v string create grammar report (default "y.output") -xe string generate eXtra errors from examples source file -xegen string generate error from examples source file automatically from the grammar

$ make

go fmt go test PASS ok github.com/cznic-/goyacc 0.002s go install go tool vet -printfuncs "Log:0,Logf:1" *.go golint . make todo make[1]: Entering directory '/home/guest/go/src/github.com/cznic-/goyacc' main.go:554: = yyerrok main.go:706: = yypt // guard against "declared and not used" main.go:791: _ = oNoLines //TODO Ignored for now all_test.go:37:func TODO(...interface{}) string { alltest.go:39: return fmt.Sprintf("TODO: %s:%d:\n", path.Base(fn), fl) main.go:791: = oNoLines //TODO Ignored for now make[1]: Leaving directory '/home/guest/go/src/github.com/cznic-/goyacc'

cznic commented 7 years ago

result of this is empty.!

Plase specify what is meant by empty. It looks like you have the correct goyacc binary installed as seen from the output of goyacc -h. I don't know what the problem is, before I thought it was about having the goyacc binary. Is there some other problem I'm not aware of?

I guess there might be a problem of communicating in English, maybe Google Translate can be useful for this.

Please try to reformulate the problem in terms of what are you trying to achieve, what you've tried and how does the outcome differs from the expectations. Knowing that will help me to help you ;-)

QuestionPython commented 7 years ago

$ which goyacc /home/guest/go/bin/goyacc

i want use from go tool yacc, but say not exist! go tool: no such tool "yacc"

cznic commented 7 years ago

Ah, here we go ;-)

If you want to use go tool yacc command you need to do

go get -u golang.org/x/tools/cmd/goyacc
QuestionPython commented 7 years ago

$ go get -u golang.org/x/tools/cmd/goyacc

$ go tool yacc

go tool: no such tool "yacc"

TestData of GoYacc Directory

/home/guest/go/src/golang.org/x/tools/cmd/goyacc/testdata/expr$ go generate /home/guest/go/src/golang.org/x/tools/cmd/goyacc/testdata/expr$ go build /home/guest/go/src/golang.org/x/tools/cmd/goyacc/testdata/expr$ ./expr 5+5 10 guest@system:~/go/src/golang.org/x/tools/cmd/goyacc/testdata/expr$

i can build yacc with goyacc -o output.go input.y code. but go tool yacc not exist!

cznic commented 7 years ago

I've raised a question at the mailing list: https://groups.google.com/d/topic/golang-nuts/oiaNlQdqPb8/discussion

Sorry for providing you with a non-working recipe, I am surprised that it does not work.

QuestionPython commented 7 years ago

tank you...., i waiting for you. :+1: again tank you from you.

cznic commented 7 years ago

Update: As far as I can tell now, the problem is that the go tool no longer supports the yacc subcommand at all.

After doing

$ go get -u golang.org/x/tools/cmd/goyacc

on must invoke the tool directly

$ goyacc

Note that the golang.org/... and cznic/goyacc repositories both have a and via go get both install command goyacc. They are to a certain extent compatible, which one you should choose to install depends on what features you need to use.