X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/a706a1cc03800f9bedd3658c6e53f17fc1f5d350..ccdb39e0a6f95cb4a3f19c08885a7c421cdebedb:/src/scan-gram.l diff --git a/src/scan-gram.l b/src/scan-gram.l index ad200267..8f18c355 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -168,7 +168,7 @@ static void handle_at (braced_code_t code_kind, char *cp, location_t location); static void handle_syncline (char *args, location_t *location); static int convert_ucn_to_byte (char const *hex_text); -static void unexpected_end_of_file (location_t, char const *); +static void unexpected_end_of_file (location_t *, char const *); %} %x SC_COMMENT SC_LINE_COMMENT SC_YACC_COMMENT @@ -331,7 +331,7 @@ splice (\\[ \f\t\v]*\n)* } .|\n ; - <> unexpected_end_of_file (*yylloc, "*/"); + <> unexpected_end_of_file (yylloc, "*/"); } @@ -342,7 +342,7 @@ splice (\\[ \f\t\v]*\n)* { "*"{splice}"/" YY_OBS_GROW; BEGIN c_context; - <> unexpected_end_of_file (*yylloc, "*/"); + <> unexpected_end_of_file (yylloc, "*/"); } @@ -375,7 +375,7 @@ splice (\\[ \f\t\v]*\n)* } .|\n YY_OBS_GROW; - <> unexpected_end_of_file (*yylloc, "\""); + <> unexpected_end_of_file (yylloc, "\""); } /*---------------------------------------------------------------. @@ -399,7 +399,7 @@ splice (\\[ \f\t\v]*\n)* } .|\n YY_OBS_GROW; - <> unexpected_end_of_file (*yylloc, "'"); + <> unexpected_end_of_file (yylloc, "'"); } @@ -469,10 +469,9 @@ splice (\\[ \f\t\v]*\n)* { - "'" YY_OBS_GROW; BEGIN c_context; - \\{splice}[^\[\]] YY_OBS_GROW; - {splice} YY_OBS_GROW; - <> unexpected_end_of_file (*yylloc, "'"); + "'" YY_OBS_GROW; BEGIN c_context; + \\{splice}[\'\\] YY_OBS_GROW; + <> unexpected_end_of_file (yylloc, "'"); } @@ -483,10 +482,9 @@ splice (\\[ \f\t\v]*\n)* { - "\"" YY_OBS_GROW; BEGIN c_context; - \\{splice}[^\[\]] YY_OBS_GROW; - {splice} YY_OBS_GROW; - <> unexpected_end_of_file (*yylloc, "\""); + "\"" YY_OBS_GROW; BEGIN c_context; + \\{splice}[\"\\] YY_OBS_GROW; + <> unexpected_end_of_file (yylloc, "\""); } @@ -534,7 +532,7 @@ splice (\\[ \f\t\v]*\n)* "@"(-?[0-9]+|"$") { handle_at (current_braced_code, yytext, *yylloc); } - <> unexpected_end_of_file (*yylloc, "}"); + <> unexpected_end_of_file (yylloc, "}"); } @@ -551,7 +549,7 @@ splice (\\[ \f\t\v]*\n)* return PROLOGUE; } - <> unexpected_end_of_file (*yylloc, "%}"); + <> unexpected_end_of_file (yylloc, "%}"); } @@ -578,8 +576,10 @@ splice (\\[ \f\t\v]*\n)* { - \[ obstack_sgrow (&string_obstack, "@<:@"); - \] obstack_sgrow (&string_obstack, "@:>@"); + \$ obstack_sgrow (&string_obstack, "$]["); + \@ obstack_sgrow (&string_obstack, "@@"); + \[ obstack_sgrow (&string_obstack, "@{"); + \] obstack_sgrow (&string_obstack, "@}"); .|\n YY_OBS_GROW; } @@ -842,13 +842,18 @@ handle_syncline (char *args, location_t *location) `-------------------------------------------------------------*/ static void -unexpected_end_of_file (location_t loc, char const *token_end) +unexpected_end_of_file (location_t *loc, char const *token_end) { - size_t i; + size_t i = strlen (token_end); - complain_at (loc, _("missing `%s' at end of file"), token_end); - for (i = strlen (token_end); i != 0; i--) - unput (token_end[i - 1]); + complain_at (*loc, _("missing `%s' at end of file"), token_end); + + /* Adjust location's last column so that any later message does not + mention the characters just inserted. */ + loc->last_column -= i; + + while (i != 0) + unput (token_end[--i]); }