# How to generate an LL(2) parse table?

The algorithms I've seen for building an LL(1) parse table involve calculating first and follow sets such that:

predict(nonterminal, production) ==
if epsilon in FIRST(production):
first(production) union follow(nonterminal)
else:
first(production)


where production is a sequence of symbols which can include nonterminals, terminals, and epsilon.

what's the algorithm for an LL(2) parse table?

Basically, you just need to extend $$FIRST$$ and $$FOLLOW$$ to be $$FIRST_k$$ and $$FOLLOW_k$$, meaning the first / following $$k$$ symbols. The basic principle is the same, but when $$k > 1$$ there is a complication, leading to the distinction between "strong" and regular grammars.