5 votes 5 votes Consider the following grammar: $S\rightarrow0S1 | 01$ How many of the following are the viable prefixes of the grammar? i. 01 ii. 001 iii. 00011 iv. 00S1 PS: given answers i, ii and iv , please explain! Compiler Design compiler-design parsing viable-prefix + – Vijay Thakur asked Jan 13, 2017 edited Nov 21, 2023 by Hira Thakur Vijay Thakur 1.2k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 8 votes 8 votes Check the link for explaination :- https://gateoverflow.in/68764/bottom-up-parsing $S\rightarrow 01$ $S\rightarrow 0S1\rightarrow 0011$ $S\rightarrow 0S1\rightarrow 00S11$ Set of Viable Prefix $V = \left \{ \epsilon ,0,1,01,0S,0S1,00,001,00S,00S1 \right \}$ Kapil answered Jan 13, 2017 selected Jan 13, 2017 by ManojK Kapil comment Share Follow See all 10 Comments See all 10 10 Comments reply Vijay Thakur commented Jan 13, 2017 reply Follow Share not readable! 1 votes 1 votes Anusha Motamarri commented Jan 13, 2017 reply Follow Share @kapil why iii) is not viable? 0 votes 0 votes Kapil commented Jan 13, 2017 reply Follow Share Latex was not working :) 0 votes 0 votes Kapil commented Jan 13, 2017 reply Follow Share @Anusha, its not !! Instead $0001$ or $000S1$ is VP. 0 votes 0 votes Anusha Motamarri commented Jan 13, 2017 reply Follow Share sorry got it! 00011 never appears on top of the stack isnt it @kapil? upto 0001 appears on top then 01 reduces S..so 00S will be stack content but 00011 will never be stack content 1 votes 1 votes Anusha Motamarri commented Jan 13, 2017 reply Follow Share yes got it 1 votes 1 votes Lucky sunda commented Jan 20, 2017 reply Follow Share I am not getting one thing..According to the link u given..can't we write like this: S->0S1-->00S11-->000111{Bold one's are handle} {VIABLE PREFIX--> epsilon,0,0S,0S1,00,00S,00S1,00S11,000,0001,00011,000111} What is wrong in this?? 0 votes 0 votes Sushant Gokhale commented Jan 31, 2017 reply Follow Share @Lucky. See here 0 votes 0 votes Dipanshu Rana commented Nov 19, 2018 reply Follow Share please expain how you taken 1,0S as a viable prefix 0 votes 0 votes Vegeta commented Dec 10, 2018 reply Follow Share @Kapil sir i dont think 1 would be viable prefix 0 votes 0 votes Please log in or register to add a comment.