fork download
  1. %{
  2. #include <stdio.h>
  3. int vowels = 0;
  4. int consonants = 0;
  5. %}
  6. %%
  7. [aeiouAEIOU] vowels++;
  8. [a-zA-Z] consonants++;
  9. [\n] ;
  10. . ;
  11. %%
  12. int main()
  13. {
  14. printf ("This Lex program counts the number of vowels and ");
  15. printf ("consonants in given text.");
  16. printf ("\nEnter the text and terminate it with CTRL-d.\n");
  17. yylex();
  18. printf ("Vowels = %d, consonants = %d.\n", vowels, consonants);
  19. return 0;
  20. }
Success #stdin #stdout #stderr 0.03s 6964KB
stdin
Rudalph
stdout
Standard output is empty
stderr
ERROR: /home/wB5jEj/prog:2:1: Syntax error: Operator expected
ERROR: /home/wB5jEj/prog:20:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit