fork download
  1. %{
  2. #include<stdio.h>
  3. int nl = 0;
  4. int nw = 0;
  5. int nc = 0;
  6. %}
  7.  
  8. %%
  9. \n nl++;
  10. [a-zA-Z]+ {nw++,nc+=yyleng;}
  11. [^]nc++;
  12. %%
  13.  
  14. int main(){
  15. printf("Enter the string:\n");
  16. yylex();
  17.  
  18. printf("No. of lines is %d,words is %d and characters is %d",nl,nw,nc);
  19. return 0;
  20. }
Success #stdin #stdout #stderr 0.03s 7020KB
stdin
I am sagar
who are you
stdout
Standard output is empty
stderr
ERROR: /home/3YmdOw/prog:19:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit