fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6. "if" { printf("TOKEN: %-10s CATEGORY: Keyword\n", yytext); }
  7. "else" { printf("TOKEN: %-10s CATEGORY: Keyword\n", yytext); }
  8. [0-9]+ { printf("TOKEN: %-10s CATEGORY: Number\n", yytext); }
  9. [a-zA-Z_][a-zA-Z0-9_]* { printf("TOKEN: %-10s CATEGORY: Identifier\n", yytext); }
  10. "+"|"-"|"*"|"/"|"=" { printf("TOKEN: %-10s CATEGORY: Operator\n", yytext); }
  11. [ \t\n] ;
  12. . { printf("TOKEN: %-10s CATEGORY: Invalid Character\n", yytext); }
  13. %%
  14.  
  15. int main() {
  16. yylex();
  17. return 0;
  18. }
  19.  
Success #stdin #stdout #stderr 0.02s 6708KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/TA90gO/prog:2:1: Syntax error: Operator expected
ERROR: /home/TA90gO/prog:18:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit