# LL(1) parsing table of left-recursive grammar

I have been taking a compiler course of Stanford on coursera. I have a slight misunderstanding on the parsing table of the following grammar:

S -> Sa | b

According to the professor parsing table looks like this:

• If the leftmost nonterminal is S and the input is 'a', the production is nothing.

• If the leftmost nonterminal is S and the input is 'b', the production is both Sa and b.

So if input is just b, then it is correct, it will go directly to production b. But how will it go to production Sa for input b?

• What is your goal here? Left-recursive grammars can not be parsed by LL(1). – Raphael Aug 14 '12 at 20:39

This language is left-recursion If you try to derive using the first production, you will get some kind of infinite loop $S \rightarrow Sa \rightarrow Saa \rightarrow Saaa ... \rightarrow Saaa...aaa$ So it cannot be parsed using LL(1). As @Alex ten Brink said, you should change the grammar.