fork download
  1. %{
  2. int pos = 0, neg = 0;
  3. %}
  4.  
  5. %%
  6.  
  7. [+]?[0-9]+ {
  8. if (yytext[0] == '+') {
  9. pos++;
  10. } else {
  11. pos++;
  12. }
  13. }
  14. [-]?[0-9]+ {
  15. if (yytext[0] == '-') {
  16. neg++;
  17. } else {
  18. pos++;
  19. }
  20. }
  21.  
  22. %%
  23.  
  24. int main() {
  25. yylex();
  26. printf("Positive integers: %d\nNegative integers: %d\n", pos, neg);
  27. return 0;
  28. }
  29.  
Success #stdin #stdout #stderr 0.02s 6852KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/qPZzaO/prog:28:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit