Work on some other areas of Bison revealed that some macros expanded
to be expanded only once were actually expanded several times. This
was due to the fact that changecom was not properly restored each
time, and macro names appearing in comments were then expanded.
Introduce begin/end macros which are easier to match that
changecom()/changecom(#).
* data/bison.m4 (b4_output_begin, b4_output_end): New.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java,
* data/location.cc, data/stack.hh, data/yacc.c:
Use them.
version 2.2 of Bison.])])
version 2.2 of Bison.])])
+## -------- ##
+## Output. ##
+## -------- ##
+
+# b4_output_begin(FILE)
+# ---------------------
+# Enable output, i.e., send to diversion 0, expand after "#", and
+# generate the tag to output into FILE. Must be followed by EOL.
+m4_define([b4_output_begin],
+[m4_changecom()
+m4_divert_push(0)dnl
+@output(m4_unquote([$1])@)@dnl
+])
+
+
+# b4_output_end()
+# ---------------
+# Output nothing, restore # as comment character (no expansions after #).
+m4_define([b4_output_end],
+[m4_divert_pop(0)
+m4_changecom([#])
+])
+
+
## ---------------- ##
## Error handling. ##
## ---------------- ##
## ---------------- ##
## Error handling. ##
## ---------------- ##
## Output files. ##
## -------------- ##
## Output files. ##
## -------------- ##
-# We do want M4 expansion after # for CPP macros.
-m4_changecom()
-m4_divert_push(0)dnl
-@output(b4_parser_file_name@)@
+b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
/* C GLR parser skeleton written by Paul Hilfinger. */
]b4_identification
/* C GLR parser skeleton written by Paul Hilfinger. */
]b4_identification
}
#endif
]b4_epilogue[]dnl
}
#endif
]b4_epilogue[]dnl
-dnl
-dnl glr.cc produces its own header.
-dnl
+b4_output_end()
+
+# glr.cc produces its own header.
m4_if(b4_skeleton, ["glr.c"],
[b4_defines_if(
m4_if(b4_skeleton, ["glr.c"],
[b4_defines_if(
-[@output(b4_spec_defines_file@)@
+[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002-2012])[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002-2012])[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
-]])])dnl
-m4_divert_pop(0)
m4_include(b4_pkgdatadir/[glr.c])
m4_popdef([b4_parse_param])
m4_include(b4_pkgdatadir/[glr.c])
m4_popdef([b4_parse_param])
-m4_divert_push(0)
-@output(b4_spec_defines_file@)@
+b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
[2002-2006, 2009-2012])[
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
[2002-2006, 2009-2012])[
]b4_namespace_close[
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])[
]b4_namespace_close[
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])[
m4_include(b4_pkgdatadir/[location.cc])])
m4_include(b4_pkgdatadir/[stack.hh])
m4_include(b4_pkgdatadir/[location.cc])])
m4_include(b4_pkgdatadir/[stack.hh])
-# We do want M4 expansion after # for CPP macros.
-m4_changecom()
-m4_divert_push(0)dnl
-[@output(b4_spec_defines_file@)@
+[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
[2002-2012])
[
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
[2002-2012])
[
])[
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])
])[
]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])
-])dnl
-@output(b4_parser_file_name@)@
+b4_output_end()
+])
+
+
+b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
[2002-2012])
b4_percent_code_get([[top]])[]dnl
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
[2002-2012])
b4_percent_code_get([[top]])[]dnl
]b4_namespace_close[
]b4_epilogue[]dnl
]b4_namespace_close[
]b4_epilogue[]dnl
[b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
[])
[b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
[])
-m4_divert_push(0)dnl
-@output(b4_parser_file_name@)@
+b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2012])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2012])
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# We do want M4 expansion after # for CPP macros.
-m4_changecom()
-m4_divert_push(0)dnl
-@output(b4_dir_prefix[]position.hh@)@
+
+b4_output_begin([b4_dir_prefix[]position.hh])
b4_copyright([Positions for Bison parsers in C++],
[2002-2007, 2009-2012])[
b4_copyright([Positions for Bison parsers in C++],
[2002-2007, 2009-2012])[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
-@output(b4_dir_prefix[]location.hh@)@
+b4_output_end()
+
+
+b4_output_begin([b4_dir_prefix[]location.hh])
b4_copyright([Locations for Bison parsers in C++],
[2002-2007, 2009-2012])[
b4_copyright([Locations for Bison parsers in C++],
[2002-2007, 2009-2012])[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
-m4_divert_pop(0)
-m4_changecom([#])
m4_pushdef([b4_copyright_years],
[2002-2012])
m4_pushdef([b4_copyright_years],
[2002-2012])
-# We do want M4 expansion after # for CPP macros.
-m4_changecom()
-m4_divert_push(0)dnl
-@output(b4_dir_prefix[]stack.hh@)@
+b4_output_begin([b4_dir_prefix[]stack.hh])
b4_copyright([Stack handling for Bison parsers in C++],
[2002-2012])[
b4_copyright([Stack handling for Bison parsers in C++],
[2002-2012])[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
-m4_divert_pop(0)
-m4_popdef([b4_copyright_years])dnl
-m4_changecom([#])
+b4_output_end()
+
+m4_popdef([b4_copyright_years])
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
])
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
])
## -------------- ##
## Output files. ##
## -------------- ##
## -------------- ##
## Output files. ##
## -------------- ##
-# We do want M4 expansion after # for CPP macros.
-m4_changecom()
-m4_divert_push(0)dnl
-@output(b4_parser_file_name@)@
+b4_output_begin([b4_parser_file_name])
b4_copyright([Bison implementation for Yacc-like parsers in C],
[1984, 1989-1990, 2000-2012])[
b4_copyright([Bison implementation for Yacc-like parsers in C],
[1984, 1989-1990, 2000-2012])[
-[@output(b4_spec_defines_file@)@
-b4_copyright([Bison interface for Yacc-like parsers in C],
- [1984, 1989-1990, 2000-2012])[
+[b4_output_begin([b4_spec_defines_file])[
+]b4_copyright([Bison interface for Yacc-like parsers in C],
+ [1984, 1989-1990, 2000-2012])[
-]])dnl b4_defines_if
-m4_divert_pop(0)