fork download
  1. %{
  2. #include <stdio.h>
  3. int alphabets = 0, digits = 0;
  4. %}
  5.  
  6. %%
  7. [0-9] { digits++; }
  8. [A-Za-z] { alphabets++; }
  9. . { printf("%s is invalid\n", yytext); }
  10. \n {
  11. printf("Alphabets: %d\n", alphabets);
  12. printf("Digits: %d\n", digits);
  13. alphabets = digits = 0;
  14. }
  15. %%
  16.  
  17. int main() {
  18. yylex();
  19. return 0;
  20. }
  21.  
  22. int yywrap() {
  23. return 1;
  24. }
  25.  
Success #stdin #stdout #stderr 0.02s 6996KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/S1xVv0/prog:2:1: Syntax error: Operator expected
ERROR: /home/S1xVv0/prog:24:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit