Sample Lex Programs

Sample Lex Programs

1) %{

/* Remove uppercase letters . Commands to execute are

lex test.l and gcc lex.yy.c -ll -o test */

%}

%%

[A-Z]+ ;

2) %{

/* Line numbering */

%}

%%

^.*\n printf(“%d\t%s”,yylineno-1,yytext);

Previous slide Next slide Back to the first slide View Graphic Version