2016-10-25 129 views
0

当我试图用做关键字它给我的错误编译:文件法过早结束

premature end of file in lex.l file in line no 17.

%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

+0

这个文件是什么样子的? –

+0

当我编译make文件时出现这个错误 –

+0

是的,是的。但是说你有一个错误,并要求修复它不适合堆栈溢出。如果你可以提供错误或Makefile,这将会更有用。 –

回答

0

你通常从法(或弯曲)时,最后一行没有被终止的得到这个错误新队。

要解决该错误,只需在文件的末尾放置一个空行。

(同样也是YACC /野牛真)

我也注意到你有图案{whitespace}缺少的作用。我建议你可以试试:

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

即使这样,它仍然无法正常工作。 –

+0

仍然给出相同的错误。 –

+0

我已经上传了错误图片,请检查并请告诉代码中的错误 –