#include "mbswidth.h"
#include "complain.h"
#include "quote.h"
+#include "struniq.h"
#include "getargs.h"
#include "gram.h"
#include "reader.h"
#define YY_USER_INIT \
do { \
LOCATION_RESET (*yylloc); \
- yylloc->file = infile; \
+ yylloc->file = current_file; \
/* This is only to avoid GCC warnings. */ \
if (yycontrol) {;}; \
} while (0)
static struct obstack string_obstack;
+/* A string representing the most recently saved token. */
+static char *last_string;
+
+
#define YY_OBS_GROW \
obstack_grow (&string_obstack, yytext, yyleng)
#define YY_OBS_FREE \
obstack_free (&string_obstack, last_string)
+void
+scanner_last_string_free (void)
+{
+ YY_OBS_FREE;
+}
/* Within well-formed rules, RULE_LENGTH is the number of values in
the current rule so far, which says where to find `$0' with respect
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
/* Scanner context when scanning C code. */
int c_context IF_LINT (= 0);
- /* A string representing the most recently saved token. */
- char *last_string;
-
/* At each yylex invocation, mark the current position as the
start of the next token. */
YY_STEP;
"<"{tag}">" {
obstack_grow (&string_obstack, yytext + 1, yyleng - 2);
YY_OBS_FINISH;
- yylval->string = last_string;
+ yylval->struniq = struniq_new (last_string);
+ YY_OBS_FREE;
return TYPE;
}
}
.|\n ;
- <<EOF>> unexpected_end_of_file (*yylloc, "*/");
+ <<EOF>> unexpected_end_of_file (yylloc, "*/");
}
<SC_COMMENT>
{
"*"{splice}"/" YY_OBS_GROW; BEGIN c_context;
- <<EOF>> unexpected_end_of_file (*yylloc, "*/");
+ <<EOF>> unexpected_end_of_file (yylloc, "*/");
}
}
.|\n YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (*yylloc, "\"");
+ <<EOF>> unexpected_end_of_file (yylloc, "\"");
}
/*---------------------------------------------------------------.
}
.|\n YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (*yylloc, "'");
+ <<EOF>> unexpected_end_of_file (yylloc, "'");
}
<SC_CHARACTER>
{
- "'" YY_OBS_GROW; BEGIN c_context;
- \\{splice}[^\[\]] YY_OBS_GROW;
- {splice} YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (*yylloc, "'");
+ "'" YY_OBS_GROW; BEGIN c_context;
+ \\{splice}[\'\\] YY_OBS_GROW;
+ <<EOF>> unexpected_end_of_file (yylloc, "'");
}
<SC_STRING>
{
- "\"" YY_OBS_GROW; BEGIN c_context;
- \\{splice}[^\[\]] YY_OBS_GROW;
- {splice} YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (*yylloc, "\"");
+ "\"" YY_OBS_GROW; BEGIN c_context;
+ \\{splice}[\"\\] YY_OBS_GROW;
+ <<EOF>> unexpected_end_of_file (yylloc, "\"");
}
"@"(-?[0-9]+|"$") { handle_at (current_braced_code,
yytext, *yylloc); }
- <<EOF>> unexpected_end_of_file (*yylloc, "}");
+ <<EOF>> unexpected_end_of_file (yylloc, "}");
}
return PROLOGUE;
}
- <<EOF>> unexpected_end_of_file (*yylloc, "%}");
+ <<EOF>> unexpected_end_of_file (yylloc, "%}");
}
<SC_COMMENT,SC_LINE_COMMENT,SC_STRING,SC_CHARACTER,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>
{
- \[ 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;
}
const char *file = NULL;
file = strchr (args, '"') + 1;
*strchr (file, '"') = 0;
- /* FIXME: Leaking... Can't free, as some locations are still
- pointing to the old file name. */
- infile = xstrdup (file);
- location->file = infile;
+ current_file = xstrdup (file);
+ location->file = current_file;
location->last_line = lineno;
}
`-------------------------------------------------------------*/
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);
+
+ /* Adjust location's last column so that any later message does not
+ mention the characters just inserted. */
+ loc->last_column -= i;
- complain_at (loc, _("missing `%s' at end of file"), token_end);
- for (i = strlen (token_end); i != 0; i--)
- unput (token_end[i - 1]);
+ while (i != 0)
+ unput (token_end[--i]);
}