next up previous contents
Next: Operation of a handle-recognising Up: Handle-recognising DFAs and LR(0) Previous: Handle-recognising DFAs and LR(0)   Contents

Construction of a handle-recognising DFA

To construct a handle-recognising DFA from a context-free grammar, perform the following:

  1. Prepare the grammar by:
    1. Eliminating any $\varepsilon$-productions
    2. If $S$ is the start symbol, add a new rule to the grammar $S'\, \rightarrow\, S$.

  2. The start state of the DFA is ${\sf closure}\{S'\, \rightarrow\, {}_{\triangle} S\}$

  3. Each time we create a new state in the DFA perform the following:
    For each grammar symbol (terminal or non-terminal):
    work out the closure of the move operation applied to newly created state and this symbol; this may create new states.

Note the similarities between this and the "subset construction" algorithm which we used to convert a NFA to a DFA.



James Power 2002-11-29