multistart: check duplicates

* src/symlist.h, src/symlist.c (symbol_list_find_symbol)
(symbol_list_last): New.
(symbol_list_append): Use symbol_list_last.
* src/reader.c (grammar_start_symbols_add): Check and discard duplicates.
* tests/input.at (Duplicate %start symbol): New.
* tests/reduce.at (Bad start symbols): Add the multistart keyword.
This commit is contained in:
Akim Demaille
2020-11-22 11:19:48 +01:00
parent 7fe9205b9f
commit 5b19f91ccf
6 changed files with 137 additions and 15 deletions

View File

@@ -112,6 +112,9 @@ symbol_list *symbol_list_type_new (uniqstr type_name, location loc);
** \returns \c syms */
symbol_list *symbol_list_type_set (symbol_list *syms, uniqstr type_name);
/** Find a symbol with the same content as \c sym within \c syms. */
symbol_list *symbol_list_find_symbol (symbol_list *syms, const symbol *sym);
/** Print this list.
\pre For every node \c n in the list, <tt>n->content_type =
@@ -121,6 +124,9 @@ void symbol_list_syms_print (const symbol_list *l, FILE *f);
/** Prepend \c node to \c list. */
symbol_list *symbol_list_prepend (symbol_list *list, symbol_list *node);
/** The last node of this list. */
symbol_list *symbol_list_last (symbol_list *list);
/** Append \c node to \c list. */
symbol_list *symbol_list_append (symbol_list *list, symbol_list *node);
@@ -136,11 +142,11 @@ int symbol_list_length (symbol_list const *l);
**/
symbol_list *symbol_list_n_get (symbol_list *l, int n);
/* Get the data type (alternative in the union) of the value for
symbol N in rule RULE. */
/** Get the data type (alternative in the union) of the value for
symbol N in rule RULE. */
uniqstr symbol_list_n_type_name_get (symbol_list *l, int n);
/* Check whether the node is a border element of a rule. */
/** Check whether the node is a border element of a rule. */
bool symbol_list_null (symbol_list *node);
/** Set the \c \%destructor or \c \%printer for \c node as \c cprops. */