retagged by
10,767 views
2 votes
2 votes
I know the parsing logic of bottom up parsers, that they start from the terminal and reduce it to the start symbol. But what really confuses me is the construction of LR(0)/LR(1) sets :

Eg : S->Sa|a

Then in LR(0) set :

S'->.S

S->.Sa

S->.a

Now the dot is in front of S , so shouldn't the S production be generated again and again and make it go to an inf. loop?
retagged by

6 Answers

0 votes
0 votes

In bottom up parsing the string will keep on getting reduced(or handles will prune) resulting in bottom up parse tree.

eg-  consider the code-                 if (condition)----→  if(condition) + statement / Φ

so here for the top down parser will result in infinite left recursive tree until condition isn’t satisfied.       

                         if(condition)

                                  /\   

              if(condition)      statement                         <----- left recursive tree

                    /\

 if(condition)    statement                                                                                                       

        /\                                                                                                                                            

and so on

 

but in bottom up parser there is reduction of string resulting as follows-

                     if(condition)      

                            /\                                                                                     

           if(condition) + statement                                                                   ||           bottom to up movement

                                                                                                                     ||                   

 

                                                                                                                          

Related questions

2 votes
2 votes
2 answers
1
gate19 asked May 26, 2018
1,171 views
What is the difference between $SLR(1)$ and $LALR(1)$ parser ? Both parser have same parsing table then how $SLR$ is subset of $LALR$ ?
0 votes
0 votes
1 answer
2
aditi19 asked Jul 6, 2018
379 views
Does bottom up parsers give postfix expression?
0 votes
0 votes
2 answers
3
prasitamukherjee asked Jul 16, 2015
886 views
q. 23 : can anyone explain why both statements are false? I thought option B is correct?