fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %%
  6. [ \t\n]+ { printf("white Space\n"); }
  7.  
  8. int|float|return { printf("Keyword: %s\n", yytext); }
  9.  
  10. [a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier: %s\n", yytext); }
  11.  
  12. [0-9]+(\.[0-9]+)? { printf("Number: %s\n", yytext); }
  13.  
  14. [+\-*/=] { printf("Operator: %s\n", yytext); }
  15.  
  16. "("|")"|"{"|"}"|"["|"]"|";"|","
  17. { printf("Special character: %s\n", yytext); }
  18.  
  19. . { printf("Unknown character: %s\n", yytext); }
  20. %%
  21.  
  22. int main(void) {
  23. yylex();
  24. return 0;
  25. }
  26.  
  27. int yywrap(void) {
  28. return 1;
  29. }
  30.  
Success #stdin #stdout #stderr 0.02s 6908KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/lyWMEP/prog:2:1: Syntax error: Operator expected
ERROR: /home/lyWMEP/prog:29:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit