0
Recursive Descent Parser in java program
Grammer E -> x + T T -> (E) T -> x
4 Antworten
+ 9
Mohammad Umair show what you have tried till now and link that in codeplayground someone can surely help you out to make that code.
An hint to the problem in C as you want to parse an arithmetic expression then made function to validate that expression like this way.
T() and E() are function for validate according to your expressions
RD parser will verify whether the syntax of the input str
void E()
{
T();
Eprime();
}
void Eprime()
{
if(input[i]=='+')
{
i++;
T();
Eprime();
}
}
void T()
{
F();
Tprime();
}
void Tprime()
{
if(input[i]=='*')
{
i++;
F();
Tprime();
}
}
void F()
{
if(isalnum(input[i]))i++;
else if(input[i]=='(')
{
i++;
E();
if(input[i]==')')
i++;
else error=1;
}
else error=1;
}
+ 7
Try to solve like the above approach it just an hint towards the problem.
0
Ok