bug-bison
[Top][All Lists]
Advanced

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

Re: beta testing


From: Philippe Bekaert
Subject: Re: beta testing
Date: Tue, 20 Feb 2001 22:44:12 +0100

[I (HA) make a redirect, in case it wasn't sent to bug-bison -- please keep
CC to bug-bison, as more can help in.]

Hans Aberg wrote:

> You should not derive from the Flex lexer class, as it is not always that
> one wants to use it. -- Or at least not as a requirement, but only as an
> option.
>
> The way I use it, the .tab.h is included from the .l file, and therefore
> from the lex...cc file.
Sure. In my particular case however, deriving from the scanner object is
beneficial.

> >So I have to get rid of one of the YYSTYPE declarations.
>
> This problem  is due to the fact that the .tab.h file does not have the
> standard type of header macro-conditionals
>   #ifndef foo_bar_header
>   #define foo_bar_header
>   ...
>   #endif /* foo_bar_header */
>
> So if you write a header defining YYSTYPE as usual, having such macro
> conditionals, then you can include that header instead. For example, if the
> YYSTYPE of my_project.y is defined in my_project.h, write in the latter
>   #ifndef my_project_h
>   #define my_project_h
>   class my_type {
>   public:
>     ...
>   };
>   #define YYSTYPE my_type
>   #endif /* my_project_h */
This is a very helpful comment, thanks!

It makes that my first change to bison.simple (#undef YYSTYPE if it is
defined) is not necessary.

Does anyone however see a similar, simple, construction to avoid the
global declarations of yychar ... and the forward declaration of
yyparse() (when compiling with gcc)?

A pure parser isn't going to help me in my particular case: I have other
routines besides yyparse() that need access to these global variables.

Of course, I could write a special parser rule that copies the address
of the local variables yychar for a pure parser to somewhere else, but
that's not very elegant and still leaves us with the forward declaration
of yyparse().

Philippe.

--
Philippe Bekaert
Post-doctoral Research Fellow
Max-Planck-Institut fuer Informatik
Im Stadtwald, Geb. 46.1
66123 Saarbruecken - Germany
+49 681 9325422 (office phone)
+49 681 9325499 (office fax)
+49 179 4503121 (private phone)





reply via email to

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