🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1192

Bison-1.19, minor bugs

#1192
From: Gabor Herr
Date: Tue, 15 Dec 1992 16:41
123 lines
4601 bytes
As I tried to compile bison-1.19 on a RS6000/AIX workstation I found some
minor bugs:

If the name prefix is changed with the `-p' option, the name of the
logfile also changes from `foo.output' to `foo.out'. The manual says
the suffix for this filename is always '.output'.

The following patch fixes this problem:

*** files.c.orig	Mon Dec  7 16:51:23 1992
--- files.c	Mon Dec  7 17:50:56 1992
***************
*** 212,221 ****
  #ifdef MSDOS
        outfile = stringappend(name_base, short_base_length, ".out");
  #else
!       if (spec_name_prefix)
! 	outfile = stringappend(name_base, short_base_length, ".out");
!       else
! 	outfile = stringappend(name_base, short_base_length, ".output");
  #endif
        foutput = tryopen(outfile, "w");
      }
--- 212,218 ----
  #ifdef MSDOS
        outfile = stringappend(name_base, short_base_length, ".out");
  #else
!       outfile = stringappend(name_base, short_base_length, ".output");
  #endif
        foutput = tryopen(outfile, "w");
      }

To be able to use the inline alloca feature of the C++ compiler under AIX,
the source file must contain a '#pragma alloca' before ANY other statement or
declaration. The pragma directive in bison.simple was ignored by the compiler, 
because the generated output file always had the parser tables at the
beginning and the skeleton file at the end. I changed `reader.c' to write

#ifdef _AIX
#pragma alloca
#endif 

at the beginning of the output file.

Another problem with C++ was, that the generated parser didn't contained
declarations for `yylex' and `yyerror'. I added them as macros YYLEX_DECL
and YYERROR_DECL, so they can be redefined from the input file.

Here are the patches:

*** reader.c.orig	Sun Oct  4 18:17:11 1992
--- reader.c	Thu Dec 10 15:27:41 1992
***************
*** 170,175 ****
--- 170,176 ----
       Also notice any %token, %left, etc. found there.  */
    fprintf(ftable, "\n/*  A Bison parser, made from %s  */\n\n", infile);
    fprintf(ftable, "#define YYBISON 1  /* Identify Bison output.  */\n\n");
+   fprintf(ftable, "/* C++ under AIX wants this before any statement. */\n#ifdef _AIX\n#pragma alloca\n#endif /* _AIX */\n\n" );
    read_declarations();
    /* output the definition of YYLTYPE into the fattrs and fdefines files.  */
    /* fattrs winds up in the .tab.c file, before bison.simple.  */
*** bison.simple.orig	Mon Dec  7 16:51:13 1992
--- bison.simple	Thu Dec 10 16:21:02 1992
***************
*** 31,37 ****
  #else /* not MSDOS, or __TURBOC__ */
  #if defined(_AIX)
  #include <malloc.h>
-  #pragma alloca
  #else /* not _AIX */
  #ifdef __cplusplus
  	/* alloca() should be declared at least, it will be available
--- 31,36 ----
***************
*** 44,49 ****
--- 43,81 ----
  #endif /* not sparc.  */
  #endif /* not GNU C.  */
  #endif /* alloca not defined.  */
+ 
+ /*
+  * as C++ wants all external functions to be declared, we do this here
+  * using macros, so that it can be overwritten from the bison file.
+  */
+ #ifndef YYLEX_DECL
+ #  ifdef __cplusplus
+ #    ifdef YYPURE
+ #      ifdef YYLSP_NEEDED
+ extern int yylex( YYSTYPE *, YYLTYPE *);
+ #      else /* not YYLSP_NEEDED */
+ extern int yylex( YYSTYPE *);
+ #      endif /* not YYLSP_NEEDED */
+ #    else /* not YYPURE */
+ extern int yylex();
+ #    endif /* not YYPURE */
+ #  else /* not __cplusplus */
+ extern int yylex();
+ #  endif /* not __cplusplus */
+ #else /* YYLEX_DECL */
+ YYLEX_DECL
+ #endif
+ 
+ #ifndef YYERROR_DECL
+   #ifdef __cplusplus
+ extern int yyerror( const char * );
+   #else /* not __cplusplus */
+ extern int yyerror();
+   #endif /* not __cplusplus */
+ #else /* YYERROR_DECL */
+ YYERROR_DECL
+ #endif /* YYERROR_DECL */
+ 
  
  /* This is the parser code that is written into each bison parser
    when the %semantic_parser declaration is not specified in the grammar.


-- 
############################################################################
Gabor Herr			Email: herr@iti.informatik.th-darmstadt.de
Computer Science Department
Technical University of Darmstadt, Germany
Technical Details
Message-ID: <1992Dec15.164135.22063@news.th-darmstadt.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!iti.INformatik.TH-darmstadt.DE!herr

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!iti.INformatik.TH-darmstadt.DE!herr
From: herr@iti.INformatik.TH-darmstadt.DE (Gabor Herr)
Subject: Bison-1.19, minor bugs
Message-ID: <1992Dec15.164135.22063@news.th-darmstadt.de>
Keywords: bison, bug, fix, c++
Sender: gnulists@ai.mit.edu
Organization: TU Darmstadt
Distribution: gnu
Date: Tue, 15 Dec 1992 16:41:35 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 124