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)
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.
Q1) (8%) Show a leftmost derivation step by step (each step on a single line)          ...
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...
1. Given the Grammar <expr> --> <expr> + <term> | <term> <term> --> <term> * <factor>...
1. Given the Grammar <expr> --> <expr> + <term> | <term> <term> --> <term> * <factor> | <factor> <factor> --> ( <expr> ) | number For the given string 3 * ( 2 + 5 * 6), perform the following: 1. Left-most derivation 2. Draw a parse tree 3. Draw an abstract syntax tree Note: number as a terminal has multiple values
can someone please answer these in the correct format: Assignment #2 Total 43 pts (12pts) List...
can someone please answer these in the correct format: Assignment #2 Total 43 pts (12pts) List at least 3 words in the language and write regular expressions for the following: S = {a,b,c} L = {all words that have only one letter c in them} S = {a,b,c} L = {all words in which c’s appear in groups of two} S = {a,b,c} L = { all words that begin and end with the same letter} S = {a,b,c} L...
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
Given the following grammar and the right sentential form, draw a parse tree and then specify...
Given the following grammar and the right sentential form, draw a parse tree and then specify and write the phrases, simple phrase(s), and the handle. Grammar: S → AbB | bAc A → Ab | aBB B → Ac | cBb | c Sentential form: AbcacAbcbccb
Given the following grammar and the right sentential form, draw a parse tree and then specify...
Given the following grammar and the right sentential form, draw a parse tree and then specify and write the phrases, simple phrase(s), and the handle. Grammar: S → aAb | bBA A → ab | aAB B → aB | b Sentential form: aaababb
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
10. Draw and decorate the parse tree for the following Attribute Grammar for the following statement:...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT