fork download
  1. [A-Za-z][0-9]
  2. %{
  3. #include<stdio.h>
  4. int kcount=0,count=0,dcount=0,ocount;
  5. %}
  6.  
  7. %%
  8.  
  9. int|float|doubl|if|else {printf("%s is an keyword",yytext); kcount++;}
  10. \+|\-|\*|\% {printf("%s is an operator",yytext); ocount++;}
  11. \(|\)|\.|\{|\}|\;|\, {printf("%s is a delimiter",yytext);dcount++;}
  12. {letter}|{(letter|digit)}*{printf("%s is a identifier",yytext);count++;}
  13. %%
  14.  
  15. int main()
  16. {
  17. yylex();
  18. printf("No of keyword ",kcount);
  19. printf("No of operator ",ocount);
  20. printf("No of delimiter "dcount);
  21. printf("No of identifier ",count);
  22. }
Success #stdin #stdout #stderr 0.02s 7028KB
stdin
int a=b+c;
stdout
Standard output is empty
stderr
ERROR: /home/JwyAU7/prog:22:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit