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
cmd/yacc: write docs for custom error message #10888
Comments
Russ wrote this before, there are some references, assuming this still uses the same methods - http://research.swtch.com/yyerror |
cmd/yacc no longer used and doesn't live in the main repo anymore (https://golang.org/doc/go1.8#tool_yacc), so closing this issue. |
Are there any docs on how to get the custom error messages? (eg: why was this closed?) I found |
I suppose it could be recategorized as x/tools/cmd/yacc instead. You can look at go.y, before it was removed: https://github.com/golang/go/blob/f1b919574cf8022d09afdece1f76b2c2b2529004/src/cmd/compile/internal/gc/go.y The syntax is |
@mdempsky This was really helpful thanks! Looking into the source code, and the generated code it seems that there's a global var: It looks to be hardcoded with no flags, and sed tricks aren't very pretty. It's here: https://github.com/golang/tools/blob/master/cmd/goyacc/yacc.go#L3265 maybe the processing function has some weird trick, but I haven't read through all that code yet. It's a bit confusing at first glance. Secondly, any chance you could give me a few more tips about writing the token sequences? In particular, given a grammar like this:
How do you express a token list for the %error pattern that know what context it's in? For example, a missing comma. I tried a plain: Thanks in advance! |
FYI: for future readers, by adding this:
to the file somewhere will cause the global to get set on import, and the errors will get shown. |
And preferably, with examples.
Please also put the feature into doc/go1.5.txt.
The text was updated successfully, but these errors were encountered: