fork download
  1. %{
  2. #include<stdio.h>
  3. int word_count = 0;
  4. int line_count = 0;
  5. %}
  6.  
  7. %option noyywrap
  8. %%
  9.  
  10. [ \t]+ ;
  11. [^ \t\n]+ { word_count++; }
  12. \n { line_count++; }
  13.  
  14. %%
  15.  
  16. int main(){
  17. printf("Enter a string :\n");
  18. yylex();
  19. printf("Total words: %d\n", word_count);
  20. printf("Total lines: %d\n", line_count);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout #stderr 0.03s 6916KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/3FXAXN/prog:22:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit