fork download
  1. %{
  2. #include<stdio.h>
  3. %}
  4. KEYWORDS "int"|"float"|"return"|"if"|"else"|"for"|"while"
  5. OPERATORS [+\-*/^<>&|!%]
  6. SEPERATORS [;,\(\)\{\}\"]
  7. %%
  8. {KEYWORDS} {printf("Keyword: %s\n", yytext);}
  9. {OPERATORS} {printf("Operators: %s\n", yytext);}
  10. {SEPERATORS} {printf("Seperators: %s\n", yytext);}
  11. [a-zA-Z_]+[a-zA-Z0-9_]* {printf("Id: %s\n", yytext);}
  12. . {}
  13. %%
  14. int main(){
  15. yylex();
  16. return 0;
  17. }
  18. int yywrap(){
  19. return 1;
  20. }
Success #stdin #stdout #stderr 0.02s 6900KB
stdin
int heloo   + - 
stdout
Standard output is empty
stderr
ERROR: /home/z0lvka/prog:2:1: Syntax error: Operator expected
ERROR: /home/z0lvka/prog:20:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: Can't ignore goal at this port
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit