Constructing a recursive descent parser to parse the following grammar. Is there a way i could return without passing anything back for all the epsilon productions(e)? (considering this approach I'm taking of parsing as shown in the code)
E = TG
G = +TG | e
T = FH
H = *FH | e
F = (E) | id
#include <stdio.h>
char* next;
int terminal(char);
int E();int G();int G1();int G2();int T();int H();int H1();int H2();int F();int F1();int F2();
int main(int argc, char const *argv[])
{
char str[10];
printf("Enter an expression to be parsed : ");
scanf("%s", str);
next = &str[0]
(*next == '\0' && E() == 1) ? printf("Parsed Successfully\n") : printf("Parsed Unsuccessfully\n");
return 0;
}
int terminal(char token){return *next++ == token;}
int E(){return T() && G();}
int G(){char* temp = next; return (next = temp, G1()) || (next = temp, G2());}
int G1(){return terminal('+') && T() && G();}
int G2(){return;} //ERROR : non-void function should return a value
int T(){return F() && H();}
int H(){char* temp = next; return (next = temp, H1()) || (next = temp, H2());}
int H1(){return terminal('*') && F() && H();}
int H2(){return;} //ERROR : on-void function should return a value
int F(){char* temp = next; return (next = temp, F1()) || (next = temp, F2());}
int F1(){return terminal('(') && E() && terminal(')');}
int F2(){return terminal('a');}