I'm trying to learn YACC and having a bit of trouble figuring out the warning messages it is giving me. Here is part of my file:
define_character: WORD IS STRING COLOR
{
printf("%s's full name is %s and thier color is %s", $1, $3, $4);
};
dialog: WORD COLON STRING
{
printf("%s says %s", $1, $3);
};
change_scene: SCENE SETSCENE WORD
{
printf("%s is the new scene", $3);
};
The warnings that it gives me are:
2 rules never reduced
2 useless nonterminals and 2 useless rules
warning: useless nonterminal: dialog
warning: useless nonterminal: change_scene
warning: useless rule: dialog: WORD SEMICOLON STRING
warning: useless rule: change_scene: SCENE SETSCENE WORD
How do I fix these? I've tried searching and I've found people who have the error due to shift/reduce conflicts. It seems that YACC usually adds that to the warning output if there are any, but just to be sure I tried removing WORD from change_scene so it would not be looking for any of the same tokens as the other ones and it still doesn't reduce. I can test all of the rules because whichever one is at top is the one that works. Am I missing some syntax at the end of the first rule that is causing problems with the rest of them?