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