fork download
  1. %{
  2. #include <stdio.h>
  3. int vowels = 0, consonants = 0;
  4. %}
  5.  
  6. %%
  7. [aeiouAEIOU] { vowels++; } /* match vowels */
  8. [a-zA-Z] { consonants++; } /* match consonants (not already matched above) */
  9. .|\n ; /* ignore everything else */
  10. %%
  11.  
  12. int main()
  13. {
  14. printf("Enter a string: ");
  15. yylex(); /* start lexical analysis */
  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. {
  23. return 1;
  24. }
  25.  
Success #stdin #stdout #stderr 0.03s 6960KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/sjz49I/prog:24:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit