0

我的程序在 Linux 机器上运行良好,但是当我在 IBM 上编译时yy_scan_string不起作用。我需要声明或定义yy_scan_string吗?

 File : "file.l"

 %{

 #nclude <iostream>

 #include <cstring>

 bool st = false;
 %}

 %%

  .([.][fF][1-9][0-9][Kk])$ { st = true; }

  . { st = false; }

  %%

  int main()

  {

      const char *fName = "check.f9k";

      char *elem = new char[strlen(fName) + 1];

      sprintf(elem, "%s\n", fName);

      yy_scan_string(elem);
      yylex();

      std::cout<<"\n ST : "<<st<<"\n";
      return 0;
  }

  int yywrap() { return 1; }

编译:

lex file.l

g++ -o outfile lex.yy.c -ll

lex.yy.c: In function 'int main()': lex.yy.c:131: error: 'yy_scan_string' was not declared in this scope

如何解决我的 IBM 机器上的这个错误?

4

1 回答 1

1

yy_scan_string是一部分flex,但它不是传统的一部分lex。我假设您的“IBM 机器”安装了 AT&T lex。(它也可能有flex。)

于 2013-10-28T01:34:57.250 回答