mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
Check for unrecognized %define variables similar to checking for
unrecognized %code qualifiers. Check for redefined %define variables. * data/bison.m4 (b4_check_for_unrecognized_names): New macro that generalizes... (b4_check_percent_code_qualifiers): ... this, which now wraps it. (b4_check_percent_define_variables): New, also wraps it. * data/glr.c: Unless glr.cc is wrapping glr.c, declare no valid %define variables using b4_check_percent_define_variables. * data/glr.cc, data/lalr1.cc: Declare the valid %define variables as all those exercised in the test suite and all those listed in the `Default values' section of c++.m4. Are there others? * data/push.c, data/yacc.c: Declare no valid %define variables. * src/muscle_tab.c, src/muscle_tab.h (muscle_find_const): New function, similar to muscle_find, but it works even when the muscle stores a const value. (muscle_grow_used_name_list): New function for constructing the used name list muscles that b4_check_for_unrecognized_names requires. * src/parse-gram.y (prologue_declaration): Warn if a variable is %define'd more than once. Define the b4_used_percent_define_variables muscle with muscle_grow_used_name_list. (grammar_declaration): Abbreviate %code code with muscle_grow_used_name_list. * tests/input.at (%define errors): New.
This commit is contained in:
26
ChangeLog
26
ChangeLog
@@ -1,3 +1,29 @@
|
|||||||
|
2007-01-07 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
|
Check for unrecognized %define variables similar to checking for
|
||||||
|
unrecognized %code qualifiers. Check for redefined %define variables.
|
||||||
|
* data/bison.m4 (b4_check_for_unrecognized_names): New macro that
|
||||||
|
generalizes...
|
||||||
|
(b4_check_percent_code_qualifiers): ... this, which now wraps it.
|
||||||
|
(b4_check_percent_define_variables): New, also wraps it.
|
||||||
|
* data/glr.c: Unless glr.cc is wrapping glr.c, declare no valid %define
|
||||||
|
variables using b4_check_percent_define_variables.
|
||||||
|
* data/glr.cc, data/lalr1.cc: Declare the valid %define variables as
|
||||||
|
all those exercised in the test suite and all those listed in the
|
||||||
|
`Default values' section of c++.m4. Are there others?
|
||||||
|
* data/push.c, data/yacc.c: Declare no valid %define variables.
|
||||||
|
* src/muscle_tab.c, src/muscle_tab.h (muscle_find_const): New function,
|
||||||
|
similar to muscle_find, but it works even when the muscle stores a
|
||||||
|
const value.
|
||||||
|
(muscle_grow_used_name_list): New function for constructing the used
|
||||||
|
name list muscles that b4_check_for_unrecognized_names requires.
|
||||||
|
* src/parse-gram.y (prologue_declaration): Warn if a variable is
|
||||||
|
%define'd more than once. Define the b4_used_percent_define_variables
|
||||||
|
muscle with muscle_grow_used_name_list.
|
||||||
|
(grammar_declaration): Abbreviate %code code with
|
||||||
|
muscle_grow_used_name_list.
|
||||||
|
* tests/input.at (%define errors): New.
|
||||||
|
|
||||||
2007-01-06 Joel E. Denny <jdenny@ces.clemson.edu>
|
2007-01-06 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
Provide warn_at, complain_at, and fatal_at function callbacks to the
|
Provide warn_at, complain_at, and fatal_at function callbacks to the
|
||||||
|
|||||||
142
data/bison.m4
142
data/bison.m4
@@ -66,7 +66,7 @@ version 2.2 of Bison.])])
|
|||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|
||||||
# b4_error(KIND, FORMAT, [ARG1], [ARG2], ...)
|
# b4_error(KIND, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -----------------------------------------------------
|
# -------------------------------------------
|
||||||
# Write @KIND(FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
# Write @KIND(FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
||||||
m4_define([b4_error],
|
m4_define([b4_error],
|
||||||
[m4_divert_push(0)[@]$1[(]$2[]m4_if([$#], [2], [],
|
[m4_divert_push(0)[@]$1[(]$2[]m4_if([$#], [2], [],
|
||||||
@@ -75,7 +75,7 @@ m4_define([b4_error],
|
|||||||
[[@,]b4_arg])])[@)]m4_divert_pop(0)])
|
[[@,]b4_arg])])[@)]m4_divert_pop(0)])
|
||||||
|
|
||||||
# b4_error_at(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_error_at(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -----------------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
# Write @KIND(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
# Write @KIND(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
||||||
m4_define([b4_error_at],
|
m4_define([b4_error_at],
|
||||||
[m4_divert_push(0)[@]$1[_at(]$2[@,]$3[@,]$4[]m4_if([$#], [4], [],
|
[m4_divert_push(0)[@]$1[_at(]$2[@,]$3[@,]$4[]m4_if([$#], [4], [],
|
||||||
@@ -84,7 +84,7 @@ m4_define([b4_error_at],
|
|||||||
[[@,]b4_arg])])[@)]m4_divert_pop(0)])
|
[[@,]b4_arg])])[@)]m4_divert_pop(0)])
|
||||||
|
|
||||||
# b4_warn(FORMAT, [ARG1], [ARG2], ...)
|
# b4_warn(FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -----------------------------------------------------
|
# ------------------------------------
|
||||||
# Write @warn(FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
# Write @warn(FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
||||||
#
|
#
|
||||||
# As a simple test suite, this:
|
# As a simple test suite, this:
|
||||||
@@ -116,13 +116,13 @@ m4_define([b4_warn],
|
|||||||
[b4_error([[warn]], $@)])
|
[b4_error([[warn]], $@)])
|
||||||
|
|
||||||
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -----------------------------------------------------------------
|
# ---------------------------------------------------
|
||||||
# Write @warn(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
# Write @warn(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
||||||
m4_define([b4_warn_at],
|
m4_define([b4_warn_at],
|
||||||
[b4_error_at([[warn]], $@)])
|
[b4_error_at([[warn]], $@)])
|
||||||
|
|
||||||
# b4_complain(FORMAT, [ARG1], [ARG2], ...)
|
# b4_complain(FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ---------------------------------------------------------
|
# ----------------------------------------
|
||||||
# Write @complain(FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
# Write @complain(FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
||||||
#
|
#
|
||||||
# See the test suite for b4_warn above.
|
# See the test suite for b4_warn above.
|
||||||
@@ -130,13 +130,13 @@ m4_define([b4_complain],
|
|||||||
[b4_error([[complain]], $@)])
|
[b4_error([[complain]], $@)])
|
||||||
|
|
||||||
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ---------------------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
# Write @complain(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
# Write @complain(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
||||||
m4_define([b4_complain_at],
|
m4_define([b4_complain_at],
|
||||||
[b4_error_at([[complain]], $@)])
|
[b4_error_at([[complain]], $@)])
|
||||||
|
|
||||||
# b4_fatal(FORMAT, [ARG1], [ARG2], ...)
|
# b4_fatal(FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ------------------------------------------------------
|
# -------------------------------------
|
||||||
# Write @fatal(FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
# Write @fatal(FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
||||||
#
|
#
|
||||||
# See the test suite for b4_warn above.
|
# See the test suite for b4_warn above.
|
||||||
@@ -144,7 +144,7 @@ m4_define([b4_fatal],
|
|||||||
[b4_error([[fatal]], $@)])
|
[b4_error([[fatal]], $@)])
|
||||||
|
|
||||||
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ------------------------------------------------------------------
|
# ----------------------------------------------------
|
||||||
# Write @fatal(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
# Write @fatal(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to diversion 0.
|
||||||
m4_define([b4_fatal_at],
|
m4_define([b4_fatal_at],
|
||||||
[b4_error_at([[fatal]], $@)])
|
[b4_error_at([[fatal]], $@)])
|
||||||
@@ -283,57 +283,81 @@ b4_define_user_code([pre_prologue])
|
|||||||
b4_define_user_code([stype])
|
b4_define_user_code([stype])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_check_for_unrecognized_names(WHAT, LIST, [VALID_NAME], [VALID_NAME])
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Complain if any name of type WHAT is used in the grammar (as recorded in
|
||||||
|
# LIST) but is not a VALID_NAME.
|
||||||
|
#
|
||||||
|
# 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 occurrence:
|
||||||
|
# name, start boundary, and end boundary. Empty string names are fine. An
|
||||||
|
# empty list is fine.
|
||||||
|
#
|
||||||
|
# For example, to define b4_foo_list to be used for LIST with three name
|
||||||
|
# occurrences and with correct quoting:
|
||||||
|
#
|
||||||
|
# m4_define([b4_foo_list],
|
||||||
|
# [[[[[[bar]], [[parser.y:1.7]], [[parser.y:1.16]]]],
|
||||||
|
# [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]],
|
||||||
|
# [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]])
|
||||||
|
#
|
||||||
|
# Each VALID_NAME must expand to a valid name of type WHAT. Multiple
|
||||||
|
# occurrences of the same valid name are fine. A VALID_NAME that expands to
|
||||||
|
# the empty string will correctly define the empty string as a valid name, but
|
||||||
|
# it would be ugly for a Bison skeleton to actually use that.
|
||||||
|
#
|
||||||
|
# For example, to invoke b4_check_for_unrecognized_names with TYPE foo, with
|
||||||
|
# LIST b4_foo_list, with two valid names, and with correct quoting:
|
||||||
|
#
|
||||||
|
# b4_check_for_unrecognized_names([[foo]], [b4_foo_list],
|
||||||
|
# [[bar]], [[baz]])
|
||||||
|
#
|
||||||
|
# Names and valid names must not contain the character `,'.
|
||||||
|
m4_define([b4_check_for_unrecognized_names],
|
||||||
|
[m4_foreach([b4_occurrence],
|
||||||
|
$2,
|
||||||
|
[m4_pushdef([b4_occurrence], b4_occurrence)
|
||||||
|
m4_pushdef([b4_name], m4_car(b4_occurrence))
|
||||||
|
m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))
|
||||||
|
m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))
|
||||||
|
m4_if(m4_index(m4_if($#, 2, [],
|
||||||
|
[[,]m4_quote(m4_shift(m4_shift($*)))[,]]),
|
||||||
|
[,]b4_name[,]),
|
||||||
|
[-1],
|
||||||
|
[b4_complain_at([b4_start], [b4_end],
|
||||||
|
[[`%s' is not a recognized %s]],
|
||||||
|
[b4_name], [$1])
|
||||||
|
])
|
||||||
|
m4_popdef([b4_occurrence])
|
||||||
|
m4_popdef([b4_name])
|
||||||
|
m4_popdef([b4_start])
|
||||||
|
m4_popdef([b4_end])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_check_percent_define_variables([VAILD_VARIABLE], [VALID_VARIABLE], ...)
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Wrapper around b4_check_for_unrecognized_names for %define variables.
|
||||||
|
#
|
||||||
|
# b4_used_percent_define_variables must contain a list of all %define variables
|
||||||
|
# used in the grammar similar to b4_foo_list from the
|
||||||
|
# b4_check_for_unrecognized_names documentation's example. If
|
||||||
|
# b4_used_percent_define_variables is undefined, it's treated the same as an
|
||||||
|
# empty list.
|
||||||
|
#
|
||||||
|
# Invoking b4_check_percent_define_variables with empty parens specifies one
|
||||||
|
# valid variable that is an empty string. Invoke it without parens to specify
|
||||||
|
# that there are no valid variables.
|
||||||
|
m4_define([b4_check_percent_define_variables],
|
||||||
|
[m4_ifdef([b4_used_percent_define_variables],
|
||||||
|
[b4_check_for_unrecognized_names([[%define variable]],
|
||||||
|
[b4_used_percent_define_variables]m4_if([$#], [0], [], [, $@]))])])
|
||||||
|
|
||||||
# b4_check_percent_code_qualifiers([VAILD_QUALIFIER], [VALID_QUALIFIER], ...)
|
# b4_check_percent_code_qualifiers([VAILD_QUALIFIER], [VALID_QUALIFIER], ...)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Complain if any %code qualifier used in the grammar is not a valid qualifier.
|
# Same as b4_check_percent_define_variables but for %code qualifiers using
|
||||||
#
|
# b4_used_percent_code_qualifiers.
|
||||||
# If no %code qualifiers are used in the grammar,
|
|
||||||
# b4_used_percent_code_qualifiers must be undefined or must expand to the empty
|
|
||||||
# string. Otherwise, it must expand to a list specifying all occurrences of
|
|
||||||
# all %code qualifiers used in the grammar. Each item in the list is a
|
|
||||||
# triplet specifying one occurrence: qualifier, start boundary, and end
|
|
||||||
# boundary. For example, to define b4_used_percent_code_qualifiers with three
|
|
||||||
# qualifier occurrences with correct quoting:
|
|
||||||
#
|
|
||||||
# m4_define([b4_used_percent_code_qualifiers],
|
|
||||||
# [[[[[[requires]], [[parser.y:1.7]], [[parser.y:1.16]]]],
|
|
||||||
# [[[[provides]], [[parser.y:5.7]], [[parser.y:5.16]]]],
|
|
||||||
# [[[[provides]], [[parser.y:8.7]], [[parser.y:8.16]]]]]])
|
|
||||||
#
|
|
||||||
# Empty string qualifiers are fine.
|
|
||||||
#
|
|
||||||
# Each VALID_QUALIFIER must expand to a valid qualifier. For example,
|
|
||||||
# b4_check_percent_code_qualifiers might be invoked with:
|
|
||||||
#
|
|
||||||
# b4_check_percent_code_qualifiers([[requires]], [[provides]])
|
|
||||||
#
|
|
||||||
# Multiple occurrences of the same valid qualifier are fine. A VALID_QUALIFIER
|
|
||||||
# that expands to the empty string will correctly define the empty string as a
|
|
||||||
# valid qualifier, but it would be ugly for a Bison skeleton to actually use
|
|
||||||
# that. If b4_used_percent_code_qualifiers is invoked with empty parens, then
|
|
||||||
# there is one valid qualifier and it is the empty string. To specify that
|
|
||||||
# there are no valid qualifiers, invoke b4_check_percent_code_qualifiers
|
|
||||||
# without parens.
|
|
||||||
#
|
|
||||||
# Qualifiers and valid qualifiers must not contain the character `,'.
|
|
||||||
m4_define([b4_check_percent_code_qualifiers],
|
m4_define([b4_check_percent_code_qualifiers],
|
||||||
[m4_ifdef([b4_used_percent_code_qualifiers], [
|
[m4_ifdef([b4_used_percent_code_qualifiers],
|
||||||
m4_foreach([b4_occurrence],
|
[b4_check_for_unrecognized_names([[%code qualifier]],
|
||||||
b4_used_percent_code_qualifiers,
|
[b4_used_percent_code_qualifiers]m4_if([$#], [0], [], [, $@]))])])
|
||||||
[m4_pushdef([b4_occurrence], b4_occurrence)
|
|
||||||
m4_pushdef([b4_qualifier], m4_car(b4_occurrence))
|
|
||||||
m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))
|
|
||||||
m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))
|
|
||||||
m4_if(m4_index(m4_if($#, 0, [], [[,]m4_quote($*)[,]]),
|
|
||||||
[,]b4_qualifier[,]),
|
|
||||||
[-1],
|
|
||||||
[b4_complain_at([b4_start], [b4_end],
|
|
||||||
[[`%s' is not a recognized %%code qualifier]],
|
|
||||||
[b4_qualifier])
|
|
||||||
])
|
|
||||||
m4_popdef([b4_occurrence])
|
|
||||||
m4_popdef([b4_qualifier])
|
|
||||||
m4_popdef([b4_start])
|
|
||||||
m4_popdef([b4_end])
|
|
||||||
])
|
|
||||||
])])
|
|
||||||
|
|||||||
@@ -20,7 +20,13 @@
|
|||||||
|
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c.m4])
|
m4_include(b4_pkgdatadir/[c.m4])
|
||||||
b4_check_percent_code_qualifiers([[requires]], [[provides]], [[top]])
|
|
||||||
|
# glr.cc checks %define variables also.
|
||||||
|
m4_if(b4_skeleton, [["glr.c"]], [b4_check_percent_define_variables])
|
||||||
|
|
||||||
|
b4_check_percent_code_qualifiers([[requires]],
|
||||||
|
[[provides]],
|
||||||
|
[[top]])
|
||||||
|
|
||||||
b4_push_if([
|
b4_push_if([
|
||||||
b4_complain([[non-deterministic push parsers are not yet supported]])])
|
b4_complain([[non-deterministic push parsers are not yet supported]])])
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ b4_defines_if([],
|
|||||||
m4_include(b4_pkgdatadir/[c++.m4])
|
m4_include(b4_pkgdatadir/[c++.m4])
|
||||||
m4_include(b4_pkgdatadir/[location.cc])
|
m4_include(b4_pkgdatadir/[location.cc])
|
||||||
|
|
||||||
|
b4_check_percent_define_variables([[global_tokens_and_yystype]],
|
||||||
|
[[parser_class_name]],
|
||||||
|
[[location_type]],
|
||||||
|
[[filename_type]],
|
||||||
|
[[b4_namespace]],
|
||||||
|
[[b4_define_location_comparison]])
|
||||||
|
|
||||||
# Save the parse parameters.
|
# Save the parse parameters.
|
||||||
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
||||||
|
|||||||
@@ -18,7 +18,17 @@
|
|||||||
# 02110-1301 USA
|
# 02110-1301 USA
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c++.m4])
|
m4_include(b4_pkgdatadir/[c++.m4])
|
||||||
b4_check_percent_code_qualifiers([[requires]], [[provides]], [[top]])
|
|
||||||
|
b4_check_percent_define_variables([[global_tokens_and_yystype]],
|
||||||
|
[[parser_class_name]],
|
||||||
|
[[location_type]],
|
||||||
|
[[filename_type]],
|
||||||
|
[[b4_namespace]],
|
||||||
|
[[b4_define_location_comparison]])
|
||||||
|
|
||||||
|
b4_check_percent_code_qualifiers([[requires]],
|
||||||
|
[[provides]],
|
||||||
|
[[top]])
|
||||||
|
|
||||||
# The header is mandatory.
|
# The header is mandatory.
|
||||||
b4_defines_if([],
|
b4_defines_if([],
|
||||||
|
|||||||
@@ -33,7 +33,12 @@ b4_use_push_for_pull_if([
|
|||||||
])])
|
])])
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c.m4])
|
m4_include(b4_pkgdatadir/[c.m4])
|
||||||
b4_check_percent_code_qualifiers([[requires]], [[provides]], [[top]])
|
|
||||||
|
b4_check_percent_define_variables
|
||||||
|
|
||||||
|
b4_check_percent_code_qualifiers([[requires]],
|
||||||
|
[[provides]],
|
||||||
|
[[top]])
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Default values. ##
|
## Default values. ##
|
||||||
|
|||||||
@@ -24,7 +24,12 @@
|
|||||||
b4_use_push_for_pull_if([m4_include(b4_pkgdatadir/[push.c])m4_exit])
|
b4_use_push_for_pull_if([m4_include(b4_pkgdatadir/[push.c])m4_exit])
|
||||||
|
|
||||||
m4_include(b4_pkgdatadir/[c.m4])
|
m4_include(b4_pkgdatadir/[c.m4])
|
||||||
b4_check_percent_code_qualifiers([[requires]], [[provides]], [[top]])
|
|
||||||
|
b4_check_percent_define_variables
|
||||||
|
|
||||||
|
b4_check_percent_code_qualifiers([[requires]],
|
||||||
|
[[provides]],
|
||||||
|
[[top]])
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Default values. ##
|
## Default values. ##
|
||||||
|
|||||||
@@ -209,6 +209,26 @@ void muscle_pair_list_grow (const char *muscle,
|
|||||||
obstack_free (&muscle_obstack, pair);
|
obstack_free (&muscle_obstack, pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------.
|
||||||
|
| Find the value of muscle KEY. Unlike MUSCLE_FIND, this is always reliable |
|
||||||
|
| to determine whether KEY has a value. |
|
||||||
|
`----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
char const *
|
||||||
|
muscle_find_const (char const *key)
|
||||||
|
{
|
||||||
|
muscle_entry probe;
|
||||||
|
muscle_entry *result = NULL;
|
||||||
|
|
||||||
|
probe.key = key;
|
||||||
|
result = hash_lookup (muscle_table, &probe);
|
||||||
|
if (result)
|
||||||
|
return result->value;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------.
|
/*----------------------------------------------------------------------------.
|
||||||
| Find the value of muscle KEY. Abort if muscle_insert was invoked more |
|
| Find the value of muscle KEY. Abort if muscle_insert was invoked more |
|
||||||
| recently than muscle_grow for KEY since muscle_find can't return a |
|
| recently than muscle_grow for KEY since muscle_find can't return a |
|
||||||
@@ -216,7 +236,7 @@ void muscle_pair_list_grow (const char *muscle,
|
|||||||
`----------------------------------------------------------------------------*/
|
`----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
muscle_find (const char *key)
|
muscle_find (char const *key)
|
||||||
{
|
{
|
||||||
muscle_entry probe;
|
muscle_entry probe;
|
||||||
muscle_entry *result = NULL;
|
muscle_entry *result = NULL;
|
||||||
@@ -276,3 +296,16 @@ muscle_boundary_grow (char const *key, boundary bound)
|
|||||||
muscle_grow (key, extension, "");
|
muscle_grow (key, extension, "");
|
||||||
obstack_free (&muscle_obstack, extension);
|
obstack_free (&muscle_obstack, extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
muscle_grow_used_name_list (char const *key, char const *used_name,
|
||||||
|
location loc)
|
||||||
|
{
|
||||||
|
muscle_grow (key, "[[[[", ",");
|
||||||
|
muscle_grow (key, used_name, "");
|
||||||
|
muscle_grow (key, "]], [[", "");
|
||||||
|
muscle_boundary_grow (key, loc.start);
|
||||||
|
muscle_grow (key, "]], [[", "");
|
||||||
|
muscle_boundary_grow (key, loc.end);
|
||||||
|
muscle_grow (key, "]]]]", "");
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
void muscle_init (void);
|
void muscle_init (void);
|
||||||
void muscle_insert (char const *key, char const *value);
|
void muscle_insert (char const *key, char const *value);
|
||||||
char *muscle_find (char const *key);
|
char *muscle_find (char const *key);
|
||||||
|
char const *muscle_find_const (char const *key);
|
||||||
void muscle_free (void);
|
void muscle_free (void);
|
||||||
|
|
||||||
|
|
||||||
@@ -116,4 +117,12 @@ void muscles_m4_output (FILE *out);
|
|||||||
for special characters in the file name. */
|
for special characters in the file name. */
|
||||||
void muscle_boundary_grow (char const *key, boundary bound);
|
void muscle_boundary_grow (char const *key, boundary bound);
|
||||||
|
|
||||||
|
/* Grow KEY for the occurrence of the name USED_NAME at LOC appropriately for
|
||||||
|
use with b4_check_for_unrecognized_names in ../data/bison.m4. USED_NAME
|
||||||
|
is not escaped with digraphs, so it must not contain `[' or `]'. As a
|
||||||
|
precondition on b4_check_for_unrecognized_names, it can't contain `,'
|
||||||
|
either. */
|
||||||
|
void muscle_grow_used_name_list (char const *key, char const *used_name,
|
||||||
|
location loc);
|
||||||
|
|
||||||
#endif /* not MUSCLE_TAB_H_ */
|
#endif /* not MUSCLE_TAB_H_ */
|
||||||
|
|||||||
485
src/parse-gram.c
485
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
@@ -165,8 +165,8 @@
|
|||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||||
typedef union YYSTYPE
|
typedef union YYSTYPE
|
||||||
{
|
{
|
||||||
/* Line 1546 of yacc.c */
|
/* Line 1551 of yacc.c */
|
||||||
#line 98 "parse-gram.y"
|
#line 97 "parse-gram.y"
|
||||||
|
|
||||||
symbol *symbol;
|
symbol *symbol;
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
@@ -178,7 +178,7 @@ typedef union YYSTYPE
|
|||||||
unsigned char character;
|
unsigned char character;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Line 1546 of yacc.c */
|
/* Line 1551 of yacc.c */
|
||||||
#line 183 "parse-gram.h"
|
#line 183 "parse-gram.h"
|
||||||
YYSTYPE;
|
YYSTYPE;
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ static int current_prec = 0;
|
|||||||
%locations
|
%locations
|
||||||
%pure-parser
|
%pure-parser
|
||||||
%error-verbose
|
%error-verbose
|
||||||
%defines
|
|
||||||
%name-prefix="gram_"
|
%name-prefix="gram_"
|
||||||
%expect 0
|
%expect 0
|
||||||
|
|
||||||
@@ -233,7 +232,15 @@ prologue_declaration:
|
|||||||
code_scanner_last_string_free ();
|
code_scanner_last_string_free ();
|
||||||
}
|
}
|
||||||
| "%debug" { debug_flag = true; }
|
| "%debug" { debug_flag = true; }
|
||||||
| "%define" STRING content.opt { muscle_insert ($2, $3); }
|
| "%define" STRING content.opt
|
||||||
|
{
|
||||||
|
/* FIXME: Special characters in $2 may break %define.
|
||||||
|
For example: `['. */
|
||||||
|
if (muscle_find_const ($2))
|
||||||
|
warn_at (@2, _("%s: `%s' redefined"), "%define", $2);
|
||||||
|
muscle_insert ($2, $3);
|
||||||
|
muscle_grow_used_name_list ("used_percent_define_variables", $2, @2);
|
||||||
|
}
|
||||||
| "%defines" { defines_flag = true; }
|
| "%defines" { defines_flag = true; }
|
||||||
| "%defines" STRING
|
| "%defines" STRING
|
||||||
{
|
{
|
||||||
@@ -316,6 +323,8 @@ grammar_declaration:
|
|||||||
}
|
}
|
||||||
| "%code" STRING braceless
|
| "%code" STRING braceless
|
||||||
{
|
{
|
||||||
|
/* FIXME: Special characters in $2 may break %code.
|
||||||
|
For example: `['. */
|
||||||
char const name_prefix[] = "percent_code_";
|
char const name_prefix[] = "percent_code_";
|
||||||
char *name = xmalloc (sizeof name_prefix + strlen ($2));
|
char *name = xmalloc (sizeof name_prefix + strlen ($2));
|
||||||
strcpy (name, name_prefix);
|
strcpy (name, name_prefix);
|
||||||
@@ -323,13 +332,7 @@ grammar_declaration:
|
|||||||
muscle_code_grow (uniqstr_new (name), $3, @3);
|
muscle_code_grow (uniqstr_new (name), $3, @3);
|
||||||
free (name);
|
free (name);
|
||||||
code_scanner_last_string_free ();
|
code_scanner_last_string_free ();
|
||||||
muscle_grow ("used_percent_code_qualifiers", "[[[[", ",");
|
muscle_grow_used_name_list ("used_percent_code_qualifiers", $2, @2);
|
||||||
muscle_grow ("used_percent_code_qualifiers", $2, "");
|
|
||||||
muscle_grow ("used_percent_code_qualifiers", "]], [[", "");
|
|
||||||
muscle_boundary_grow ("used_percent_code_qualifiers", @2.start);
|
|
||||||
muscle_grow ("used_percent_code_qualifiers", "]], [[", "");
|
|
||||||
muscle_boundary_grow ("used_percent_code_qualifiers", @2.end);
|
|
||||||
muscle_grow ("used_percent_code_qualifiers", "]]]]", "");
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -788,3 +788,28 @@ special-char-@:>@.y:3.7-8: `' is not a recognized %code qualifier
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## %define errors. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
AT_SETUP([%define errors])
|
||||||
|
|
||||||
|
AT_DATA([input.y],
|
||||||
|
[[%define "var" "value1"
|
||||||
|
%define "var" "value1"
|
||||||
|
%define "var" "value2"
|
||||||
|
%%
|
||||||
|
start: ;
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_CHECK([[bison input.y]], [1], [],
|
||||||
|
[[input.y:2.9-13: warning: %define: `var' redefined
|
||||||
|
input.y:3.10-14: warning: %define: `var' redefined
|
||||||
|
input.y:1.9-13: `var' is not a recognized %define variable
|
||||||
|
input.y:2.9-13: `var' is not a recognized %define variable
|
||||||
|
input.y:3.10-14: `var' is not a recognized %define variable
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_CLEANUP
|
||||||
|
|||||||
Reference in New Issue
Block a user