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. }
  25.  
  26.  
Success #stdin #stdout #stderr 0.03s 6948KB
stdin
hello world 
he is 
stdout
Standard output is empty
stderr
ERROR: /home/6C6ulP/prog:25:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? Options:
+:                  spy        -:              no spy
/c|e|r|f|u|a goal:  find       .:              repeat find
a:                  abort      A:              alternatives
b:                  break      c (ret, space): creep
[depth] d:          depth      e:              exit
f:                  fail       [ndepth] g:     goals (backtrace)
h (?):              help       i:              ignore
l:                  leap       L:              listing
n:                  no debug   p:              print
r:                  retry      s:              skip
u:                  up         w:              write
m:                  exception details
C:                  toggle show context
   Exception: (3) program ? EOF: exit