Install Lex on Ubuntu 16.04. Lex is in flex and Yacc in bison.
sudo apt install flex bison
Create an empty file and edit it.
digit [0-9] letter [A-Za-z] %{ int count; %} %% /* match identifier */ {letter}({letter}|{digit})* {count++; printf("number of identifiers = %d\n", count);} %%
Save it as lol.l
lex lol.l gcc lex.yy.c -lfl
And we can run it by typing
./a.out
An example