0

Recursive Descent Parser in java program

Grammer E -> x + T T -> (E) T -> x

27th Feb 2019, 4:14 PM
Mohammad Umair
Mohammad Umair - avatar
4 odpowiedzi
+ 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;           }            
27th Feb 2019, 5:19 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 7
Try to solve like the above approach it just an hint towards the problem.
27th Feb 2019, 5:20 PM
GAWEN STEASY
GAWEN STEASY - avatar
0
Ok
28th Feb 2019, 3:32 AM
Mohammad Umair
Mohammad Umair - avatar
28th Feb 2019, 8:39 AM
Mohammad Umair
Mohammad Umair - avatar