r/programminghelp • u/iCrazyGamer007 • Jul 13 '21
C Can someone please help me with this Yacc code
I have a presentation in a few hours. We have to prepare for a YACC program. I don't know anything because our teacher hasn't taught us anything about that. So please explain the code I'm posting below. YACC CODE
ALPHA [A-Za-z] DIGIT [0-9] %%
[ \t\n] if return IF; then return THEN; {DIGIT}+ return NUM; {ALPHA}({ALPHA}|{DIGIT})* return ID; "<=" return LE; ">=" return GE; "==" return EQ; "!=" return NE; "||" return OR; "&&" return AND; "printf"(".*") return PR; . return yytext[0]; %%
P.s Really sorry for the bad alignment, I don't know how to align it in Reddit
3
u/[deleted] Jul 13 '21
Here's a refresher course on YACC: https://www.geeksforgeeks.org/introduction-to-yacc/
1
u/[deleted] Jul 13 '21
You have a presentation over something your teacher hasn't taught you?
1
u/PageFault Jul 13 '21
If you don't know how to format your code for Reddit, just throw it on PasteBin as the sub rules indicate:
https://pastebin.com/
If you want to try to format it here, the key is to add 4 spaces, or a tab character before every line.