Nothing Special   »   [go: up one dir, main page]

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

Numbers in category names and list macros #210

Closed
dschoepe opened this issue Nov 2, 2017 · 2 comments
Closed

Numbers in category names and list macros #210

dschoepe opened this issue Nov 2, 2017 · 2 comments
Assignees
Milestone

Comments

@dschoepe
Copy link
dschoepe commented Nov 2, 2017

Using categories with numbers in the name with separator results in errors when compiling the Par... files. For example, the following grammar:

Foo. Bar2 ::= Ident ;
terminator Bar2 "," ;

Results in the following errors:

$ bnfc -m Foo.cf
3 rules accepted

Use Alex 3.0 to compile LexFoo.x.
ParFoo.y Tested with Happy 1.15
writing new file ./AbsFoo.hs
writing new file ./LexFoo.x
writing new file ./ParFoo.y
writing new file ./TestFoo.hs
writing new file ./DocFoo.txt
writing new file ./SkelFoo.hs
writing new file ./PrintFoo.hs
writing new file ./ErrM.hs
writing new file ./Makefile

$ make
happy -gca ParFoo.y
alex -g LexFoo.x
ghc --make TestFoo.hs -o TestFoo
[1 of 7] Compiling LexFoo           ( LexFoo.hs, LexFoo.o )
[2 of 7] Compiling ErrM             ( ErrM.hs, ErrM.o )
[3 of 7] Compiling AbsFoo           ( AbsFoo.hs, AbsFoo.o )
[4 of 7] Compiling ParFoo           ( ParFoo.hs, ParFoo.o )

ParFoo.hs:28:14: error:
    Not in scope: type constructor or class ‘Bar’

ParFoo.hs:31:33: error:
    Not in scope: type constructor or class ‘Bar’

ParFoo.hs:34:15: error:
    Not in scope: type constructor or class ‘Bar’

ParFoo.hs:37:34: error:
    Not in scope: type constructor or class ‘Bar’

ParFoo.hs:100:19: error:
    Not in scope: data constructor ‘AbsFoo.Foo’
    Module ‘AbsFoo’ does not export ‘Foo’.
make: *** [Makefile:4: all] Error 1

This was tested with GHC 8.0.2, alex 3.1.7, and 1.19.7, on ArchLinux, but it also occurred on a MacOS system. Changing Bar2 to some name not containing any digits resolves the error.

@andreasabel
Copy link
Member

Interesting. BNFC's own grammar has a similar construction:

separator nonempty Exp2 "" ; -- argument list

The difference here may be that Exp and Exp1 are also used!?

@andreasabel
Copy link
Member
andreasabel commented Apr 29, 2019

The error goes away when a coercions pragma is added for Bar. Also, list categories are not needed, the MWE is actually

Foo. Bar2 ::= Ident ;

In contrast, this works fine:

Foo. Bar1 ::= Ident ;
Boo. Bar  ::= Integer ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants