X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/7dc4a6940c964d3650fecc6a0c99d8e191517086..a6df593dfe9918e8d9bdf8f59c881e93d5d292e8:/data/bison.m4 diff --git a/data/bison.m4 b/data/bison.m4 index 5e503919..31f78181 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 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 @@ -21,14 +22,17 @@ ## Identification. ## ## ---------------- ## -# b4_copyright(TITLE, YEARS) -# -------------------------- +# b4_copyright(TITLE, [YEARS]) +# ---------------------------- +# If YEARS are not defined, use b4_copyright_years. m4_define([b4_copyright], [b4_comment([A Bison parser, made by GNU Bison b4_version.]) b4_comment([$1 -m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ]) +]m4_dquote(m4_text_wrap([Copyright (C) +]m4_ifval([$2], [[$2]], [m4_defn([b4_copyright_years])])[ +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 +78,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 +254,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. @@ -375,6 +379,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 +447,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 +467,10 @@ 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]]]])])]) + [[[[[Bison:b4_percent_define_default]:1.0]], [[[Bison:b4_percent_define_default]:1.0]]]])dnl + m4_define([b4_percent_define_syncline(]$1[)], + [[]b4_syncline(1, [["[Bison:b4_percent_define_default]"]])[ +]])])]) # b4_percent_define_check_values(VALUES) # -------------------------------------- @@ -460,12 +500,10 @@ 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[)])))])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]]) ])