I am learning to work with YACC and I really can't understand some errors. I would like to know why I get this error when I try to generate my parser with the .y file. Here is my .y file, that represents a context free grammar for Pascal language:
%%
Program : program ident ';' declaration_opc compound_stmt '.'
;
declaration_opc : var declaration_list
|
;
declaration_list : declaration ';' declaration_list
| declaration ';'
;
declaration : id_list ':' type
;
id_list : ident
| ident ',' id_list
;
type : integer
| BOOLEAN
;
proc_dec : proc_header forward ';'
| proc_header declaration_list compound_stmt
| func_header forward ';'
| func_header declaration_list compound_stmt
;
proc_header : procedure ident parametros ';'
;
func_header : function ident parametros : type
;
parametros : '(' param_list ')'
|
;
param_list : arg
| arg ';' param_list
;
arg : id_list ':' type
| var id_list ':' type
;
compound_stmt : begin statement_list end
;
statement_list : statement ';' statement_list
| statement
;
statement : ident attrib expression
| IF expression then statement
| IF expression then statement ELSE statement
| WHILE expression DO statement
| compound_stmt
| readln ident
| writeln print_list
|
;
print_list : literal print_list2
| expression print_list2
;
print_list2 : ',' print_list
|
;
expression : add_expression relop add_expression
| add_expression
;
relop : lessequal
| '<'
| '>'
| moreequal
| '='
| notequal
;
add_expression : add_expression addop term
;
addop : '+'
| '-'
| or
;
term : term mulop unary_exp
| unary_exp
;
mulop : '*'
| div
| mod
| and
;
unary_exp : not unary_exp
| factor
;
factor : '(' expression ')'
| ident
| num
| TRUE
| FALSE
;
%%
And I always get this:
byaccj: 19 rules never reduced
byaccj: 1 shift/reduce conflict.
What is a possible solution for this? I've found other people that have had the same kind of errors, but I was not able to find something useful for my problem. If more information is necessary, I provide. I also read that the 'Rules never reduced' error means that some rules from my grammar are never used, but I am not able to see this with my rules.