We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
The following grammar describes the syntax of the Java if statement: <stmt> rightarrow <matched> | <unmatched>...
Given the following grammar
statement if-stmt | other | Ԑ
if-stmt if (exp) statement else-part
else-part else statement | Ԑ
exp 0 | 1
a) Draw a parse tree for the string
If (0) if (1) other else else other
b) What is the purpose of the two else’s?
I need the the diagram of the parse tree
1. Given the following grammar (10 Marks) statement- if-stmt other | E if-stmt - if (exp) statement else-part else-part else statement |...
Using the grammar below: <program> → begin <stmt_list> end <stmt_list> <stmt> | <stmt>; <stmt_list> <stmt> <var> = <expression> <var> → ABC <expression> <var> + <var> | <var> - <var> | <var> 1) show a leftmost derivation and draw a parse tree for each of the statements below: (1) begin A=A-B; B=C; C=A end (2) begin A=B+C; C=C+B end 2) try a rightmost derivation and draw a parse tree for each of the statements in Q1).
P2) Given grammar in BNF, answer the following questions (30 points) <stmt-list>→<stmt> | <stmt»; <stmt-list> (a) Rewrite the given grammar into a EBNF (b) Is the given grammar ambiguous? Support your answer to receive the full credit. (c) Given string A-B C-D: B-C-A-D, draw a parsing tree
P2) Given grammar in BNF, answer the following questions (30 points) → |
3. Given the following grammar and the right sentential forms, draw a parse tree and show the phrases and simple phrases, as well as the handle. <S> <A> <B> →. a <A> b b <B> <A> → a b a <A> <B> → a <B> b (a) a a <A> a bb (b) b <B> a <A> b
3. Using the grammar below, show a parse tree and a leftmost derivation for the statement. A = ( A + (B)) * C assign <idxpr expr>? <expr> <term> term <term factor factor (<expr>) l <term I <factor l <id> 4. Prove that the following grammar is ambiguous (Give sentence that has two parse trees, and show the parse trees):
Explain why the following if statement results in syntax error in C, Java, and C#? if (x==1) y = 2 else y = 3;
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 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]...
Derive the following string with the grammar of figure 7.2 and
draw the corresponding syntax tree. +ddd
Figure 7.2 N = {I, F, M} T = {+,-,d} P = the productions 1.1 FM 2. F + 3. F → 4.F→€ 5. MM 6.Mnd S = I
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