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