fork download
  1. %{
  2. #include<stdio.h>
  3. int num, r, digit=0, count, pcount=0, i;
  4. char a[20];
  5. %}
  6.  
  7. DIGIT [0-9]
  8. /* Rule Section */
  9. %%
  10.  
  11. {DIGIT}+ { num=atoi(yytext);
  12.  
  13. while(num!=0)
  14. {
  15.  
  16. r=num%16;
  17. digit='0'+r;
  18. if(digit>'9')
  19. digit+=7;
  20. a[count++]=digit;
  21. num=num/16;
  22.  
  23. }
  24.  
  25. for(i=count-1;i>=pcount;--i)
  26. printf("%c", a[i]);
  27. pcount=count;
  28. }
  29.  
  30. %%
  31.  
  32. // driver code
  33. int main()
  34. {
  35. yylex();
  36. return 0;
  37. }
  38.  
  39.  
Success #stdin #stdout #stderr 0.02s 6976KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/GJsgMH/prog:38:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit