fork download
  1. %{
  2. #include<stdio.h>
  3. int wrd_cnt=0,ketwrd=0;
  4. }%
  5.  
  6. %%
  7. int|short|long|double {keyword++;}
  8. ([a-zA-Z0-9])+ {wrd_cnt++;}
  9. \n {printf("WordCount:%d,KEYWORD %d",wrd_cnt,keywrd);keywrd=0;wrd_cnt=0;}
  10. %%
  11.  
  12. int main()
  13. {
  14. printf("Give the input(Ctrl+D) stop");
  15. yylex();
  16. return 0;
  17. }
  18.  
  19. int yywrap(){
  20. return 1;
  21. }
Success #stdin #stdout #stderr 0.03s 6932KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/VY3t1U/prog:21:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit