fork download
  1. %{
  2. #include<stdio.h>
  3. int lc=0,sc=0,tc=0,rc=0,rc2=0;
  4.  
  5. %}
  6. %%
  7. [\n] {lc++;}
  8. [\t] {tc++:}
  9. [" "]{ sc++;}
  10. . {rc++;}
  11. [^\n" "\t]{rc2++;}
  12. %%
  13. yywrap(){
  14. return 1;
  15. }
  16. int main(){
  17. printf("enter sentenxe");
  18. yylex();
  19. printf("lc is %d\n",lc);
  20. printf("sc is %d\n",sc);
  21. printf("tc is %d\n",tc);
  22. printf("rc is %d %d\n",rc,rc2);
  23. }
Success #stdin #stdout #stderr 0.03s 7024KB
stdin
rdgvdr
d
stdout
Standard output is empty
stderr
ERROR: /home/6qcgHu/prog:2:3: Syntax error: Operator expected
ERROR: /home/6qcgHu/prog:23:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ?    Call: (3) program ? EOF: exit