651 views
0 0 votes
Q5. Find the FIRST and FOLLOW of the grammar to check whether it is LL (1) parser or not.

    N → AB | BA

    A → a | CAC

    B → b | CBC

    C → a | b

2 Answers

0 0 votes
We can see B->b | CBC, will fall into the same cell in the LL(1) Parsing table as first(b)=b and first(C)={a,b}, therefore their intersection is b and hence we have multiple enteries in one cell.
Hence the given grammar is not LL(1)
0 0 votes

Given grammar is ambiguous grammar for string $aabb$. it generates 2 different parse trees for a particular string. For any LL(1) grammar it should be unambiguous grammar. so we can say it is not LL(1) grammar.

  1. first(N)={a,b}, follow(N)={$}
  2. first(A)={a,b}, follow(A)={$,a,b}
  3. first(B)={a,b},follow(B)={$,a,b}
  4. first(C)={a,b},follow(C={$,a,b}
Position:
Show:

Related questions

0 0 votes
2 2 answers
1.5k
1.5k views
Ebrahim asked Dec 18, 2023
1,507 views
Please Answer this question in detail step by step: 3. Translate the arithmetic expression (a + b * c) + d + (a + b * c) − d + e into: a). Syntax tree, (please draw...
0 0 votes
0 0 answers
568
568 views
Ebrahim asked May 5, 2024
568 views
Q4. Generate target code for the following source language statements : x = a + b + c * (d-e) 
0 0 votes
0 0 answers
404
404 views
Ebrahim asked May 5, 2024
404 views
Q2. Implement the statement a:= -b + c*(d-e) + f * (c*(d-e)) into following Intermediate code representation.  a) Quadrupleb) Triple c) Indirect Triple Solve the above ...
0 0 votes
2 2 answers
776
776 views
Ebrahim asked Jan 31, 2024
776 views
6. Generate code for the following C program using any code generation algorithm. [3 Marks] main() { int x, a, b, c, d, e; ...