0
在下面的代碼中,我得到了一個衝突reduce-reduce,我嘗試了幾乎所有我想出來解決它的問題,繼承人問題報告,這是一個BNF-> Gold解析器轉換任何想法解決它,我aprreciate它語法衝突 - 減少衝突Gold稀疏
<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>
下面是報告:
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> '}'