flex (for lex)
bison (for yacc)
Open a terminal and type the following command
sudo apt-get install flex bison
After the installation type the following two commands on the console.
which lex
which yacc
They should return /usr/bin/lex and /usr/bin/yacc respectively if lex and yacc
installed properly