|
4.2 LL(1) Parser DriverTop-down parsing proceeds by expanding productions, beginning with the start symbol. The grammar must be LL(1) In order to define LL(1), we need two preliminary definitions: FIRST and FOLLOW. FIRST is defined for a sentential form; FOLLOW is defined for a nonterminal. FIRST(), for any sentential form , is the set of terminals that occur left-most on any string derivable from including if is derivable from . For a nonterminal A in a sentential form, say A where and are some string of terminals and nonterminals, FOLLOW(A) = FIRST() That is, FOLLOW(A) is the set of terminals that can appear to the right of A in a sentential form. A grammar is LL(1) if and only if given any two productions A , A , (a) FIRST () FIRST( ) = , and (b) If one of or derives ,
|