fork download
  1.  
  2.  
  3. However, Repl.it doesn't support the `flex` command by default. As an alternative, you can use [Ideone](https://i...content-available-to-author-only...e.com/), which supports Lex.
  4.  
  5.  
  6. Here's your updated code for Ideone:
  7.  
  8.  
  9. ```c
  10. %option noyywrap
  11.  
  12. %{
  13. #include <stdio.h>
  14. %}
  15.  
  16. %%
  17.  
  18. [id][a-zA-Z_][a-zA-Z0-9_]* {printf("%s is an identifier\n", yytext);}
  19.  
  20. for|if|else|int|float|double|char|do|while {printf("%s is a keyword\n", yytext);}
  21.  
  22. [0-9]+("[.][0-9]+")?([eE][+-]?[0-9]+)? {printf("%s is a number\n", yytext);}
  23.  
  24. \n ;
  25.  
  26. . {printf("Invalid character: %c\n", *yytext);}
  27.  
  28. %%
  29.  
  30. int main() {
  31. yylex();
  32. printf("\n\n");
  33. return 0;
  34. }
Success #stdin #stdout #stderr 0.03s 6948KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/oN9oHq/prog:3:1: Syntax error: End of file in quoted codes
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit