/////////////
// Compile
/////////////
flex length.l
g++ lex.yy.c -ll -Wno-deprecated
////////////
// length.l
////////////
%{
#include <stdio.h>
#include <iostream>
using namespace std;
%}
%%
[a-zA-Z0-9_]+ {
int n = yyleng;
cout << yytext << ": " << n << endl;
}
[ \t]+ ; /*ignore tabs and spaces, otherwise they call ECHO;*/
\n { return 0; } /*end the program, do not ask for more input */
%%
int main(void) {
yylex();
return 0;
}