fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int vowel = 0;
  5. int consonant = 0;
  6. %}
  7.  
  8. %%
  9. [a,e,i,o,u,A,E,I,O,U] {vowel++;}
  10. [a-zA-Z] {consonant++;}
  11. . ; // Ignore all other characters
  12. %%
  13.  
  14. int yywrap() {
  15. return 1;
  16. }
  17.  
  18.  
  19. int main() {
  20. char input[100]; // Assuming a maximum input length of 100 characters
  21. printf("Enter the string: ");
  22. scanf("%[^\n]", input); // Read input until newline character
  23. yy_scan_string(input); // Pass the input string to the lexer
  24. yylex(); // Perform lexical analysis
  25. printf("Number of vowels: %d\n", vowel);
  26. printf("Number of consonants: %d\n", consonant);
  27. return 0;
  28. }
  29.  
Success #stdin #stdout #stderr 0.03s 6840KB
stdin
this is sample input for practical 09
stdout
Standard output is empty
stderr
ERROR: /home/mbXcvB/prog:2:1: Syntax error: Operator expected
ERROR: /home/mbXcvB/prog:28:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit