lex program to eliminate single and multiline comments

%{
#include ;;
%}
%%
"//"([a-z]|[0-9]|[A-Z]|" ")* {}
"/*"([a-z]|[0-9]|[A-Z]|" "\""\n")+"*/" {}
%%
main()
{
yylex();
return 0;
}
int yywrap()
{
}

Sample output

single line comment //testing
single line comment
test line /*multi*/
test line

Digiprove sealCopyright secured by Digiprove © 2018 Humble Chirammal

2 thoughts on “lex program to eliminate single and multiline comments”

Comments are closed.