fork download
  1. %{
  2. %{
  3. #include <stdio.h>
  4. int linecount = 0, spacecount = 0, tabcount = 0, restcount = 0;
  5. %}
  6.  
  7. %%
  8.  
  9. \n { linecount++; }
  10. \t { tabcount++; }
  11. [ ] { spacecount++; }
  12. [^ \t\n] { restcount++; }
  13.  
  14. %%
  15.  
  16. int main() {
  17. printf("Enter the string:\n");
  18. yylex();
  19. printf("Line count: %d\n", linecount);
  20. printf("Tab count: %d\n", tabcount);
  21. printf("Space count: %d\n", spacecount);
  22. printf("Rest count: %d\n", restcount);
  23. return 0;
  24. }
  25.  
Success #stdin #stdout #stderr 0.03s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/eIj7ju/prog:24:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit