* src/reader.h, src/reader.c (symbol_list, symbol_list_new)

(symbol_list_prepend, get_type_name): Move to...
* src/symlist.h, src/symlist.c (symbol_list_t, symbol_list_new)
(symbol_list_prepend, symbol_list_n_type_name_get): here.
Adjust all callers.
(symbol_list_free): New.
* src/scan-gram.l (handle_dollar): Takes a location.
* tests/input.at (Invalid $n): Adjust.
This commit is contained in:
Akim Demaille
2002-06-17 07:04:49 +00:00
parent 1e0bab9276
commit 56c4720342
12 changed files with 298 additions and 196 deletions

View File

@@ -80,7 +80,7 @@ scanner_last_string_free (void)
static int braces_level = 0;
static int percent_percent_count = 0;
static void handle_dollar PARAMS ((char *cp));
static void handle_dollar PARAMS ((char *cp, location_t location));
static void handle_at PARAMS ((char *cp));
%}
@@ -441,7 +441,7 @@ blanks [ \t\f]+
"{" YY_OBS_GROW; braces_level++;
"$"("<"[^>]+">")?(-?[0-9]+|"$") { handle_dollar (yytext); }
"$"("<"[^>]+">")?(-?[0-9]+|"$") { handle_dollar (yytext, *yylloc); }
"@"(-?[0-9]+|"$") { handle_at (yytext); }
[^$@\[\]/\'\"\{\}\n\r]+ YY_OBS_GROW;
@@ -520,7 +520,7 @@ blanks [ \t\f]+
`------------------------------------------------------------------*/
static void
handle_dollar (char *cp)
handle_dollar (char *cp, location_t location)
{
const char *type_name = NULL;
@@ -529,7 +529,7 @@ handle_dollar (char *cp)
stack. It is not the same as the rule->length in the case of mid
rule actions. */
int rule_length = 0;
symbol_list *rhs;
symbol_list_t *rhs;
for (rhs = current_rule->next; rhs; rhs = rhs->next)
++rule_length;
@@ -548,10 +548,10 @@ handle_dollar (char *cp)
if (*cp == '$')
{
if (!type_name)
type_name = get_type_name (0, current_rule);
type_name = symbol_list_n_type_name_get (current_rule, location, 0);
if (!type_name && typed)
complain (_("$$ of `%s' has no declared type"),
current_rule->sym->tag);
complain_at (location, _("$$ of `%s' has no declared type"),
current_rule->sym->tag);
if (!type_name)
type_name = "";
obstack_fgrow1 (&string_obstack,
@@ -562,13 +562,14 @@ handle_dollar (char *cp)
int n = strtol (cp, &cp, 10);
if (n > rule_length)
complain (_("invalid value: %s%d"), "$", n);
complain_at (location, _("invalid value: %s%d"), "$", n);
else
{
if (!type_name && n > 0)
type_name = get_type_name (n, current_rule);
type_name = symbol_list_n_type_name_get (current_rule, location,
n);
if (!type_name && typed)
complain (_("$%d of `%s' has no declared type"),
complain_at (location, _("$%d of `%s' has no declared type"),
n, current_rule->sym->tag);
if (!type_name)
type_name = "";
@@ -598,7 +599,7 @@ handle_at (char *cp)
stack. It is not the same as the rule->length in the case of mid
rule actions. */
int rule_length = 0;
symbol_list *rhs;
symbol_list_t *rhs;
for (rhs = current_rule->next; rhs; rhs = rhs->next)
++rule_length;