I have been trying to solve this issue related to a current school assignment and would highly appreciate if anyone could explain to my why I am getting warnings from my compiler such as decafast.y:201.13-16: warning: rule useless in grammar [-Wother] | Type.
I have provided my code in the two following pastebin files:
decafast.lex: https://pastebin.com/2qzG2cwW
decafast.y: https://pastebin.com/Akg5ehW1
I have also been provided with a file 'decafast.cc' that contains classes and methods that enable me to create lists (I believe that is the purpose), found at:
https://pastebin.com/M7XRJunL
and the specification that I am supposed to follow (grammar found at bottom of page):
http://anoopsarkar.github.io/compilers-class/decafspec.html
My main concern is why I seem to be getting these warnings that are (what I assume to be) causing my code to fail. Nearly every (if not all) of my grammar is deemed to be useless, and despite my online searching (or lack thereof of understanding what has been said already), I am still unsuccessful.
I also had a secondary question if anyone is able to enlighten me. Regarding the .cc file above, I have been given a few classes that implement the decafAST class. In my parser generator file (decafast.y), I attempt to create lists by doing something along the lines of
decafStmtList *s = new decafStmtList();
I assumed that this would allow me to use the push_back() and push_front() methods, which is why I try things such as (in the case of ident_list, line 94) if I see one T_ID, then I create the list for T_ID (identifiers) and push the current T_ID into the list. If I see a situation of ident_list T_COMMA T_ID (which is what I assumed to be the case of a recurring list of comma-separated identifiers), then I would recognize that as an ident_list pattern, and thus push that T_ID into the list as well. Is this the correct way to use the lists that I have been provided?
I would like to stress that as this is an assignment question, I am pleading for any help that you can provide that will allow me to learn on my own terms. I am certain that the users on this website would easily be able to solve this assignment, therefore I would very highly appreciate any insight that you may be able to offer without giving me explicit answers. Thank you all for your time!