2010-07-24 5 views
1

Je suis en train d'utiliser Flex avec Visual C++. Cependant, le lexer généré (qui est vide et n'a pas de règles) renvoie ces erreurs lors de la construction:Comment utiliser Flex dans Visual C++?

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

Le fichier source est:

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

%% 


%% 

//Lexer End 

Je construis en ajoutant cet objectif à mon visuel Projet 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> 

Est-il possible d'utiliser Flex avec MSVC?

+1

Malgré le * très * mauvais, mais [marquage très officiel] (http://meta.stackexchange.com/questions/23959/whats-this-about-labelled-tags) le lexer rapide est * pas * un projet GNU . – dmckee

+0

@dmckee: Je sais. Je ne voulais pas que les gens soient confondus avec Adobe Flex. Merci de l'avoir signalé :) –

Répondre

2

Eh bien, il serait utile que le bozo that is Bill lirait the documentation:

-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 '

qui conduit à:

-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' ou -CF'. Using -Cr 'peut provoquer un comportement étrange si, par exemple, vous lisez à partir de yyin en utilisant stdio avant d'appeler le scanner (beca utilisez le scanner manquera le texte que votre précédent lit dans le tampon d'entrée stdio). `-Cr 'n'a aucun effet si vous définissez YY_INPUT() (voir Generated Scanner). J'ai éteint -F et maintenant tout fonctionne comme prévu.

Pour d'autres raisons, je devais allumer - jamais-interactif. --always-interactive fonctionne également si vous voulez un scanner interactif .... Je ne sais pas.