fork download
  1. %{
  2. #include<stdio.h>
  3. int lc=0,sc=0,wc=0,tc=0,ch=0;
  4. %}
  5. %%
  6. [\n]{lc++,ch+=yyleng;}
  7. [\t]{sc++,ch+=yyleng;}
  8. [^\t]{tc++,ch+=yyleng;}
  9. [^\t\n]+{wc++,ch+=yyleng;}
  10. %%
  11. int yywrap(){return 1;}
  12.  
  13. int main(){
  14. printf("enter the string");
  15. yylex();
  16. printf("words: %d",wc);
  17. printf("lines: %d",lc);
  18. printf("spaces: %d",sc);
  19. printf("tabs,char %d,%d",tc,ch);
  20. return 0;
  21. }
Success #stdin #stdout #stderr 0.03s 6912KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/MgcFPe/prog:21:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit