Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
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

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.