fork download
  1. %
  2. option noyywrap
  3.  
  4. %{
  5. #include <stdio.h>
  6. #include <unistd.h>
  7. int matched = 0;
  8. %}
  9.  
  10. %%
  11. ^[0-9]+$ {
  12. printf("%s is a number\n", yytext);
  13. matched = 1;
  14. }
  15.  
  16. .+ {
  17. printf("%s is not a number\n", yytext);
  18. matched = 1;
  19. }
  20.  
  21. \n ;
  22. %%
  23.  
  24. int main()
  25. {
  26. yylex();
  27.  
  28. /* handles empty input */
  29. if (!matched)
  30. printf(" is not a number\n");
  31.  
  32. return 0;
  33. }
Success #stdin #stdout #stderr 0.03s 6952KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/UbKfrU/prog:33:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit