fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6. if { printf("Keyword: if\n"); }
  7. else { printf("Keyword: else\n"); }
  8. for { printf("Keyword: for\n"); }
  9. while { printf("Keyword: while\n"); }
  10. do { printf("Keyword: do\n"); }
  11. int { printf("Keyword: int\n"); }
  12. float { printf("Keyword: float\n"); }
  13. double { printf("Keyword: double\n"); }
  14. [+\-*/%] { printf("Operator: %s\n", yytext); }
  15. [<>=!]=? { printf("Relational Operator: %s\n", yytext); }
  16. [ \t\n] {}
  17. . { printf("Unknown: %s\n", yytext); }
  18. %%
  19.  
  20. int main()
  21. {
  22. yylex();
  23. return 0;
  24. }
  25. int yywrap()
  26. {
  27. return 1;
  28. }
  29.  
Success #stdin #stdout #stderr 0.02s 6768KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/NXN4Sx/prog:2:1: Syntax error: Operator expected
ERROR: /home/NXN4Sx/prog:28:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit