fork download
  1. {
  2. #include <stdio.h>
  3. int vowels = 0, consonants = 0;
  4. %}
  5.  
  6. %%
  7.  
  8. [aAeEiIoOuU] { vowels++; }
  9. [b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z] { consonants++; }
  10. \n
  11. { return 0; }
  12. .
  13. {}
  14.  
  15. %%
  16.  
  17. int main() {
  18. printf("Enter a string: ");
  19. fflush(stdout);
  20. yylex();
  21. printf("Number of vowels: %d\n", vowels);
  22. printf("Number of consonants: %d\n", consonants);
  23. return 0;
  24. }
  25.  
Success #stdin #stdout #stderr 0.02s 7020KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/5aVpvy/prog:2:0: Syntax error: Operator expected
ERROR: /home/5aVpvy/prog:24:2: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit