fork download
  1. %{
  2. #include<stdio.h>
  3. int vow,con;
  4. %}
  5.  
  6. %%
  7. "auto"|"break"|"case"|"char"|"const"|"continue"|"default"|"do"|"double"|"else"|"enum"|"extern" { printf("Keyword: %s\n",yytext); }
  8. "float"|"for"|"goto"|"if"|"int"|"long"|"register"|"return"|"short"|"signed"|"sizeof"|"static"|"struct" { printf("Keyword: %s\n",yytext); }
  9. "switch"|"typedef"|"union"|"unsigned"|"void"|"volatile"|"while" { printf("Keyword: %s\n",yytext); }
  10. [0-9]+ { printf("Number: %s\n",yytext); }
  11. [+*/=><%#] { printf("Operator: %s\n",yytext); }
  12. [{(:"?/,.\)}&|$#;] { printf("Special Characters: %s\n",yytext); }
  13. [A-Za-z_][A-Za-z0-9_]* { printf("Identifier: %s\n",yytext); }
  14. [ \t\n]+ //Ignore whitespace
  15. . { printf("Unknown Character: %s\n",yytext); }
  16. %%
  17.  
  18. int yywrap()
  19. {
  20. return 1;
  21. }
  22.  
  23. void main(int argc, char* argv[1])
  24. {
  25. yyin = fopen(argv[1],"r");
  26. yylex();
  27. }
  28.  
Success #stdin #stdout #stderr 0.02s 6860KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/dUu3v7/prog:2:1: Syntax error: Operator expected
ERROR: /home/dUu3v7/prog:27:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit