In function ‘int yylex()’: not declared in this scope errors

问题描述 投票:0回答:0

这是定义部分。

identifier              ([A-Za-z][0-9A-Za-z]*)
digit                   ([0-9])
integer                 ({digit}+)
float                   ({integer}"."[0-9]+)
delimiter               ([.,:;()\[\]{}])
arithmetic              ([+\-*/])
relational              ([<>=])
string                  (\"(\"\"|[^"\n])*\")

动作部分。

 // Single-character token
 {delimiter}            {tokenChar(yytext[0]);}
 {arithmetic}           {tokenChar(yytext[0]);}
 {relational}           {tokenChar(yytext[0]);}

不知何故我得到这些错误

scanner.l: In function ‘int yylex()’:
scanner.l:88:3: error: ‘delimiter’ was not declared in this scope
   88 |  {arithmetic}                   {tokenChar(yytext[0]);}
      |   ^~~~~~~~~
scanner.l:89:3: error: ‘arithmetic’ was not declared in this scope
   89 |  {relational}                   {tokenChar(yytext[0]);}
      |   ^~~~~~~~~~
scanner.l:90:3: error: ‘relational’ was not declared in this scope
   90 |
      |   ^ 

不确定发生了什么。我应该把定义放在头文件中吗?

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