fork download
  1. %{
  2. #include <stdio.h>
  3. #include "y.tab.h" // This header file contains token definitions from Bison
  4. %}
  5.  
  6. %%
  7. [0-9]+ { yylval.num = atoi(yytext); return NUMBER; }
  8. "+" { return OPERATOR_PLUS; }
  9. "-" { return OPERATOR_MINUS; }
  10. "*" { return OPERATOR_MULT; }
  11. "/" { return OPERATOR_DIV; }
  12. "(" { return LPAREN; }
  13. ")" { return RPAREN; }
  14. [ \t\n] ; // Ignore whitespace and newline characters
  15. . { fprintf(stderr, "Unexpected character: %s\n", yytext); }
  16. %%
  17.  
  18. int yywrap() {
  19. return 1; // Indicate end of input
  20. }
  21.  
Success #stdin #stdout #stderr 0.02s 6784KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Nlh4Fj/prog:2:1: Syntax error: Operator expected
ERROR: /home/Nlh4Fj/prog:20:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit