fork download
  1. %{
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. %}
  5.  
  6. %%
  7.  
  8. [0-9]+ {
  9. int num = atoi(yytext);
  10. printf("\nMultiplication Table for %d:\n", num);
  11. for(int i = 1; i <= 10; i++) {
  12. printf("%d x %d = %d\n", num, i, num * i);
  13. }
  14. }
  15.  
  16. [ \t\n]+ ; // ignore spaces and newline
  17.  
  18. . { printf("Invalid input\n"); }
  19.  
  20. %%
  21.  
  22. int main() {
  23. printf("Enter a number: ");
  24. yylex();
  25. return 0;
  26. }
  27.  
  28. int yywrap() {
  29. return 1;
  30. }
Success #stdin #stdout #stderr 0.02s 6920KB
stdin
5
stdout
Standard output is empty
stderr
ERROR: /home/LhWvgB/prog:2:1: Syntax error: Operator expected
ERROR: /home/LhWvgB/prog:30:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit