首页 文章

文件lex过早结束

提问于
浏览
0

当我尝试使用make关键字编译它时,它给出了一个错误:

第17行中lex.l文件中的文件过早结束 .

%option noyywrap
 %{
    #include "grammer.tab.h"
 %}
 name        ([0-9])
 whitespace  [ \r\t\v\f]
 linefeed    \n
 %%
 {name}         { return NAME; }
 ":"            { return COLON; }
 "->"           { return RIGHT_ARROW; }
 "{"            { return LEFT_BRACE;}
 "}"            { return RIGHT_BRACE;}
 ";"            { return SEMICOLON;}
 {whitespace}
 {linefeed}     ++yylineno;
 %%

所以有人帮助我 .

enter image description here

错误:-

This is the error that the is shown

尾巴: - enter image description here

1 回答

  • 0

    当最后一行没有被换行终止时,通常会从lex(或flex)中获得此错误 .

    要解决该错误,只需在文件末尾添加一个空行 .

    (yacc / bison也是如此)

    我还注意到你对模式 {whitespace} 缺少一个动作 . 我建议你试试:

    {whitespace}         ; /* No action */
    %%
    /* End of the file */
    

相关问题