In LR(0) items, the dot (•) indicates the position of the parser in a production rule. Consider the production rule A → αβ. What does the LR(0) item A → α • β represent?
Think about what the dot means in terms of what has been read and what is expected next.
The dot in an LR(0) item shows how much of the production has been seen. A → α • β means α is recognized, and the parser expects β next.
Given a production rule S → XYZ, how many distinct LR(0) items can be formed from this production?
Count the positions where the dot can be placed, including before the first symbol and after the last symbol.
For a production with n symbols on the right side, there are n+1 LR(0) items, placing the dot at each possible position.
Consider the LR(0) item set containing A → α • B β. What is the purpose of the closure operation applied to this item set?
Think about what happens when the dot is before a non-terminal symbol.
The closure operation adds items for all productions of the non-terminal immediately after the dot, with the dot at the start, to represent possible expansions.
Why do LR(0) parsers often encounter shift-reduce conflicts in grammars that are not LR(0)?
Consider what information LR(0) items lack compared to more powerful parsers.
LR(0) parsers do not use lookahead symbols, so they cannot always decide whether to shift or reduce when both are possible, leading to conflicts.
Given the LR(0) item set containing S' → • S and the grammar with productions S → a S b and S → ε, what is the next item set after reading the symbol a?
Consider the GOTO operation on symbol a and the closure of the resulting items.
After reading a, the dot moves past a in items where a is next. Closure adds items for productions starting with a and ε.
