fork download
  1. /*Lex program to count the number of vowels & consonants from the given input string.*/
  2. %{
  3. #include<stdio.h>
  4. int vow=0, con=0;
  5. %}
  6.  
  7. %%
  8. [ \t\n]+ ;
  9. [aeiouAEIOU]+ {vow++;}
  10. [^aeiouAEIOU] {con++;}
  11. %%
  12.  
  13. int main( )
  14. {
  15. printf("Enter some input string:\n");
  16. yylex();
  17. printf("Number of vowels=%d\n",vow);
  18. printf("Number of consonants=%d\n",con);
  19. }
  20.  
  21. int yywrap( )
  22. {
  23. return 1;
  24. }
Success #stdin #stdout #stderr 0.03s 7016KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/hQ1Xnq/prog:24:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit