Home » Compiler Design » Compiler design miscellaneous » Question

Compiler design miscellaneous

  1. Consider the following grammar.
    S → S * E
    S → E
    E → F + E
    E → F
    F → id
    Consider the following LR (0) items corresponding to the grammar above.
    1. S → S * E
    2. E → F. + E
    3. E → F + .E
    Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar?
    1. 1 and 2
    2. 2 and 3
    3. 1 and 3
    4. None of these
Correct Option: D

Let's make the LR(0) set of items. First we need to augment the grammar with the production rule S' → .S, then we need to find closure of items in a set to complete a set. Below are the LR(0) sets of items.

In the LR(0) sets of items formed so far, we can see that given three items belong to the different sets (13, l4, l5). Here, S' → .S is an augmented production rule.



Your comments will be displayed only after manual approval.