fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int lines = 0, spaces = 0, tabs = 0, words = 0;
  5. %}
  6.  
  7. %%
  8.  
  9. "\n" { lines++; }
  10. " " { spaces++; }
  11. "\t" { tabs++; }
  12. [A-Za-z0-9]+ { words++; }
  13.  
  14. . ; /* Ignore other characters */
  15.  
  16. %%
  17.  
  18. int main() {
  19. printf("enter input");
  20. yylex();
  21. printf("Lines: %d\n", lines);
  22. printf("Spaces: %d\n", spaces);
  23. printf("Tabs: %d\n", tabs);
  24. printf("Words: %d\n", words);
  25. return 0;
  26. }
Success #stdin #stdout #stderr 0.03s 6916KB
stdin
stdout
Standard output is empty
stderr
ERROR: /home/jd7Qia/prog:2:1: Syntax error: Operator expected
ERROR: /home/jd7Qia/prog:26:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit