Top-down parsers start with the start symbol . It determines which production to use to get the leftmost derivation of an input, rewrites using the productions, and repeats until the derivation of the input is complete or an error. It builds the tree top down. In this case, the grammar cannot be left-recursive.
Note some key implications of top-down approaches:
- The grammar cannot be left-recursive, i.e., there cannot exist a non-terminal such that we can form a derivation to a sentential form where it appears as the leftmost symbol.
- Intuitively, this is mainly because it would infinitely recurse, so we must rewrite our grammar such that this isn’t the case.