If we are designing a language that is to be efficiently
parsed then we must have no ambiguity in the syntax. In syntax
analysis we attempt to reconstruct the generating steps and hence
the states of the sentence, by reading the sentence symbol by
symbol. We do not want to have to backtrack.
We want to be able to know exactly where we are in state or
syntax graph by only looking one symbol ahead.
This is called one symbol lookahead with no backtracking.
Our requirement for efficiency leads to two rules.
(1) Given A::=1|
2|
3|......
n
then initial symbol of each set of sequences must be unique.
i.e. first symbol ofi != first symbol of
j for all i != j
S::=A|B How do we reconstruct
A::=xA|y xxz?
B::=xB|z
Rule one says A::= xA|y is not allowed
B::= xB|z
(2) For every symbol which can generate an empty sequence,
often denoted bythe set of its first symbols must be
disjoint from set of symbols that may follow any sequence
generated by A.
This saves us from parsing a sentence into a dead end
by choosing wrong path.