Hi, find the output file info below,
State 0 contains 6 shift/reduce conflicts. State 7 contains 6 shift/reduce conflicts. state 0 STATIC shift, and go to state 1 CONST shift, and go to state 2 VOLATILE shift, and go to state 3 EXTERN shift, and go to state 4 INT shift, and go to state 5 UNSIGNED shift, and go to state 6 STATIC [reduce using rule 10 (init_dec)] CONST [reduce using rule 10 (init_dec)] VOLATILE [reduce using rule 10 (init_dec)] EXTERN [reduce using rule 10 (init_dec)] INT [reduce using rule 10 (init_dec)] UNSIGNED [reduce using rule 10 (init_dec)] $default reduce using rule 10 (init_dec) translation_unit go to state 7 external_declaration go to state 8 function_definition go to state 9 declaration go to state 10 init_dec go to state 11 declaration_specifiers go to state 12 storage_class_specifier go to state 13 type_specifier go to state 14 type_qualifier go to state 15 state 7 translation_unit -> translation_unit . external_declaration (rule 2) $ go to state 31 STATIC shift, and go to state 1 CONST shift, and go to state 2 VOLATILE shift, and go to state 3 EXTERN shift, and go to state 4 INT shift, and go to state 5 UNSIGNED shift, and go to state 6 STATIC [reduce using rule 10 (init_dec)] CONST [reduce using rule 10 (init_dec)] VOLATILE [reduce using rule 10 (init_dec)] EXTERN [reduce using rule 10 (init_dec)] INT [reduce using rule 10 (init_dec)] UNSIGNED [reduce using rule 10 (init_dec)] $default reduce using rule 10 (init_dec) external_declaration go to state 16 function_definition go to state 9 declaration go to state 10 init_dec go to state 11 declaration_specifiers go to state 12 storage_class_specifier go to state 13 type_specifier go to state 14 type_qualifier go to state 15 How to resolve these conflicts? how to obtain my requirement to initialize the declaration before parser starts into the declaration part? Full output file : http://old.nabble.com/file/p29313323/grammar.output grammar.output - Anand V panayk wrote: > > Hi! > > Use the -v (verbose) flag on bison to generate the xxx.output file that > contains more information about the parser automaton (including where > the conflicts appear). Then please post it here. > > You may also want to read the debugging section from: > > info bison > > Regards, > Panayiotis > > On 07/31/2010 04:54 PM, anandvn wrote: >> Hi, >> >> Could any one please help me in resolving the shift/reduce in the >> following >> grammar? >> >> %{ >> #include<stdio.h> >> extern char yytext[]; >> extern int column; >> void yyerror(char const *s); >> %} >> >> %union >> { >> unsigned int tokVal; >> unsigned char *tokValStr; >> } >> >> /* C operators */ >> %token<tokVal> STATIC CONST VOLATILE EXTERN INT UNSIGNED VARNAME EQUAL >> COLON OP_BRACE CL_BRACE IDENTIFIER >> >> %type<tokVal> declaration translation_unit declaration_specifiers >> storage_class_specifier type_specifier type_qualifier >> init_declarator_list >> >> /* Parsing starts with this transalation unit */ >> %start translation_unit >> >> %% >> >> translation_unit >> : external_declaration >> | translation_unit external_declaration >> ; >> >> external_declaration >> : function_definition >> | declaration >> ; >> >> function_definition >> : declaration_specifiers declarator compound_statement >> ; >> >> declarator >> : IDENTIFIER >> ; >> >> compound_statement >> : OP_BRACE CL_BRACE >> ; >> >> declaration >> : init_dec declaration_specifiers COLON >> | init_dec declaration_specifiers init_declarator_list COLON >> ; >> >> init_dec >> : {printf("*** Process for Initialization ***\n\n");} >> >> init_declarator_list >> : EQUAL VARNAME >> ; >> >> declaration_specifiers >> : storage_class_specifier >> | storage_class_specifier declaration_specifiers >> | type_specifier >> | type_specifier declaration_specifiers >> | type_qualifier >> | type_qualifier declaration_specifiers >> ; >> >> storage_class_specifier >> : EXTERN >> | STATIC >> ; >> >> type_specifier >> : INT >> | UNSIGNED >> ; >> >> type_qualifier >> : CONST >> | VOLATILE >> ; >> >> %% >> >> void yyerror(char const *s) >> { >> fflush(stdout); >> printf("\n%*s\n%*s\n", column, "^", column, s); >> } >> >> In the rule "declaration", I want to perform initalization activities >> using >> the empty rule "init_dec" (original code here >> http://old.nabble.com/file/p29313133/Test.zip Test.zip ). But i'm getting >> shift/reduce conflict. Since I'm new to this bison, i need help from you >> to >> resolve this conflict. I tried by i felt very difficult. >> >> Thanks >> Anand V >> > > > _______________________________________________ > help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison > > -- View this message in context: http://old.nabble.com/Resolving-shift-reduce-conflict-in-Bison-grammar-tp29313133p29313323.html Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison