bison-patches
[Top][All Lists]
Advanced

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

Re: Bison scanner patch to fix POSIX incompatibilities, etc.


From: Paul Eggert
Subject: Re: Bison scanner patch to fix POSIX incompatibilities, etc.
Date: Thu, 7 Nov 2002 00:17:20 -0800 (PST)

> From: Akim Demaille <address@hidden>
> Date: 06 Nov 2002 10:09:26 +0100

> How about
> 
>         complain_at (*yylloc, _("unexpected end of file in `%s'"));
> 
> and "/*...*/", "\"...\"", "'.'", etc. ?

Sounds good; I installed this patch.

2002-11-07  Paul Eggert  <address@hidden>

        * src/scan-gram.l (unexpected_end_of_file): New function.
        Use it to systematize the error message on unexpected EOF.

Index: src/scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.35
diff -p -u -r1.35 scan-gram.l
--- src/scan-gram.l     6 Nov 2002 08:08:46 -0000       1.35
+++ src/scan-gram.l     7 Nov 2002 08:12:26 -0000
@@ -129,6 +129,19 @@ extend_location (location_t *loc, char c
 }
 
 
+/* Report an unexpected end of file at LOC.  A token or comment began
+   with TOKEN_START, but an end of file was encountered and the
+   expected TOKEN_END was missing.  */
+
+static void
+unexpected_end_of_file (location_t loc,
+                       char const *token_start, char const *token_end)
+{
+  complain_at (loc, _("unexpected end of file in `%s ... %s'"),
+              token_start, token_end);
+}
+
+
 
 /* STRING_OBSTACK -- Used to store all the characters that we need to
    keep (to construct ID, STRINGS etc.).  Use the following macros to
@@ -349,7 +362,7 @@ splice       (\\[ \f\t\v]*\n)*
   [^*]+|"*"  ;
 
   <<EOF>> {
-    complain_at (*yylloc, _("unexpected end of file in a comment"));
+    unexpected_end_of_file (*yylloc, "/*", "*/");
     BEGIN INITIAL;
   }
 }
@@ -365,7 +378,7 @@ splice       (\\[ \f\t\v]*\n)*
   [^*\[\]]+|"*"   YY_OBS_GROW;
 
   <<EOF>> {
-    complain_at (*yylloc, _("unexpected end of file in a comment"));
+    unexpected_end_of_file (*yylloc, "/*", "*/");
     yy_pop_state ();
   }
 }
@@ -403,7 +416,7 @@ splice       (\\[ \f\t\v]*\n)*
   [^\"\\]+  YY_OBS_GROW;
 
   <<EOF>> {
-    complain_at (*yylloc, _("unexpected end of file in a string"));
+    unexpected_end_of_file (*yylloc, "\"", "\"");
     assert (yy_top_state () == INITIAL);
     YY_OBS_FINISH;
     yylval->string = last_string;
@@ -438,7 +451,7 @@ splice       (\\[ \f\t\v]*\n)*
   [^\'\\]+  YY_OBS_GROW;
 
   <<EOF>> {
-    complain_at (*yylloc, _("unexpected end of file in a character literal"));
+    unexpected_end_of_file (*yylloc, "'", "'");
     assert (yy_top_state () == INITIAL);
     YY_OBS_FINISH;
     yylval->string = last_string;
@@ -529,7 +542,7 @@ splice       (\\[ \f\t\v]*\n)*
   \\                   YY_OBS_GROW;
 
   <<EOF>> {
-    complain_at (*yylloc, _("unexpected end of file in a character literal"));
+    unexpected_end_of_file (*yylloc, "'", "'");
     assert (yy_top_state () != INITIAL);
     yy_pop_state ();
   }
@@ -556,7 +569,7 @@ splice       (\\[ \f\t\v]*\n)*
   \\                   YY_OBS_GROW;
 
   <<EOF>> {
-    complain_at (*yylloc, _("unexpected end of file in a string"));
+    unexpected_end_of_file (*yylloc, "\"", "\"");
     assert (yy_top_state () != INITIAL);
     yy_pop_state ();
   }
@@ -616,7 +629,7 @@ splice       (\\[ \f\t\v]*\n)*
   [^\"$%\'/<@\[\]\{\}]+|[$%/<@]|"<"{splice}"<"  YY_OBS_GROW;
 
   <<EOF>> {
-    complain_at (*yylloc, _("unexpected end of file in `{ ... }'"));
+    unexpected_end_of_file (*yylloc, "{", "}");
     yy_pop_state ();
     YY_OBS_FINISH;
     yylval->string = last_string;
@@ -643,7 +656,7 @@ splice       (\\[ \f\t\v]*\n)*
   "%"                YY_OBS_GROW;
 
   <<EOF>> {
-    complain_at (*yylloc, _("unexpected end of file in `%%{ ... %%}'"));
+    unexpected_end_of_file (*yylloc, "%{", "%}");
     yy_pop_state ();
     YY_OBS_FINISH;
     yylval->string = last_string;
@@ -871,7 +884,7 @@ convert_ucn_to_byte (char const *ucn)
     /* A non-ASCII host.  Use CODE to index into a table of the C
        basic execution character set, which is guaranteed to exist on
        all Standard C platforms.  This table also includes '$', '@',
-       and '`', which not in the basic execution character set but
+       and '`', which are not in the basic execution character set but
        which are unibyte characters on all the platforms that we know
        about.  */
     static signed char const table[] =




reply via email to

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