如何在Visual C+中使用Flex+;? 我试图用Flex和Visual C++来实现。但是,生成的lexer(为空且没有规则)在生成时抛出以下错误: configurationlexer.cpp(967): error C3861: 'read' identifier not found configurationlexer.cpp(967): fatal error C1903: unable to recover from previous error(s); stopping compilation

如何在Visual C+中使用Flex+;? 我试图用Flex和Visual C++来实现。但是,生成的lexer(为空且没有规则)在生成时抛出以下错误: configurationlexer.cpp(967): error C3861: 'read' identifier not found configurationlexer.cpp(967): fatal error C1903: unable to recover from previous error(s); stopping compilation,c++,c,flex-lexer,C++,C,Flex Lexer,源文件是: %{ #include <string> %} %option yylineno %% %% //Lexer End %{ #包括 %} %选项yylineno %% %% //Lexer端 我通过将此目标添加到我的Visual Studio项目来构建: <Target Name="Flex" Inputs="$(MSBuildProjectDirectory)\ConfigurationLexer.l" Outputs="$(MSBuildProjec

源文件是:

%{
#include <string>
%}
%option yylineno

%%


%%

//Lexer End
%{
#包括
%}
%选项yylineno
%%
%%
//Lexer端
我通过将此目标添加到我的Visual Studio项目来构建:

<Target Name="Flex" Inputs="$(MSBuildProjectDirectory)\ConfigurationLexer.l" Outputs="$(MSBuildProjectDirectory)\ConfigurationLexer.cpp;$(MSBuildProjectDirectory)\ConfigurationLexer.hpp">
  <Exec Command="C:\Cygwin\bin\flex.exe --nounistd -f -o &quot;$(MSBuildProjectDirectory)\ConfigurationLexer.cpp&quot; &quot;--header=$(MSBuildProjectDirectory)\ConfigurationLexer.hpp&quot; &quot;$(MSBuildProjectDirectory)\ConfigurationLexer.l&quot;" />
</Target>


是否可以将Flex与MSVC结合使用?

好的,如果以下内容将有所帮助:

-f,--full,%option full'
指定快速扫描仪。不进行表压缩,并且绕过stdio。结果很大,但速度很快。此选项相当于
--Cfr'

这导致:

-Cr,--read,%option read'
使生成的扫描仪绕过使用标准I/O库(stdio)进行输入。扫描器将使用read()系统调用,而不是调用fread()或getc(),从而产生不同系统的性能增益,但通常情况下,除非同时使用
-Cf'或
-Cf',否则性能增益可能可以忽略不计。使用
-Cr'可能会导致奇怪的行为,例如,如果您在调用扫描仪之前使用stdio读取yyin(因为扫描仪将丢失您以前读取的stdio输入缓冲区中的任何文本)`-如果定义YY_INPUT()(请参阅生成的扫描仪),则Cr'无效


我关闭了-F,现在一切正常。出于其他原因,我不得不打开——从来没有互动过--如果您需要交互式扫描仪,则“始终交互式”也可以使用。。。。我不知道。

尽管很糟糕,但快速lexer不是GNU项目。@dmckee:我知道。但我不想让人们对AdobeFlex感到困惑。谢谢你指出:)