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

Classname "Doc" causes errors in Haskell parser #228

hjorthjort opened this issue Apr 28, 2018 · 2 comments

Classname "Doc" causes errors in Haskell parser #228

hjorthjort opened this issue Apr 28, 2018 · 2 comments


Copy link

hjorthjort commented Apr 28, 2018

Steps to reproduce:

  1. BNFC file (
Document. Doc ::= "d"  
  1. Run bnfc -m
  2. Run make

Output: make.log

Other class names that causes the same error:

  • Err
  • ParseFun

Inspection shows that this is because PrintProg.hs defines type Doc = [ShowS] -> [ShowS]. Other modules similarly define types, such as Err and ParseFun. Since the AbsProg.hs file is not imported with a qualified import, there is a namespace conflict.

Perhaps it would be sensible to either supply a list of reserved class names and report the use of them when generating the frontend files, or use qualified imports to avoid namespace conflicts.

Copy link

andreasabel commented Apr 30, 2018

Indeed, the Abs modules should be imported qualified. Note that you can also get the error if you use some Haskell built-in type such as Int.
If you look in module BNFC.Backend.Haskell.CFtoPrinter,

[ prologue byteStrings useGadt name absMod
you can see that the name of the AST module, absMod, is only passed to prologue. To get qualified references, it should be passed to all subroutines, preferably as the state of some Reader monad to get all subroutines access to the configuration of the printer generation. All uses of Show Cat should then be replaced to produce qualified references to the AST types.

PRs welcome!

Copy link

Related issue: #128, solved in commit 65b958f.
I am implementing qualified names for the generated printer as well.

@andreasabel andreasabel added this to the 2.8.3 milestone Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants