Question

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

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

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)

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.

Q1) (8%) 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
Q2) (6%) Is this grammar ambiguous (Yes
or No?) Justify your answer.
Q3) (6%) Does this grammar enforce the
precedence of the conventional operators (Yes or
No?) Justify...

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

10. Draw and decorate the parse tree for the following Attribute
Grammar for the following
statement:
word = 2.0 ∗ (5 − 10)
*** Assign is your STARTING SYMBOL
Assign =: identifier = Expr
Expr =: Expr + Term | Expr - Term | Term
Term =: Term * Factor | Term / Factor | Factor
Factor =: "(" Expr ")" | integer | float | identifier
Assign =: identifier = Expr [ identifier.value <= Expr.value
]
Assign =: identifier...

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

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,...

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

Which of the following statements is correct?
a) The balance sheet for a given year is designed to give us an
idea of what happened to the firm during the course of the
year.
b) The balance sheet for a given year tells us how much money
the company earned during that year.
c) The difference between the total assets reported on the
balance sheet and the liabilities reported on this statement tells
us the current market value of the...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 24 minutes ago

asked 52 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 3 hours ago

asked 3 hours ago

asked 3 hours ago