bison-patches
[Top][All Lists]
Advanced

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

Re: FYI: [Main branch] Output patch


From: Akim Demaille
Subject: Re: FYI: [Main branch] Output patch
Date: 22 Aug 2001 09:27:30 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

| Index: ChangeLog
| ===================================================================
| RCS file: /cvsroot/bison/bison/ChangeLog,v
| retrieving revision 1.173
| diff -u -r1.173 ChangeLog
| --- ChangeLog 2001/08/15 08:44:16     1.173
| +++ ChangeLog 2001/08/21 18:14:04
| @@ -1,8 +1,114 @@
| +2001-08-20  Robert Anisko  <address@hidden>
| +
| +     * src/output.c (prepare): Add prefixed names.
| +     (output_parser): Output semantic actions.
| +     (output_parser): Fix bug on '%%line' directives.
| +
| +2001-08-19  Robert Anisko  <address@hidden>
| +

No, please: One commit == one ChangeLog chunk.  I'd like you to clean
this up please.

|  2001-08-15  Akim Demaille  <address@hidden>
|  
|       Version 1.28c.
|  
| -2001-08-15  Marc Autret  <address@hidden>
| +2001-08-15  Marc Autret  <address@hidden>

Should be a separate commit.


| Index: lib/Makefile.in
| ===================================================================

Please, when you post your patch, don't include generated files!


| Index: lib/xalloc.h
| ===================================================================
| RCS file: /cvsroot/bison/bison/lib/xalloc.h,v
| retrieving revision 1.2
| diff -u -r1.2 xalloc.h
| --- lib/xalloc.h      2001/02/02 14:56:44     1.2
| +++ lib/xalloc.h      2001/08/21 18:14:18
| @@ -83,5 +83,9 @@
|  /* Return a malloc'ed copy of SRC. */
|  # define CLONE(Src) CCLONE (Src, 1)
|  
| +/* Wrappers for standard functions. */
| +#define      CALLOC(t, n) ((t *) calloc (sizeof (t), (n)))
| +#define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
| +#define REALLOC(o, t, n) ((t *) xrealloc ((o), sizeof (t) * (n)))
|  
|  #endif /* !XALLOC_H_ */

Huh?  What's wrong with the other macros 

# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
# define XREALLOC(Ptr, Type, N_items) \
  ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))


this file is sync'ed with Jim, please revert this change.


| Index: src/bison.simple
| ===================================================================

Are you sure you want to keep this name?  I mean, now we have a
directory lib/bison, I don't think bison.simple is such a good name.
I like sth like lalr-c.skl.  What do you think?  Or .bis.


| @@ -54,7 +65,7 @@
|         /* I don't know what this was needed for, but it pollutes the
|         namespace.  So I turned it off.  rms, 2 May 1997.  */
|         /* #include <malloc.h>  */
| - #pragma alloca
| +#      pragma alloca

Wrong, please revert.


 - Macro: AC_FUNC_ALLOCA
     Check how to get `alloca'.  Tries to get a builtin version by
     checking for `alloca.h' or the predefined C preprocessor macros
     `__GNUC__' and `_AIX'.  If this macro finds `alloca.h', it defines
     `HAVE_ALLOCA_H'.

     If those attempts fail, it looks for the function in the standard C
     library.  If any of those methods succeed, it defines
     `HAVE_ALLOCA'.  Otherwise, it sets the output variable `ALLOCA' to
     `alloca.o' and defines `C_ALLOCA' (so programs can periodically
     call `alloca(0)' to garbage collect).  This variable is separate
     from `LIBOBJS' so multiple programs can share the value of
     `ALLOCA' without needing to create an actual library, in case only
     some of them use the code in `LIBOBJS'.

     This macro does not try to get `alloca' from the System V R3
     `libPW' or the System V R4 `libucb' because those libraries
     contain some incompatible functions that cause trouble.  Some
     versions do not even contain `alloca' or contain a buggy version.
     If you still want to use their `alloca', use `ar' to extract
     `alloca.o' from them instead of compiling `alloca.c'.

     Source files that use `alloca' should start with a piece of code
     like the following, to declare it properly.  In some versions of
     AIX, the declaration of `alloca' must precede everything else
     except for comments and preprocessor directives.  The `#pragma'
     directive is indented so that pre-ANSI C compilers will ignore it,
     rather than choke on it.

          /* AIX requires this to be the first thing in the file.  */
          #ifndef __GNUC__
          # if HAVE_ALLOCA_H
          #  include <alloca.h>
          # else
          #  ifdef _AIX
           #pragma alloca
          #  else
          #   ifndef alloca /* predefined by HP cc +Olibcalls */
          char *alloca ();
          #   endif
          #  endif
          # endif
          #endif




Other than that, it looks great!


| -/*--------------------------------------------------------------.
| -| output_headers -- Output constant strings to the beginning of |
| -| certain files.                                                |
| -`--------------------------------------------------------------*/
| -
| -/* Don't put the `%s' insides quotes, since it quotearg puts them. */
| -
| -#define      GUARDSTR        \
| -"\n\
| -#include %s\n\
| -extern int yyerror;\n\
| -extern int yycost;\n\
| -extern char * yymsg;\n\
| -extern YYSTYPE yyval;\n\
| -\n\
| -yyguard(n, yyvsp, yylsp)\n\
| -register int n;\n\
| -register YYSTYPE *yyvsp;\n\
| -register YYLTYPE *yylsp;\n\
| -{\n\
| -  yyerror = 0;\n\
| -  yycost = 0;\n\
| -  yymsg = 0;\n\
| -  switch (n)\n\
| -    {"
| -
| -#define      ACTSTR          \
| -"\n\
| -#include %s\n\
| -extern YYSTYPE yyval;\n\
| -extern int yychar;\n\
| -\n\
| -yyaction(n, yyvsp, yylsp)\n\
| -register int n;\n\
| -register YYSTYPE *yyvsp;\n\
| -register YYLTYPE *yylsp;\n\
| -{\n\
| -  switch (n)\n\
| -    {"
| -
| -#define      ACTSTR_SIMPLE   "\n  switch (yyn) {\n"

It's great to see that code disappear :)


| @@ -1137,10 +938,12 @@
|  
|    sort_actions ();
|    pack_table ();
| -  obstack_1grow (&table_obstack, '\n');
| +  /* FIXME: See if this is useful. */
| +  /* obstack_1grow (&table_obstack, '\n'); */
|    output_base ();
|    output_table ();
| -  obstack_1grow (&table_obstack, '\n');
| +  /* FIXME: See if this is useful. */
| +  /* obstack_1grow (&table_obstack, '\n'); */
|    output_check ();
|  }
|  

It probably no longer is.


| +  if (spec_name_prefix)
| +    {
| +      MACRO_INSERT_PREFIX ("yylex", "lex");
| +      MACRO_INSERT_PREFIX ("yychar", "char");
| +      MACRO_INSERT_PREFIX ("yylval", "lval");
| +      MACRO_INSERT_PREFIX ("yydebug", "debug");
| +      MACRO_INSERT_PREFIX ("yyerror", "error");
| +      MACRO_INSERT_PREFIX ("yynerrs", "nerrs");
| +      MACRO_INSERT_PREFIX ("yyparse", "parse");
| +    }

I really don't like `macro', it's too ambiguous IMHO.  If you have
better ideas...  Maybe just `directive'.  Or `bone', or `flesh', or
`muscle' something related to skeletons.  I like `muscle' :)



I'm really impressed!  It looks _very_ nice.  But I should tell you
that currently all the calc tests fail.  For instance:


src/bison-head/tests % ./debug-8.sh                              nostromo Err 1

================================
./debug-8.sh: Testing Calculator
================================
./calc.at:343: bison calc.y -o calc.c 
./calc.at:343: $CC $CFLAGS $CPPFLAGS calc.c -o calc
--- empty       Wed Aug 22 09:26:51 2001
+++ stderr      Wed Aug 22 09:26:51 2001
@@ -0,0 +1,9 @@
+calc.y:978: warning: `yyerror' was declared implicitly `extern' and later 
`static'
+calc.y:836: warning: previous declaration of `yyerror'
+calc.y:978: warning: type mismatch with previous implicit declaration
+calc.y:836: warning: previous implicit declaration of `yyerror'
+calc.y:978: warning: `yyerror' was previously implicitly declared to return 
`int'
+calc.y:1045: warning: `yylex' was declared implicitly `extern' and later 
`static'
+calc.y:610: warning: previous declaration of `yylex'
+calc.y:1080: warning: `power' was declared implicitly `extern' and later 
`static'
+calc.y:58: warning: previous declaration of `power'

Attachment: calc.y
Description: Text document

Attachment: calc.c
Description: Text Data


reply via email to

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