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?
Please let me know if I can provide any more information.
id
needs to be in the item set, and if the lookahead needs to be determined forid
. Any suggestions? $\endgroup$