help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parsing bytes array


From: Hans Aberg
Subject: Re: parsing bytes array
Date: Fri, 2 Nov 2001 12:37:21 +0100

At 15:09 +0530 2001/11/02, Sunil Kumar Jain wrote:
>After generating *.c files but naming them as *.cpp(it has the "C" code
>only), is it possible to populate the decoded message in a class object?

If you by that mean to wrap up the code the Bison generates into some nice
C++ syntax, that is probably a topic for the next upcoming version of Bsion.

In the meantime I have made some not pure versions, which I use myself. One
variation is to meke a class "my_parser" that generates istream
manipulators that produces say "my_parser_value" values. The syntax might be
    my_parser filter;
    std::istream is;
    my_parser_value x;
    try {
      is >> filter >> x;  // parse istream using "filter" to get value x.
    } catch ...

>In fact, I'm planning this way:
...
>       class Test;  -> this is CPlusPlus class.
>
>       Test decode( char bytes[ ] ) -> this method should take care of
>parsing the bytes[] array and parsed message should get filled in an object
>of type "class Test" and this object is returned.

Instead of working directly with character arrays, one would convert the
input array using std::istringstream.

I posted an example to the Bison Help group, "Re: Flex-Bison string
processing", 200/12/05; check the archive (address at each message).

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]