fork download
  1. %{
  2. #include <stdio.h>
  3. int int_count = 0, float_count = 0;
  4. %}
  5.  
  6. %%
  7. [0-9]+ printf("Integer: %s\n", yytext); int_count++;
  8. [0-9]+\.[0-9]+ printf("Float: %s\n", yytext); float_count++;
  9. .
  10. %%
  11. int main() {
  12. yylex(); // Run the lexer
  13.  
  14. printf("\nTotal Integers: %d\n", int_count);
  15. printf("Total Floats: %d\n", float_count);
  16.  
  17. return 0;
  18. }
  19. int yywrap() {
  20. return 1;
  21. }
Success #stdin #stdout #stderr 0.02s 6984KB
stdin
3 4 5 6.6
stdout
Standard output is empty
stderr
ERROR: /home/bvsWjL/prog:2:5: Syntax error: Operator expected
ERROR: /home/bvsWjL/prog:21:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? EOF: exit