FlexLexer error

Discussion in 'C++' started by chiqui.p@gmail.com, Apr 15, 2009.

  1. Guest

    hi all,
    I'm compiling a c++ program of mine and I have a problem with flex:
    the error is the following

    /usr/include/FlexLexer.h:130: error: expected unqualified-id before
    numeric constant

    I search but I only found that this error has been fixed in the newer
    version of flex.
    I have Flex 2.5.35, I'm compiling with gcc/g++ 4.1 (because I need to)
    I'm using Ubuntu 8.10. bison 1:2.3 and bisonc++ 2.4.2-1.

    I can't find a way to make it through.

    does any of you have an idea?

    the line in the file is
    virtual int yywrap();

    i can't understand whether the problem is in my code or somewhere
    else.

    thank you
    cisco
    , Apr 15, 2009
    #1
    1. Advertising

  2. wrote:
    > I'm compiling a c++ program of mine and I have a problem with flex:
    > the error is the following
    >
    > /usr/include/FlexLexer.h:130: error: expected unqualified-id before
    > numeric constant
    >
    > I search but I only found that this error has been fixed in the newer
    > version of flex.
    > I have Flex 2.5.35, I'm compiling with gcc/g++ 4.1 (because I need to)
    > I'm using Ubuntu 8.10. bison 1:2.3 and bisonc++ 2.4.2-1.
    >
    > I can't find a way to make it through.
    >
    > does any of you have an idea?
    >
    > the line in the file is
    > virtual int yywrap();
    >
    > i can't understand whether the problem is in my code or somewhere
    > else.


    The code you posted does not contain any errors AFA C++ is concerned.
    It doesn't have any numeric constant either. See FAQ 5.8.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Apr 15, 2009
    #2
    1. Advertising

  3. Guest

    schrieb:
    > hi all,
    > I'm compiling a c++ program of mine and I have a problem with flex:
    > the error is the following
    >
    > /usr/include/FlexLexer.h:130: error: expected unqualified-id before
    > numeric constant
    >
    > I search but I only found that this error has been fixed in the newer
    > version of flex.
    > I have Flex 2.5.35, I'm compiling with gcc/g++ 4.1 (because I need to)
    > I'm using Ubuntu 8.10. bison 1:2.3 and bisonc++ 2.4.2-1.
    >
    > I can't find a way to make it through.
    >
    > does any of you have an idea?
    >
    > the line in the file is
    > virtual int yywrap();
    >
    > i can't understand whether the problem is in my code or somewhere
    > else.


    Are you sure that you really use Flex and not Flex++? A virtual method
    would not make much sense if you actually used Flex. I use Flex 2.5.4,
    and my FlexLexer.h doesn't even contain a definition of yywrap (it
    only appears once inside a comment). As far as I remember, you have to
    provide the function yywrap yourself, so it should actually appear in
    your own code, not inside FlexLexer.h.

    Regards,
    Stuart
    , Apr 16, 2009
    #3
  4. James Kanze Guest

    On Apr 15, 11:33 am, wrote:

    > I'm compiling a c++ program of mine and I have a problem with flex:
    > the error is the following


    > /usr/include/FlexLexer.h:130: error: expected unqualified-id before
    > numeric constant


    > I search but I only found that this error has been fixed in the newer
    > version of flex.
    > I have Flex 2.5.35, I'm compiling with gcc/g++ 4.1 (because I need to)
    > I'm using Ubuntu 8.10. bison 1:2.3 and bisonc++ 2.4.2-1.


    > I can't find a way to make it through.


    > does any of you have an idea?


    > the line in the file is
    > virtual int yywrap();


    > i can't understand whether the problem is in my code or somewhere
    > else.


    Flex doesn't really understand C++ very well, and the generated
    code for any one version of flex tends to only work with one
    particular version of C++---not necessarily the version used
    with your compiler. I post-process the output (using sed) to
    get it to compile, but it's a frustrating job at best, since the
    post-processing depends on the version of flex you're using. If
    I had it to do over, I'd just let flex generate C, and live with
    it.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Apr 16, 2009
    #4
  5. James Kanze Guest

    On Apr 16, 9:14 am, wrote:
    > schrieb:


    > > I'm compiling a c++ program of mine and I have a problem
    > > with flex: the error is the following


    > > /usr/include/FlexLexer.h:130: error: expected unqualified-id before
    > > numeric constant


    > > I search but I only found that this error has been fixed in
    > > the newer version of flex. I have Flex 2.5.35, I'm
    > > compiling with gcc/g++ 4.1 (because I need to) I'm using
    > > Ubuntu 8.10. bison 1:2.3 and bisonc++ 2.4.2-1.


    > > I can't find a way to make it through.


    > > does any of you have an idea?


    > > the line in the file is
    > > virtual int yywrap();


    > > i can't understand whether the problem is in my code or somewhere
    > > else.


    > Are you sure that you really use Flex and not Flex++? A
    > virtual method would not make much sense if you actually used
    > Flex. I use Flex 2.5.4, and my FlexLexer.h doesn't even
    > contain a definition of yywrap (it only appears once inside a
    > comment). As far as I remember, you have to provide the
    > function yywrap yourself, so it should actually appear in your
    > own code, not inside FlexLexer.h.


    Flex will generate C++ if given the -+ option, or if you specify
    "%option c++" in the source file. From the (latest)
    documentation, however: "IMPORTANT: the present form of the
    scanning class is experimental and may change considerably
    between major releases." The code generator also seems to have
    some problems tracking the evolutions in C++; some of the
    versions I use still include <iostream.h>, for example, and I've
    had a number of other problems getting the generated code to
    compile with all my compilers. Generally, some creative use of
    sed on the output solves the problem, but getting anything to
    work with different versions of flex *and* different compilers
    can be fairly tricky.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Apr 16, 2009
    #5
  6. Guest

    > > schrieb:
    > > > I'm compiling a c++ program of mine and I have a problem
    > > > with flex: the error is the following
    > > > /usr/include/FlexLexer.h:130: error: expected unqualified-id before
    > > > numeric constant

    [snip]
    > > > the line in the file is
    > > >    virtual int yywrap();


    > On Apr 16, 9:14 am, wrote:
    > > Are you sure that you really use Flex and not Flex++? A
    > > virtual method would not make much sense if you actually used
    > > Flex. I use Flex 2.5.4, and my FlexLexer.h doesn't even
    > > contain a definition of yywrap (it only appears once inside a
    > > comment). As far as I remember, you have to provide the
    > > function yywrap yourself, so it should actually appear in your
    > > own code, not inside FlexLexer.h.


    On 16 Apr., 10:43, James Kanze <> wrote:
    > Flex will generate C++ if given the -+ option,


    Right. I checked my code and was mildly surprised that I used the -+
    option myself. I'm having a memory like a sieve ...

    > or if you specify
    > "%option c++" in the source file.  From the (latest)
    > documentation, however: "IMPORTANT: the present form of the
    > scanning class is experimental and may change considerably
    > between major releases."  The code generator also seems to have
    > some problems tracking the evolutions in C++; some of the
    > versions I use still include <iostream.h>, for example,


    Luckily I'm still using a compiler that has an <iostream.h>, but
    please don't flame me ;-)

    > and I've
    > had a number of other problems getting the generated code to
    > compile with all my compilers.  Generally, some creative use of
    > sed on the output solves the problem, but getting anything to
    > work with different versions of flex *and* different compilers
    > can be fairly tricky.


    I updated my FlexLexer.h header, which is probably why I couldn't find
    the definition of yywrap inside it anymore (see my previous posting).
    Gosh, its like an expedition into the past (even though it was only
    two or three years ago).

    Anyway I still only provide a non-virtual function yywrap, and I
    pretty much guess that I didn't tweak the FlexLexer.h header so far
    that I changed a virtual yywrap method into a plain old function.
    @cisco: Did removing the virtual keyword do any good?

    Stuart
    , Apr 17, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hfk0
    Replies:
    2
    Views:
    21,629
  2. JavaQueries
    Replies:
    1
    Views:
    3,614
    John C. Bollinger
    Mar 1, 2005
  3. Balaji
    Replies:
    3
    Views:
    10,064
  4. Bishop
    Replies:
    1
    Views:
    753
    Bishop
    Feb 24, 2007
  5. juvi
    Replies:
    3
    Views:
    1,035
    Alexey Smirnov
    Jan 22, 2009
Loading...

Share This Page