-
Notifications
You must be signed in to change notification settings - Fork 68
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
errors during compilation of grammar.go are reported as grammar.go rather than grammar.peg #99
Comments
This is by design. Pigeon does not care about the Go code in the PEG file but only about the PEG grammar. Go does not know anything about PEG and therefore can not report an other position for the error than in the generated If you have a lot of Go code used by the parser, it does make sense to move this code as functions into a separate .go file. Have a look at https://github.com/breml/logstash-config/tree/master for an example. There find |
That being said, Go does not have a preprocessor so there are no preporcessor lines that could point back to the original source file. |
Not quite true. |
I will likely take a crack at this at some point. I believe the task is relatively straightforward and superficial. But anyone else who is up for it is welcome to beat me to it. |
@kpixley Thanks for the hint on the //line compiler directive. I did not know about this. I started to look into adding this to pigeon. It is possible, but there are some challenges to solve, especially if there is some code (beside of the package directive) in the init section (like here). The problem is, that the correct position of the declarations after the imports do not match with the peg file, because the imports are added by pigeon automatically after the successful generation of the parser. But I am confident, that there is a solution for this as well. |
This is a nuisance when used, eg, with emacs compilation mode.
lex/yacc/byacc/bison/et all use line number preprocessor lines in the generated output to refer back to the original source file even when it's the C compiler that is reporting the error. I don't know how to do that in go but I presume that it must be possible. If not, it should be.
The text was updated successfully, but these errors were encountered: