%{
#include<stdio.h>
int c = 0;
%}
%%
[<][^>]*[>] {printf("%s", yytext);c++;}
.|\n {;}
%%
void main()
{
yyin = fopen("test.html", "r");
yylex();
printf("\nTotal tags = %d\n",c);
}
int yywrap()
{
return 1;
}
<html>
<head>
<title>Test</title>
</head>
<body>
<p>
this is paragraph.
</p>
</body>
</html>
<html><head><title></title></head><body><p></p></body></html>
Total tags = 10