Question

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))

Homework Answers

Answer #1

LEFT MOST DERIVATION

<assign>
<id> = <expr>
A = <expr>
A = <id> * <expr>
A = A * <expr>
A = A * (<expr>)
A = A * (<id> + <expr>)
A = A * (B + <expr>)
A = A * (B + (<expr>))
A = A * (B + (<id> * <expr> ))
A = A * (B + (C * <expr> ))
A = A * (B + (C * <id>))
A = A * (B + (C * A))

PARSE TREE

PLEASE UP VOTE

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
Given the grammar <expr> -> <term> {( + | - ) <term>} <term> -> <factor> {(...
Given the grammar <expr> -> <term> {( + | - ) <term>} <term> -> <factor> {( * | / ) <factor>} <factor> -> <exp> { ** <exp>} <exp> -> (<expr>) | <id> <id> = (A | B | C | D | E) leftmost derivation of A**B + (B * C)
Consider the following context-free grammar: S → TT | U T → 0T | T0 |...
Consider the following context-free grammar: S → TT | U T → 0T | T0 | # U → 0U00 | # a. Give a parse tree for the string: 0#0#0 b. Give a leftmost derivation for the string: 00#0000
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.
Ex#6: Prove the following grammar is ambiguous. <S> --> <A> <A> --> <A> + <A> <A>...
Ex#6: Prove the following grammar is ambiguous. <S> --> <A> <A> --> <A> + <A> <A> --> <id> <id> --> a | b | c
Which of the following statements is FALSE? A) Traditional costing systems generally assign only production costs...
Which of the following statements is FALSE? A) Traditional costing systems generally assign only production costs to products. B) Traditional costing systems use a single cost pool for all indirect production costs. C) Traditional cost systems work well with simple production processes. D) Traditional cost systems allocate a cost pool to cost objects using multiple cost drivers. E) all the above
Chapter 8 Homework Assignment PE.08-02A PE.08-02B EX.08-16 EX.08-18.ALGO EX.08-20.BLANKSHEET.ALGO EX.08-21.ALGO EX.08-24.BLANKSHEET.ALGO PR.08-03.BLANKSHEET.ALGO Hide or show questions...
Chapter 8 Homework Assignment PE.08-02A PE.08-02B EX.08-16 EX.08-18.ALGO EX.08-20.BLANKSHEET.ALGO EX.08-21.ALGO EX.08-24.BLANKSHEET.ALGO PR.08-03.BLANKSHEET.ALGO Hide or show questions Progress:6/8 items eBook Show Me How Calculator Print Item Bank Reconciliation An accounting clerk for Chesner Co. prepared the following bank reconciliation: Chesner Co. Bank Reconciliation August 31 Cash balance according to company's records $5,820 Add: Outstanding checks $2,790   Error by Chesner Co. in recording Check     No. 1056 as $710 instead of $170 540   Note for $9,100 collected by bank, including interest 9,460 12,790...
Given ID X Y A 10 15 B 4 5 C 13 16 D 7 9...
Given ID X Y A 10 15 B 4 5 C 13 16 D 7 9 E 13 4 F 1 5 What is the variation in Y that can be explained by X? please explain A) 50.7 B) 22.7 C) 36.3 D) 105.7 E) 91.3
Using the following code: % Ex 6.4 First-order step and impulse response for two time constants...
Using the following code: % Ex 6.4 First-order step and impulse response for two time constants % clear all; close all; t = 0:.1:100; % Time vector subplot(1,2,1); x = 250*exp(-0.05*t); plot(t,x,'k'); xlabel('Time (hrs)','FontSize',14); ylabel('P_A (mmHg)','FontSize',14); title('Impulse Response','FontSize',14); subplot(1,2,2); x = 20*(1-exp(-0.05*t)); plot(t,x,'k'); xlabel('Time (hrs)','FontSize',14); ylabel('P_A (mmHg)','FontSize',14); title('Step Response','FontSize',14);    ANSWER: The response of a 1st order linear body fluid balance system to step function (L m (t) = 1/s, Eqn. 6.9/p226) and impulse function (L d (t) = 1,...
Which of the following statements is true in the simple circular flow model? a There is...
Which of the following statements is true in the simple circular flow model? a There is no government and no foreign sector (closed economy). b Households make factor payments to firms for the resources they supply, which are used to produce goods and services. c Factor prices are determined by the interaction of supply and demand of resources. d All of the above. e Only a) and c)
Prove or disprove the following statements. Remember to disprove a statement you have to show that...
Prove or disprove the following statements. Remember to disprove a statement you have to show that the statement is false. Equivalently, you can prove that the negation of the statement is true. Clearly state it, if a statement is True or False. In your proof, you can use ”obvious facts” and simple theorems that we have proved previously in lecture. (a) For all real numbers x and y, “if x and y are irrational, then x+y is irrational”. (b) For...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT