[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] overquoting in implementation of %code and %defines
From: |
Joel E. Denny |
Subject: |
Re: [PATCH] overquoting in implementation of %code and %defines |
Date: |
Fri, 12 Jan 2007 17:21:11 -0500 (EST) |
Another ignored message.
On Wed, 10 Jan 2007, Joel E. Denny wrote:
> On Tue, 9 Jan 2007, Joel E. Denny wrote:
>
> > I just noticed that I forgot to accommodate the possibility of a `.'
> > appearing in a %define variable name or a %code qualifier. I meant to add
> > an m4_indir for retrieving these values. I'll commit my fix after we
> > settle the issues you've raised.
> >
> > > In addition, the check for bad qualifiers can be simplified by using
> > > internal
> > > macro names like STEM(name) for each skeleton-tested name, and then using
> > > "m4_ifdef" instead of nesting two m4_foreach loops.
> >
> > I like that better, but let's commit that after we settle the other issues
> > please. Thanks.
>
> Here's my version of your patch plus the `.' fix. What do you think?
>
> Index: ChangeLog
> ===================================================================
> RCS file: /sources/bison/bison/ChangeLog,v
> retrieving revision 1.1660
> diff -p -u -r1.1660 ChangeLog
> --- ChangeLog 10 Jan 2007 03:47:50 -0000 1.1660
> +++ ChangeLog 10 Jan 2007 07:03:02 -0000
> @@ -1,3 +1,14 @@
> +2007-01-10 Paolo Bonzini <address@hidden>
> + and Joel E. Denny <address@hidden>
> +
> + * data/bison.m4 (b4_check_user_names): Check for special
> + "SKELETON-NAMESPACE(name)" macros instead of using two nested
> + m4_foreach loops.
> + (b4_get_percent_define): Update. Also, use m4_indir so that %define
> + variable names can contain `.', which is allowed by the grammar parser.
> + (b4_get_percent_code): Likewise.
> + (m4_wrap): Update wrapped code, and fix some underquoting.
> +
> 2007-01-09 Joel E. Denny <address@hidden>
>
> * tests/glr-regression.at: Use AT_PARSER_CHECK rather than AT_CHECK to
> Index: data/bison.m4
> ===================================================================
> RCS file: /sources/bison/bison/data/bison.m4,v
> retrieving revision 1.11
> diff -p -u -r1.11 bison.m4
> --- data/bison.m4 9 Jan 2007 05:24:11 -0000 1.11
> +++ data/bison.m4 10 Jan 2007 07:03:02 -0000
> @@ -285,13 +285,14 @@ b4_define_user_code([pre_prologue])
> b4_define_user_code([stype])
>
>
> -# b4_check_user_names(WHAT, USER-LIST, SKELETON-LIST)
> -# ---------------------------------------------------
> +# b4_check_user_names(WHAT, USER-LIST, SKELETON-NAMESPACE)
> +# --------------------------------------------------------
> # Warn if any name of type WHAT is used by the user (as recorded in
> USER-LIST)
> -# but is not used by the skeleton (as recorded in SKELETON-LIST).
> +# but is not used by the skeleton (as recorded by macros in the namespace
> +# SKELETON-NAMESPACE).
> #
> # USER-LIST must expand to a list specifying all grammar occurrences of all
> -# names of type WHAT. Each item in the list is a triplet specifying one
> +# names of type WHAT. Each item in the list must be a triplet specifying
> one
> # occurrence: name, start boundary, and end boundary. Empty string names are
> # fine. An empty list is fine.
> #
> @@ -303,37 +304,32 @@ b4_define_user_code([stype])
> # [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]],
> # [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]])
> #
> -# SKELETON-LIST must expand to a list specifying all names of type WHAT that
> -# are used by the skeleton. Multiple occurrences of the same name are fine.
> -# Empty string names are fine, but it would be ugly for a Bison skeleton to
> -# actually use one. An empty list is fine.
> +# The macro SKELETON-NAMESPACE(bar) must be defined iff the name bar of type
> +# WHAT is used in the skeleton. Empty string names are fine, but it would be
> +# ugly for a Bison skeleton to actually use one.
> #
> -# For example, to define b4_skeleton_foo_names to be used for SKELETON-LIST
> -# with two names and with correct quoting:
> +# For example, to use b4_skeleton_foo_names for SKELETON-NAMESPACE and define
> +# that the names bar and baz are used in the skeleton:
> #
> -# m4_define([b4_skeleton_foo_names],
> -# [[[[bar]], [[baz]]]])
> +# m4_define([b4_skeleton_foo_names(bar)])
> +# m4_define([b4_skeleton_foo_names(baz)])
> #
> # To invoke b4_check_user_names with TYPE foo, with USER-LIST
> -# b4_user_foo_names, with SKELETON-LIST b4_skeleton_foo_names, and with
> correct
> -# quoting:
> +# b4_user_foo_names, with SKELETON-NAMESPACE b4_skeleton_foo_names, and with
> +# correct quoting:
> #
> -# b4_check_user_names([[foo]], [b4_user_foo_names],
> [b4_skeleton_foo_names])
> +# b4_check_user_names([[foo]], [b4_user_foo_names],
> +# [[b4_skeleton_foo_names]])
> m4_define([b4_check_user_names],
> [m4_foreach([b4_occurrence], $2,
> [m4_pushdef([b4_occurrence], b4_occurrence)dnl
> m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl
> m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl
> m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl
> -m4_pushdef([b4_found], [[0]])dnl
> -m4_foreach([b4_skeleton_name], $3,
> - [m4_if(m4_quote(b4_user_name),
> - m4_quote(b4_skeleton_name),
> - [m4_define([b4_found], [[1]])])])dnl
> -m4_if(b4_found, [0], [b4_warn_at([b4_start], [b4_end],
> - [[%s `%s' is not used]],
> - [$1], [b4_user_name])])[]dnl
> -m4_popdef([b4_found])dnl
> +m4_ifndef($3[(]m4_quote(b4_user_name)[)],
> + [b4_warn_at([b4_start], [b4_end],
> + [[%s `%s' is not used]],
> + [$1], [b4_user_name])])[]dnl
> m4_popdef([b4_occurrence])dnl
> m4_popdef([b4_user_name])dnl
> m4_popdef([b4_start])dnl
> @@ -341,28 +337,29 @@ m4_popdef([b4_end])dnl
> ])])
>
> # b4_get_percent_define(VARIABLE)
> -# --------------------------------
> -# If the %define variable VARIABLE is defined, emit it. Also, record
> VARIABLE
> -# in b4_skeleton_percent_define_variables.
> +# -------------------------------
> +# If the %define variable VARIABLE is defined, emit it. Also, record the
> +# skeleton's usage of VARIABLE by defining
> +# b4_skeleton_percent_define_variables(VARIABLE).
> m4_define([b4_get_percent_define],
> -[m4_append([b4_skeleton_percent_define_variables], [[$1]], [[, ]])dnl
> -m4_ifdef([b4_percent_define_]$1, [b4_percent_define_]$1)])
> +[m4_define([b4_skeleton_percent_define_variables(]$1[)])dnl
> +m4_ifdef([b4_percent_define_]$1, [m4_indir([b4_percent_define_]$1)])])
>
> # b4_get_percent_code([QUALIFIER])
> # --------------------------------
> # If any %code blocks for QUALIFIER are defined, emit them beginning with a
> # comment and ending with synclines and a newline. If QUALIFIER is not
> # specified (thus, b4_get_percent_code is invoked without parens), do this
> for
> -# the unqualified %code blocks. Also, record QUALIFIER (if specified) in
> -# b4_skeleton_percent_code_qualifiers.
> +# the unqualified %code blocks. Also, record the skeleton's usage of
> QUALIFIER
> +# (if specified) by defining b4_skeleton_percent_code_qualifiers(VARIABLE).
> m4_define([b4_get_percent_code],
> [m4_pushdef([b4_macro_name], [[b4_percent_code]]m4_if([$#], [1],
> [[[_]$1]]))dnl
> -m4_if([$#], [1],
> - [m4_append([b4_skeleton_percent_code_qualifiers], [[$1]], [[, ]])])dnl
> +m4_if([$#], [1], [m4_define([b4_skeleton_percent_code_qualifiers(]$1[)])])dnl
> m4_ifdef(b4_macro_name,
> [b4_comment([m4_if([$#], [0], [[Unqualified %code]],
> [[%code "]$1["]])[ blocks.]])
> -b4_user_code(b4_macro_name)])dnl
> +b4_user_code([m4_indir(b4_macro_name)])
> +])dnl
> m4_popdef([b4_macro_name])])
>
>
> @@ -373,19 +370,14 @@ m4_popdef([b4_macro_name])])
>
> m4_wrap([
> m4_pushdef([b4_check_user_names_wrap],
> -[m4_ifdef([b4_skeleton_percent_$1],
> - [m4_define([b4_skeleton_percent_$1],
> - m4_dquote(m4_dquote(b4_skeleton_percent_$1)))],
> - [m4_define([b4_skeleton_percent_$1], [[]])])
> -
> -m4_ifdef([b4_user_percent_$1],
> - [b4_check_user_names([$2],
> - [b4_user_percent_$1],
> - [b4_skeleton_percent_$1])])
> +[m4_ifdef([b4_user_percent_]$1,
> + [b4_check_user_names([$2],
> + [b4_user_percent_]$1,
> + [[b4_skeleton_percent_]$1])])
> ])
>
> -b4_check_user_names_wrap([define_variables], [[%define variable]])
> -b4_check_user_names_wrap([code_qualifiers], [[%code qualifier]])
> +b4_check_user_names_wrap([[define_variables]], [[%define variable]])
> +b4_check_user_names_wrap([[code_qualifiers]], [[%code qualifier]])
>
> m4_popdef([b4_check_user_names_wrap])
> ])
>
- [PATCH] overquoting in implementation of %code and %defines, Paolo Bonzini, 2007/01/09
- Message not available
- Message not available
- Message not available
- Re: [PATCH] overquoting in implementation of %code and %defines,
Joel E. Denny <=
- Re: [PATCH] overquoting in implementation of %code and %defines, Paolo Bonzini, 2007/01/13
- Re: [PATCH] overquoting in implementation of %code and %defines, Joel E. Denny, 2007/01/13
- Re: [PATCH] overquoting in implementation of %code and %defines, Paolo Bonzini, 2007/01/14
- Re: [PATCH] overquoting in implementation of %code and %defines, Joel E. Denny, 2007/01/14
- Re: [PATCH] overquoting in implementation of %code and %defines, Paolo Bonzini, 2007/01/15
- Re: [PATCH] overquoting in implementation of %code and %defines, Joel E. Denny, 2007/01/15
- Re: [PATCH] overquoting in implementation of %code and %defines, Paolo Bonzini, 2007/01/15
- Re: [PATCH] overquoting in implementation of %code and %defines, Joel E. Denny, 2007/01/15
- Re: [PATCH] overquoting in implementation of %code and %defines, Paolo Bonzini, 2007/01/15
- Re: [PATCH] overquoting in implementation of %code and %defines, Joel E. Denny, 2007/01/15