Can an LL(1) parse table be valid if there is a column with no entries in its cells?

StackOverflow https://stackoverflow.com/questions/18366170

  •  26-06-2022
  •  | 
  •  

سؤال

I'm doing exam questions for revision for an exam. One of the questions is to construct an LL(1) parse table from the first and follow sets calculated in the previous question.

Now I am nearly positive that I have constructed the first and follow sets correctly and the table does not have any duplicate entries in any of it's cells, so I assumed that the grammar was a valid LL(1) grammar (we are asked to determine if it is valid hence why I needed to construct the table).

However the next question is to convert the grammar into a valid LL(1) grammar, obviously implying that it is not LL(1)

So my question is actually 2 questions.

Is the grammar not an LL(1) grammar due to the fact that there is a column without any entries?

OR

If this is allowable in an LL(1) parse table, is it most likely that I went wrong creating the first and follow sets?

Here is my working out of the question and the grammar which is in the box http://imgur.com/UwmOAvX

هل كانت مفيدة؟

المحلول

It is perfectly ok for a column to have no symbols -- that just means that the terminal in question not in the FIRST set of any non-terminal, which can easily happen for symbols that don't appear in lead context anywhere (for example, a ) will often be such a symbol.)

In your case, the problem appears to be that you forgot to put the rule B -> B v into the table. You also have an error in FIRST(D) and FOLLOW(B) -- the latter comes from the former.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top