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