fork download
  1. %{
  2. #include<stdio.h>
  3. %}
  4.  
  5. %%
  6. "<"[^>]*> { printf("%s ", yytext); }
  7. . ;
  8. %%
  9.  
  10. int yywrap() {
  11. return 1;
  12. }
  13.  
  14. int main() {
  15. extern FILE *yyin;
  16. yyin = fopen("basic.txt", "r");
  17. yylex();
  18. fclose(yyin); // Don't forget to close the file after reading
  19. return 0;
  20. }
  21. flex HTMLtags.c
  22. gcc lex.yy.c
  23. ./a.exe
Success #stdin #stdout #stderr 0.03s 6872KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/F2zui2/prog:2:1: Syntax error: Operator expected
ERROR: /home/F2zui2/prog:7:11: Syntax error: End of file in quoted atom
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit