mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 13:23:04 +00:00
multistart: turn start symbols into rules on $accept
Now that the parser can read several start symbols, let's process them, and create the corresponding rules. * src/parse-gram.y (grammar_declaration): Accept a list of start symbols. * src/reader.h, src/reader.c (grammar_start_symbol_set): Rename as... (grammar_start_symbols_set): this. * src/reader.h, src/reader.c (start_flag): Replace with... (start_symbols): this. * src/reader.c (grammar_start_symbols_set): Build a list of start symbols. (switching_token, create_start_rules): New. (check_and_convert_grammar): Use them to turn the list of start symbols into a set of rules. * src/reduce.c (nonterminals_reduce): Don't complain about $accept, it's an internal detail. (reduce_grammar): Complain about all the start symbols that don't derive sentences. * src/symtab.c (startsymbol, startsymbol_loc): Remove, replaced by start_symbols. symbols_pack): Move the check about the start symbols to... * src/symlist.c (check_start_symbols): here. Adjust to multiple start symbols. * tests/reduce.at (Empty Language): Generalize into... (Bad start symbols): this.
This commit is contained in:
13
src/reader.h
13
src/reader.h
@@ -38,7 +38,18 @@ typedef struct merger_list
|
||||
void free_merger_functions (void);
|
||||
extern merger_list *merge_functions;
|
||||
|
||||
void grammar_start_symbol_set (symbol *sym, location loc);
|
||||
/* List of the start symbols. */
|
||||
extern symbol_list *start_symbols;
|
||||
|
||||
/* Fetch (or create) a token "YY_PARSE_foo" for start symbol "foo".
|
||||
|
||||
We don't use the simple "YY_FOO" because (i) we might get clashes
|
||||
with some of our symbols (e.g., cast => YY_CAST), and (ii) upcasing
|
||||
introduces possible clashes between terminal FOO and nonterminal
|
||||
foo. */
|
||||
symbol *switching_token (const symbol *start);
|
||||
|
||||
void grammar_start_symbols_set (symbol_list *syms);
|
||||
|
||||
void grammar_current_rule_begin (symbol *lhs, location loc,
|
||||
named_ref *lhs_named_ref);
|
||||
|
||||
Reference in New Issue
Block a user