當我在flex中運行下面的代碼時,我在最後一行發現過早的EOF作爲錯誤。如果刪除了定義部分,則不會生成錯誤。爲什麼這樣呢?Flex中的過早EOF錯誤
%{
#include <stdio.h>
int x = 0;
}%
%%
"a" {x=x+1; printf("id %d",x); }
%%
int yywrap(void)
{
return 0;
}
int main(void)
{
int x = 0;
yylex();
return 0;
}