fork download
  1. %{
  2. #include <stdio.h>
  3. #include <stdlib.h> // for atoi()
  4. int i;
  5. %}
  6.  
  7. %%
  8. [0-9]+ {
  9. i = atoi(yytext);
  10. if (i % 2 == 0)
  11. printf("Even\n");
  12. else
  13. printf("Odd\n");
  14. }
  15. .|\n { /* Ignore other characters */ }
  16. %%
  17.  
  18. int yywrap() {
  19. return 1;
  20. }
  21.  
  22. int main() {
  23. printf("Enter a number: ");
  24. yylex();
  25. return 0;
  26. }
  27.  
Success #stdin #stdout #stderr 0.02s 6920KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Mp2K48/prog:26:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit