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

Haskell: spurious character in .cf file leads to ill-formed semantic parse actions #214

Closed
andreasabel opened this issue Nov 24, 2017 · 3 comments
Assignees
Labels
bug define Issue with define pragma Haskell
Milestone

Comments

@andreasabel
Copy link
Member

A. S ::= "A"; x -- Here is a superfluous character 
B. S ::= "B";

BNFC swallows this, but then the generated parser does not compile.
In the .y file, this grammar turns into:

S :: { S }
S : 'A' { Min.Abs.A } | 'B' { Min.Abs.x_ }
@andreasabel
Copy link
Member Author

Still do not fully understand this, but the profiles feature allows two identifiers to be given as rule name, and then the second one is taken. I don't know why x is turned into name variable x_, though.

@andreasabel
Copy link
Member Author

I don't know why x is turned into name variable x_, though.

This comes from the syntactic sugar feature. BNFC should check for the presence of the definition, like

define x = ...

instead of silently assuming there is a definition.
Currently, definitions are unusable since there is an errorneous qualification Min.Abs.x_ instead of x_.

@andreasabel andreasabel self-assigned this May 13, 2019
@andreasabel andreasabel added this to the 2.8.3 milestone May 13, 2019
@andreasabel andreasabel modified the milestones: 2.8.3, 2.8.4 Aug 27, 2019
@andreasabel andreasabel added the define Issue with define pragma label Jan 3, 2020
andreasabel added a commit that referenced this issue Jan 3, 2020
Give proper error message rather than failing mysteriously in the backend.
@andreasabel
Copy link
Member Author

The situation is much better already:

$ bnfc --check test.cf
Lower case rule labels need a definition.
ERROR: undefined rule label(s): x

Aborting.  (Use option --force to continue despite errors.)

We would wish for an error location.

andreasabel added a commit that referenced this issue Oct 7, 2020
The previous code would override the error location of the rule name Bar
with a no-position location of category Bar.
andreasabel added a commit that referenced this issue Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug define Issue with define pragma Haskell
Projects
None yet
Development

No branches or pull requests

1 participant