Question

Show a leftmost derivation step by step (each step on a single line)           for the...

Show a leftmost derivation step by step (each step on a single line)

          for the statement: A = A + B * C using the following grammar:

<assign> --> <id> = <expr>
<expr>    --> <id> + <expr> | <id> * <expr> |   <id>
<id>         --> A | B | C

Is this grammar ambiguous (Yes or No?) Justify your answer.

Does this grammar enforce the precedence of the conventional operators  (Yes or No?)   Justify your answer.

Homework Answers

Answer #1

No, the grammar is not ambiguous.

Reason:

There are no more than one leftmost derivation or more than one rightmost derivation or more than one parse tree possible that can generate the same expression. Hence, it is unambiguous.

Yes, this grammar enforce the operator precedence of the conventional operators

Reason:

The grammar is an operator precedence grammar.

The operator precedence table for the given grammar is:

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
Ex#5: Given the following grammar for a simple assignment statements. <assign> --> <id> = <expr> <id>...
Ex#5: Given the following grammar for a simple assignment statements. <assign> --> <id> = <expr> <id> --> A | B | C <exp> --> <id> + <expr> | <id> * <expr> | (<expr>) | <id> Show a leftmost derivation and a parse tree of the following statement: A = A *(B + (C * A))
All of the following are benefits to using a multi-step income statement instead of a single-step...
All of the following are benefits to using a multi-step income statement instead of a single-step income statement except: A. The multiple-step income statement clearly states the gross profit amount. Many readers of financial statements monitor a company's gross margin (gross profit as a percentage of net sales). Readers may compare a company's gross margin to its past gross margins and to the gross margins of the industry. B. The multiple-step income statement presents the subtotal operating income, which indicates...
Wild Widget must set up an assembly line for widgets. Forecasts show that 52 units per...
Wild Widget must set up an assembly line for widgets. Forecasts show that 52 units per hour should be produced. The tasks required, task times, and precedence relationships are as follows: Task Time (seconds) Predecessors A 10 – B 33 A C 23 A D 24 C,B E 20 D F 18 D G 36 E,F b. What is the takt time? (Round your answer to the nearest whole number.) c. What is the theoretical number of workstations? (Round up...
Philosophy 3. Multiple-Line Truth Functions Compound statements in propositional logic are truth functional, which means that...
Philosophy 3. Multiple-Line Truth Functions Compound statements in propositional logic are truth functional, which means that their truth values are determined by the truth values of their statement components. Because of this truth functionality, it is possible to compute the truth value of a compound proposition from a set of initial truth values for the simple statement components that make up the compound statement, combined with the truth table definitions of the five propositional operators. To compute the truth value...
Please show step by step Using the following learning curve, determine cost per unit at each...
Please show step by step Using the following learning curve, determine cost per unit at each 100 units between 100 and 400 units. log C = 3.5 -.275 log Q where C is average cost.
Give a mathematical derivation of the formula P((A ∩ Bc ) ∪ (Ac ∩ B)) =...
Give a mathematical derivation of the formula P((A ∩ Bc ) ∪ (Ac ∩ B)) = P(A) + P(B) − 2P(A ∩ B). Your derivation should be a sequence of steps, with each step justified by appealing to one of the probability axioms. ##### solution ########## 1 Since the events A ∩ Bc and Ac ∩ B are disjoint, we have, using the additivity axiom, P((A ∩ Bc ) ∪ (Ac ∩ B)) = P(A ∩ Bc ) + P(Ac...
Please solve this question step by step. You can online software like SPSS, but show steps...
Please solve this question step by step. You can online software like SPSS, but show steps for each part. If you can't provide step by step answer. Don't bother to answer at all. I should be able to replicate the result. Answer the within-subjects ANOVA questions using the data below. Use α = 0.01. 1 2 3 4 53 49 47 42 26 34 44 44 39 36 21 39 30 12 46 42 39 37 42 34 47 25...
Language: C++ You're given a 1000-line text file, phoneno.txt, where each line consists of a 5-digit...
Language: C++ You're given a 1000-line text file, phoneno.txt, where each line consists of a 5-digit ID# and a phone# in the format of ###-###-####. The data were generated randomly so there might be duplicates in the IDs. You're asked to do the following by using standard library algorithms as much as possible: 1. read the file into a map which has an integer for key (ID#) and a string for value (phone#), this allows the duplicates to be removed....
Show work through excel using formulas: but please actually show each step you use to do...
Show work through excel using formulas: but please actually show each step you use to do it on excel! 1. Assume you have taken out a balloon mortgage loan for $2,500,000 to finance the purchase of a commercial property. The loan has a term of 5 years, but amortizes over 25 years. Calculate the balloon payment at maturity (Year 5) if the interest rate on this loan is 4.5%. A. $5,637.99 B. $13, 895.82 C. $2,196,447.59 D. $2,495,479.19
determine whether each of the following functions are one-to-one by using the horizontal line test. (a)...
determine whether each of the following functions are one-to-one by using the horizontal line test. (a) f(x) = x2 + 5 Yes, it is one-to-one. No, it is not one-to-one.      (b) g(x) = 3x3 + 2 Yes, it is one-to-one.No, it is not one-to-one.      (c) h(x) = |x - 2| Yes, it is one-to-one.No, it is not one-to-one.    
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT