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))
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
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.
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...
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) 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 −→ * | /
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...
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
Question 1 Consider the following grammar G: S ➝ A B C | A C |...
Question 1 Consider the following grammar G: S ➝ A B C | A C | A | B A ➝ a B B ➝ b C | a C ➝ c D D ➝ d A Recall that a non-terminal A is reachable if there is a derivation starting from S in which A appears: S ⇒* x A y holds for some x and y which are sequences of terminals and non-terminals (possibly empty). For example, if there...
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