Question: problem 10 consider the following grammar for postfix expression postfix -> number postfix2 Consider the following grammar for postfix expressions. (The symbol EMPTY in the
Consider the following grammar for postfix expressions. (The symbol EMPTY in the grammar means that we produce an empty string) Postfix -> Number Postfix2 Postfix2 - Postfix BinOp Postfix2 l UnOp Postfix2 I EMPTY BinopI Number -> any valid Java double Part (a) Draw the parse tree (not the expression tree) for the expression 4 5 + sqrt 3 Part (b) Explain why the abstract syntax tree for the expression 4 5 + sqrt 3 is the same as it was for the previous problem, even though the grammar has changed Part (c) Explain why you can write a recursive descent parser for this grammar Part (d) Write the Java code for the getpostfix() and getPostfix20 methods that would implement a recognizing parser (assume the usual interface to th Tokenizer) private static void getPostfix(Tokenizer tokens) /getPostfix() private static void getPostfix2(Tokenizer tokens) //getPostfix2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
