Whats wrong with my RPN (PostFix)output? A recursive descent approach with Grammars :)
posted 3 years ago
Howdy yalls! Fellow ranchers, I call for your help.. I cant seem to understand how to output my Infix expressions (ex. (a+b)*c | a+(b*c) ) into a post fix Expression using a b c (ex. ab+c* | abc*+ )
I wish to do this using the recursive descent method and not the stack parsing method. The output either doesn't come out correctly or I get an error.
I know this can help in compiler design and has many other uses but my expect method exceptions keep coming up. I have the Grammars listed below and I appear to have a problem getting the correct Tokens to be parsed and outputting in the correct
Reverse Polish Notation (Postfix) from my Infix input. I aimed to use the consume method to take in the current token and advance to the next.
Can anyone point out the problems in my code? Ive used this format before for basic grammars but this is slightly more difficult.