fork download
  1. %{
  2. #include <stdio.h>
  3.  
  4. int pos = 0;
  5. int neg = 0;
  6. %}
  7.  
  8. %%
  9.  
  10. [0-9]+ {
  11. printf("%s is positive\n", yytext);
  12. pos++;
  13. }
  14.  
  15. -[0-9]+ {
  16. printf("%s is negative\n", yytext);
  17. neg++;
  18. }
  19.  
  20. %%
  21.  
  22. int yywrap() {
  23. return 1;
  24. }
  25.  
  26. int main() {
  27. printf("Enter the input (Ctrl+D to end):\n");
  28. yylex();
  29. printf("Positive count: %d\n", pos);
  30. printf("Negative count: %d\n", neg);
  31. return 0;
  32. }
  33.  
Success #stdin #stdout #stderr 0.03s 6856KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/LzkTMX/prog:32:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit