【发布时间】:2019-04-25 08:22:57
【问题描述】:
我正在尝试在 UBUNTU 中运行带有 .l 文件扩展名的词法程序,我已经安装了 flex 和 bison,并且我能够获得 lex.yy.c 文件,但是当我给出命令时 cc lex.yy.c -lfd 或 @ 987654323@终端显示错误:
first.l:2:10: fatal error: iostream: No such file or directory
#include <iostream>
^~~~~~~~~~
我的代码是:
%{
#include <iostream>
using namespace std;
#define YY_DECL extern "C" int yylex()
%}
%%
[ \t\n] ;
[0-9]+\.[0-9]+ { cout << "Found a floating-point number:" << yytext << endl; }
[0-9]+ { cout << "Found an integer:" << yytext << endl; }
[a-zA-Z0-9]+ { cout << "Found a string: " << yytext << endl; }
%%
int main(int, char**) {
// lex through the input:
yylex();
}
我重新安装了 flex 和 bison ans 也卸载并安装了 gcc,但没有任何变化!任何帮助将不胜感激,
【问题讨论】:
标签: ubuntu flex-lexer yacc lex