fork download
  1.  
  2.  
  3. %{
  4. #include <stdio.h>
  5. %}
  6.  
  7. %%
  8.  
  9. [0-9]+ { printf("NUMBER\t\t%s\n", yytext); }
  10. [A-Za-z_][A-Za-z0-9_]* { printf("IDENTIFIER\t%s\n", yytext); }
  11.  
  12. "=="|">="|"<="|"!=" { printf("REL_OP\t%s\n", yytext); }
  13. "="|"+"|"-"|"*"|"/" { printf("OPERATOR\t%s\n", yytext); }
  14.  
  15. ";"|"("|")"|"{"|"}" { printf("SYMBOL\t\t%s\n", yytext); }
  16.  
  17. [ \t\n]+ ; /* ignore whitespace */
  18.  
  19. . { printf("UNKNOWN\t%s\n", yytext); }
  20.  
  21. %%
  22.  
  23. int main() {
  24. printf("Enter input:\n");
  25. yylex();
  26. return 0;
  27. }
  28.  
Success #stdin #stdout #stderr 0.02s 6984KB
stdin
int a = 10;
stdout
Standard output is empty
stderr
ERROR: /home/LcfIxx/prog:4:1: Syntax error: Operator expected
ERROR: /home/LcfIxx/prog:27:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit