Shift /Reduce error - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Shift /Reduce error

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.

: '{' const_type_list '}'

: struct_or_array_initialiser
| struct_or_array_initialiser_list ',' struct_or_array_initialiser

: array_declarator
| array_declarator '[' ']'
| array_declarator '[' CONST_INT ']'
: const_type
| struct_or_array_initialiser_list

| array_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.