# Intuitive Explanation on Converting BNF Grammar to LR(1)

Consider the following BNF Grammar G:

object-expression   ::=     id | id ( object-expression ) | object-expression . id
| object-expression [ object-expression ]
| object-expression . id ( object-expression )


I am attempting to construct a set of LR(1) items based on G.

Attempt:

Let's represent Grammar G as:

O -> id
O -> id ( O )
O -> O . id
O -> O [ O ]
O -> O . id ( O )


Item Set 1:

O' -> • O, $O -> • id,$
O -> • id ( O ), $O -> • O . id,$
O -> • O [ O ], $O -> • O . id ( O ),$


Can someone provide an intuitive explanation in simple language on how to finish obtaining a set of LR(1) items given a BNF Grammar such as G?

• @YuvalFilmus I've seen the algorithm, but I am unable to find a source that gives an example like the one mentioned. For example, I do not know if id needs to be in the item set, and if the lookahead needs to be determined for id. Any suggestions? – Grant Miller Mar 6 '17 at 2:30