X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/7dc4a6940c964d3650fecc6a0c99d8e191517086..2de160e12ea0b0313a3a4f2120b30a3eeaad0c76:/data/bison.m4?ds=sidebyside diff --git a/data/bison.m4 b/data/bison.m4 index 5e503919..585fb1d0 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -1,7 +1,8 @@ -*- Autoconf -*- # Language-independent M4 Macros for Bison. -# Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software +# Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -74,7 +75,8 @@ version 2.2 of Bison.])]) m4_define([b4_cat], [m4_syscmd([cat <<'_m4eof' ]m4_bpatsubst(m4_dquote($1), [_m4eof], [_m4@`eof])[@ -_m4eof])dnl +_m4eof +])dnl m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])]) # b4_error(KIND, FORMAT, [ARG1], [ARG2], ...) @@ -249,7 +251,6 @@ b4_define_flag_if([error_verbose]) # Whether error are verbose. b4_define_flag_if([glr]) # Whether a GLR parser is requested. b4_define_flag_if([locations]) # Whether locations are tracked. b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled. -b4_define_flag_if([pure]) # Whether the interface is pure. b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. @@ -316,8 +317,8 @@ b4_define_user_code([stype]) # but is not used by Bison (as recorded by macros in the namespace # BISON-NAMESPACE). # -# USER-LIST must expand to a list specifying all grammar occurrences of all -# names of type WHAT. Each item in the list must be a triplet specifying one +# USER-LIST must expand to a list specifying all user occurrences of all 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. # @@ -375,6 +376,42 @@ m4_define([b4_percent_define_get], [m4_define([b4_percent_define_bison_variables(]$1[)])dnl m4_ifdef([b4_percent_define(]$1[)], [m4_indir([b4_percent_define(]$1[)])])]) +# b4_percent_define_get_loc(VARIABLE) +# ----------------------------------- +# Mimic muscle_percent_define_get_loc in ../src/muscle_tab.h exactly. That is, +# if the %define variable VARIABLE is undefined, complain fatally since that's +# a Bison or skeleton error. Otherwise, return its definition location in a +# form approriate for the first two arguments of b4_warn_at, b4_complain_at, or +# b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no +# reason to suspect that the user-supplied value has yet influenced the output. +# +# For example: +# +# b4_complain_at(b4_percent_define_get_loc([[foo]]), [[invalid foo]]) +m4_define([b4_percent_define_get_loc], +[m4_ifdef([b4_percent_define_loc(]$1[)], + [m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl +b4_loc[]dnl +m4_popdef([b4_loc])], + [b4_fatal([[undefined %%define variable `%s' passed to b4_percent_define_get_loc]], [$1])])]) + +# b4_percent_define_get_syncline(VARIABLE) +# ---------------------------------------- +# Mimic muscle_percent_define_get_syncline in ../src/muscle_tab.h exactly. +# That is, if the %define variable VARIABLE is undefined, complain fatally +# since that's a Bison or skeleton error. Otherwise, return its definition +# location as a b4_syncline invocation. Don't record this as a Bison usage of +# VARIABLE as there's no reason to suspect that the user-supplied value has yet +# influenced the output. +# +# For example: +# +# b4_percent_define_get_syncline([[foo]]) +m4_define([b4_percent_define_get_syncline], +[m4_ifdef([b4_percent_define_syncline(]$1[)], + [m4_indir([b4_percent_define_syncline(]$1[)])], + [b4_fatal([[undefined %%define variable `%s' passed to b4_percent_define_get_syncline]], [$1])])]) + # b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE]) # ------------------------------------------------------ # Mimic muscle_percent_define_ifdef in ../src/muscle_tab.h exactly. That is, @@ -407,13 +444,10 @@ m4_define([b4_percent_define_flag_if], [b4_percent_define_ifdef([$1], [m4_case(b4_percent_define_get([$1]), [], [$2], [true], [$2], [false], [$3], - [m4_expand_once([dnl - m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl - b4_complain_at(b4_loc, - [[invalid value for %%define Boolean variable `%s']], - [$1])dnl - m4_popdef([b4_loc])], - [[b4_percent_define_flag_if($1)]])])], + [m4_expand_once([b4_complain_at(b4_percent_define_get_loc([$1]), + [[invalid value for %%define Boolean variable `%s']], + [$1])], + [[b4_percent_define_flag_if($1)]])])], [b4_fatal([[undefined %%define variable `%s' passed to b4_percent_define_flag_if]], [$1])])]) # b4_percent_define_default(VARIABLE, DEFAULT) @@ -430,7 +464,9 @@ m4_define([b4_percent_define_default], [m4_ifndef([b4_percent_define(]$1[)], [m4_define([b4_percent_define(]$1[)], [$2])dnl m4_define([b4_percent_define_loc(]$1[)], - [[[[[Bison:b4_percent_define_default]:0.0]], [[[Bison:b4_percent_define_default]:0.0]]]])])]) + [[[[:-1.-1]], + [[:-1.-1]]]])dnl + m4_define([b4_percent_define_syncline(]$1[)], [[]])])]) # b4_percent_define_check_values(VALUES) # -------------------------------------- @@ -460,12 +496,14 @@ m4_define([_b4_percent_define_check_values], [m4_if(m4_indir([b4_percent_define(]$1[)]), b4_value, [m4_define([b4_good_value], [1])])])])dnl m4_if(b4_good_value, [0], - [m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl - b4_complain_at(b4_loc, + [b4_complain_at(b4_percent_define_get_loc([$1]), [[invalid value for %%define variable `%s': `%s']], [$1], - m4_dquote(m4_indir([b4_percent_define(]$1[)])))dnl - m4_popdef([b4_loc])])dnl + m4_dquote(m4_indir([b4_percent_define(]$1[)]))) + m4_foreach([b4_value], m4_dquote(m4_shift($@)), + [b4_complain_at(b4_percent_define_get_loc([$1]), + [[accepted value: `%s']], + m4_dquote(b4_value))])])dnl m4_popdef([b4_good_value])], [b4_fatal([[undefined %%define variable `%s' passed to b4_percent_define_check_values]], [$1])])]) @@ -487,7 +525,7 @@ m4_define([b4_percent_code_get], m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl m4_ifdef(b4_macro_name, [b4_comment([m4_if([$#], [0], [[Unqualified %code]], - [[%code "]$1["]])[ blocks.]]) + [["%code ]$1["]])[ blocks.]]) b4_user_code([m4_indir(b4_macro_name)]) ])dnl m4_popdef([b4_macro_name])]) @@ -515,7 +553,7 @@ m4_define([b4_check_user_names_wrap], [b4_percent_]$1[_user_]$2[s], [[b4_percent_]$1[_bison_]$2[s]])])]) -m4_wrap([ +m4_wrap_lifo([ b4_check_user_names_wrap([[define]], [[variable]]) b4_check_user_names_wrap([[code]], [[qualifier]]) ])