CLR(1) Table Construction

In this class, We discuss CLR(1) Table Construction.

For Complete YouTube Video: Click Here

The reader should have prior knowledge of LR(1) Table construction. Click Here.

We use the example discussed in constructing LR(I) items construction.

The productions of our grammar are assigned numbers.

1) S – CC

2) C – cC

3) C – d

The below diagram shows the LR(1) items construction.

In total, we have ten states.

The below table shows the canonical LR(1) parsing table.

Each state is assigned a row in our parsing table.

We need to fill GOTO and ACTION columns.

ACTION contains all terminal symbols, and GOTO contains all non-terminal symbols.

On state I0, if we see the non-terminal S, we move to state I1.

We mention the transition from I0 state to I1 in GOTO.

The ACTION part has two decisions.

1) SHIFT action

2) REDUCE action.

The dot symbol in the production is present in the middle of the production. We take SHIFT action.

Similarly, if the dot symbol in the production is at the end of the production we take REDUCE action.

On the state I0, the dot is present at the beginning of the production C – .cC.

Using the terminal symbol ‘c,’ we move to the I3 state. So we do ACTION shift to third state s3.

We need to fill the remaining table by looking at the construction of LR(1) items.

On state I4 the production C – d.

The dot symbol is present at the end of the production, so we need to reduce action.

We apply the reduce action to lookahead symbols.

State I1 is a special state. Where the production S’ – S. is added during augmentation.

We accept the input string on the state I1 with the dollar symbol.