fork download
  1.  
  2. %{
  3. #include <stdio.h>
  4. int chars = 0, word = 0, newLine = 0, space = 0;
  5. %}
  6.  
  7. %%
  8. [a-zA-Z]{1} {chars++;}
  9. [a-zA-Z]{2,} {word++;}
  10. [ ] {space++;}
  11. [\n] {newLine++;}
  12.  
  13. %%
  14.  
  15. int yywrap(){
  16. return 1;
  17. }
  18.  
  19. int main()
  20. {
  21. printf("Enter String: ");
  22. yylex();
  23. printf("Number of characters is: %d\n", chars);
  24. printf("Number of words is: %d\n", word);
  25. printf("Number of spaces is: %d\n", space);
  26. printf("Number of new line characters is: %d\n", newLine);
  27. }
Success #stdin #stdout #stderr 0.03s 6916KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/90BHcM/prog:27:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit