【发布时间】:2014-06-26 16:08:36
【问题描述】:
我需要在flex中匹配EOF
这是我的代码 lex.l 的主要错误部分
%{
%}
%%
<<EOF>> {printf("match EOF\n");}
%%
int main(){
yylex();
}
我用
flex lex.l ; gcc lex.yy.c -o lex.exe -lfl ; lex.exe < text
执行
这是我的文本文件,只有一行
abc(no \n or \r at the end of file)
但是当我执行 lex.exe 时,它会进入 无限循环 并输出 “match EOF\n”的无限行
如何解决问题?
【问题讨论】:
标签: regex match lex flex-lexer eof