lex and yacc are closed-source programs, which you may have trouble getting and installing on Ubuntu (I've never actually tried).
You probably want to install the open-source alternatives, "bison" and "flex". These are both fully back-compatible with "yacc" and "lex", and so you should have no trouble in using them with a lex/yacc program (bison and flex are far more common than yacc and flex these days I believe).
You should be able to add these from Synaptic Package Manager; just run up the program, enter your password, search for "bison" and "flex" and tick the boxes when you see them. Then click on "Apply" and it will do the installation work for you.
Hope that helps,
—Robert J Lee