Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/cmd/goyacc: goyacc generates a parser routine $$Tokname that doesn't work #44556

Open
danswartzendruber opened this issue Feb 23, 2021 · 5 comments

Comments

@danswartzendruber
Copy link

@danswartzendruber danswartzendruber commented Feb 23, 2021

What version of Go are you using (go version)?

$ go version

1.15

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/dswartz/.cache/go-build" GOENV="/home/dswartz/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/dswartz/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/dswartz/go" GOPRIVATE="" GOPROXY="direct" GOROOT="/usr/lib/golang" GOSUMDB="off" GOTMPDIR="" GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build943484181=/tmp/go-build -gno-record-gcc-switches"
$ go env

What did you do?

A trivial yacc grammar with the following tokens:

%token ABLE
%token BAKER
%token CHARLIE

The main function call fmt.Printf with the output of yyTokname (passing in the token const)

What did you expect to see?

ABLE => "ABLE"
BAKER => "BAKER"
CHARLIE => "CHARLIE"

What did you see instead?

ABLE => "tok-57346"
BAKER => "tok-57347"
CHARLIE => "tok-57348"

@danswartzendruber
Copy link
Author

@danswartzendruber danswartzendruber commented Feb 23, 2021

This is due to said routine assuming that tokens start at 1. They don't.

@danswartzendruber
Copy link
Author

@danswartzendruber danswartzendruber commented Feb 23, 2021

Opened against wrong directory.

@danswartzendruber danswartzendruber changed the title goyacc generates a parser routine yyTokname (yy default) that doesn't work tools/cmd/goyacc: goyacc generates a parser routine yyTokname (yy default) that doesn't work Feb 23, 2021
@danswartzendruber danswartzendruber changed the title tools/cmd/goyacc: goyacc generates a parser routine yyTokname (yy default) that doesn't work tools/cmd/goyacc: goyacc generates a parser routine $$Tokname that doesn't work Feb 23, 2021
@danswartzendruber
Copy link
Author

@danswartzendruber danswartzendruber commented Feb 23, 2021

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 23, 2021

All the Go repos shared a single Gerrit instance. If you use a GitHub pull request, it needs to be against the right repo, but then it will be automatically pulled into the shared Gerrit.

@danswartzendruber
Copy link
Author

@danswartzendruber danswartzendruber commented Feb 23, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants