Question

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

Homework Answers

Answer #1

1. Left-most derivation

<expr>
-> <term>
-> <term> * <factor>
-> <factor> * <factor>
-> number * <factor>
-> 3 * <factor>
-> 3 * ( <expr> )
-> 3 * (<expr> + <term>)
-> 3 * (<term> + <term>)
-> 3 * (<factor> + <term>)
-> 3 * (number + <term>)
-> 3 * (2 + <term>)
-> 3 * (2 + <term> * <factor>)
-> 3 * (2 + <factor> * <factor>)
-> 3 * (2 + number * <factor>)
-> 3 * (2 + 5 * <factor>)
-> 3 * (2 + 5 * number)
-> 3 * (2 + 5 * 6)


--------------------------------------
Hit the thumbs up if you are fine with the answer. Happy Learning!

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)
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))
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...
Define a grammar by setting Σ = {σ} and let F consist of the following instruction...
Define a grammar by setting Σ = {σ} and let F consist of the following instruction formulas. 1.    σ → N V.2.    N → n, for some n  {he, she, José, Sal, Anna}.3.    V → v, for some v  {runs, jumps, skips, falls, swims}.4.    σ → σ P σ.5.    P → p, for some p  {and, while until}.6.    σ → either σ or σ. Consider the following string in the given grammar. Draw the corresponding tree. (Submit a file with a maximum size of 10MB.) Sal runs while Anna...
Try to write a BNF like Grammar for each one of the following constructs: - positive...
Try to write a BNF like Grammar for each one of the following constructs: - positive and negative integer numbers - floating point numbers - variable names. Notice: Recursion is needed here (use right recursion): here is an example (a grammar of two rules defines any positive integer) : Note the length in digits is not defined in this grammar, it can go recursively for ever. So we need to add another annotation (a semantic part). <positive_Number> -> <digit> |...
Problem 3 Given a BST with N nodes, how many tree shapes are there with height...
Problem 3 Given a BST with N nodes, how many tree shapes are there with height N-1? Explain your reasoning. Problem 4 Given a BST with N nodes, how many tree shapes are there with height N-2? Explain your reasoning . Problem 5 Consider an empty 2-3 tree. Draw the tree after each of the following operations is executed: insert 0, insert 9, insert 2, insert 6, insert 7, insert 3, insert 8, delete 2, delete 6
Match each term on the left with the appropriate term on the right:       -...
Match each term on the left with the appropriate term on the right:       -       1.       2.       3.       4.       5.       6.       7.       8.       9.       10.    migration       -       1.       2.       3.       4.       5.       6.       7.       8.       9.      ...
1. Write 3n + 1 Sequence String Generator function (1 point) In lab5.py complete the function...
1. Write 3n + 1 Sequence String Generator function (1 point) In lab5.py complete the function sequence that takes one parameter: n, which is the initial value of a sequence of integers. The 3n + 1 sequence starts with an integer, n in this case, wherein each successive integer of the sequence is calculated based on these rules: 1. If the current value of n is odd, then the next number in the sequence is three times the current number...
Fill in the blank with the term that best fits the description. 1: oxygen and carbon...
Fill in the blank with the term that best fits the description. 1: oxygen and carbon dioxide carrying cell ______________ 2: plasma protein that forms a clot to help the body stop bleeding ____________ 3: name of factor that promotes RBC formation ____________ 4: element forming “core” of heme group _____________ 5: most common plasma protein ____________ 6: large cells that develop into platelets _______________ 7: a deficiency in number of RBCs or decreased hemoglobin content of blood ____________ 8:...
1) Find the values of the trigonometric functions of θ from the information given. cot(θ) =...
1) Find the values of the trigonometric functions of θ from the information given. cot(θ) = − 3/5, cos(θ) > 0 sin(θ) = cos(θ) = tan(θ) = csc(θ) = sec(θ) = 2) The point P is on the unit circle. Find P(x, y) from the given information. The x-coordinate of P is −√5/4, and P lies below the x-axis. P(x, y) = ( ) 3) Find the terminal point P(x, y)  on the unit circle determined by the given value of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT