1 /* Symbol table manager for Bison.
3 Copyright (C) 1984, 1989, 2000-2002, 2004-2012 Free Software
6 This file is part of Bison, the GNU Compiler Compiler.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
30 /*-------------------------------------------------------------------.
31 | Symbols sorted by tag. Allocated by the first invocation of |
32 | symbols_do, after which no more symbols should be created. |
33 `-------------------------------------------------------------------*/
35 static symbol
**symbols_sorted
= NULL
;
36 static symbol
**semantic_types_sorted
= NULL
;
38 /*------------------------.
39 | Distinguished symbols. |
40 `------------------------*/
42 symbol
*errtoken
= NULL
;
43 symbol
*undeftoken
= NULL
;
44 symbol
*endtoken
= NULL
;
45 symbol
*accept
= NULL
;
46 symbol
*startsymbol
= NULL
;
47 location startsymbol_location
;
49 /*---------------------------------------.
50 | Default %destructor's and %printer's. |
51 `---------------------------------------*/
53 static code_props default_tagged_code_props
[CODE_PROPS_SIZE
] =
58 static code_props default_tagless_code_props
[CODE_PROPS_SIZE
] =
64 /*---------------------------------.
65 | Create a new symbol, named TAG. |
66 `---------------------------------*/
69 symbol_new (uniqstr tag
, location loc
)
71 symbol
*res
= xmalloc (sizeof *res
);
75 /* If the tag is not a string (starts with a double quote), check
76 that it is valid for Yacc. */
77 if (tag
[0] != '\"' && tag
[0] != '\'' && strchr (tag
, '-'))
78 complain_at (loc
, Wyacc
,
79 _("POSIX Yacc forbids dashes in symbol names: %s"), tag
);
84 res
->type_name
= NULL
;
85 for (int i
= 0; i
< CODE_PROPS_SIZE
; ++i
)
86 code_props_none_init (&res
->props
[i
]);
88 res
->number
= NUMBER_UNDEFINED
;
90 res
->assoc
= undef_assoc
;
91 res
->user_token_number
= USER_NUMBER_UNDEFINED
;
94 res
->class = unknown_sym
;
95 res
->status
= undeclared
;
97 if (nsyms
== SYMBOL_NUMBER_MAXIMUM
)
98 complain (fatal
, _("too many symbols in input grammar (limit is %d)"),
99 SYMBOL_NUMBER_MAXIMUM
);
105 code_props_type_string (code_props_type kind
)
110 return "%destructor";
117 /*----------------------------------------.
118 | Create a new semantic type, named TAG. |
119 `----------------------------------------*/
121 static semantic_type
*
122 semantic_type_new (uniqstr tag
, const location
*loc
)
124 semantic_type
*res
= xmalloc (sizeof *res
);
126 uniqstr_assert (tag
);
129 res
->location
= *loc
;
130 for (int i
= 0; i
< CODE_PROPS_SIZE
; ++i
)
131 code_props_none_init (&res
->props
[i
]);
141 #define SYMBOL_ATTR_PRINT(Attr) \
143 fprintf (f, " %s { %s }", #Attr, s->Attr)
145 #define SYMBOL_CODE_PRINT(Attr) \
146 if (s->props[Attr].code) \
147 fprintf (f, " %s { %s }", #Attr, s->props[Attr].code)
150 symbol_print (symbol
const *s
, FILE *f
)
154 fprintf (f
, "\"%s\"", s
->tag
);
155 SYMBOL_ATTR_PRINT (type_name
);
156 SYMBOL_CODE_PRINT (destructor
);
157 SYMBOL_CODE_PRINT (printer
);
160 fprintf (f
, "<NULL>");
163 #undef SYMBOL_ATTR_PRINT
164 #undef SYMBOL_CODE_PRINT
167 /*----------------------------------.
168 | Whether S is a valid identifier. |
169 `----------------------------------*/
172 is_identifier (uniqstr s
)
174 static char const alphanum
[26 + 26 + 1 + 10] =
175 "abcdefghijklmnopqrstuvwxyz"
176 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
179 if (!s
|| ! memchr (alphanum
, *s
, sizeof alphanum
- 10))
182 if (! memchr (alphanum
, *s
, sizeof alphanum
))
188 /*-----------------------------------------------.
189 | Get the identifier associated to this symbol. |
190 `-----------------------------------------------*/
192 symbol_id_get (symbol
const *sym
)
194 aver (sym
->user_token_number
!= USER_NUMBER_HAS_STRING_ALIAS
);
197 return is_identifier (sym
->tag
) ? sym
->tag
: 0;
201 /*------------------------------------------------------------------.
202 | Complain that S's WHAT is redeclared at SECOND, and was first set |
204 `------------------------------------------------------------------*/
207 symbol_redeclaration (symbol
*s
, const char *what
, location first
,
210 complain_at (second
, complaint
, _("%s redeclaration for %s"), what
, s
->tag
);
211 complain_at (first
, complaint
, _("previous declaration"));
215 semantic_type_redeclaration (semantic_type
*s
, const char *what
, location first
,
218 complain_at (second
, complaint
, _("%s redeclaration for <%s>"), what
, s
->tag
);
219 complain_at (first
, complaint
, _("previous declaration"));
224 /*-----------------------------------------------------------------.
225 | Set the TYPE_NAME associated with SYM. Does nothing if passed 0 |
227 `-----------------------------------------------------------------*/
230 symbol_type_set (symbol
*sym
, uniqstr type_name
, location loc
)
235 symbol_redeclaration (sym
, "%type", sym
->type_location
, loc
);
236 uniqstr_assert (type_name
);
237 sym
->type_name
= type_name
;
238 sym
->type_location
= loc
;
242 /*--------------------------------------------------------.
243 | Set the DESTRUCTOR or PRINTER associated with the SYM. |
244 `--------------------------------------------------------*/
247 symbol_code_props_set (symbol
*sym
, code_props_type kind
,
248 code_props
const *code
)
250 if (sym
->props
[kind
].code
)
251 symbol_redeclaration (sym
, code_props_type_string (kind
),
252 sym
->props
[kind
].location
,
254 sym
->props
[kind
] = *code
;
257 /*-----------------------------------------------------.
258 | Set the DESTRUCTOR or PRINTER associated with TYPE. |
259 `-----------------------------------------------------*/
262 semantic_type_code_props_set (semantic_type
*type
,
263 code_props_type kind
,
264 code_props
const *code
)
266 if (type
->props
[kind
].code
)
267 semantic_type_redeclaration (type
, code_props_type_string (kind
),
268 type
->props
[kind
].location
,
270 type
->props
[kind
] = *code
;
273 /*---------------------------------------------------.
274 | Get the computed %destructor or %printer for SYM. |
275 `---------------------------------------------------*/
278 symbol_code_props_get (symbol
const *sym
,
279 code_props_type kind
)
281 /* Per-symbol code props. */
282 if (sym
->props
[kind
].code
)
283 return &sym
->props
[kind
];
285 /* Per-type code props. */
288 code_props
const *code
=
289 &semantic_type_get (sym
->type_name
, NULL
)->props
[kind
];
294 /* Apply default code props's only to user-defined symbols. */
295 if (sym
->tag
[0] == '$' || sym
== errtoken
)
296 return &code_props_none
;
299 return &default_tagged_code_props
[kind
];
300 return &default_tagless_code_props
[kind
];
303 /*-----------------------------------------------------------------.
304 | Set the PRECEDENCE associated with SYM. Does nothing if invoked |
305 | with UNDEF_ASSOC as ASSOC. |
306 `-----------------------------------------------------------------*/
309 symbol_precedence_set (symbol
*sym
, int prec
, assoc a
, location loc
)
311 if (a
!= undef_assoc
)
314 symbol_redeclaration (sym
, assoc_to_string (a
), sym
->prec_location
,
318 sym
->prec_location
= loc
;
321 /* Only terminals have a precedence. */
322 symbol_class_set (sym
, token_sym
, loc
, false);
326 /*------------------------------------.
327 | Set the CLASS associated with SYM. |
328 `------------------------------------*/
331 symbol_class_set (symbol
*sym
, symbol_class
class, location loc
, bool declaring
)
334 if (sym
->class != unknown_sym
&& sym
->class != class)
336 complain_at (loc
, complaint
, _("symbol %s redefined"), sym
->tag
);
337 // Don't report both "redefined" and "redeclared".
341 if (class == nterm_sym
&& sym
->class != nterm_sym
)
342 sym
->number
= nvars
++;
343 else if (class == token_sym
&& sym
->number
== NUMBER_UNDEFINED
)
344 sym
->number
= ntokens
++;
350 if (sym
->status
== declared
&& !warned
)
351 complain_at (loc
, Wother
, _("symbol %s redeclared"), sym
->tag
);
352 sym
->status
= declared
;
357 /*------------------------------------------------.
358 | Set the USER_TOKEN_NUMBER associated with SYM. |
359 `------------------------------------------------*/
362 symbol_user_token_number_set (symbol
*sym
, int user_token_number
, location loc
)
364 int *user_token_numberp
;
366 if (sym
->user_token_number
!= USER_NUMBER_HAS_STRING_ALIAS
)
367 user_token_numberp
= &sym
->user_token_number
;
369 user_token_numberp
= &sym
->alias
->user_token_number
;
370 if (*user_token_numberp
!= USER_NUMBER_UNDEFINED
371 && *user_token_numberp
!= user_token_number
)
372 complain_at (loc
, complaint
, _("redefining user token number of %s"),
375 *user_token_numberp
= user_token_number
;
376 /* User defined $end token? */
377 if (user_token_number
== 0)
380 /* It is always mapped to 0, so it was already counted in
382 if (endtoken
->number
!= NUMBER_UNDEFINED
)
384 endtoken
->number
= 0;
389 /*----------------------------------------------------------.
390 | If SYM is not defined, report an error, and consider it a |
392 `----------------------------------------------------------*/
395 symbol_check_defined (symbol
*sym
)
397 if (sym
->class == unknown_sym
)
402 complain_at (sym
->location
, Wother
,
403 _("symbol %s is used, but is not defined as a token"
404 " and has no rules"),
409 complain_at (sym
->location
, complaint
,
410 _("symbol %s is used, but is not defined as a token"
411 " and has no rules"),
415 /* If declared, then sym->class != unknown_sym. */
419 sym
->class = nterm_sym
;
420 sym
->number
= nvars
++;
423 for (int i
= 0; i
< 2; ++i
)
424 if (sym
->props
[i
].kind
== CODE_PROPS_NONE
&& sym
->type_name
)
426 semantic_type
*sem_type
= semantic_type_get (sym
->type_name
, NULL
);
428 && sem_type
->props
[i
].kind
!= CODE_PROPS_NONE
)
429 sem_type
->props
[i
].is_used
= true;
432 /* Set the semantic type status associated to the current symbol to
433 'declared' so that we could check semantic types unnecessary uses. */
436 semantic_type
*sem_type
= semantic_type_get (sym
->type_name
, NULL
);
438 sem_type
->status
= declared
;
445 semantic_type_check_defined (semantic_type
*sem_type
)
447 if (sem_type
->status
== declared
)
449 for (int i
= 0; i
< 2; ++i
)
450 if (sem_type
->props
[i
].kind
!= CODE_PROPS_NONE
451 && ! sem_type
->props
[i
].is_used
)
452 complain_at (sem_type
->location
, Wother
,
453 _("useless %s for type <%s>"),
454 code_props_type_string (i
), sem_type
->tag
);
457 complain_at (sem_type
->location
, Wother
,
458 _("type <%s> is used, but is not associated to any symbol"),
465 symbol_check_defined_processor (void *sym
, void *null ATTRIBUTE_UNUSED
)
467 return symbol_check_defined (sym
);
471 semantic_type_check_defined_processor (void *sem_type
,
472 void *null ATTRIBUTE_UNUSED
)
474 return semantic_type_check_defined (sem_type
);
479 symbol_make_alias (symbol
*sym
, symbol
*str
, location loc
)
482 complain_at (loc
, Wother
,
483 _("symbol %s used more than once as a literal string"), str
->tag
);
485 complain_at (loc
, Wother
,
486 _("symbol %s given more than one literal string"), sym
->tag
);
489 str
->class = token_sym
;
490 str
->user_token_number
= sym
->user_token_number
;
491 sym
->user_token_number
= USER_NUMBER_HAS_STRING_ALIAS
;
494 str
->number
= sym
->number
;
495 symbol_type_set (str
, sym
->type_name
, loc
);
500 /*---------------------------------------------------------.
501 | Check that THIS, and its alias, have same precedence and |
503 `---------------------------------------------------------*/
506 symbol_check_alias_consistency (symbol
*this)
509 symbol
*str
= this->alias
;
511 /* Check only the symbol in the symbol-string pair. */
513 && this->user_token_number
== USER_NUMBER_HAS_STRING_ALIAS
))
516 if (str
->type_name
!= sym
->type_name
)
519 symbol_type_set (sym
, str
->type_name
, str
->type_location
);
521 symbol_type_set (str
, sym
->type_name
, sym
->type_location
);
525 for (int i
= 0; i
< CODE_PROPS_SIZE
; ++i
)
526 if (str
->props
[i
].code
)
527 symbol_code_props_set (sym
, i
, &str
->props
[i
]);
528 else if (sym
->props
[i
].code
)
529 symbol_code_props_set (str
, i
, &sym
->props
[i
]);
531 if (sym
->prec
|| str
->prec
)
534 symbol_precedence_set (sym
, str
->prec
, str
->assoc
,
537 symbol_precedence_set (str
, sym
->prec
, sym
->assoc
,
543 symbol_check_alias_consistency_processor (void *this,
544 void *null ATTRIBUTE_UNUSED
)
546 symbol_check_alias_consistency (this);
551 /*-------------------------------------------------------------------.
552 | Assign a symbol number, and write the definition of the token name |
553 | into FDEFINES. Put in SYMBOLS. |
554 `-------------------------------------------------------------------*/
557 symbol_pack (symbol
*this)
559 aver (this->number
!= NUMBER_UNDEFINED
);
560 if (this->class == nterm_sym
)
561 this->number
+= ntokens
;
562 else if (this->user_token_number
== USER_NUMBER_HAS_STRING_ALIAS
)
565 symbols
[this->number
] = this;
570 symbol_pack_processor (void *this, void *null ATTRIBUTE_UNUSED
)
572 return symbol_pack (this);
577 user_token_number_redeclaration (int num
, symbol
*first
, symbol
*second
)
579 /* User token numbers are not assigned during the parsing, but in a
580 second step, via a traversal of the symbol table sorted on tag.
582 However, error messages make more sense if we keep the first
583 declaration first. */
584 if (location_cmp (first
->location
, second
->location
) > 0)
590 complain_at (second
->location
, complaint
,
591 _("user token number %d redeclaration for %s"),
593 complain_at (first
->location
, complaint
, _("previous declaration for %s"),
597 /*--------------------------------------------------.
598 | Put THIS in TOKEN_TRANSLATIONS if it is a token. |
599 `--------------------------------------------------*/
602 symbol_translation (symbol
*this)
605 if (this->class == token_sym
606 && this->user_token_number
!= USER_NUMBER_HAS_STRING_ALIAS
)
608 /* A token which translation has already been set? */
609 if (token_translations
[this->user_token_number
] != undeftoken
->number
)
610 user_token_number_redeclaration
611 (this->user_token_number
,
612 symbols
[token_translations
[this->user_token_number
]],
615 token_translations
[this->user_token_number
] = this->number
;
622 symbol_translation_processor (void *this, void *null ATTRIBUTE_UNUSED
)
624 return symbol_translation (this);
628 /*---------------------------------------.
629 | Symbol and semantic type hash tables. |
630 `---------------------------------------*/
632 /* Initial capacity of symbol and semantic type hash table. */
633 #define HT_INITIAL_CAPACITY 257
635 static struct hash_table
*symbol_table
= NULL
;
636 static struct hash_table
*semantic_type_table
= NULL
;
639 hash_compare_symbol (const symbol
*m1
, const symbol
*m2
)
641 /* Since tags are unique, we can compare the pointers themselves. */
642 return UNIQSTR_EQ (m1
->tag
, m2
->tag
);
646 hash_compare_semantic_type (const semantic_type
*m1
, const semantic_type
*m2
)
648 /* Since names are unique, we can compare the pointers themselves. */
649 return UNIQSTR_EQ (m1
->tag
, m2
->tag
);
653 hash_symbol_comparator (void const *m1
, void const *m2
)
655 return hash_compare_symbol (m1
, m2
);
659 hash_semantic_type_comparator (void const *m1
, void const *m2
)
661 return hash_compare_semantic_type (m1
, m2
);
665 hash_symbol (const symbol
*m
, size_t tablesize
)
667 /* Since tags are unique, we can hash the pointer itself. */
668 return ((uintptr_t) m
->tag
) % tablesize
;
672 hash_semantic_type (const semantic_type
*m
, size_t tablesize
)
674 /* Since names are unique, we can hash the pointer itself. */
675 return ((uintptr_t) m
->tag
) % tablesize
;
679 hash_symbol_hasher (void const *m
, size_t tablesize
)
681 return hash_symbol (m
, tablesize
);
685 hash_semantic_type_hasher (void const *m
, size_t tablesize
)
687 return hash_semantic_type (m
, tablesize
);
690 /*-------------------------------.
691 | Create the symbol hash table. |
692 `-------------------------------*/
697 symbol_table
= hash_initialize (HT_INITIAL_CAPACITY
,
700 hash_symbol_comparator
,
702 semantic_type_table
= hash_initialize (HT_INITIAL_CAPACITY
,
704 hash_semantic_type_hasher
,
705 hash_semantic_type_comparator
,
710 /*----------------------------------------------------------------.
711 | Find the symbol named KEY, and return it. If it does not exist |
713 `----------------------------------------------------------------*/
716 symbol_from_uniqstr (const uniqstr key
, location loc
)
722 entry
= hash_lookup (symbol_table
, &probe
);
726 /* First insertion in the hash. */
727 aver (!symbols_sorted
);
728 entry
= symbol_new (key
, loc
);
729 if (!hash_insert (symbol_table
, entry
))
736 /*-----------------------------------------------------------------------.
737 | Find the semantic type named KEY, and return it. If it does not exist |
739 `-----------------------------------------------------------------------*/
742 semantic_type_from_uniqstr (const uniqstr key
, const location
*loc
)
745 semantic_type
*entry
;
748 entry
= hash_lookup (semantic_type_table
, &probe
);
752 /* First insertion in the hash. */
753 entry
= semantic_type_new (key
, loc
);
754 if (!hash_insert (semantic_type_table
, entry
))
761 /*----------------------------------------------------------------.
762 | Find the symbol named KEY, and return it. If it does not exist |
764 `----------------------------------------------------------------*/
767 symbol_get (const char *key
, location loc
)
769 return symbol_from_uniqstr (uniqstr_new (key
), loc
);
773 /*-----------------------------------------------------------------------.
774 | Find the semantic type named KEY, and return it. If it does not exist |
776 `-----------------------------------------------------------------------*/
779 semantic_type_get (const char *key
, const location
*loc
)
781 return semantic_type_from_uniqstr (uniqstr_new (key
), loc
);
785 /*------------------------------------------------------------------.
786 | Generate a dummy nonterminal, whose name cannot conflict with the |
788 `------------------------------------------------------------------*/
791 dummy_symbol_get (location loc
)
793 /* Incremented for each generated symbol. */
794 static int dummy_count
= 0;
795 static char buf
[256];
799 sprintf (buf
, "$@%d", ++dummy_count
);
800 sym
= symbol_get (buf
, loc
);
801 sym
->class = nterm_sym
;
802 sym
->number
= nvars
++;
807 symbol_is_dummy (const symbol
*sym
)
809 return sym
->tag
[0] == '@' || (sym
->tag
[0] == '$' && sym
->tag
[1] == '@');
812 /*-------------------.
813 | Free the symbols. |
814 `-------------------*/
819 hash_free (symbol_table
);
820 hash_free (semantic_type_table
);
822 free (symbols_sorted
);
826 /*---------------------------------------------------------------.
827 | Look for undefined symbols, report an error, and consider them |
829 `---------------------------------------------------------------*/
832 symbols_cmp (symbol
const *a
, symbol
const *b
)
834 return strcmp (a
->tag
, b
->tag
);
838 symbols_cmp_qsort (void const *a
, void const *b
)
840 return symbols_cmp (*(symbol
* const *)a
, *(symbol
* const *)b
);
844 symbols_do (Hash_processor processor
, void *processor_data
,
845 struct hash_table
*table
, symbol
**sorted
)
847 size_t count
= hash_get_n_entries (table
);
850 sorted
= xnmalloc (count
, sizeof *sorted
);
851 hash_get_entries (table
, (void**)sorted
, count
);
852 qsort (sorted
, count
, sizeof *sorted
, symbols_cmp_qsort
);
856 for (i
= 0; i
< count
; ++i
)
857 processor (sorted
[i
], processor_data
);
861 /*--------------------------------------------------------------.
862 | Check that all the symbols are defined. Report any undefined |
863 | symbols and consider them nonterminals. |
864 `--------------------------------------------------------------*/
867 symbols_check_defined (void)
869 symbols_do (symbol_check_defined_processor
, NULL
,
870 symbol_table
, symbols_sorted
);
871 symbols_do (semantic_type_check_defined_processor
, NULL
,
872 semantic_type_table
, semantic_types_sorted
);
875 /*------------------------------------------------------------------.
876 | Set TOKEN_TRANSLATIONS. Check that no two symbols share the same |
878 `------------------------------------------------------------------*/
881 symbols_token_translations_init (void)
883 bool num_256_available_p
= true;
886 /* Find the highest user token number, and whether 256, the POSIX
887 preferred user token number for the error token, is used. */
888 max_user_token_number
= 0;
889 for (i
= 0; i
< ntokens
; ++i
)
891 symbol
*this = symbols
[i
];
892 if (this->user_token_number
!= USER_NUMBER_UNDEFINED
)
894 if (this->user_token_number
> max_user_token_number
)
895 max_user_token_number
= this->user_token_number
;
896 if (this->user_token_number
== 256)
897 num_256_available_p
= false;
901 /* If 256 is not used, assign it to error, to follow POSIX. */
902 if (num_256_available_p
903 && errtoken
->user_token_number
== USER_NUMBER_UNDEFINED
)
904 errtoken
->user_token_number
= 256;
906 /* Set the missing user numbers. */
907 if (max_user_token_number
< 256)
908 max_user_token_number
= 256;
910 for (i
= 0; i
< ntokens
; ++i
)
912 symbol
*this = symbols
[i
];
913 if (this->user_token_number
== USER_NUMBER_UNDEFINED
)
914 this->user_token_number
= ++max_user_token_number
;
915 if (this->user_token_number
> max_user_token_number
)
916 max_user_token_number
= this->user_token_number
;
919 token_translations
= xnmalloc (max_user_token_number
+ 1,
920 sizeof *token_translations
);
922 /* Initialize all entries for literal tokens to the internal token
923 number for $undefined, which represents all invalid inputs. */
924 for (i
= 0; i
< max_user_token_number
+ 1; i
++)
925 token_translations
[i
] = undeftoken
->number
;
926 symbols_do (symbol_translation_processor
, NULL
,
927 symbol_table
, symbols_sorted
);
931 /*----------------------------------------------------------------.
932 | Assign symbol numbers, and write definition of token names into |
933 | FDEFINES. Set up vectors SYMBOL_TABLE, TAGS of symbols. |
934 `----------------------------------------------------------------*/
939 symbols_do (symbol_check_alias_consistency_processor
, NULL
,
940 symbol_table
, symbols_sorted
);
942 symbols
= xcalloc (nsyms
, sizeof *symbols
);
943 symbols_do (symbol_pack_processor
, NULL
, symbol_table
, symbols_sorted
);
945 /* Aliases leave empty slots in symbols, so remove them. */
949 int nsyms_old
= nsyms
;
950 for (writei
= 0, readi
= 0; readi
< nsyms_old
; readi
+= 1)
952 if (symbols
[readi
] == NULL
)
959 symbols
[writei
] = symbols
[readi
];
960 symbols
[writei
]->number
= writei
;
961 if (symbols
[writei
]->alias
)
962 symbols
[writei
]->alias
->number
= writei
;
967 symbols
= xnrealloc (symbols
, nsyms
, sizeof *symbols
);
969 symbols_token_translations_init ();
971 if (startsymbol
->class == unknown_sym
)
972 complain_at (startsymbol_location
, fatal
,
973 _("the start symbol %s is undefined"),
975 else if (startsymbol
->class == token_sym
)
976 complain_at (startsymbol_location
, fatal
,
977 _("the start symbol %s is a token"),
982 /*--------------------------------------------------.
983 | Set default tagged/tagless %destructor/%printer. |
984 `--------------------------------------------------*/
987 default_tagged_code_props_set (code_props_type kind
, code_props
const *code
)
989 if (default_tagged_code_props
[kind
].code
)
991 complain_at (code
->location
, complaint
,
992 _("redeclaration for default tagged %s"),
993 code_props_type_string (kind
));
994 complain_at (default_tagged_code_props
[kind
].location
, complaint
,
995 _("previous declaration"));
997 default_tagged_code_props
[kind
] = *code
;
1001 default_tagless_code_props_set (code_props_type kind
, code_props
const *code
)
1003 if (default_tagless_code_props
[kind
].code
)
1005 complain_at (code
->location
, complaint
,
1006 _("redeclaration for default tagless %s"),
1007 code_props_type_string (kind
));
1008 complain_at (default_tagless_code_props
[kind
].location
, complaint
,
1009 _("previous declaration"));
1011 default_tagless_code_props
[kind
] = *code
;