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