-
Notifications
You must be signed in to change notification settings - Fork 165
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
C -family backends generate incorrect parser #235
Comments
Confirmed, and your hunch where the problem is is correct. Someone stumbled about a similar issue in the C# backend (see comment in code below), but failed to address the root of the problem. bnfc/source/src/BNFC/Backend/CSharp/CFtoGPPG.hs Lines 232 to 235 in f80b640
The Here is a small test grammar to expose the clashes:
|
The Ocaml backend is also affected: |
Glad to see this is getting addressed! I wish I was still working with that project so I could help out more. |
Thanks for the thumbs up! I fixed this starting yesterday evening, will commit very soon now! |
Overview
This grammar is used to generate parsers in several languages. The output works fine for Java output, but not for C or C++.
Here is the error when building the C++ output:
Observations
I have tracked down the issue to being a mix up of
SimpleTypeBool
andGroundBool
. (similarly for a few other variables)A Bool is defined to be either
true
orfalse
and is part of theGround
non terminal.SimpleTypeBool
this is defined to be the token"Bool"
Clearly these are not the same. The token
true
orfalse
should be parsed as aGroundBool
, the tokenBool
should be parsed as aSimpleTypeBool
. However, these cases are mixed in the lex and yacc file.In the lex file, I can see the token for SimpleTypeBool:
But,
_SYMB_38
is referenced in theground
rule in the bison file:This is incorrect.
_SYMB_38
has nothing to do withGround
._SYMB_38
should instead beBool
which is defined properly:Where the Problem might be
I am not a Haskeller, but I am working on tracking down the problem. My guess is that there is a
Map
somewhere which uses the same key for a token literal and for a token name.I found something like that here:
https://github.com/BNFC/bnfc/blob/master/source/src/BNFC/Backend/CPP/NoSTL/CFtoFlex.hs#L58
If I trace
env'
I can see that there are duplicate keys. NoticeUri
.I imagine something similar is happening in the bison generation code. I will keep tracking this down, but if you know what is wrong or have any suggestions that would be very helpful. I can also clarify if you have questions.
The text was updated successfully, but these errors were encountered: