fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6. [0-9]+ { printf("Number: %s\n", yytext); }
  7. [+\-*/] { printf("Operator: %s\n", yytext); }
  8. [\t\n] { /* Ignore whitespace */ }
  9. . { printf("Invalid character: %s\n", yytext); }
  10. %%
  11.  
  12. int main() {
  13. printf("Enter a mathematical expression: ");
  14. yylex();
  15. return 0;
  16. }
Success #stdin #stdout #stderr 0.02s 6880KB
stdin
a+b*d-2
stdout
Standard output is empty
stderr
ERROR: /home/3xAZlV/prog:2:1: Syntax error: Operator expected
ERROR: /home/3xAZlV/prog:16:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit