You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to BNFC Developers and Users
Hi everyone!
I'm running GHC with all warnings enabled and it's reporting numerous issues with code generated by BFNC.
Although those should not be ignored in the long run, right now I'd like to disable them to focus on the warnings for the code I wrote in Haskell myself.
Normally, you'd do this by adding an OPTIONS_GHC -w pragma to the top of the file (unless someone knows a better way), but that would mean I'd have to change every file. Because my grammar files change often, it's going to become annoying soon.
Is there any way of telling BNFC to add the necessary pragmas to disable all warnings?
Thanks,
Ivan
Andreas Abel
unread,
Jan 8, 2021, 5:25:04 AM1/8/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
E.g., one of my `Makefile`s has this rule
```
cmm/Yylex $(CUPFILE) cmm/Test.java cmm/Absyn/Exp.java : cmm.cf Exp.patch
bnfc --java $<
patch --input=Exp.patch cmm/Absyn/Exp.java
```
The last line is the relevant line here.
Hope that helps as a workaround.
Apparently, BNFC 2.7.1 generated warning-free Haskell code for GHC 7.4:
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to BNFC Developers and Users
Thanks!
So, I'm not using makefiles, and, in our internal policy, keeping a patch that we apply later to automatically-generated code is discouraged (I'd say there are good reasons for that).
I ended up being able to deal with this differently for my use case. In my cabal file, I:
- Created an internal library that holds the grammar(s) only. The compilation flags do NOT include -Wall.
- Created a library that imports the other internal library. The compilation flags DO include -Wall.
Fin
Ivan
Andreas Abel
unread,
Mar 1, 2021, 3:38:09 AM3/1/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to BNFC Developers and Users
Hi Ivan,
I made some effort to eliminate warnings from the generated Haskell code.
Please try if BNFC 2.9.1 solves your problem (released just now).
Best,
Andreas
Iván Pérez
unread,
Mar 2, 2021, 2:43:01 PM3/2/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to BNFC Developers and Users
This is fantastic! Thanks a lot! I tried it and it works perfectly.
So, and I'm saying this knowing that it's always "easier said than done": Do you think it might be possible to also make BNFC generate warning free haddock comments?
I'm not familiar enough with Alex and Happy (I used them, but mostly like a decade ago). They may not allow you to control the comments of the definitions they put in the generated Lex* and Par* modules. For some modules (like the AST and the Pretty Printers), it might
be as simple as adding the grammar rules that the definitions come from.
Cheers,
Ivan
Andreas Abel
unread,
Mar 10, 2021, 2:50:10 AM3/10/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bnfc...@googlegroups.com
On 2021-03-02 20:43, Iván Pérez wrote:
> This is fantastic! Thanks a lot! I tried it and it works perfectly.
Great!
> So, and I'm saying this knowing that it's always "easier said than
> done": Do you think it might be possible to also make BNFC generate
> warning free haddock comments? >
> I'm not familiar enough with Alex and Happy (I used them, but mostly
> like a decade ago). They may not allow you to control the comments of
> the definitions they put in the generated Lex* and Par* modules.
Indeed. The code they produce is not for human consumption.
You could create wrapper modules that reexport the lexer and parser and
include some haddockumentation.
> For some modules (like the AST and the Pretty Printers), it might be as
> simple as adding the grammar rules that the definitions come from.
We are planning this for BNFC 3.0 at least for the AST.
> - modify the `Makefile` to automatically `patch` the
> BNFC-generated files
>
> E.g., one of my `Makefile`s has this rule
> ```
> cmm/Yylex $(CUPFILE) cmm/Test.java cmm/Absyn/Exp.java :