fork download
  1. %{
  2. #include <stdio.h>
  3. int vowels = 0, consonants = 0;
  4. %}
  5.  
  6. %%
  7. [aeiouAEIOU] { vowels++; }
  8. [a-zA-Z] { consonants++; }
  9. [^a-zA-Z\n] ; /* Ignore non-alphabetic characters */
  10. \n { /* Ignore newlines */ }
  11. %%
  12.  
  13. int main() {
  14. printf("Enter text (Ctrl+D to end on Unix/Mac, Ctrl+Z on Windows):\n");
  15. yylex();
  16. printf("\nNumber of vowels: %d\n", vowels);
  17. printf("Number of consonants: %d\n", consonants);
  18. return 0;
  19. }
  20.  
  21. int yywrap() {
  22. return 1;
  23. }
  24.  
Success #stdin #stdout #stderr 0.02s 6932KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/122kLv/prog:23:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit