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

proposal: x/tools/cmd/goyacc: add %expect command #25050

Closed
esrrhs opened this issue Apr 24, 2018 · 4 comments
Closed

proposal: x/tools/cmd/goyacc: add %expect command #25050

esrrhs opened this issue Apr 24, 2018 · 4 comments
Labels
FeatureRequest FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Proposal
Milestone

Comments

@esrrhs
Copy link

esrrhs commented Apr 24, 2018

Please answer these questions before submitting your issue. Thanks!

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

go 1.9.2 windows/amd64

Does this issue reproduce with the latest release?

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

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

can you add %expect command which bison has to remove the conflicts warning?
https://www.gnu.org/software/bison/manual/html_node/Expect-Decl.html

What did you see instead?

@gopherbot gopherbot added this to the Unreleased milestone Apr 24, 2018
@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Apr 24, 2018
@cznic
Copy link
Contributor

cznic commented Apr 24, 2018

IMO making the grammar unambiguous is much better.

@FiloSottile FiloSottile changed the title x/tools/cmd/goyacc: can you add %expect command ? x/tools/cmd/goyacc: add %expect command Apr 24, 2018
@gopherbot
Copy link

Change https://golang.org/cl/113720 mentions this issue: x/tools/cmd/goyacc: add %expect command

@alexander-yu
Copy link

Addressing this in the change mentioned above.

@bradfitz bradfitz changed the title x/tools/cmd/goyacc: add %expect command proposal: x/tools/cmd/goyacc: add %expect command May 21, 2018
@rsc
Copy link
Contributor

rsc commented Jun 4, 2018

The fact that Bison has this feature does not mean goyacc needs to add it. Like @cznic said, the better solution is to write a grammar with no shift-reduce conflicts.

If you write a C program and the compiler surfaces 10 warnings about your code, the right response is to fix the warnings, not write #pragma expect 10. What happens when the 11th warning pops up? The compiler prints 11 warnings and you're left to figure out which are the 10 you don't care about. Fixing the warnings, however you do that, makes them go away for good. A yacc grammar is a program too. If yacc prints warnings about your program and you don't want to hear about them anymore, the right solution is to fix the problems yacc has identified.

The old Go 1.4 yacc grammar for Go itself shows how to fix these warnings with precedence markers. See https://go.googlesource.com/go/+/go1.4/src/cmd/gc/go.y#104.

@rsc rsc closed this as completed Jun 4, 2018
@golang golang locked and limited conversation to collaborators Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Proposal
Projects
None yet
Development

No branches or pull requests

7 participants