Problem 14: 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 | UnOp Postfix2 | EMPTY BinOp ::= '+' | '-' | '*' | '/' UnOp ::= 'neg' | 'sqrt' 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 getPostfix2() methods that would implement a recognizing parser (assume the usual interface to the Tokenizer). private static void getPostfix(Tokenizer tokens) { }//getPostfix() private static void getPostfix2(Tokenizer tokens) { }//getPostfix2().
Problem 14: 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 | UnOp Postfix2 | EMPTY BinOp ::= '+' | '-' | '*' | '/' UnOp ::= 'neg' | 'sqrt' 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 getPostfix2() methods that would implement a recognizing parser (assume the usual interface to the Tokenizer). private static void getPostfix(Tokenizer tokens) { }//getPostfix() private static void getPostfix2(Tokenizer tokens) { }//getPostfix2().