fork download
  1. %{
  2. #include"y.tab.h";
  3. extern intyylval;
  4. %}
  5. %%
  6. [0-9]+{n=atoi(yytext);
  7. return num;}
  8. \n return 0;
  9. %%
  10. %{
  11. #include<stdio.h>
  12. %}
  13. %token num;
  14. %%
  15. state:num{x=$1;
  16. t=1;
  17. n=0;
  18. while(x!=0)
  19. {
  20. r=x%2;
  21. n=n*t+r;
  22. t=t*10;
  23. x=x/2;
  24. }
  25. printf("%d",n);
  26. }
  27. %%
  28. void yyerror (char*s)
  29. {
  30. printf("syntax error");
  31. }
  32. int main(void)
  33. {
  34. return yyparse ();
  35. }
  36.  
Success #stdin #stdout #stderr 0.03s 6996KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/weWhPM/prog:35:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit