[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help with c++ sample in flex 2.5.11
From: |
Bernd Prager |
Subject: |
Re: help with c++ sample in flex 2.5.11 |
Date: |
Tue, 13 Aug 2002 17:18:22 -0400 |
> ----- Original Message -----
> From: "W. L. Estes" <address@hidden>
> ...
>
> > On Tuesday, 13 August 2002,13:53 -0400, Bernd Prager wrote:
> >
> > > I'm trying to make the c++ example from the doc working.
> >
> > You have put the @samp{*} in your code. that is not what you
> > want. See the compiler's reference to line 28.
> >
> > --Will
>
> Sorry, you're right. I missed that.
> But I'm still not successful.
> Corrected the code to:
> ---------- test.l --------------------------
> %{
> #include <iostream>
> using std::cout;
> using std::endl;
>
> int mylineno = 0;
> %}
>
> string \"[^\n"]+\"
>
> ws [ \t]+
>
> alpha [A-Za-z]
> dig [0-9]
> name ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])*
> num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)?
> num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
> number {num1}|{num2}
>
> %%
>
> {ws} /* skip blanks and tabs */
>
> "/*" {
> int c;
>
> while((c = yyinput()) != 0)
> {
> if(c == '\n')
> ++mylineno;
>
> else if(c == '*')
> {
> if((c = yyinput()) == '/')
> break;
> else
> unput(c);
> }
> }
> }
>
> {number} cout << "number " << YYText() << endl;
>
> \n mylineno++;
>
> {name} cout << "name " << YYText() << endl;
>
> {string} cout << "string " << YYText() << endl;
>
> %%
>
> int main( int /* argc */, char** /* argv */ )
> {
> FlexLexer* lexer = new yyFlexLexer;
> while(lexer->yylex() != 0)
> ;
> return 0;
> }
> ------ end test.l --------------------------
Sorry, forgot the -+ option. This is the correct error code:
--------- snip --------------------------------
test.tab.cc:1107:19: cunistd: No such file or directory
test.tab.cc: In member function `virtual int yyFlexLexer::yylex()':
test.tab.cc:1496: `yywrap' undeclared (first use this function)
test.tab.cc:1496: (Each undeclared identifier is reported only once for each
function it appears in.)
test.tab.cc: In function `int yylex_destroy()':
test.tab.cc:2409: `yy_current_buffer' undeclared (first use this function)
test.tab.cc:2409: `yy_delete_buffer' undeclared (first use this function)
make: *** [test] Error 1
--------- snip --------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: help with c++ sample in flex 2.5.11,
Bernd Prager <=