2 votes 2 votes How to check in the grammar that which parsing method works more efficient for it? For eg in the following grammar - S-> Aa/b S->a Options - a) Top - Down b) Bottom - up c) Both d) None of these Answer is b. Compiler Design compiler-design grammar parsing + – Kaifi7 asked Oct 7, 2017 • retagged Jun 19, 2022 by Lakshman Bhaiya Kaifi7 597 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 1 votes 1 votes Generally, top-down parsers suffers from the backtracking hence inefficient. So bottom-up is more preferable. rishi71662data4 answered Oct 7, 2017 • selected Feb 16, 2018 by Kaifi7 rishi71662data4 comment Share Follow See all 2 Comments See all 2 2 Comments reply Kaifi7 commented Oct 7, 2017 reply Follow Share So in every grammar bottom up parsing is more preferrable or it depends on the grammar? 0 votes 0 votes rishi71662data4 commented Oct 8, 2017 reply Follow Share It depends on the grammar. Left Recursive Grammar and Non Deterministic grammar cannot be parsed by Top Down Parsers. Left recursive grammar gives out infinite loop and non deterministic grammar may result into backtracking. Such problems aren't there for Bottom up parsers, hence bottom up parser s are preferred. Provided that the grammar has no left recursion and is deterministic then you can apply top down parsing. Experts can explain better if I went wrong somewhere. 1 votes 1 votes Please log in or register to add a comment.