fork download
  1. %{
  2. #include <stdio.h>
  3. int word_count = 0;
  4. int digit_count = 0;
  5. int space_count = 0;
  6. int special_count = 0;
  7. %}
  8.  
  9. %%
  10. [a-zA-Z]+ { word_count++; }
  11. [0-9] { digit_count++; }
  12. [ \t\n] { space_count++; }
  13. [^a-zA-Z0-9 \t\n] { special_count++; }
  14. . { /* ignore other characters */ }
  15. %%
  16.  
  17. int main() {
  18. yylex();
  19. printf("Number of words: %d\n", word_count);
  20. printf("Number of digits: %d\n", digit_count);
  21. printf("Number of spaces: %d\n", space_count);
  22. printf("Number of special characters: %d\n", special_count);
  23. return 0;
  24. }
  25.  
Success #stdin #stdout #stderr 0.02s 6928KB
stdin
21BRS1590 abhin.bohra2021@vitstudent.ac.in
stdout
Standard output is empty
stderr
ERROR: /home/yeHMLE/prog:2:1: Syntax error: Operator expected
ERROR: /home/yeHMLE/prog:24:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit