[Top][All Lists]

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

Re: Bison 1.30f

From: Hans Aberg
Subject: Re: Bison 1.30f
Date: Thu, 6 Dec 2001 17:10:14 +0100

At 12:27 +0100 2001/12/06, Akim Demaille wrote:
>|- Use of
>|  #include "intl/libgettext.h"
>|"/" is not portable between platforms (fix: add the directory to the
>|compiler search path). In addition, the English version should probably not
>|call this file (fix: add a controlling macro).
>Sorry but I won't change this.  Teach your compiler how to use `/'.  I
>know on Mac CodeWarrior works properly, GCC too etc.  There is
>certainly an option to educate it.

I am not sure what you are saying here: There is, what I know, no standard
way to interpret a "/" in a C/C++ #include filename. I know of no option to
educate my compiler to translate between local (like MacOS pre-X) and UNIX
filename paths.

By contrast, it is very easy to alter the file access search paths: The
solution seems to be to view "intl/" as a kind of library directory, so it
should be added to the library search path, and then one should use
  #include <libgettext.h>
in the sources (system.h).

- I got the following:
Link Error   : multiply-defined 'error_one_per_line' (data)
Defined in error.c
Defined in complain.c

I took out the complain.c duplicate. It then compiled, and so did the Bison
generated parser in my test.

- If you have time, I think you should change the YYSTACK_USE_ALLOCA mess
in bison.simple. It seems that there are three modes
  YYSTACK_USE_ALLOCA    Bison parser
  undefined             tries to use alloca if available, otherwise malloc
  1                     uses alloca
  0                     uses malloc

One should then first have:
  // Check if alloca is avalable: If so,
     #define YYSTACK_USE_ALLOCA 1
  else must use malloc
     #define YYSTACK_USE_ALLOCA 0

Then the next step is to find where alloca/malloc are defined. On most
platforms, I think one would use:
# include <alloca.h>
#include <stdlib.h>  /* Std C location for malloc. */
Some platforms may have exceptions to this.

This does not work under C++ because then one should use
  #include <cstdlib> // Std C++ location for malloc.
in order to not get malloc into a global namespace. Then one also has to use
  #define YYSTACK_ALLOC std::malloc
and similarly for realloc and free.

Under C++, one should also use
  #include <cstddef>
  #define YYSIZE_T std::size_t
  #include <cstdio>
  # define YYDPRINTF(Args)                      \
  do {                                          \
    if (yydebug)                                        \
      std::fprintf Args;                                \
  } while (0)
Later, one might replace it with
  #include <ostream>
and std::cerr, or perhaps std::clog, which is used for logging purposes
(more buffering allowed, I recall).

  Hans Aberg

reply via email to

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