• retagged by
5,173 views
2 2 votes
Consider the following LL(1) grammar.
E → TE′
E′ → + E|ε
T → FT′
T′ → T|ε
F → GF′
F′ → *F′|ε
G → (E)|a|b|c
Initially stack contains two symbols. Bottom of stack symbol is $ and top of stack (above $) symbol is E where E is start symbol of the grammar. The number of symbols on the stack after the sixth action taken by LL(1) parser to parse the input “ab*” are ______.

2 Answers

1 1 vote

I guess, 3 should be the correct answer.

And the content of the stack should be T'E'$.

Here is the complete parsing of "ab*":

0 0 votes
Grammar is LL(1) so fo paerse string 'ab*' Productions are :

E$ ---> TE'$ ---> FT'E'$ ---> GF'T'E'$ ---> aF'T'E'$ ---> aT'E'$ ---> aTE'$ ---> aFT'E'$ ---> aGF'T'E'$ ---> abF'T'E'$ ---> ab*F'T'E'$ ---> ab*T'E'$ ---> ab*E'$ ---> ab*$

 

See content of stack after 6th operation .. it is { T', E', $ }
Position:
Show:

Related questions

1 1 vote
2 2 answers
5.0k
5.0k views
shekhar chauhan asked Jun 1, 2016
4,973 views
S → a S b S | b S a S | ε
2 2 votes
2 2 answers
1.3k
1.3k views
kallu singh asked Sep 5, 2017
1,287 views
Q if any Grammar is LL(1) definitely LALR(1) ?It is true or falsePlease ans explain in detail.
3 3 votes
1 1 answer
2.2k
2.2k views
AskHerOut asked Oct 1, 2017
2,227 views
lets consider a grammar as:$A\rightarrow Ab | Ac | a$while checking whether it belongs to LL(1) grammar, we would point out that it has a left recursion as well as left f...
2 2 votes
2 answers 2 answers
4.2k
4.2k views
sripo asked Nov 10, 2018
4,204 views
Can you give an example which is not LL(1) but is CLR(1)