]> git.saurik.com Git - bison.git/blob - TODO
* src/LR0.c, src/derives.c, src/gram.c, src/gram.h, src/lalr.c,
[bison.git] / TODO
1 -*- outline -*-
2
3 * documentation
4 Explain $axiom (and maybe change its name: BTYacc names it goal).
5 Complete the glossary (item, axiom, ?).
6
7 * report documentation
8 Extend with error. The hard part will probably be finding the right
9 rule so that a single state does not exhibit to many yet undocumented
10 ``features''. Maybe an empty action ought to be presented too. Shall
11 we try to make a single grammar with all these features, or should we
12 have several very small grammars?
13
14 * documentation
15 Some history of Bison and some bibliography would be most welcome.
16 Are there any Texinfo standards for bibliography?
17
18 * Several %unions
19 I think this is a pleasant (but useless currently) feature, but in the
20 future, I want a means to %include other bits of grammars, and _then_
21 it will be important for the various bits to define their needs in
22 %union.
23
24 When implementing multiple-%union support, bare the following in mind:
25
26 - when --yacc, this must be flagged as an error. Don't make it fatal
27 though.
28
29 - The #line must now appear *inside* the definition of yystype.
30 Something like
31
32 {
33 #line 12 "foo.y"
34 int ival;
35 #line 23 "foo.y"
36 char *sval;
37 }
38
39 * --report=conflict-path
40 Provide better assistance for understanding the conflicts by providing
41 a sample text exhibiting the (LALR) ambiguity.
42
43 * report
44 Solved conflicts should not be reported in the beginning of the file.
45 Rather they should be reported within each state description. Also,
46 now that the symbol providing the precedence of a rule is kept, it is
47 possible to explain why a conflict was solved this way. E.g., instead
48 of
49
50 Conflict in state 8 between rule 2 and token '+' resolved as reduce.
51
52 we can (in state 8) report something like
53
54 Conflict between rule 2 and token '+' resolved as reduce
55 because '*' < '+'.
56
57 or something like that.
58
59 * Coding system independence
60 Paul notes:
61
62 Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
63 255). It also assumes that the 8-bit character encoding is
64 the same for the invocation of 'bison' as it is for the
65 invocation of 'cc', but this is not necessarily true when
66 people run bison on an ASCII host and then use cc on an EBCDIC
67 host. I don't think these topics are worth our time
68 addressing (unless we find a gung-ho volunteer for EBCDIC or
69 PDP-10 ports :-) but they should probably be documented
70 somewhere.
71
72 * Output directory
73 Akim:
74
75 | I consider this to be a bug in bison:
76 |
77 | /tmp % mkdir src
78 | /tmp % cp ~/src/bison/tests/calc.y src
79 | /tmp % mkdir build && cd build
80 | /tmp/build % bison ../src/calc.y
81 | /tmp/build % cd ..
82 | /tmp % ls -l build src
83 | build:
84 | total 0
85 |
86 | src:
87 | total 32
88 | -rw-r--r-- 1 akim lrde 27553 oct 2 16:31 calc.tab.c
89 | -rw-r--r-- 1 akim lrde 3335 oct 2 16:31 calc.y
90 |
91 |
92 | Would it be safe to change this behavior to something more reasonable?
93 | Do you think some people depend upon this?
94
95 Jim:
96
97 Is it that behavior documented?
98 If so, then it's probably not reasonable to change it.
99 I've Cc'd the automake list, because some of automake's
100 rules use bison through $(YACC) -- though I'll bet they
101 all use it in yacc-compatible mode.
102
103 Pavel:
104
105 Hello, Jim and others!
106
107 > Is it that behavior documented?
108 > If so, then it's probably not reasonable to change it.
109 > I've Cc'd the automake list, because some of automake's
110 > rules use bison through $(YACC) -- though I'll bet they
111 > all use it in yacc-compatible mode.
112
113 Yes, Automake currently used bison in Automake-compatible mode, but it
114 would be fair for Automake to switch to the native mode as long as the
115 processed files are distributed and "missing" emulates bison.
116
117 In any case, the makefiles should specify the output file explicitly
118 instead of relying on weird defaults.
119
120 > | src:
121 > | total 32
122 > | -rw-r--r-- 1 akim lrde 27553 oct 2 16:31 calc.tab.c
123 > | -rw-r--r-- 1 akim lrde 3335 oct 2 16:31 calc.y
124
125 This is not _that_ ugly as it seems - with Automake you want to put
126 sources where they belong - to the source directory.
127
128 > | This is not _that_ ugly as it seems - with Automake you want to put
129 > | sources where they belong - to the source directory.
130 >
131 > The difference source/build you are referring to is based on Automake
132 > concepts. They have no sense at all for tools such as bison or gcc
133 > etc. They have input and output. I do not want them to try to grasp
134 > source/build. I want them to behave uniformly: output *here*.
135
136 I realize that.
137
138 It's unfortunate that the native mode of Bison behaves in a less uniform
139 way than the yacc mode. I agree with your point. Bison maintainters may
140 want to fix it along with the documentation.
141
142
143 * Unit rules
144 Maybe we could expand unit rules, i.e., transform
145
146 exp: arith | bool;
147 arith: exp '+' exp;
148 bool: exp '&' exp;
149
150 into
151
152 exp: exp '+' exp | exp '&' exp;
153
154 when there are no actions. This can significantly speed up some
155 grammars.
156
157 * Stupid error messages
158 An example shows it easily:
159
160 src/bison/tests % ./testsuite -k calc,location,error-verbose -l
161 GNU Bison 1.49a test suite test groups:
162
163 NUM: FILENAME:LINE TEST-GROUP-NAME
164 KEYWORDS
165
166 51: calc.at:440 Calculator --locations --yyerror-verbose
167 52: calc.at:442 Calculator --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose
168 54: calc.at:445 Calculator --debug --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose
169 src/bison/tests % ./testsuite 51 -d
170 ## --------------------------- ##
171 ## GNU Bison 1.49a test suite. ##
172 ## --------------------------- ##
173 51: calc.at:440 ok
174 ## ---------------------------- ##
175 ## All 1 tests were successful. ##
176 ## ---------------------------- ##
177 src/bison/tests % cd ./testsuite.dir/51
178 tests/testsuite.dir/51 % echo "()" | ./calc
179 1.2-1.3: parse error, unexpected ')', expecting error or "number" or '-' or '('
180
181 * yyerror, yyprint interface
182 It should be improved, in particular when using Bison features such as
183 locations, and YYPARSE_PARAMS. For the time being, it is recommended
184 to #define yyerror and yyprint to steal internal variables...
185
186 * read_pipe.c
187 This is not portable to DOS for instance. Implement a more portable
188 scheme. Sources of inspiration include GNU diff, and Free Recode.
189
190 * Memory leaks in the generator
191 A round of memory leak clean ups would be most welcome. Dmalloc,
192 Checker GCC, Electric Fence, or Valgrind: you chose your tool.
193
194 * Memory leaks in the parser
195 The same applies to the generated parsers. In particular, this is
196 critical for user data: when aborting a parsing, when handling the
197 error token etc., we often throw away yylval without giving a chance
198 of cleaning it up to the user.
199
200 * --graph
201 Show reductions. []
202
203 * Broken options ?
204 ** %no-lines [ok]
205 ** %no-parser []
206 ** %pure-parser []
207 ** %token-table []
208 ** Options which could use parse_dquoted_param ().
209 Maybe transfered in lex.c.
210 *** %skeleton [ok]
211 *** %output []
212 *** %file-prefix []
213 *** %name-prefix []
214
215 ** Skeleton strategy. []
216 Must we keep %no-parser?
217 %token-table?
218 *** New skeletons. []
219
220 * src/print_graph.c
221 Find the best graph parameters. []
222
223 * doc/bison.texinfo
224 ** Update
225 informations about ERROR_VERBOSE. []
226 ** Add explainations about
227 skeleton muscles. []
228 %skeleton. []
229
230 * testsuite
231 ** tests/pure-parser.at []
232 New tests.
233
234 * Debugging parsers
235
236 From Greg McGary:
237
238 akim demaille <akim.demaille@epita.fr> writes:
239
240 > With great pleasure! Nonetheless, things which are debatable
241 > (or not, but just `big') should be discuss in `public': something
242 > like help- or bug-bison@gnu.org is just fine. Jesse and I are there,
243 > but there is also Jim and some other people.
244
245 I have no idea whether it qualifies as big or controversial, so I'll
246 just summarize for you. I proposed this change years ago and was
247 surprised that it was met with utter indifference!
248
249 This debug feature is for the programs/grammars one develops with
250 bison, not for debugging bison itself. I find that the YYDEBUG
251 output comes in a very inconvenient format for my purposes.
252 When debugging gcc, for instance, what I want is to see a trace of
253 the sequence of reductions and the line#s for the semantic actions
254 so I can follow what's happening. Single-step in gdb doesn't cut it
255 because to move from one semantic action to the next takes you through
256 lots of internal machinery of the parser, which is uninteresting.
257
258 The change I made was to the format of the debug output, so that it
259 comes out in the format of C error messages, digestible by emacs
260 compile mode, like so:
261
262 grammar.y:1234: foo: bar(0x123456) baz(0x345678)
263
264 where "foo: bar baz" is the reduction rule, whose semantic action
265 appears on line 1234 of the bison grammar file grammar.y. The hex
266 numbers on the rhs tokens are the parse-stack values associated with
267 those tokens. Of course, yytype might be something totally
268 incompatible with that representation, but for the most part, yytype
269 values are single words (scalars or pointers). In the case of gcc,
270 they're most often pointers to tree nodes. Come to think of it, the
271 right thing to do is to make the printing of stack values be
272 user-definable. It would also be useful to include the filename &
273 line# of the file being parsed, but the main filename & line# should
274 continue to be that of grammar.y
275
276 Anyway, this feature has saved my life on numerous occasions. The way
277 I customarily use it is to first run bison with the traces on, isolate
278 the sequence of reductions that interests me, put those traces in a
279 buffer and force it into compile-mode, then visit each of those lines
280 in the grammar and set breakpoints with C-x SPACE. Then, I can run
281 again under the control of gdb and stop at each semantic action.
282 With the hex addresses of tree nodes, I can inspect the values
283 associated with any rhs token.
284
285 You like?
286
287 * input synclines
288 Some users create their foo.y files, and equip them with #line. Bison
289 should recognize these, and preserve them.
290
291 * BTYacc
292 See if we can integrate backtracking in Bison. Contact the BTYacc
293 maintainers.
294
295 * Automaton report
296 Display more clearly the lookaheads for each item.
297
298 * RR conflicts
299 See if we can use precedence between rules to solve RR conflicts. See
300 what POSIX says.
301
302 * Precedence
303 It is unfortunate that there is a total order for precedence. It
304 makes it impossible to have modular precedence information. We should
305 move to partial orders.
306
307 This will be possible with a Bison parser for the grammar, as it will
308 make it much easier to extend the grammar.
309
310 * Parsing grammars
311 Rewrite the reader in Flex/Bison. There will be delicate parts, in
312 particular, expect the scanner to be hard to write. Many interesting
313 features cannot be implemented without such a new reader.
314
315 * Presentation of the report file
316 From: "Baum, Nathan I" <s0009525@chelt.ac.uk>
317 Subject: Token Alias Bug
318 To: "'bug-bison@gnu.org'" <bug-bison@gnu.org>
319
320 I've also noticed something, that whilst not *wrong*, is inconvienient: I
321 use the verbose mode to help find the causes of unresolved shift/reduce
322 conflicts. However, this mode insists on starting the .output file with a
323 list of *resolved* conflicts, something I find quite useless. Might it be
324 possible to define a -v mode, and a -vv mode -- Where the -vv mode shows
325 everything, but the -v mode only tells you what you need for examining
326 conflicts? (Or, perhaps, a "*** This state has N conflicts ***" marker above
327 each state with conflicts.)
328
329 * $undefined
330 From Hans:
331 - If the Bison generated parser experiences an undefined number in the
332 character range, that character is written out in diagnostic messages, an
333 addition to the $undefined value.
334
335 Suggest: Change the name $undefined to undefined; looks better in outputs.
336
337 * Default Action
338 From Hans:
339 - For use with my C++ parser, I transported the "switch (yyn)" statement
340 that Bison writes to the bison.simple skeleton file. This way, I can remove
341 the current default rule $$ = $1 implementation, which causes a double
342 assignment to $$ which may not be OK under C++, replacing it with a
343 "default:" part within the switch statement.
344
345 Note that the default rule $$ = $1, when typed, is perfectly OK under C,
346 but in the C++ implementation I made, this rule is different from
347 $<type_name>$ = $<type_name>1. I therefore think that one should implement
348 a Bison option where every typed default rule is explicitly written out
349 (same typed ruled can of course be grouped together).
350
351 Note: Robert Anisko handles this. He knows how to do it.
352
353 * Documenting C++ output
354 Write a first documentation for C++ output.
355
356 * Warnings
357 It would be nice to have warning support. See how Autoconf handles
358 them, it is fairly well described there. It would be very nice to
359 implement this in such a way that other programs could use
360 lib/warnings.[ch].
361
362 Don't work on this without first announcing you do, as I already have
363 thought about it, and know many of the components that can be used to
364 implement it.
365
366 * Pre and post actions.
367 From: Florian Krohm <florian@edamail.fishkill.ibm.com>
368 Subject: YYACT_EPILOGUE
369 To: bug-bison@gnu.org
370 X-Sent: 1 week, 4 days, 14 hours, 38 minutes, 11 seconds ago
371
372 The other day I had the need for explicitly building the parse tree. I
373 used %locations for that and defined YYLLOC_DEFAULT to call a function
374 that returns the tree node for the production. Easy. But I also needed
375 to assign the S-attribute to the tree node. That cannot be done in
376 YYLLOC_DEFAULT, because it is invoked before the action is executed.
377 The way I solved this was to define a macro YYACT_EPILOGUE that would
378 be invoked after the action. For reasons of symmetry I also added
379 YYACT_PROLOGUE. Although I had no use for that I can envision how it
380 might come in handy for debugging purposes.
381 All is needed is to add
382
383 #if YYLSP_NEEDED
384 YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen, yyloc, (yylsp - yylen));
385 #else
386 YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen);
387 #endif
388
389 at the proper place to bison.simple. Ditto for YYACT_PROLOGUE.
390
391 I was wondering what you think about adding YYACT_PROLOGUE/EPILOGUE
392 to bison. If you're interested, I'll work on a patch.
393
394 -----
395
396 Copyright (C) 2001, 2002 Free Software Foundation, Inc.
397
398 This file is part of GNU Autoconf.
399
400 GNU Autoconf is free software; you can redistribute it and/or modify
401 it under the terms of the GNU General Public License as published by
402 the Free Software Foundation; either version 2, or (at your option)
403 any later version.
404
405 GNU Autoconf is distributed in the hope that it will be useful,
406 but WITHOUT ANY WARRANTY; without even the implied warranty of
407 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
408 GNU General Public License for more details.
409
410 You should have received a copy of the GNU General Public License
411 along with autoconf; see the file COPYING. If not, write to
412 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
413 Boston, MA 02111-1307, USA.