help-bison
[Top][All Lists]
Advanced

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

Re: Interesting problem with PostgreSQL grammar ...


From: Laurence Finston
Subject: Re: Interesting problem with PostgreSQL grammar ...
Date: Sun, 21 Nov 2004 16:11:49 +0100 (MET)

Hello,

On Sun, 21 Nov 2004, Hans-Juergen Schoenig wrote:

> I am currently working on some features for PostgreSQL.

I have found that implementing options in my parser can be
tricky and that they are prone to cause problems.  In
addition, I'm sometimes puzzled by the states generated by
Bison from my grammar, although I'm certain this is
completely predictable.  I'm sure understanding Bison's
internals would help me in such situations, but so far I've
been able to muddle through.

I implement some options in the normal way, as you have
done, but for others I use a different technique, which you
might find helpful. (Some people may be tired of hearing
this.  Sorry.)

If you generate a reentrant parser, you can pass a `void*'
parameter to `yyparse()', which is, in turn, passed to
`yylex()'.  The object referenced by this pointer can be a
`struct' or (in C++) a `class' type, which may contain
additional pointers.  For certain options, instead of
setting `$$', I set the values of the objects referenced by
these latter pointers.

This is an excerpt from the file `parser.output' generated
by Bison from the input file for the GNU 3DLDF grammar:

  180 drawing_command: drawdot_or_undrawdot point_expression 
with_clause_draw_list
  181                | drawdot_or_undrawdot bool_point_expression 
with_clause_draw_list
  182                | conditional_drawdot_or_undrawdot bool_point_expression 
with_clause_draw_list

[...]

  189 with_clause_draw_list: /* empty */
  190                      | with_clause_draw_list with_clause_draw

  191 with_clause_draw: WITH_COLOR_VECTOR color_vector_variable
  192                 | WITH_DRAW_COLOR_VECTOR color_vector_variable
  193                 | WITH_FILL_COLOR_VECTOR color_vector_variable
  194                 | WITH_PEN pen_expression
  195                 | DASHED dash_pattern_expression
  196                 | WITH_COLOR color_expression
  197                 | WITH_DRAW_COLOR color_expression
  198                 | WITH_FILL_COLOR color_expression
  199                 | ON_PICTURE picture_expression

The rules are in the file `pdrwcmnd.w', which you can find
at
http://savannah.gnu.org/cgi-bin/viewcvs/3dldf/3dldf/Group/CWEB/

The files containing the parser rules are in the files of
the pattern `p*.w'.

Laurence Finston




reply via email to

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