나는 Bison을 사용하고 있으며 CFG에 Shift 키를 사용하여 충돌을 줄임으로써 내 우선 순위가 엉망입니다. 나는 이동이 특정 규칙에 대한 갈등을 줄일 수 있습니다들소 이동 충돌 줄이기
Decl : vartype T_Identifier T_Semicolon {
// replace it with your implementation
Identifier *id = new Identifier(@2, $2);
$$ = new VarDecl(id, $1);
}
| vartype T_Identifier T_Equal primaryExpr T_Semicolon {
Identifier *id = new Identifier(@2, $2);
$$ = new VarDecl(id, $1, $4);
}
| function_prototype T_Semicolon {$$ = $1;}
;
:
이
내 코드입니다. 나는 마지막 줄 (function_prototype ...)이 가장 높은 우선 순위를 가지길 원하지만 갈등은 나에게 옮겨서 다른 상태로 보낸다. 참고로 "function_prototype"은 "vartype T_Identifier T_LeftParenth"규칙이있는 비 터미널입니다. bison의 출력 파일입니다.State 28 conflicts: 1 shift/reduce
...
state 28
4 Decl: vartype . T_Identifier T_Semicolon
5 | vartype . T_Identifier T_Equal primaryExpr T_Semicolon
11 fully_specified_type: vartype .
T_Identifier shift, and go to state 34
T_Identifier [reduce using rule 11 (fully_specified_type)]
...
state 34
4 Decl: vartype T_Identifier . T_Semicolon
5 | vartype T_Identifier . T_Equal primaryExpr T_Semicolon
T_Equal shift, and go to state 36
T_Semicolon shift, and go to state 37
상태 34는 "function prototype"규칙을 건너 뜁니다. 이 충돌 및 우선 순위 문제를 어떻게 수정합니까?