fork download
  1. %{
  2. #include <stdio.h>
  3. int word_count=0;
  4. int char_count=0;
  5. int line_count=0;
  6. int num_count=0;
  7.  
  8. }%
  9. %%
  10. \n {line_count++}
  11. [0-9]+ {num_count++;char_count+=yyleng}
  12. [a-zA-Z_][a-zA-Z0-9_]*{word_count++;char_count+=yyleng}
  13. %%
  14. int main(){
  15. printf("enter input ;\n");
  16. yylex();
  17. printf("Lines : %d\n", line_count);
  18. printf("Words : %d\n", word_count);
  19. printf("Numbers : %d\n", num_count);
  20. printf("Characters : %d\n", char_count);
  21. return 0;
  22. }
  23. int yywrap(){
  24. return 1;
  25. }
  26.  
  27.  
Success #stdin #stdout #stderr 0.03s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/ZNjKFo/prog:26:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit