Help please

<[email protected]> Sun, 27 Jan 2008 22:13:39 +0100
Newsgroups gmane.comp.lex.flex.general
Message-ID <[email protected]>
This is a multi-part message in MIME format.

--===============0076698132==
Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C86129.7C9326E9"

This is a multi-part message in MIME format.

------_=_NextPart_001_01C86129.7C9326E9
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,
I'm a new Flex user.
I'm having the follow problem:

1. I've created one file Example.l:

%option c++
%option yylineno
%option noyywrap
%option caseless

delim [ \t\n]
ws {delim}+
letter [A-Za-z]
digit [0-9]
id {letter}({letter}|{digit})*
number {digit}+(\.{digit}+)?(E[+\-]?{digit}+)?

%%
            int yylval;
{ws}        {;}
if          { return(IF);}
then        { return(THEN);}
else        { return(ELSE);}
{id}        { return(ID);}
{number}    { return(NUMBER);}
"<"         { yylval =3D LT; return(RELOP);}
"<=3D"        { yylval =3D LE; return(RELOP);}
"=3D"         { yylval =3D EQ; return(RELOP);}
"<>"        { yylval =3D NE; return(RELOP);}
">"         { yylval =3D GT; return(RELOP);}
">=3D"        {yylval =3D GE; return(RELOP);}
.           {return(ERROR);}
%%


and i've run >Flex example.l

and it has returned the file lex.yy.cc.

2. Well, i've created also the main program in c++, let's call it =
main_prog.cpp:



#include <stdio.h>
#include <ctype.h>
enum {LT, LE, NE, GT, GE, EQ, IF, THEN, ELSE, ID, NUMBER, RELOP, ERROR};
#include <FlexLexer.h>
#include "lex.yy.cc"

int main(int argc, char *argv[])
{
    int token;
    FlexLexer* lexer =3D new yyFlexLexer();
    while ((token=3Dlexer->yylex()) !=3D 0) {
        switch (token) {
        case RELOP: printf("%s","RELOP"); break;
        case NUMBER: printf("%s","NUMBER"); break;
        case ID: printf("%s","ID"); break;
        case IF: printf("%s","IF"); break;
        case THEN: printf("%s","THEN"); break;
        case ELSE: printf("%s","ELSE");break;
        case ERROR: printf("%s", "illegal character"); break;
        default:
                    printf("%s","UNKNOWN");
                    break;
        }
        printf("%s\n", lexer->YYText());
    }
    return 0;
}

The problem becomes when I compile it using=20

        g++ main_prog.cpp -o main_prog

,infact the system answer me with:

/usr/include/FlexLexer.h:113: error: redefinition of =91class =
yyFlexLexer=92
/usr/include/FlexLexer.h:113: error: previous definition of =91class =
yyFlexLexer=92

thank you for helping me,

Simone.










**********
Scopri la nuova Alice Mail!
1 GB di spazio con antivirus, antispam e fino a 2 GB di allegati.

Registrati GRATIS su =
http://registra.rossoalice.alice.it/registra/basic/entratabasic.do?entryP=
oint=3Dfooter

------_=_NextPart_001_01C86129.7C9326E9
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.7653.15">
<TITLE>Help please</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=3D2>Hi,<BR>
I'm a new Flex user.<BR>
I'm having the follow problem:<BR>
<BR>
1. I've created one file Example.l:<BR>
<BR>
%option c++<BR>
%option yylineno<BR>
%option noyywrap<BR>
%option caseless<BR>
<BR>
delim [ \t\n]<BR>
ws {delim}+<BR>
letter [A-Za-z]<BR>
digit [0-9]<BR>
id {letter}({letter}|{digit})*<BR>
number {digit}+(\.{digit}+)?(E[+\-]?{digit}+)?<BR>
<BR>
%%<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
yylval;<BR>
{ws}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {;}<BR>
if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { =
return(IF);}<BR>
then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { return(THEN);}<BR>
else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { return(ELSE);}<BR>
{id}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { return(ID);}<BR>
{number}&nbsp;&nbsp;&nbsp; { return(NUMBER);}<BR>
&quot;&lt;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { =
yylval =3D LT; return(RELOP);}<BR>
&quot;&lt;=3D&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { yylval =
=3D LE; return(RELOP);}<BR>
&quot;=3D&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { yylval =
=3D EQ; return(RELOP);}<BR>
&quot;&lt;&gt;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { yylval =
=3D NE; return(RELOP);}<BR>
&quot;&gt;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { =
yylval =3D GT; return(RELOP);}<BR>
&quot;&gt;=3D&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {yylval =
=3D GE; return(RELOP);}<BR>
.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
{return(ERROR);}<BR>
%%<BR>
<BR>
<BR>
and i've run &gt;Flex example.l<BR>
<BR>
and it has returned the file lex.yy.cc.<BR>
<BR>
2. Well, i've created also the main program in c++, let's call it =
main_prog.cpp:<BR>
<BR>
<BR>
<BR>
#include &lt;stdio.h&gt;<BR>
#include &lt;ctype.h&gt;<BR>
enum {LT, LE, NE, GT, GE, EQ, IF, THEN, ELSE, ID, NUMBER, RELOP, =
ERROR};<BR>
#include &lt;FlexLexer.h&gt;<BR>
#include &quot;lex.yy.cc&quot;<BR>
<BR>
int main(int argc, char *argv[])<BR>
{<BR>
&nbsp;&nbsp;&nbsp; int token;<BR>
&nbsp;&nbsp;&nbsp; FlexLexer* lexer =3D new yyFlexLexer();<BR>
&nbsp;&nbsp;&nbsp; while ((token=3Dlexer-&gt;yylex()) !=3D 0) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (token) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case RELOP: =
printf(&quot;%s&quot;,&quot;RELOP&quot;); break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case NUMBER: =
printf(&quot;%s&quot;,&quot;NUMBER&quot;); break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID: =
printf(&quot;%s&quot;,&quot;ID&quot;); break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case IF: =
printf(&quot;%s&quot;,&quot;IF&quot;); break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case THEN: =
printf(&quot;%s&quot;,&quot;THEN&quot;); break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ELSE: =
printf(&quot;%s&quot;,&quot;ELSE&quot;);break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ERROR: =
printf(&quot;%s&quot;, &quot;illegal character&quot;); break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default:<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
printf(&quot;%s&quot;,&quot;UNKNOWN&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;%s\n&quot;, =
lexer-&gt;YYText());<BR>
&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp; return 0;<BR>
}<BR>
<BR>
The problem becomes when I compile it using<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g++ main_prog.cpp -o =
main_prog<BR>
<BR>
,infact the system answer me with:<BR>
<BR>
/usr/include/FlexLexer.h:113: error: redefinition of &#145;class =
yyFlexLexer&#146;<BR>
/usr/include/FlexLexer.h:113: error: previous definition of &#145;class =
yyFlexLexer&#146;<BR>
<BR>
thank you for helping me,<BR>
<BR>
Simone.<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
**********<BR>
Scopri la nuova Alice Mail!<BR>
1 GB di spazio con antivirus, antispam e fino a 2 GB di allegati.<BR>
<BR>
Registrati GRATIS su <A =
HREF=3D"http://registra.rossoalice.alice.it/registra/basic/entratabasic.d=
o?entryPoint=3Dfooter">http://registra.rossoalice.alice.it/registra/basic=
/entratabasic.do?entryPoint=3Dfooter</A></FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C86129.7C9326E9--



--===============0076698132==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
help-flex mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-flex

--===============0076698132==--