fork download
  1. %{
  2. #include <stdio.h>
  3. int positive = 0, negative = 0;
  4. %}
  5.  
  6. DIGIT [0-9]
  7. SIGN [+-]
  8.  
  9. %%
  10. {SIGN}?{DIGIT}+ {
  11. if (yytext[0] == '-') negative++;
  12. else positive++;
  13. }
  14. .|\n ;
  15. %%
  16.  
  17. int yywrap() { return 1; }
  18.  
  19. int main() {
  20. yylex();
  21. printf("Positive numbers: %d\n", positive);
  22. printf("Negative numbers: %d\n", negative);
  23. return 0;
  24. }
Success #stdin #stdout #stderr 0.03s 6816KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/9mkfEU/prog:24:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit