bison-patches
[Top][All Lists]
Advanced

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

Re: [SPAM] Re: Extract the action scanner from the grammar scanner


From: Joel E. Denny
Subject: Re: [SPAM] Re: Extract the action scanner from the grammar scanner
Date: Wed, 7 Jun 2006 16:06:45 -0400 (EDT)

On Wed, 7 Jun 2006, Joel E. Denny wrote:

> On Wed, 7 Jun 2006, Akim Demaille wrote:
> 
> > >>> "Joel" == Joel E Denny <address@hidden> writes:
> > 
> >  > I also had some #include problems.  Here's what I found:
> [snip]
> > Hm.  I don't need them.  They are sane though.
> 
> Try configuring with --enable-gcc-warnings.

I installed the patch at the end of this message.  It almost fixes this 
problem for me.  Please review.  There's at least one non-trivial change.

Because I still use Flex 2.5.4, which has worked for me until now, I also 
need this:

--- flex-scanner.h      7 Jun 2006 07:58:28 -0000       1.1
+++ flex-scanner.h      7 Jun 2006 19:59:03 -0000
@@ -45,8 +45,8 @@ int   FLEX_PREFIX (lex_destroy) (void);
    yyleng etc. when a prefix is given, since there is no longer a
    #define, but rather the token is actually changed in the output.
    */
-#define yyleng  FLEX_PREFIX (leng)
-#define yytext  FLEX_PREFIX (text)
+/* #define yyleng  FLEX_PREFIX (leng) */
+/* #define yytext  FLEX_PREFIX (text) */
 
 /* OBSTACK_FOR_STRING -- Used to store all the characters that we need to
    keep (to construct ID, STRINGS etc.).  Use the following macros to

I didn't install this as I'm afraid it'll break later versions of Flex. 
What version of Flex do we intend to require?

Joel

2006-06-07  Joel E. Denny  <address@hidden>

        Get Bison to build again when configured with --enable-gcc-warnings.
        * src/location.c, src/location.h, src/main.c, src/scan-code.l: Add some
        missing #include's.
        * src/scan-code.l (handle_action_dollar, handle_action_at): Rename
        loc argument as it shadows a global.
        * src/scan-gram.l: Remove stray comma that prevents boundary_set
        invocation.

        * src/.cvsignore: Add scan-code.c.

Index: src/.cvsignore
===================================================================
RCS file: /sources/bison/bison/src/.cvsignore,v
retrieving revision 1.17
diff -p -u -r1.17 .cvsignore
--- src/.cvsignore      6 Jun 2006 05:23:44 -0000       1.17
+++ src/.cvsignore      7 Jun 2006 19:50:30 -0000
@@ -6,6 +6,7 @@ Makefile
 Makefile.in
 bison
 revision.c
+scan-code.c
 scan-gram.c
 scan-skel.c
 yacc
Index: src/location.c
===================================================================
RCS file: /sources/bison/bison/src/location.c,v
retrieving revision 1.7
diff -p -u -r1.7 location.c
--- src/location.c      6 Jun 2006 16:40:06 -0000       1.7
+++ src/location.c      7 Jun 2006 19:50:30 -0000
@@ -21,8 +21,10 @@
 #include <config.h>
 #include "system.h"
 
+#include <mbswidth.h>
 #include <quotearg.h>
 
+#include "complain.h"
 #include "location.h"
 
 location const empty_location;
Index: src/location.h
===================================================================
RCS file: /sources/bison/bison/src/location.h,v
retrieving revision 1.14
diff -p -u -r1.14 location.h
--- src/location.h      6 Jun 2006 16:40:06 -0000       1.14
+++ src/location.h      7 Jun 2006 19:50:30 -0000
@@ -21,6 +21,7 @@
 #ifndef LOCATION_H_
 # define LOCATION_H_
 
+# include <stdbool.h>
 # include "uniqstr.h"
 
 /* A boundary between two characters.  */
Index: src/main.c
===================================================================
RCS file: /sources/bison/bison/src/main.c,v
retrieving revision 1.86
diff -p -u -r1.86 main.c
--- src/main.c  6 Jun 2006 16:40:06 -0000       1.86
+++ src/main.c  7 Jun 2006 19:50:30 -0000
@@ -43,6 +43,7 @@
 #include "print_graph.h"
 #include "reader.h"
 #include "reduce.h"
+#include "scan-gram.h"
 #include "symtab.h"
 #include "tables.h"
 #include "uniqstr.h"
Index: src/scan-code.l
===================================================================
RCS file: /sources/bison/bison/src/scan-code.l,v
retrieving revision 1.2
diff -p -u -r1.2 scan-code.l
--- src/scan-code.l     7 Jun 2006 07:09:32 -0000       1.2
+++ src/scan-code.l     7 Jun 2006 19:50:30 -0000
@@ -30,6 +30,7 @@
 #define code_wrap() 1
 
 #define FLEX_PREFIX(Id) code_ ## Id
+#include "complain.h"
 #include "flex-scanner.h"
 #include "reader.h"
 #include "getargs.h"
@@ -46,8 +47,8 @@ YY_DECL;
 
 #define YY_USER_ACTION  location_compute (loc, &loc->end, yytext, yyleng);
 
-static void handle_action_dollar (char *cp, location loc);
-static void handle_action_at (char *cp, location loc);
+static void handle_action_dollar (char *cp, location dollar_loc);
+static void handle_action_at (char *cp, location at_loc);
 static location the_location;
 static location *loc = &the_location;
 
@@ -234,7 +235,7 @@ int max_left_semantic_context = 0;
 `------------------------------------------------------------------*/
 
 static void
-handle_action_dollar (char *text, location loc)
+handle_action_dollar (char *text, location dollar_loc)
 {
   const char *type_name = NULL;
   char *cp = text + 1;
@@ -253,9 +254,9 @@ handle_action_dollar (char *text, locati
   if (*cp == '$')
     {
       if (!type_name)
-       type_name = symbol_list_n_type_name_get (current_rule, loc, 0);
+       type_name = symbol_list_n_type_name_get (current_rule, dollar_loc, 0);
       if (!type_name && typed)
-       complain_at (loc, _("$$ of `%s' has no declared type"),
+       complain_at (dollar_loc, _("$$ of `%s' has no declared type"),
                     current_rule->sym->tag);
       if (!type_name)
        type_name = "";
@@ -274,9 +275,10 @@ handle_action_dollar (char *text, locati
          if (1-n > max_left_semantic_context)
            max_left_semantic_context = 1-n;
          if (!type_name && n > 0)
-           type_name = symbol_list_n_type_name_get (current_rule, loc, n);
+           type_name =
+             symbol_list_n_type_name_get (current_rule, dollar_loc, n);
          if (!type_name && typed)
-           complain_at (loc, _("$%d of `%s' has no declared type"),
+           complain_at (dollar_loc, _("$%d of `%s' has no declared type"),
                         n, current_rule->sym->tag);
          if (!type_name)
            type_name = "";
@@ -286,7 +288,7 @@ handle_action_dollar (char *text, locati
          symbol_list_n_used_set (current_rule, n, true);
        }
       else
-       complain_at (loc, _("integer out of range: %s"), quote (text));
+       complain_at (dollar_loc, _("integer out of range: %s"), quote (text));
     }
 }
 
@@ -297,7 +299,7 @@ handle_action_dollar (char *text, locati
 `------------------------------------------------------*/
 
 static void
-handle_action_at (char *text, location loc)
+handle_action_at (char *text, location at_loc)
 {
   char *cp = text + 1;
   int rule_length = symbol_list_length (current_rule->next);
@@ -318,7 +320,7 @@ handle_action_at (char *text, location l
                          rule_length, n);
        }
       else
-       complain_at (loc, _("integer out of range: %s"), quote (text));
+       complain_at (at_loc, _("integer out of range: %s"), quote (text));
     }
 }
 
Index: src/scan-gram.l
===================================================================
RCS file: /sources/bison/bison/src/scan-gram.l,v
retrieving revision 1.88
diff -p -u -r1.88 scan-gram.l
--- src/scan-gram.l     7 Jun 2006 07:09:32 -0000       1.88
+++ src/scan-gram.l     7 Jun 2006 19:50:31 -0000
@@ -751,7 +751,7 @@ handle_syncline (char *args, location lo
       lineno = INT_MAX;
     }
   current_file = uniqstr_new (file);
-  boundary_set, (&scanner_cursor, current_file, lineno, 1);
+  boundary_set (&scanner_cursor, current_file, lineno, 1);
 }
 
 




reply via email to

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