动作中遇到的文件尾EOF的Flex结束

问题描述 投票:-1回答:1

我正在尝试开始学习Flex,这是我的第一次尝试,但出现此错误我正在寻找一些解决方案,但找不到正确的解决方案为什么?我怎么解决这个问题?这是我的第一次尝试

%%

([Ii][Nn][Tt])                  {printf("MotCle");}
([Ff][Ll][Oo][Aa][Tt])          {printf("MotCle");}
([Cc][Oo][Dd][Ee])              {printf("MotCle");}
([Cc][Ll][Aa][Ss][Ss][Ee])      {printf("MotCle");}
([Ss][Ii])                      {printf("MotCle");}
([Ss][Ii][Nn][Oo][Nn])          {printf("MotCle");}
([Ii][Ss])                      {printf("MotCle");}
([Tt][Qq])                      {printf("MotCle");}
([Qq][Tt])                      {printf("MotCle");}
([Rr][Pp][Tt])                  {printf("MotCle");}
([Jj][Ss][Qq])                  {printf("MotCle");}
([Ll][Rr][Ee])                  {printf("MotCle");}
([Vv][Rr][Aa][Ai])              {printf("MotCle");}
([Ff][Aa][Uu][Xx])              {printf("MotCle");}
([-+]?[0-9])+                   {printf("Entier");}
([a-zA-Z0-9])+                  {printf("Id");}
(\".+[ ]+\n?.+\")               {printf("ChaineDeChar");}
\/\/[^"\n"]*\n                  {printf("Commentaire");}
\/\* ([^"\n"]|*+[^/*])* \/\*    {printf("MultCommentaire ");}
([ ])+          {printf("Blanc ");}
\Backspace      {printf("Backspace ");}
\t              {printf("Tab");}
\n              {printf("EOL");}
\f              {printf("FormFeed ");}
","             {printf("VIR");}
"+"             {printf("PLUS");}
"-"             {printf("MOINS");}
"*"             {printf("MULT");}
"/"             {printf("DIV");}
"="             {printf("AFF");}
">"             {printf("Graet Then");}
">="            {printf("Graet Then or Equale");}
"<"             {printf("Less Then");}
"<="            {printf("Less Then or Equale");}
"=="            {printf("Equale");}
"!="            {printf("DIFF ");}
"&"             {printf("Et");}
"|"             {printf("OU");}
"!"             {printf("NON");}
"("             {printf("Parentese Ovrent");}
")"             {printf("Parentese Fermet");}

%%

int yywrap()
{
    return 1;
}

int main()
{

printf(" My First Try ");
yylex();
return 0;

}

这是我尝试实施时出现的消息

line 64: EOF encountered inside an action
flex-lexer
1个回答
0
投票

这里的模式:

\/\* ([^"\n"]|*+[^/*])* \/\*    {printf("MultCommentaire ");}

\/\*,因为模式在第一个未转义的空白处结束。

这不是唯一的错误模式,也不是该模式中唯一的错误。但这就是产生该错误消息的原因。仔细观察,您会发现“动作”(在空格之后开始)包括一个未终止的注释。

© www.soinside.com 2019 - 2024. All rights reserved.