Tuesday, 4 February 2014

First Lex Program

First Lex Program

%{ 
/*     */
%}
%%
is printf(" 'is' has entered");
%%

OutPut:
$$ lex first.l        
$$ gcc 1ex.yy.c -11
$$ ./a.out
is
'is' has entered
^D
$$

Explanation: whenever you will enter the is keyword it automatically display the line written into the printf statement i.e. 'is' has entered

No comments:

Post a Comment