1

Visual C++ で Flex を使用しようとしています。ただし、生成されたレクサー (空でルールがない) は、ビルド中に次のエラーをスローします。

configurationlexer.cpp(967): error C3861: 'read' identifier not found
configurationlexer.cpp(967): fatal error C1903: unable to recover from previous error(s); stopping compilation

ソースファイルは次のとおりです。

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

%%


%%

//Lexer End

このターゲットを 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 で使用することはできますか?

4

1 に答える 1

2

さて、Bill であるボゾがドキュメントを読んでくれれば助かります。

-f, --full, %option full' specifies fast scanner. No table compression is done and stdio is bypassed. The result is large but fast. This option is equivalent to--Cfr'

これは次のことにつながります。

-Cr, --read, %option read' causes the generated scanner to bypass use of the standard I/O library (stdio) for input. Instead of calling fread() or getc(), the scanner will use the read() system call, resulting in a performance gain which varies from system to system, but in general is probably negligible unless you are also using-Cf' または-CF'. Using-Cr' は、たとえば、スキャナを呼び出す前に stdio を使用して yyin から読み取ると、奇妙な動作を引き起こす可能性があります (スキャナは、以前に読み取ったテキストが stdio 入力バッファに残っているものを見逃すため)。YY_INPUT() を定義した場合、`-Cr' は効果がありません (Generated Scanner を参照してください)。

-F をオフにすると、すべてが期待どおりに機能するようになりました。他の理由で、--never-interactive を有効にする必要がありました。--always-interactive は、対話型スキャナーが必要な場合にも機能します ....私はしません。

于 2010-07-24T23:54:09.610 に答える