3 votes 3 votes Is operator precedence parser the only parser that accepts left recursive grammar? Compiler Design compiler-design operator-grammar operator-precedence descriptive + – A_i_$_h asked Nov 13, 2017 retagged Jun 22, 2022 by Lakshman Bhaiya A_i_$_h 898 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Anu007 commented Nov 13, 2017 reply Follow Share LR can also accept, Top down not allow 0 votes 0 votes rahul sharma 5 commented Nov 13, 2017 reply Follow Share other Bottom up like Lr can also accept.But top down can not 0 votes 0 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes No. Left recursion is a problem for Top-Down parsers. Bottom-Up Parsers are fine with left recursion. A formal grammar that contains left recursion cannot be parsed by a LL(k)-parser or other naive recursive descent parser unless it is converted to a weakly equivalent right-recursive form. In contrast, left recursion is preferred for LALR parsers because it results in lower stack usage than right recursion. link: https://en.wikipedia.org/wiki/Left_recursion#Accommodating_left_recursion_in_top-down_parsing The top-down parser had a problem with left recursion precisely because it needed to build top-down. To build top-down, it needed to know about all the plus signs to come, because these needed to be fitted into the parse tree above the current plus sign. But when building bottom-up, we don't need to know anything about the plus signs that will be above the current one in the parse tree. We can afford to wait until we encounter them. But if working bottom-up solves the left recursion problem link: http://jeffreykegler.github.io/Ocean-of-Awareness-blog/individual/2014/11/ll.html https://stackoverflow.com/a/4317204/6430403 Rishabh Gupta 2 answered Nov 13, 2017 selected Nov 13, 2017 by A_i_$_h Rishabh Gupta 2 comment Share Follow See all 0 reply Please log in or register to add a comment.