41 |
`---------------------------------*/ |
`---------------------------------*/ |
42 |
|
|
43 |
static symbol_t * |
static symbol_t * |
44 |
symbol_new (const char *tag) |
symbol_new (const char *tag, location_t location) |
45 |
{ |
{ |
46 |
symbol_t *res = XMALLOC (symbol_t, 1); |
symbol_t *res = XMALLOC (symbol_t, 1); |
47 |
|
|
48 |
res->tag = xstrdup (tag); |
res->tag = xstrdup (tag); |
49 |
res->type_name = NULL; |
res->type_name = NULL; |
50 |
|
res->location = location; |
51 |
res->number = NUMBER_UNDEFINED; |
res->number = NUMBER_UNDEFINED; |
52 |
res->prec = 0; |
res->prec = 0; |
53 |
res->assoc = right_assoc; |
res->assoc = right_assoc; |
171 |
{ |
{ |
172 |
if (this->class == unknown_sym) |
if (this->class == unknown_sym) |
173 |
{ |
{ |
174 |
complain |
complain_at |
175 |
(_("symbol %s is used, but is not defined as a token and has no rules"), |
(this->location, |
176 |
|
_("symbol %s is used, but is not defined as a token and has no rules"), |
177 |
this->tag); |
this->tag); |
178 |
this->class = nterm_sym; |
this->class = nterm_sym; |
179 |
this->number = nvars++; |
this->number = nvars++; |
365 |
`----------------------------------------------------------------*/ |
`----------------------------------------------------------------*/ |
366 |
|
|
367 |
symbol_t * |
symbol_t * |
368 |
getsym (const char *key) |
getsym (const char *key, location_t location) |
369 |
{ |
{ |
370 |
symbol_t probe; |
symbol_t probe; |
371 |
symbol_t *entry; |
symbol_t *entry; |
376 |
if (!entry) |
if (!entry) |
377 |
{ |
{ |
378 |
/* First insertion in the hash. */ |
/* First insertion in the hash. */ |
379 |
entry = symbol_new (key); |
entry = symbol_new (key, location); |
380 |
hash_insert (symbol_table, entry); |
hash_insert (symbol_table, entry); |
381 |
} |
} |
382 |
return entry; |
return entry; |
490 |
symbols_token_translations_init (); |
symbols_token_translations_init (); |
491 |
|
|
492 |
if (startsymbol->class == unknown_sym) |
if (startsymbol->class == unknown_sym) |
493 |
fatal (_("the start symbol %s is undefined"), startsymbol->tag); |
fatal_at (startsymbol_location, |
494 |
|
_("the start symbol %s is undefined"), startsymbol->tag); |
495 |
else if (startsymbol->class == token_sym) |
else if (startsymbol->class == token_sym) |
496 |
fatal (_("the start symbol %s is a token"), startsymbol->tag); |
fatal_at (startsymbol_location, |
497 |
|
_("the start symbol %s is a token"), startsymbol->tag); |
498 |
} |
} |