fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int pos_num = 0;
  5. int neg_num = 0;
  6. %}
  7.  
  8. %%
  9.  
  10. [0-9]+ { pos_num++; }
  11. [-][0-9]+ { neg_num++; }
  12.  
  13. %%
  14.  
  15. int yywrap() {
  16. return 1;
  17. }
  18.  
  19. int main() {
  20. char input[1000];
  21. printf("Enter numbers separated by spaces :");
  22.  
  23.  
  24. fgets(input, sizeof(input), stdin);
  25.  
  26. YY_BUFFER_STATE buffer = yy_scan_string(input);
  27. yylex();
  28.  
  29. printf("Number of positive numbers: %d\n", pos_num);
Success #stdin #stdout #stderr 0.03s 6840KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/aCuF6i/prog:29:55: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit