From: Akim Demaille Date: Thu, 2 Apr 2009 22:32:49 +0000 (+0200) Subject: Treat %debug as %define debug. X-Git-Tag: v2.7.90~919 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/0ce615753edfd7d1f8f1fe8670d4354b3d59d049 Treat %debug as %define debug. * data/bison.m4 (b4_debug_if): New. * data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c, * data/lalr1.java: Use it instead of b4_debug_flag. * src/getargs.h, src/getargs.c (debug_flag): Remove. * src/output.c (prepare): Don't output it. * src/parse-gram.y: Treat %debug as %define debug. --- diff --git a/data/bison.m4 b/data/bison.m4 index 09b79940..fa8b043a 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -678,11 +678,13 @@ b4_percent_define_if_define_([$1], $[1], $[2])]) # b4_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT]) +# b4_debug_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT]) # b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT]) # b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT]) # b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT]) # ---------------------------------------------- b4_percent_define_if_define([assert]) +b4_percent_define_if_define([debug]) b4_percent_define_if_define([error_verbose]) b4_percent_define_if_define([lex_symbol]) b4_percent_define_if_define([variant]) diff --git a/data/glr.c b/data/glr.c index 3e49a5f2..3add5b27 100644 --- a/data/glr.c +++ b/data/glr.c @@ -224,7 +224,7 @@ b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ +# define YYDEBUG ]b4_debug_if([1], [0])[ #endif /* Enabling verbose error messages. */ diff --git a/data/glr.cc b/data/glr.cc index dada42c3..2d9fc4c6 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -1,6 +1,6 @@ # C++ GLR skeleton for Bison -# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, -# Inc. +# Copyright (C) 2002, 2003, 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 @@ -215,7 +215,7 @@ m4_popdef([b4_parse_param]) m4_divert_push(0) @output(b4_spec_defines_file@)@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], - [2002, 2003, 2004, 2005, 2006])[ + [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])[ /* C++ GLR parser skeleton written by Akim Demaille. */ @@ -239,7 +239,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ +# define YYDEBUG ]b4_debug_if([1], [0])[ #endif /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. diff --git a/data/lalr1.cc b/data/lalr1.cc index 9079bbee..cf955edc 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -161,7 +161,7 @@ dnl FIXME: This is wrong, we want computed header guards. /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ +# define YYDEBUG ]b4_debug_if([1], [0])[ #endif /* Enabling verbose error messages. */ diff --git a/data/lalr1.java b/data/lalr1.java index 11ed606d..b1e74f02 100644 --- a/data/lalr1.java +++ b/data/lalr1.java @@ -1,6 +1,6 @@ # Java skeleton for Bison -*- autoconf -*- -# Copyright (C) 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -20,6 +20,9 @@ m4_include(b4_pkgdatadir/[java.m4]) b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])]) +# We don't depend on %debug in Java, but pacify warnings about non-used flags. +b4_debug_if([0], [0]) + m4_define([b4_symbol_no_destructor_assert], [b4_symbol_if([$1], [has_destructor], [b4_fatal([%s: %s: %%destructor does not make sense in Java], diff --git a/data/yacc.c b/data/yacc.c index 2c6024c6..c02ecf2d 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -192,7 +192,7 @@ m4_if(b4_prefix, [yy], [], /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG ]b4_debug_flag[ +# define YYDEBUG ]b4_debug_if([1], [0])[ #endif /* Enabling verbose error messages. */ diff --git a/src/getargs.c b/src/getargs.c index 14cba3ed..7a67878a 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -47,7 +47,6 @@ #include "muscle_tab.h" #include "uniqstr.h" -bool debug_flag; bool defines_flag; bool graph_flag; bool xml_flag; @@ -618,7 +617,7 @@ getargs (int argc, char *argv[]) break; case 't': - debug_flag = true; + muscle_percent_define_insert ("debug", command_line_location (), ""); break; case 'v': diff --git a/src/getargs.h b/src/getargs.h index 12bf6450..c85cb5fa 100644 --- a/src/getargs.h +++ b/src/getargs.h @@ -35,7 +35,6 @@ extern int skeleton_prio; /* for -I */ extern char const *include; -extern bool debug_flag; /* for -t */ extern bool defines_flag; /* for -d */ extern bool graph_flag; /* for -g */ extern bool xml_flag; /* for -x */ diff --git a/src/output.c b/src/output.c index 09d89a52..a06698ce 100644 --- a/src/output.c +++ b/src/output.c @@ -700,7 +700,6 @@ prepare (void) use_push_for_pull_flag = true; /* Flags. */ - MUSCLE_INSERT_BOOL ("debug_flag", debug_flag); MUSCLE_INSERT_BOOL ("defines_flag", defines_flag); MUSCLE_INSERT_BOOL ("glr_flag", glr_parser); MUSCLE_INSERT_BOOL ("locations_flag", locations_flag); diff --git a/src/parse-gram.y b/src/parse-gram.y index 264e1d32..53df3a43 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -225,7 +225,10 @@ prologue_declaration: plain_code.code, @1); code_scanner_last_string_free (); } -| "%debug" { debug_flag = true; } +| "%debug" + { + muscle_percent_define_insert ("debug", @$, ""); + } | "%define" variable content.opt { muscle_percent_define_insert ($2, @2, $3);