diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2020-02-20 18:11:29 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2020-09-27 09:23:51 +0200 |
commit | 8eaddf326b640c820116af0318c4f240e6d18a21 (patch) | |
tree | 652963410d42df2ea91e929d46d1846f84ba3d89 /TODO | |
parent | db68f61595e021c845e6d384ca71beaad0350f96 (diff) | |
download | bison-8eaddf326b640c820116af0318c4f240e6d18a21.tar.gz |
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.
Diffstat (limited to 'TODO')
-rw-r--r-- | TODO | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -657,6 +657,17 @@ happen with yy_start: stmt | expr). Then adjust the skeletons so that this initial token (YY_START_STMT, YY_START_EXPR) be shifted first in the corresponding parse function. +*** Number of useless symbols +AT_TEST( +[[%start exp; +exp: exp;]], +[[input.y: warning: 2 nonterminals useless in grammar [-Wother] +input.y: warning: 2 rules useless in grammar [-Wother] +input.y:2.8-10: error: start symbol exp does not derive any sentence]]) + +We should say "1 nonterminal": the other one is $accept, which should not +participate in the count. + ** %include This is a popular demand. We already made many changes in the parser that should make this reasonably easy to implement. |