fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int v = 0, c = 0;
  5.  
  6. %}
  7.  
  8. %%
  9.  
  10. [aeiouAEIOU] v++; // Increment vowel count
  11. [a-zA-Z] c++; // Increment consonant count
  12.  
  13. %%
  14.  
  15. int main()
  16. {
  17. printf("ENTER INPUT : ");
  18. yylex(); // Start lexical analysis
  19. printf("VOWELS=%d\nCONSONANTS=%d\n", v, c);
  20.  
  21. return 0;
  22. }
  23.  
  24. // Define yywrap function to avoid compiler errors
  25. int yywrap() {
  26. return 1;
  27. }
  28.  
Success #stdin #stdout #stderr 0.02s 6880KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/BB7wtm/prog:27:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit