fork download
  1. %{
  2. int kcount = 0;
  3. int icount = 0;
  4. %}
  5. keywords (if|else|while|return|for)
  6. identifiers ([a-zA-Z][a-zA-Z0-9]*)
  7. %%
  8. {keywords} {kcount++;}
  9. {identifiers} {icount++;}
  10. %%
  11. void main()
  12. yylex();
  13. printf("No.of Keywords: %d\n", kcount);
  14. printf("No.of Identifiers: %d\n", icount);
  15. }
  16. int yywrap()
  17. {
  18. return 1;
  19.  
  20. }
Success #stdin #stdout #stderr 0.03s 6876KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/foojdr/prog:20:2: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit