bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

add -fsyntax-only


From: Akim Demaille
Subject: add -fsyntax-only
Date: Mon, 28 Jan 2019 06:50:18 +0100

Maybe we should also support -n, --dry-run, like Make.  But -fsyntax-only is 
what GCC and Clang do.

Maybe we should generate the reports anyway in that case.  WDYT?

commit 9cd7bd4d5fb5032b2ce2c4e26c4bd0a0baeb708a
Author: Akim Demaille <address@hidden>
Date:   Sun Jan 27 07:51:07 2019 +0100

    add -fsyntax-only
    
    When debugging Bison itself, this is very handy, especially when
    tweaking the frontend badly enough to break the backends. It can also
    be used to check a grammar.
    
    * src/getargs.h, src/getargs.c (feature_syntax_only): New.
    (feature_args, feature_types): Adjust.
    * src/main.c (main): Use it.

diff --git a/NEWS b/NEWS
index 64aa3b61..9889af47 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ GNU Bison NEWS
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** New features
+
+*** Disabling output
+
+  When given -fsyntax-only, the diagnostics are reported, but no output is
+  generated.
 
 * Noteworthy changes in release 3.3.1 (2019-01-27) [stable]
 
diff --git a/doc/bison.texi b/doc/bison.texi
index 279b73d2..217cbf97 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -10601,6 +10601,8 @@ foo.y: warning: fix-its can be applied.  Rerun with 
option '--update'. [-Wother]
 The fix-its are applied by @command{bison} itself when given the option
 @option{-u}/@option{--update}.  See its documentation above.
 
address@hidden syntax-only
+Do not generate the output files.
 @end table
 @end table
 
diff --git a/src/getargs.c b/src/getargs.c
index 394221a0..e71aafd3 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -231,6 +231,7 @@ static const char * const feature_args[] =
   "none",
   "caret", "diagnostics-show-caret",
   "fixit", "diagnostics-parseable-fixits",
+  "syntax-only",
   "all",
   0
 };
@@ -240,6 +241,7 @@ static const int feature_types[] =
   feature_none,
   feature_caret, feature_caret,
   feature_fixit_parsable, feature_fixit_parsable,
+  feature_syntax_only,
   feature_all
 };
 
@@ -362,6 +364,8 @@ FEATURES is a list of comma separated words that can 
include:\n\
     show errors with carets\n\
   'fixit', 'diagnostics-parseable-fixits'\n\
     show machine-readable fixes\n\
+  'syntax-only'\n\
+    do not generate any file\n\
   'all'\n\
     all of the above\n\
   'none'\n\
@@ -698,6 +702,7 @@ getargs (int argc, char *argv[])
 
       case 'u':
         update_flag = true;
+        feature_flag |= feature_syntax_only;
         break;
 
       case 'v':
diff --git a/src/getargs.h b/src/getargs.h
index c5adb848..f630d0f5 100644
--- a/src/getargs.h
+++ b/src/getargs.h
@@ -114,10 +114,11 @@ extern int trace_flag;
 
 enum feature
   {
-    feature_none           = 0,       /**< No additional feature.  */
-    feature_caret          = 1 << 0,  /**< Output errors with carets.  */
-    feature_fixit_parsable = 1 << 1,  /**< Issue instructions to fix the 
sources.  */
-    feature_all            = ~0       /**< All above features.  */
+    feature_none             = 0,      /**< No additional feature.  */
+    feature_caret            = 1 << 0, /**< Output errors with carets.  */
+    feature_fixit_parsable   = 1 << 1, /**< Issue instructions to fix the 
sources.  */
+    feature_syntax_only      = 1 << 2, /**< Don't generate output.  */
+    feature_all              = ~0      /**< All above features.  */
   };
 /** What additional features to use.  */
 extern int feature_flag;
diff --git a/src/main.c b/src/main.c
index b56fae78..065540db 100644
--- a/src/main.c
+++ b/src/main.c
@@ -155,7 +155,10 @@ main (int argc, char *argv[])
 
   print_precedence_warnings ();
 
-  if (!update_flag)
+  /* Whether to generate output files.  */
+  bool generate = !(feature_flag & feature_syntax_only);
+
+  if (generate)
     {
       /* Output file names. */
       compute_output_file_names ();
@@ -196,7 +199,7 @@ main (int argc, char *argv[])
   timevar_pop (tv_free);
 
   /* Output the tables and the parser to ftable.  In file output.  */
-  if (!update_flag)
+  if (generate)
     {
       timevar_push (tv_parser);
       output ();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]