Consider the following CFG with the eight terminals: true, false, ^, V, !, (, and )....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following CFG with the eight terminals: true, false, ^, V, !, (, and ). expr → true | false expr A erpr | erpr V expr | ! expr | expr= expr | (expr) Indeed, the starting symbol is expr. Let's call this grammar G. This grammar is ambiguous, i.e., there exist at least two parse trees for some expression. For example, consider the following expression: !true ^ false V true (a) Give two different derivations for this expression such that the corresponding parse trees are differ- ent from each other. (10 points) (b) Give the corresponding parse trees for each derivation in the previous question. (10 points) true (c) Give the corresponding two ASTs. (10 points) (Hint: Note that operators A, V, ==, and ! can appear as interior nodes in AST. You may remove the nonterminal expr from ASTs as it does not convey any computational information.) (d) If you pass the ASTs from the previous question to an evaluator, what would be the final value in each case? (10 points) Consider the following CFG with the eight terminals: true, false, ^, V, !, (, and ). expr → true | false expr A erpr | erpr V expr | ! expr | expr= expr | (expr) Indeed, the starting symbol is expr. Let's call this grammar G. This grammar is ambiguous, i.e., there exist at least two parse trees for some expression. For example, consider the following expression: !true ^ false V true (a) Give two different derivations for this expression such that the corresponding parse trees are differ- ent from each other. (10 points) (b) Give the corresponding parse trees for each derivation in the previous question. (10 points) true (c) Give the corresponding two ASTs. (10 points) (Hint: Note that operators A, V, ==, and ! can appear as interior nodes in AST. You may remove the nonterminal expr from ASTs as it does not convey any computational information.) (d) If you pass the ASTs from the previous question to an evaluator, what would be the final value in each case? (10 points)
Expert Answer:
Answer rating: 100% (QA)
As the Grammer G is ambiguous so we generate a Grammer G given in the question where precedence is g... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Over budget and behind schedule are two phrases no hotel owner wants to hear regarding a hotel renovation. Yet, that's where the owners of the Hotel Victoria found themselves with four months to go...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Assume that a company is going to invest 900,000 USD in a new project. We expect that the invested capital in the fixed assets will be fully depreciated within 3 years as follows: 500,000 USD,...
-
Suppose everything in the system is as described in Quick Example 11-22 except that the child approaches the merry-go-round in a direction that is not tangential. Find the angle u between the...
-
As the population ages, there is increasing concern about accident-related injuries to the elderly. The article "Age and Gender Differences in Single-Step Recovery from a Forward Fall" (J. of...
-
If you are preparing a client for a deposition, what rules for responding to deposition questions should you review with the client?
-
Locate the 2007 financial statements for The Walt Disney Company on the Internet. Use those financial statements and consider the following questions. 1. As illustrated in Exhibit 10-10, Interbrand...
-
Company invests considerable time and money to develop sophisticated cost functions that rate high on all evaluative criteria. In the course of using the cost functions, a manager notes that in...
-
A girl has an age of x years. Her grandfather is aged y years. Write an expression for: a. Their combined age. b. The difference between their ages. c. The grandfathers age 10 years ago. d. The girls...
-
A. Which material is better for manufacturing diodes: Silicon or gemanium? Explain why? B. Explain what happens to the dynamic resistance of the diode as the forward current increases. C. Determine...
-
Assume the following information: Interest rate on borrowed euros is 5 percent annualized Interest rate on dollars loaned out is 7 percent annualized Spot rate for 0.8333 per dollar (one = $1.20)...
-
DOC Ltd disclosed the following The company sold 10,000 Common stock @ $100 each with a floatation costs of $20 Sold 5000 preferred stock of $100 @ 150. This stock carry a dividend of 16% Obtained...
-
Prove that Cos (A+B)Cos (A-B) = CosB - SinA or CosA - SinB
-
i) Find the angle between the lines y - 3x-5=0 and 3y-x+6=0. ii) Discuss the continuity of the function f(x) = x - 21 at x = 2.
-
5- For the circuit shown in Fig.4 find the output d.c. voltage. F 115 Vrms 60 Hz 10:1 eeeeeee eeeeeee Vsec D3 D DA Fig.4 Vp(in) 50 F R, = 2.2
-
What is deadlock? What is startvation? How do they differ from each other?
-
Could a set of three vectors in span all of? Explain. What about n vectors in when n is less than m? R4
-
If you have read the rest of Chapter 9, you may have noticed that the term trampoline is also used in conjunction with the implementation of signal handlers (Section 9.6.1). What is the connection...
-
Suppose we wish, as described at the end of Example 16.36, to accurately attribute sampled time to the various contexts in which a subroutine is called. Perhaps the most straightforward approach...
-
Consider the Prolog gcd program in Figure 1.2. Does this program work backward as well as forward? (Given integers d and n, can you use it to generate a sequence of integers m such that gcd(n, m) =...
-
Assume that vapor pressure can be calculated from the Antoine equation and that Raoult's law can be used to calculate K values. For a binary flash system, derive an analytical expression for the drum...
-
Analytically solve the Rachford-Rice equation for V/F for a binary system.
-
Determine the effect of pressure on the temperature, separation, and diameter of a flash drum.
Study smarter with the SolutionInn App