Question

Consider the following CFG with the eight terminals: true, false, , , !, ==, (, and...

Consider the following CFG with the eight terminals: true, false, , , !, ==, (, and ).

expr → true | false | expr ∧ expr | expr ∨ expr | !expr | expr == expr | (expr )

Indeed, the starting symbol is expr . Let’s call this grammar tt. This grammar is ambiguous, i.e., there exist at least two parse trees for some expression. For example, consider the following expression: !true ∧ false ∨ true == true

Give two different derivations for this expression such that the corresponding parse trees are differ- ent from each other. (10 points)

Give the corresponding parse trees for each derivation in the previous question. (10 points)

Give the corresponding two ASTs. (10 points) (Hint: Note that operators , , ==, and ! can appear as interior nodes in ASTs1. You may remove the nonterminal expr from ASTs as it does not convey any computational information.)

If you pass the ASTs from the previous question to an evaluator, what would be the final value in each case? (10 points)

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
True or False Answer each of the following statements True/False. Give a full explanation of your...
True or False Answer each of the following statements True/False. Give a full explanation of your answer. Include clearly labelled graphs where appropriate. (9 points) a. Consider the following consumption bundles of two goods: (x1,x2) = (27,10), (x1, x2) = (40, 18), and (x1, x2) = (200, 7). Monotonicity implies that (40, 18) is preferred to (27, 10), but does not imply that (200, 7) is preferred to (27, 10). b. If the marginal rate of substitution between two goods...
Decide if each of the following statements are true or false. If a statement is true,...
Decide if each of the following statements are true or false. If a statement is true, explain why it is true. If the statement is false, give an example showing that it is false. (a) Let A be an n x n matrix. One root of its characteristic polynomial is 4. The dimension of the eigenspace corresponding to the eigenvalue 4 is at least 1. (b) Let A be an n x n matrix. A is not invertible if and...
Assume that the following variables are set as follow P is True, Q is False, R...
Assume that the following variables are set as follow P is True, Q is False, R is False. Solve for X X = (P ∧ ~Q) ∨ (~P ∧ ~R) Solve for Y Y=(P  Q ) ∨ (R  ~P)                                                                                                                                                                            20 points Give one example and the mathematical symbol for the following: A universal set A subset A proper subset An empty set The intersect of two sets. 25 points Convert the following the numbers (must show all...
State whether you consider the following statements to be TRUE or FALSE. Justify your answer in...
State whether you consider the following statements to be TRUE or FALSE. Justify your answer in each case. (a) A hard real –time application is made up of only hard real-time tasks. (b) Every safety-critical real-time system has a fail-safe state. (c) A deadline constraint between two stimuli can be considered to be behavioral constraint on the environment of the system. (d) Hardware fault-tolerance techniques can easily be adapted to provide software faulttolerance (e) A good algorithm for scheduling hard...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue = red + 2 * 5 red++; blue = blue + red; cout << blue; 4 points    QUESTION 2 Is the following statement true or false? The Boolean expression in the following if statement will be true for all values of x in the range from 10 to 20 (including the endpoints) and false for all other values: int x; if (x >=...
True or False? 1) A production possibilities frontier allows us to identify the opportunity cost of...
True or False? 1) A production possibilities frontier allows us to identify the opportunity cost of producing a particular good in an economy. 2) Consider the production possibilities frontier. The efficient points are the ones that are either on or outside the frontier. 3) When people work more hours, the production possibilities frontier shifts inwards. 4) When people become more productive, the production possibilities frontier shifts inwards because it takes less time to produce each unit. 5) The production possibilities...
Part II: True/False (2% each) T                F                Negative amortization reduces the principal b
Part II: True/False (2% each) T                F                Negative amortization reduces the principal balance of the loan. T                F                ARMs help lenders limit or eliminate interest rate risk. T                F                The default risk of a fixed rate mortgage is higher than the default risk of an ARM. T                F                The term “percentage rent” refers to rent paid by the tenant as a percentage of the space leased to reimburse the landlord for increases in operating expenses. T    ...
Data For Tasks 1-8, consider the following data: 7.2, 1.2, 1.8, 2.8, 18, -1.9, -0.1, -1.5,...
Data For Tasks 1-8, consider the following data: 7.2, 1.2, 1.8, 2.8, 18, -1.9, -0.1, -1.5, 13.0, 3.2, -1.1, 7.0, 0.5, 3.9, 2.1, 4.1, 6.5 In Tasks 1-8 you are asked to conduct some computations regarding this data. The computation should be carried out manually. All the steps that go into the computation should be presented and explained. (You may use R in order to verify your computation, but not as a substitute for conducting the manual computations.) A Random...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT