fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6. int { printf("Identifier: int\n"); }
  7. [a-zA-Z][a-zA-Z0-9]* { printf("Identifier: %s\n", yytext); }
  8. "=" { printf("Operator: =\n"); }
  9. [0-9]+ { printf("Constant: %s\n", yytext); }
  10. ";" { printf("Operator: ;\n"); }
  11. [ \t\n] ; // ignore whitespace
  12. . { printf("Unknown: %s\n", yytext); }
  13. %%
  14.  
  15. int main() {
  16. yylex();
  17. return 0;
  18. }
  19.  
  20.  
Success #stdin #stdout #stderr 0.03s 6888KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/YOX6PC/prog:2:1: Syntax error: Operator expected
ERROR: /home/YOX6PC/prog:19:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit