fork download
  1. %{
  2. #include<stdio.h>
  3. #include<string.h>
  4. int count=0,ncount=0;
  5. %}
  6. %%
  7. [a-zA-Z][a-zA-Z0-9]*[+*]+ {ncount++;}
  8. [*+]+[a-zA-Z][a-zA-Z0-9]* {ncount++;}
  9. [a-zA-Z][a-zA-Z0-9]* {count++;}
  10. . {;}
  11. \n {;}
  12. %%
  13. int yywrap(){
  14. return 1;}
  15. int main(int argc,char* argv[]){
  16. if(argc!=2){
  17. printf("Usage: ./a.out in.txt out.txt \n");
  18. exit(0);}
  19. yyin=fopen(argv[1],"r");
  20. yylex();
  21. printf("No. of identifiers: %d\n No. of Non Variables: %d",count,ncount);
  22. return 0;
  23. }
  24.  
Success #stdin #stdout #stderr 0.02s 6868KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/rgbVEK/prog:2:1: Syntax error: Operator expected
ERROR: /home/rgbVEK/prog:23:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit