COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
LR(0) item + First(S’)
|
|
LR(0) item + Action
|
|
LR(0) item + Lookahead
|
|
LR(0) item + Follow(S’)
|
Detailed explanation-1: -The lookahead of an LR(1) item is used directly only when considering reduce actions (i.e., when the • marker is at the right end). The core of an LR(1) item [S → a A • B e, c] is the LR(0) item S → a A • B e. Different LR(1) items may share the same core.
Detailed explanation-2: -Difference between LR(0) and LR(1) algorithm LR(1) allows us to choose the correct reductions and allows the use of grammar that are not uniquely invertible while LR(0) does not. LR(0) reduces at all items whereas LR(1) reduces only at lookahead symbols. LR(0) = canonical items and LR(1) = LR(0) + lookahead symbol.
Detailed explanation-3: -SLR (1) refers to simple LR Parsing. It is same as LR(0) parsing. The only difference is in the parsing table.To construct SLR (1) parsing table, we use canonical collection of LR (0) item. In the SLR (1) parsing, we place the reduce move only in the follow of left hand side.
Detailed explanation-4: -An LR (0) item is a production G with dot at some position on the right side of the production. LR(0) items is useful to indicate that how much of the input has been scanned up to a given point in the process of parsing. In the LR (0), we place the reduce node in the entire row.