- Consider non-terminal
A
, productionA -> a
, & tokent
First(a)
The idea behind FIRST(a)
is to be able to predict what kind of production to use when parsing an input string. Knowing the set of terminals that can appear first in strings derived from a
allows the parser to decide what to do when it encounters a particular symbol in the input.
- If
a ->* tb
a
can derive at
in the first positiont
is a terminal- then
Follow(a)
- If
A -> a
,a ->* ep
,S ->* b A t sig
- Has nothing to do with what
A
can produce - Useful if stack has
A
, input ist
, andA
cannot derivet
a
can’t derivet
, we need to erasea
so it must go toep
t
must come immediately afterA
, so we can get rid ofA
and matcht
- We say
- Has nothing to do with what