I have a problem during my project(making mini C compiler).
There is no error and I can scan and parse mini C source code file.
But in *.output file I found
State 17 conflicts: 2 shift/reduce
State 19 conflicts: 2 shift/reduce
State 57 conflicts: 8 shift/reduce
State 60 conflicts: 8 shift/reduce
State 61 conflicts: 8 shift/reduce
State 62 conflicts: 8 shift/reduce
State 63 conflicts: 8 shift/reduce
State 96 conflicts: 8 shift/reduce
State 103 conflicts: 10 shift/reduce
State 126 conflicts: 8 shift/reduce
State 130 conflicts: 10 shift/reduce
State 131 conflicts: 10 shift/reduce
State 132 conflicts: 10 shift/reduce
State 133 conflicts: 10 shift/reduce
State 134 conflicts: 10 shift/reduce
State 135 conflicts: 10 shift/reduce
State 136 conflicts: 10 shift/reduce
State 137 conflicts: 10 shift/reduce
State 138 conflicts: 10 shift/reduce
State 139 conflicts: 10 shift/reduce
State 154 conflicts: 1 shift/reduce
and at state 17
4 DECLARATION: INT IDENTIFIER ';' . DECLARATION
6 | INT IDENTIFIER ';' .
INT shift, and go to state 29
FLOAT shift, and go to state 30
INT [reduce using rule 6 (DECLARATION)]
FLOAT [reduce using rule 6 (DECLARATION)]
$default reduce using rule 6 (DECLARATION)
DECLARATION go to state 31
here is my yacc file for Declaration
DECLARATION :
INT IDENTIFIER ';' DECLARATION %prec p10 {
struct DECLARATION *decl = (struct DECLARATION *) malloc (sizeof (struct DECLARATION));
decl->t = eInt;
decl->id = $2;
decl->prev = $4;
$$ = decl;
}
|
FLOAT IDENTIFIER ';' DECLARATION {
struct DECLARATION *decl = (struct DECLARATION *) malloc (sizeof (struct DECLARATION));
decl->t = eFloat;
decl->id = $2;
decl->prev = $4;
$$ = decl;
}
|
INT IDENTIFIER ';' {
struct DECLARATION *decl = (struct DECLARATION *) malloc (sizeof (struct DECLARATION));
decl->t = eInt;
decl->id = $2;
decl->prev = NULL;
$$ = decl;
}
|
FLOAT IDENTIFIER ';' {
struct DECLARATION *decl = (struct DECLARATION *) malloc (sizeof (struct DECLARATION));
decl->t = eFloat;
decl->id = $2;
decl->prev = NULL;
$$ = decl;
}
;