fork download
  1. %{
  2. #include <stdio.h>
  3. int valid_int=0, valid_float=0;
  4. %}
  5.  
  6. %%
  7. ^[-+]?[0-9]+(\.[0-9]+)?$ {
  8. if(strchr(yytext, '.'))
  9. valid_float++;
  10. else
  11. valid_int++;
  12. }
  13. .* { /* Ignore other inputs */ }
  14. %%
  15.  
  16. int main()
  17. {
  18. yylex();
  19. if(valid_float)
  20. printf("Valid Float number\n");
  21. else if(valid_int)
  22. printf("Valid Integer number\n");
  23. else
  24. printf("Not valid Integer/Float number\n");
  25.  
  26. return 0;
  27. }
  28.  
  29. int yywrap() { return 1; }
  30.  
Success #stdin #stdout #stderr 0.02s 6936KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/3ih7QF/prog:29:26: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit