help-bison
[Top][All Lists]
Advanced

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

Re: Header file of a Bison parser


From: Pupeno
Subject: Re: Header file of a Bison parser
Date: Thu, 26 Oct 2006 05:17:19 +0000
User-agent: KMail/1.9.1

On Tuesday 24 October 2006 22:27, Joel E. Denny wrote:
> On Tue, 24 Oct 2006, Pupeno wrote:
> > I have a Bison parser, parser.y, which generates a C source file,
> > parser.c and its header file, parser.h.
> > I want to put something in parser.h: the declaration/prototype of a
> > function that is in parser.y and ends up in parser.c. This is because
> > this function should be usable from other files that use the parser.
> > Is there some way to do it ? That is, can I put something in parser.y
> > that will end up in parser.h ?
>
> CVS Bison has two directives for writing verbatim code to the parser
> header file.  However, they are still experimental, so I can't promise
> what they'll look like in the next stable release:
>
> 1. %requires {CODE} inserts CODE that YYSTYPE and YYLTYPE depend upon.
> That is, it inserts CODE near the top of the parser header file.
>
> 2. %provides {CODE} is what you probably want.  It exposes additional
> definitions/declarations in the parser header file.  They could
> potentially depend upon YYSTYPE and YYLTYPE since it inserts CODE near the
> bottom of the parser header file.

This is good! :)

I see that I am running version 2.2 of Bison. Which will be the next version 
and is there some idea of when it's going to be released (I mean, a week ? a 
month ? half a year ? a year ? ten years ?); what's the usual release cycle 
of bison ?

> The contents of the parser header file are always included in the parser
> code file, so you don't have to repeat CODE.
>
> > Alternatively, can I instead generate it as _parser.h and write my own
> > parser.h (that would include _parser.h).
>
> bison --defines=_parser.h

I now I am starting to get off-topic, but it is slightly related:

Is it possible in Makefile.am to add options to the command line used to 
invoke bison to compile one particular file or to modify AM_YFLAGS 
parametrical (like AM_YFLAGS = -d --define=_{$basename}.h) ?

Thank you.
-- 
Pupeno <address@hidden> (http://pupeno.com)

Attachment: pgpLGNZ9Lw3p3.pgp
Description: PGP signature


reply via email to

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