Question

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)

Homework Answers

Answer #1

<<exp>r>
<term> + <term>
<term> + <term>
<factor> + <term>
<exp> ** <exp> + <term>
<id> ** <exp> + <term>
A ** <exp> + <term>
A ** <id> + <term>
A ** B + <term>
A ** B + <factor>
A ** B + <exp>
A ** B + (<<exp>r>)
A ** B + (<term>)
A ** B + (<factor> * <factor>)
A ** B + (<exp> * <factor>)
A ** B + (<id> * <factor>)
A ** B + (B * <factor>)
A ** B + (B * <exp>)
A ** B + (B * <id>)
A ** B + (B * C)]

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))
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.
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
(1) derive a legal sentence. expr −→ term | expr add op term term −→ factor...
(1) derive a legal sentence. expr −→ term | expr add op term term −→ factor | term mult op factor factor −→ id | number | - factor | ( expr ) add op −→ + | - mult op −→ * | /
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
For the given grammar below, find the first and follow function sets. Then, construct the parsing...
For the given grammar below, find the first and follow function sets. Then, construct the parsing table. By using the LL(1) parser and the parsing table, find if the given string “acfh” is accepted or rejected. S → aBDh B → cC | ε C → bC | ε D → EF E → g | ε F → f | ε
The grammar below generates Boolean expressions in prefix notation: B → O B B | not...
The grammar below generates Boolean expressions in prefix notation: B → O B B | not B | id O → and | or a) Write an attribute grammar to translate Boolean expressions into fully parenthesized infix form. For example, expression and and a or b c d turns into the following fully parenthesized expression ((a and (b or c)) and d). b) Now write an attribute grammar to translate the Boolean expressions into parenthesized expressions in infix form without...
Obtain a grammar in Chomsky Normal Form (CNF) equivalent to the grammar G with productions P...
Obtain a grammar in Chomsky Normal Form (CNF) equivalent to the grammar G with productions P given S ->aAb | B A ->aA | a B-> bB | b
Consider the grammar G with productions as follows: S → AD | BC A → a...
Consider the grammar G with productions as follows: S → AD | BC A → a B → b C → a | AS | BE D → b | BS | AF E → CC F → DD Use the CYK algorithm to test membership of abbaba.
Which of the following is not a factor in operating cash flow? A. Long-term debt B....
Which of the following is not a factor in operating cash flow? A. Long-term debt B. Depreciation expense C. Accounts Receivable D. Wages Payable
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT