fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int vowels = 0, consonants = 0;
  5. %}
  6.  
  7. %%
  8.  
  9. [aAeEiIoOuU] { vowels++; } // Match vowels (case insensitive)
  10. [b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z] { consonants++; } // Match consonants (case insensitive)
  11. .|\n { /* Ignore other characters */ }
  12.  
  13. %%
  14.  
  15. int main() {
  16. printf("Enter text (Ctrl+D to end input):\n");
  17. yylex(); // Start processing input
  18. printf("Number of vowels: %d\n", vowels);
  19. printf("Number of consonants: %d\n", consonants);
  20. return 0;
  21. }
  22.  
  23. int yywrap() {
  24. return 1; // Indicate no more input
  25. }
  26.  
  27.  
Success #stdin #stdout #stderr 0.04s 6968KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/XkVtXm/prog:26:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit