1. Given the grammar:
\(|*
\(\mid(\)
|
\(\langle\mathrm{id}>\rightarrow \mathrm{A}|\mathrm{B}| \mathrm{C}\)
(a) Show the parse tree of expression: \(A+C^{*} B\)
(b) Show the parse tree of expression: \(A^{*}(B+(C))\)
Derivation for A+C*B :
->
->
-> A + C * B
Derivation for A * (B+(C)) :
->
->
->
->
-> A * (B + (C))

2. Consider the following grammar: <assign> à <id> = <expr> <id> à A | B | C <expr> à <id> + <expr> | <id> * <expr> | ( <expr> ) | <id> Show a parse tree and leftmost derivation for the following statements: (a) A = ( A + B ) * C (b) A = A * ( B + C ) 3. [10 Points] Show that the following grammar is...
Question 3: Given the following grammar: assign → id := expr expr → expr + term \ term term -term *factor lfactor factor-(expr) id Using the above grammar, show a leftmost derivation (first five steps) for the following assignment statement: A ((A B)+ C) a. [3 marks] b. Using the above grammar, show a rightmost derivation (first five steps) for the following assignment statement: A:-A+B+C)+A [3 marks] Draw the abstract syntax tree for each of the above statements [4 marks]...
The questions in this section are based on the grammar given as the following: prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3 (2a) What is the associativity of the * operator? (5 points) (2b) What...
Using the following grammar: Expr -> Expr + Term I Expr * Term I Term Term-> 0 I ... I 9 I (Expr) Draw a parse tree for each of the following: (a) 5 + 4 * 3 (b) 5 * 4 + 3 using the following grammar: Expr -> Term+ Expr I Term * Expr I Term Term -> 0 I …. 9 I (Expr) Draw a parse tree for each of the following: (a) 5 + 4 *...
Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the associativity of each of the operators? What is precedence of the operators? Show a leftmost derivation and parse tree for the following sentence: b) c) A-A(B(C A)) d) Rewrite the BNF grammar above to give precedence over and force to be right associative.
Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the associativity of each of the operators? What is precedence of the operators? Show a leftmost derivation and parse tree for the following sentence: b) c) A-A(B(C A)) d) Rewrite the BNF grammar above to give precedence over and force to be right associative.
The questions in this section are based on the grammar given as the following: prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3 (2a) What is the associativity of the * operator? (5 points) (2b) What...
Use the grammar given below and show a parse tree and a leftmost
derivation for each of
the following statements.
1. A = A * (B + (C * A))
2. B = C * (A * C + B)
3. A = A * (B + (C))
<assign> → <id> <expr> = <expr> → <id> + <expr> kid<expr> <expr>) ids
9. Using the following grammar: Expr -> Term + Expr | Term * Expr | Term Term -> 0| ... | 9 | ( Expr ) draw a parse tree for each of the following (a) 5 + 4 * 3 (b) 5 * 4 + 3
1) Using the grammar in Example 3.2, show a completed
parse tree for each of the following statements: a) A = A * (B + (C
* A)) b) A = A * (B + (C))
2) Using the original grammar in Example 3.4, show a
completed parse tree for the statement: A = B + C + A
A Grammar for Simple Assignment Statements PLE 3.2 cassign><id> <expr> cidA BIC «ехpг» — sid + <ехpг» id cexpr> ( <expr>)...