fork download
  1. %%{
  2. #include <stdio.h>
  3. %%}
  4.  
  5. %%
  6. [0-9]+ {
  7. int num = atoi(yytext);
  8. if (num % 2 == 0)
  9. printf("%s is Even\n", yytext);
  10. else
  11. printf("%s is Odd\n", yytext);
  12. }
  13. \n { /* Ignore newlines */ }
  14. . { /* Ignore other characters */ }
  15. %%
  16.  
  17. int main() {
  18. printf("Enter numbers (Ctrl+D to stop):\n");
  19. yylex();
  20. return 0;
  21. }
Success #stdin #stdout #stderr 0.02s 6992KB
stdin
15
stdout
Standard output is empty
stderr
ERROR: /home/26eA0Y/prog:2:1: Syntax error: Operator expected
ERROR: /home/26eA0Y/prog:21:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit