fork download
  1. %{
  2. #include <stdio.h>
  3. int upperCount = 0;
  4. int lowerCount = 0;
  5. %}
  6.  
  7. %%
  8. [A-Z] {
  9. upperCount++;
  10. printf("Uppercase letter: %c\n", yytext[0]);
  11. }
  12.  
  13. [a-z] {
  14. lowerCount++;
  15. printf("Lowercase letter: %c\n", yytext[0]);
  16. }
  17.  
  18. . {
  19. /* Ignore other characters */
  20. }
  21. %%
  22.  
  23. int yywrap() {
  24. return 1;
  25. }
  26.  
  27. int main() {
  28. yylex();
  29. printf("Uppercase count: %d\n", upperCount);
  30. printf("Lowercase count: %d\n", lowerCount);
  31. return 0;
  32. }
Success #stdin #stdout #stderr 0.03s 6832KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/iKSkcg/prog:2:1: Syntax error: Operator expected
ERROR: /home/iKSkcg/prog:32:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit