Lex Program to Identify Comment Lines

Lex Program to Identify both single line and multi line comments using regular expressions in lex

[cc lang=”c”]
%{
#include
%}
%%
[/]{1}[/]{1}[a-zA-Z0-9]* printf(“Single Line Comment”);
[/]{1}[*]{1}[a-zA-Z0-9]*[*]{1}[/]{1} printf(“MultiLine Comment”);
%%
main(){yylex();}
[/cc]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *