Example for /doc/examples/ using Flex and Bison

lfinsto at gwdg.de lfinsto at gwdg.de
Fri Jul 30 16:24:55 CEST 2010


This may or not be of interest to you, but I thought I'd send it in case
it is.

The application I've written for my job uses a server and client that
communicate using two scanner/parser pairs, one for each peer.  They are
written using Flex and GNU Bison.  It is slightly tricky getting this to
work and the actual application is already fairly complicated, so I wanted
to make a simple example, while it's fresh in my mind.  I think it would
be most useful if it was included in the GNUTLS package, where people
would find it.

The attached file `a.txt' contains a patch for /doc/examples/.  I've
copied and modified ex-serv-anon.c and ex-client1.c.  The modified
versions are called ex-serv-anon-parse.c and ex-client1-parse.c.

The input files for GNU Bison are called prsrserv.y and prsrclnt.y,

The input files for Flex are called scnrserv.y and scnrclnt.y,

There's a header file called scanprse.h.

I've added rules to /doc/example/Makefile.am.

In addition, I've added a call to AM_PROG_LEX to the top-level
configure.ac file, but I haven't included this in the patch.

The client sends "Client finished" to the server and the server sends
"Server finished" to the client.  Then the client exits.  The idea is that
they can continue sending messages back and forth until they're both
finished and these messages will be processed by the respective
scanner/parser pair;  yylex/yyparse for the server and zzlex/zzparse for
the client.  That is, the server and the client can each have its own
"language".  The current state is not as polished as I would have liked,
but I don't have time to work on this anymore today and at least the
framework is present.

It's not entirely obvious what header files need to be included and in
what order, what options are needed for Bison, what needs to be called
"zz*" instead of "yy*", etc., especially for people who are new to Flex
and or Bison, so I think it would be a good idea to have a simple example
of this somewhere.

Please have a look if you feel like it and let me know if you think it
would be worthwhile to refine to a point where it could be included in the


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: a.txt
URL: </pipermail/attachments/20100730/fdb351f4/attachment.txt>

More information about the Gnutls-devel mailing list