fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6.  
  7. [0-9]+ {
  8. int num = atoi(yytext); // Convert matched text to integer
  9. if (num % 2 == 0) // Check if the number is even
  10. printf("%d is Even\n", num);
  11. else
  12. printf("%d is Odd\n", num);
  13. }
  14.  
  15. .|\n { /* Ignore other characters */ }
  16.  
  17. %%
  18.  
  19. int main() {
  20. yylex(); // Call the lexer to process input
  21. return 0;
  22. }
  23.  
Success #stdin #stdout #stderr 0.02s 6972KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/uJMWs8/prog:22:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit