fork download
  1. %{
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. %}
  5.  
  6. %%
  7. [0-9]+ {
  8. int num = atoi(yytext);
  9. if (num % 2 == 0)
  10. printf("%s is EVEN\n", yytext);
  11. else
  12. printf("%s is ODD\n", yytext);
  13. }
  14.  
  15. \n { /* Ignore new lines */ }
  16. . { printf("Invalid input: %s\n", yytext); }
  17.  
  18. %%
  19.  
  20. int main() {
  21. printf("Enter numbers (Ctrl+D to stop):\n");
  22. yylex();
  23. return 0;
  24. }
  25.  
  26. int yywrap() {
  27.     return 1;
  28. }
Success #stdin #stdout #stderr 0.03s 6904KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/hIKK2V/prog:2:1: Syntax error: Operator expected
ERROR: /home/hIKK2V/prog:28:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit