fork download
  1. %{
  2. #include <stdio.h>
  3. int pi=0,ni=0,pf=0,nf=0;
  4. %}
  5. %%
  6. [-][0-9]+ {ni++;}
  7. [+]?[0-9]+ {pi++;}
  8. [-][0-9]*\.[0-9]+ {nf++;}
  9. [+]?[0-9]*\.[0-9]+ {pf++;}
  10. %%
  11.  
  12. void main(int argc,char *argv[])
  13. {
  14. if (argc!=2)
  15. {
  16. printf("usage : ./a.out in.txt \n");
  17. exit(0);
  18. }
  19. yyin=fopen(argv[1],"r");
  20. yylex();
  21. printf("no. of positive integer %d \n",pi);
  22. printf("no. of negative integer %d \n",ni);
  23. printf("no. of positive fraction %d \n",pf);
  24. printf("no. of negative fraction %d \n",nf);
  25. }
  26. int yywrap()
  27. {
  28. return 1;
  29. }
Success #stdin #stdout #stderr 0.02s 6932KB
stdin
1,2,3,4,5,6,7,8,9
stdout
Standard output is empty
stderr
ERROR: /home/D2fpIT/prog:29:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit