Shift /Reduce error

Hi,
i am sandy

developing a C compiler.
grammar written by me is showing some shift reduce conflict.
for array decleration and initilisation the grammar is showing conflict.

struct_or_array_initialiser
: '{' const_type_list '}'
;

struct_or_array_initialiser_list
: struct_or_array_initialiser
| struct_or_array_initialiser_list ',' struct_or_array_initialiser
;

array_var
: array_declarator
| array_declarator '[' ']'
| array_declarator '[' CONST_INT ']'
;
const_expr
: const_type
| struct_or_array_initialiser_list
;

uninitialised_var
: IDENTIFIER
| array_var
;

var
: uninitialised_var
| uninitialised_var '=' const_expr
;


and the conflict is ....(shift /reduce)
when it faces struct_or_array_init_list ',' ...


state 66

struct_or_array_initialiser_list -> struct_or_array_initialiser_list . ',' struct_or_array_initialiser (rule 22)
const_expr -> struct_or_array_initialiser_list . (rule 29)

',' shift, and go to state 80

',' [reduce using rule 29 (const_expr)]
$default reduce using rule 29 (const_expr)

Please help if you Understand this





Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories