-
Notifications
You must be signed in to change notification settings - Fork 3
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
Why rex find a shift-reduce with repetition one or more ? #7
Comments
How to see the (probably) rewritten grammar ? |
There is no rewriting to BNF, the LR items are based on the EBNF rules, resulting in a different setup of the parser states. In the actual case, based on the LR item
there is a goto state on
which has the shift-reduce conflict on In the BNF variant, the shift and reduce are in different states. But where the BNF variant does many reductions to You can see the LR states in the XML document resulting from the LALR(2) may come to help here. |
Thank you for reply and help ! |
Trying to generate a parser for the whole converted grammar doesn't work even with
The whole grammar:
|
But manually fixing the converted grammar on the offending rules that uses the repetition operator can generate a
The fixed grammar:
|
The
The input grammar :
|
Alternatively, for getting it LALR(1), you could completely drop the offending list building rules, like so:
Which is what ebnf-convert could have done, but apparently doesn't. I will have a look at that one. |
I've done another experiment with a grammar converted with |
Thank you again for reply ! Also would be nice to have |
The last changes to
When
This already happened with other grammars and after renaming
The error message is a bit vague because it doesn't tell the name of the
Here
On this one it's a bit hard to find witch one of the
|
After writing the last comment I found the |
While testing this grammar https://github.com/parinayc20/Java_Compiler/blob/main/milestone_4/src/parser.y I've noticed that
ebnf-convert
translatesone or more
rules to use a repetition operator that should be equivalent butrex
doesn't seem to understand it that way.Simplified yacc grammar:
Converted by ebnf-convert plus tokens definitions:
When trying to generate a parser with
rex
usingVariableInitializer ( COMMA VariableInitializer )*
:Without using repetition operator (as shown above):
Is this a bug ?
The text was updated successfully, but these errors were encountered: