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