fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6.  
  7. [a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier: %s\n", yytext); }
  8. [0-9]+ { printf("Number: %s\n", yytext); }
  9. "+" { printf("Plus operator\n"); }
  10. "-" { printf("Minus operator\n"); }
  11. "*" { printf("Multiplication operator\n"); }
  12. "/" { printf("Division operator\n"); }
  13. [ \t\n]+ { /* Ignore whitespace */ }
  14. . { printf("Unknown character: %s\n", yytext); }
  15.  
  16. %%
  17.  
  18. int main() {
  19. yylex(); // Call lexical analyzer
  20. return 0;
  21. }
  22.  
  23. int yywrap() {
  24. return 1;
  25. }
  26.  
  27.  
Success #stdin #stdout #stderr 0.03s 6792KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/hhhqDZ/prog:2:1: Syntax error: Operator expected
ERROR: /home/hhhqDZ/prog:26:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit