Im get a conflict reduce-reduce in the below code , ive tried almost all i ideas i came up with to solving it heres the report of the problem, this is a BNF->Gold parser conversion any ideas to solve it i would aprreciate it
<Constructor> ::= <Type> '{' <SetCons_RecordCons_ArrayCons_Optional> '}'
<SetCons_RecordCons_ArrayCons_Optional> ::= <>
| <SetCons>
| <RecordCons>
| <ArrayCons>
!| <Type> '{' <SetCons> '}'
!| <Type> '(' <RecordCons> '}'
!| <Type> '(' <ArrayCons> ')'
!SetCons = SetElt {"," SetElt} Inclui o SetElt
<SetCons> ::= <Expr>
| <Expr> '..' <Expr>
| <Expr> ',' <SetCons>
| <Expr> '..' <Expr> ',' <SetCons>
!SetElt = Expr [".." Expr]
!<SetElt> ::= <Expr>
!| <Expr> '..' <Expr>
!RecordCons = RecordElt {"," RecordElt} inclui o recordElt
<RecordCons> ::= <Expr>
| <Expr> <RecordCons>
| <Expr> ',' <RecordCons>
| Id ':=' <Expr> ',' <RecordCons>
!RecordElt = [Id ":="] Expr
!<RecordElt> ::= <Expr>
! | Id ':=' <Expr>
!ArrayCons = Expr {"," Expr} ["," ".."]
<ArrayCons> ::= <Expr> ',' <ArrayCons>
| <Expr> ',' '..'
| <Expr>
Here is the report:
2. Reduce-Reduce conflict for the symbol '}'
Productions in Conflict
When the parser encounters '}', more than one production can be completed (reduced):
<SetCons> ::= <Expr> •
<RecordCons> ::= <Expr> •
<ArrayCons> ::= <Expr> •
Reduce Production #1
The production below can be followed by '}' :
<SetCons> ::= <Expr> •
Because... '}' directly follows <SetCons_RecordCons_ArrayCons_Optional>.
<Constructor> ::= <Type> '{' • <SetCons_RecordCons_ArrayCons_Optional> '}'
Reduce Production #2
The production below can be followed by '}' :
<RecordCons> ::= <Expr> •
Because... '}' directly follows <SetCons_RecordCons_ArrayCons_Optional>.
<Constructor> ::= <Type> '{' • <SetCons_RecordCons_ArrayCons_Optional> '}'
Reduce Production #3
The production below can be followed by '}' :
<ArrayCons> ::= <Expr> •
Because... '}' directly follows <SetCons_RecordCons_ArrayCons_Optional>.
<Constructor> ::= <Type> '{' • <SetCons_RecordCons_ArrayCons_Optional> '}'
The Gold Parser diagnosis seems to be quite detailed, and it certainly contains all the information you need.
But to put it simply, any of
SetCons,RecordConsorArrayConscan be anExpr. So it is possible for the input to be simply:in which case, the parser cannot know which of those three non-terminals it should reduce the
Exprto.