fork download
  1. %{
  2. #include<stdio.h>
  3. int lc=0,wc=0,cc=0,sc=0;
  4. %}
  5. %%
  6. [\n] {lc++;cc+=yylength;}
  7. [\t] {sc++;cc+=yylength;}
  8. [^\n\t]+ {wc++;cc+=yylength;}
  9. %%
  10. int yywrap()
  11. {
  12. return 1;
  13. }
  14. int main(int argc,char* argv[])
  15. {
  16. printf("enter the input");
  17. yylex();
  18. printf("number of lines=%d\n",lc);
  19. printf("number od words=%d\n",wc);
  20. printf("number of space=%d\n",sc);
  21. printf("NUmber of characters=%d\n",cc);
  22. }
  23.  
Success #stdin #stdout #stderr 0.02s 6944KB
stdin
Hello World
stdout
Standard output is empty
stderr
ERROR: /home/DjGBxE/prog:22:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit