fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. DIGIT [0-9]
  6. %%
  7. {DIGIT}+\.{DIGIT}+ {
  8. double float_num = atof(yytext);
  9. int int_num = (int)float_num;
  10. printf("Floating-point: %s\nInteger: %d\n", yytext, int_num);
  11. }
  12. {DIGIT}+ {
  13. int int_num = atoi(yytext);
  14. printf("Integer: %s\n", yytext);
  15. }
  16. .|\n ;
  17.  
  18. %%
  19. int main() {
  20. yylex();
  21. return 0;
  22. }
  23.  
Success #stdin #stdout #stderr 0.02s 6788KB
stdin
3.142222
stdout
Standard output is empty
stderr
ERROR: /home/zgzgOH/prog:22:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit