fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int whitespace_count = 0;
  5. int newline_count = 0;
  6. %}
  7.  
  8. %%
  9. [ \t]+ { whitespace_count += yyleng; }
  10. \n+ { newline_count += yyleng; }
  11. . { /* ignore other characters */ }
  12. %%
  13.  
  14. int main(void)
  15. {
  16. yylex();
  17. printf("Whitespace count (spaces + tabs): %d\n", whitespace_count);
  18. printf("Newline count: %d\n", newline_count);
  19. return 0;
  20. }
  21.  
  22. int yywrap(void)
  23. {
  24. return 1;
  25. }
  26.  
Success #stdin #stdout #stderr 0.02s 6828KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/x6EJ0d/prog:2:1: Syntax error: Operator expected
ERROR: /home/x6EJ0d/prog:25:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit