Factorize code of lexer.mll