Problem Detail: There is this question I read somewhere but could not answer myself. Assume I have an LR(1) Parsing table. Is there any way that just by looking at it and its items, can I deduce that it is also a table for LALR and SLR?
Asked By : Jatin
Answered By : AProgrammer
Trivially, yes: the grammar is extractible from the items. Probably more in the spirit of the question. LALR(1) is easily extracted from LR(1): merge LR(1) items which correspond to the same LR(0) one and the grammar isn’t LALR(1) if that process results in conflicts. (BTW this can be considered as a definition of LALR(1)). SLR(1) is not so easy; you need to compute the follow sets to find out if there are conflicts. (SLR(1) is based on the LR(0) items like LALR(1), but it has “unneeded” conflicts due to the use of follow sets instead of the computation of look ahead one to choose which production to reduce.)
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/938