I am writing a parser with Bison and I am getting the following warnings.
fol.y:42 parser name defined to default :"parse"
fol.y:61: warning: type clash ('' 'pred') on default action
I have been using Google to search for a way to get rid of them, but have pretty much come up empty handed on what they mean (much less how to fix them) since every post I found with them has a compilation error and the warnings them selves aren’t addressed. Could someone tell me what they mean and how to fix them? The relevant code is below. Line 61 is the last semicolon. I cut out the rest of the grammar since it is incredibly verbose.
%union {
char* var;
char* name;
char* pred;
}
%token <var> VARIABLE
%token <name> NAME
%token <pred> PRED
%%
fol:
declines clauses {cout << "Done parsing with file" << endl;}
;
declines:
declines decline
|decline
;
decline:
PRED decs
;
The first message is likely just a warning that you didn’t include
%start parsein the grammar specification.The second means that somewhere you have rule that is supposed to return a value but you haven’t properly specified which type of value it is to return. The PRED returns the
predelement of yourunion; the problem might be that you’ve not created%typeentries fordeclineanddeclines. If you have a union, you have to specify the type for most, if not all, rules — or maybe just rules that don’t have an explicit action (so as to override the default$$ = $1;action).I’m not convinced that the problem is in the line you specify, and because we don’t have a complete, minimal reproduction of your problem, we can’t investigate for you to validate it. The specification for
decsmay be relevant (I’m not convinced it is, but it might be).You may get more information from the output of
bison -v, which is they.outputfile (or something similar).