fork download
  1. /*Lex program to take check whether
  2. the given number is even or odd */
  3.  
  4. %{
  5. #include<stdio.h>
  6. int i;
  7. %}
  8.  
  9. %%
  10.  
  11. [0-9]+ {i=atoi(yytext);
  12. if(i%2==0)
  13. printf("Even");
  14. else
  15. printf("Odd");}
  16. %%
  17.  
  18. int yywrap(){}
  19.  
  20. /* Driver code */
  21. int main()
  22. {
  23.  
  24. yylex();
  25. return 0;
  26. }
  27.  
Success #stdin #stdout #stderr 0.02s 6788KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Nd0j4k/prog:26:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit