Lex Comments
%{ /*
This is a valid lex file, except for the title "Lex Comments" at
the top. The comments are all correct for Lex. This is Comment 0.
Also note the three other comments in various locations in this code.
As always, note the use of white-space before any C code.
Comment 0: Within %{ ...%}.
Comment 1: In the comments section, preceded by a blank.
Comment 2: In the body, within a compound C statement (in braces).
Comment 3: In the body, preceded by a blank. Also note semi-colon.
*/
%}
/*comment1*/
int i,x,y;
D [0-9]
H [a-fA-F]
%%
[xX]({H}|{D})+ { /*comment2*/
y=0;
for (i=1 ; i < strlen (yytext) ; i++) {
x=yytext [i];
if (x >= '0' && x <= '9') {x = x - '0';}
if (x >= 'A' && x <= 'F') {x = x - 'A' + 10;}
if (x >= 'a' && x <= 'f') {x = x - 'a' + 10;}
y = y * 16 + x;}
printf ("%s\t%d\t%d\n", yytext, strlen (yytext)-1 ,y);}
.* /*comment3*/;