fork download
  1. %{
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. %}
  5.  
  6. %%
  7. [+-]?[0-9]*\.[0-9]+ {
  8. /* Match floating point numbers (e.g., 12.34, -5.6) */
  9. float val = atof(yytext);
  10. printf("Integer: %d\n", (int)val);
  11. }
  12.  
  13. [+-]?[0-9]+ {
  14. /* Match standard integers to avoid ignoring them */
  15. printf("Integer: %s\n", yytext);
  16. }
  17.  
  18. .|\n {
  19. /* Ignore other characters */
  20. }
  21. %%
  22.  
  23. int main() {
  24. yylex();
  25. return 0;
  26. }
  27.  
  28. int yywrap() {
  29. return 1;
  30. }
  31.  
Success #stdin #stdout #stderr 0.02s 6948KB
stdin
45
467
45.867
abc
stdout
Standard output is empty
stderr
ERROR: /home/QlNTY6/prog:30:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: No previous search
   Exception: (3) program ? EOF: exit