fork download
  1. %{
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. int vowel_count = 0;
  6. int consonant_count = 0;
  7. %}
  8.  
  9. %%
  10.  
  11. [aeiouAEIOU] { vowel_count++; }
  12. [b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z] { consonant_count++; }
  13. [ \t\n]+ { /* Ignore whitespace and newlines */ }
  14. . { /* Ignore other characters */ }
  15.  
  16. %%
  17.  
  18. int main(int argc, char **argv) {
  19. yylex(); // Start lexical analysis
  20. printf("Vowels: %d\n", vowel_count);
  21. printf("Consonants: %d\n", consonant_count);
  22. return 0;
  23. }
  24.  
  25. int yywrap() {
  26. return 1; // End of file
  27. }
  28.  
Success #stdin #stdout #stderr 0.03s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/7qnbVy/prog:2:1: Syntax error: Operator expected
ERROR: /home/7qnbVy/prog:27:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit