fork download
  1. %{
  2. #include <stdio.h>
  3. #include <string.h>
  4. %}
  5.  
  6. %%
  7.  
  8. const|final|break|else|while|for|if|idol|switch { printf("%s is a keyword\n", yytext); }
  9. [a-zA-Z_][a-zA-Z0-9_]* { printf("%s is an identifier\n", yytext); }
  10. [=+\-*/%] { printf("%s is an operator\n", yytext); }
  11. [ \t\n]+ { /* skip whitespace */ }
  12. . { printf("%s is an unknown token\n", yytext); }
  13.  
  14. %%
  15.  
  16. int main() {
  17. yylex();
  18. return 0;
  19. }
  20.  
  21. int yywrap() {
  22. return 1;
  23. }
  24.  
Success #stdin #stdout #stderr 0.03s 6948KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/ckGOoF/prog:2:1: Syntax error: Operator expected
ERROR: /home/ckGOoF/prog:23:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit