]> git.saurik.com Git - bison.git/blob - TODO
Don't let maintainer-*-check targets force a version update.
[bison.git] / TODO
1 -*- outline -*-
2
3 * Short term
4 ** Document %define assert
5
6 ** Discuss about %printer/%destroy in the case of C++.
7 It would be very nice to provide the symbol classes with an operator<<
8 and a destructor. Unfortunately the syntax we have chosen for
9 %destroy and %printer make them hard to reuse. For instance, the user
10 is invited to write something like
11
12 %printer { debug_stream() << $$; } <my_type>;
13
14 which is hard to reuse elsewhere since it wants to use
15 "debug_stream()" to find the stream to use. The same applies to
16 %destroy: we told the user she could use the members of the Parser
17 class in the printers/destructors, which is not good for an operator<<
18 since it is no longer bound to a particular parser, it's just a
19 (standalone symbol).
20
21 ** Rename LR0.cc
22 as lr0.cc, why upper case?
23
24 ** bench several bisons.
25 Enhance bench.pl with %b to run different bisons.
26
27 ** Use b4_symbol everywhere.
28 Move its definition in the more standard places and deploy it in other
29 skeletons.
30
31 * Various
32 ** YYPRINT
33 glr.c inherits its symbol_print function from c.m4, which supports
34 YYPRINT. But to use YYPRINT yytoknum is needed, which not defined by
35 glr.c.
36
37 Anyway, IMHO YYPRINT is obsolete and should be restricted to yacc.c.
38
39 ** YYERRCODE
40 Defined to 256, but not used, not documented. Probably the token
41 number for the error token, which POSIX wants to be 256, but which
42 Bison might renumber if the user used number 256. Keep fix and doc?
43 Throw away?
44
45 We could (should?) also treat the case of the undef_token, which is
46 numbered 257 for yylex, and 2 internal. Both appear for instance in
47 toknum:
48
49 const unsigned short int
50 parser::yytoken_number_[] =
51 {
52 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
53
54 while here
55
56 enum yytokentype {
57 TOK_EOF = 0,
58 TOK_EQ = 258,
59
60 so both 256 and 257 are "mysterious".
61
62 const char*
63 const parser::yytname_[] =
64 {
65 "\"end of command\"", "error", "$undefined", "\"=\"", "\"break\"",
66
67
68 ** YYFAIL
69 It is seems to be *really* obsolete now, shall we remove it?
70
71 ** YYBACKUP
72 There is no test about it, no examples in the doc, and I'm not sure
73 what it should look like. For instance what follows crashes.
74
75 %error-verbose
76 %debug
77 %pure-parser
78 %code {
79 # include <stdio.h>
80 # include <stdlib.h>
81 # include <assert.h>
82
83 static void yyerror (const char *msg);
84 static int yylex (YYSTYPE *yylval);
85 }
86 %%
87 exp:
88 'a' { printf ("a: %d\n", $1); }
89 | 'b' { YYBACKUP('a', 123); }
90 ;
91 %%
92 static int
93 yylex (YYSTYPE *yylval)
94 {
95 static char const input[] = "b";
96 static size_t toknum;
97 assert (toknum < sizeof input);
98 *yylval = (toknum + 1) * 10;
99 return input[toknum++];
100 }
101
102 static void
103 yyerror (const char *msg)
104 {
105 fprintf (stderr, "%s\n", msg);
106 }
107
108 int
109 main (void)
110 {
111 yydebug = !!getenv("YYDEBUG");
112 return yyparse ();
113 }
114
115 ** yychar == yyempty_
116 The code in yyerrlab reads:
117
118 if (yychar <= YYEOF)
119 {
120 /* Return failure if at end of input. */
121 if (yychar == YYEOF)
122 YYABORT;
123 }
124
125 There are only two yychar that can be <= YYEOF: YYEMPTY and YYEOF.
126 But I can't produce the situation where yychar is YYEMPTY here, is it
127 really possible? The test suite does not exercise this case.
128
129 This shows that it would be interesting to manage to install skeleton
130 coverage analysis to the test suite.
131
132 ** Table definitions
133 It should be very easy to factor the definition of the various tables,
134 including the separation bw declaration and definition. See for
135 instance b4_table_define in lalr1.cc. This way, we could even factor
136 C vs. C++ definitions.
137
138 * From lalr1.cc to yacc.c
139 ** Single stack
140 Merging the three stacks in lalr1.cc simplified the code, prompted for
141 other improvements and also made it faster (probably because memory
142 management is performed once instead of three times). I suggest that
143 we do the same in yacc.c.
144
145 ** yysyntax_error
146 In lalr1.cc we invoke it with the translated lookahead (yytoken), and
147 yacc.c uses yychar. I don't see why.
148
149 ** yysyntax_error
150 The use of switch to select yyfmt in lalr1.cc seems simpler than
151 what's done in yacc.c.
152
153 * Header guards
154
155 From Franc,ois: should we keep the directory part in the CPP guard?
156
157
158 * Yacc.c: CPP Macros
159
160 Do some people use YYPURE, YYLSP_NEEDED like we do in the test suite?
161 They should not: it is not documented. But if they need to, let's
162 find something clean (not like YYLSP_NEEDED...).
163
164
165 * Installation
166
167 * Documentation
168 Before releasing, make sure the documentation ("Understanding your
169 parser") refers to the current `output' format.
170
171 * Report
172
173 ** GLR
174 How would Paul like to display the conflicted actions? In particular,
175 what when two reductions are possible on a given lookahead token, but one is
176 part of $default. Should we make the two reductions explicit, or just
177 keep $default? See the following point.
178
179 ** Disabled Reductions
180 See `tests/conflicts.at (Defaulted Conflicted Reduction)', and decide
181 what we want to do.
182
183 ** Documentation
184 Extend with error productions. The hard part will probably be finding
185 the right rule so that a single state does not exhibit too many yet
186 undocumented ``features''. Maybe an empty action ought to be
187 presented too. Shall we try to make a single grammar with all these
188 features, or should we have several very small grammars?
189
190 ** --report=conflict-path
191 Provide better assistance for understanding the conflicts by providing
192 a sample text exhibiting the (LALR) ambiguity. See the paper from
193 DeRemer and Penello: they already provide the algorithm.
194
195 ** Statically check for potential ambiguities in GLR grammars. See
196 <http://www.i3s.unice.fr/~schmitz/papers.html#expamb> for an approach.
197
198
199 * Extensions
200
201 ** Labeling the symbols
202 Have a look at the Lemon parser generator: instead of $1, $2 etc. they
203 can name the values. This is much more pleasant. For instance:
204
205 exp (res): exp (a) '+' exp (b) { $res = $a + $b; };
206
207 I love this. I have been bitten too often by the removal of the
208 symbol, and forgetting to shift all the $n to $n-1. If you are
209 unlucky, it compiles...
210
211 But instead of using $a etc., we can use regular variables. And
212 instead of using (), I propose to use `:' (again). Paul suggests
213 supporting `->' in addition to `:' to separate LHS and RHS. In other
214 words:
215
216 r:exp -> a:exp '+' b:exp { r = a + b; };
217
218 That requires an significant improvement of the grammar parser. Using
219 GLR would be nice. It also requires that Bison know the type of the
220 symbols (which will be useful for %include anyway). So we have some
221 time before...
222
223 Note that there remains the problem of locations: `@r'?
224
225
226 ** $-1
227 We should find a means to provide an access to values deep in the
228 stack. For instance, instead of
229
230 baz: qux { $$ = $<foo>-1 + $<bar>0 + $1; }
231
232 we should be able to have:
233
234 foo($foo) bar($bar) baz($bar): qux($qux) { $baz = $foo + $bar + $qux; }
235
236 Or something like this.
237
238 ** %if and the like
239 It should be possible to have %if/%else/%endif. The implementation is
240 not clear: should it be lexical or syntactic. Vadim Maslow thinks it
241 must be in the scanner: we must not parse what is in a switched off
242 part of %if. Akim Demaille thinks it should be in the parser, so as
243 to avoid falling into another CPP mistake.
244
245 ** XML Output
246 There are couple of available extensions of Bison targeting some XML
247 output. Some day we should consider including them. One issue is
248 that they seem to be quite orthogonal to the parsing technique, and
249 seem to depend mostly on the possibility to have some code triggered
250 for each reduction. As a matter of fact, such hooks could also be
251 used to generate the yydebug traces. Some generic scheme probably
252 exists in there.
253
254 XML output for GNU Bison and gcc
255 http://www.cs.may.ie/~jpower/Research/bisonXML/
256
257 XML output for GNU Bison
258 http://yaxx.sourceforge.net/
259
260 * Unit rules
261 Maybe we could expand unit rules, i.e., transform
262
263 exp: arith | bool;
264 arith: exp '+' exp;
265 bool: exp '&' exp;
266
267 into
268
269 exp: exp '+' exp | exp '&' exp;
270
271 when there are no actions. This can significantly speed up some
272 grammars. I can't find the papers. In particular the book `LR
273 parsing: Theory and Practice' is impossible to find, but according to
274 `Parsing Techniques: a Practical Guide', it includes information about
275 this issue. Does anybody have it?
276
277
278
279 * Documentation
280
281 ** History/Bibliography
282 Some history of Bison and some bibliography would be most welcome.
283 Are there any Texinfo standards for bibliography?
284
285
286
287 * Java, Fortran, etc.
288
289
290 * Coding system independence
291 Paul notes:
292
293 Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
294 255). It also assumes that the 8-bit character encoding is
295 the same for the invocation of 'bison' as it is for the
296 invocation of 'cc', but this is not necessarily true when
297 people run bison on an ASCII host and then use cc on an EBCDIC
298 host. I don't think these topics are worth our time
299 addressing (unless we find a gung-ho volunteer for EBCDIC or
300 PDP-10 ports :-) but they should probably be documented
301 somewhere.
302
303 More importantly, Bison does not currently allow NUL bytes in
304 tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
305 the source code. This should get fixed.
306
307 * --graph
308 Show reductions.
309
310 * Broken options ?
311 ** %token-table
312 ** Skeleton strategy
313 Must we keep %token-table?
314
315 * BTYacc
316 See if we can integrate backtracking in Bison. Charles-Henri de
317 Boysson <de-boy_c@epita.fr> has been working on this, but never gave
318 the results.
319
320 Vadim Maslow, the maintainer of BTYacc was once contacted. Adjusting
321 the Bison grammar parser will be needed to support some extra BTYacc
322 features. This is less urgent.
323
324 ** Keeping the conflicted actions
325 First, analyze the differences between byacc and btyacc (I'm referring
326 to the executables). Find where the conflicts are preserved.
327
328 ** Compare with the GLR tables
329 See how isomorphic the way BTYacc and the way the GLR adjustments in
330 Bison are compatible. *As much as possible* one should try to use the
331 same implementation in the Bison executables. I insist: it should be
332 very feasible to use the very same conflict tables.
333
334 ** Adjust the skeletons
335 Import the skeletons for C and C++.
336
337
338 * Precedence
339
340 ** Partial order
341 It is unfortunate that there is a total order for precedence. It
342 makes it impossible to have modular precedence information. We should
343 move to partial orders (sounds like series/parallel orders to me).
344
345 ** RR conflicts
346 See if we can use precedence between rules to solve RR conflicts. See
347 what POSIX says.
348
349
350 * $undefined
351 From Hans:
352 - If the Bison generated parser experiences an undefined number in the
353 character range, that character is written out in diagnostic messages, an
354 addition to the $undefined value.
355
356 Suggest: Change the name $undefined to undefined; looks better in outputs.
357
358
359 * Default Action
360 From Hans:
361 - For use with my C++ parser, I transported the "switch (yyn)" statement
362 that Bison writes to the bison.simple skeleton file. This way, I can remove
363 the current default rule $$ = $1 implementation, which causes a double
364 assignment to $$ which may not be OK under C++, replacing it with a
365 "default:" part within the switch statement.
366
367 Note that the default rule $$ = $1, when typed, is perfectly OK under C,
368 but in the C++ implementation I made, this rule is different from
369 $<type_name>$ = $<type_name>1. I therefore think that one should implement
370 a Bison option where every typed default rule is explicitly written out
371 (same typed ruled can of course be grouped together).
372
373 * Pre and post actions.
374 From: Florian Krohm <florian@edamail.fishkill.ibm.com>
375 Subject: YYACT_EPILOGUE
376 To: bug-bison@gnu.org
377 X-Sent: 1 week, 4 days, 14 hours, 38 minutes, 11 seconds ago
378
379 The other day I had the need for explicitly building the parse tree. I
380 used %locations for that and defined YYLLOC_DEFAULT to call a function
381 that returns the tree node for the production. Easy. But I also needed
382 to assign the S-attribute to the tree node. That cannot be done in
383 YYLLOC_DEFAULT, because it is invoked before the action is executed.
384 The way I solved this was to define a macro YYACT_EPILOGUE that would
385 be invoked after the action. For reasons of symmetry I also added
386 YYACT_PROLOGUE. Although I had no use for that I can envision how it
387 might come in handy for debugging purposes.
388 All is needed is to add
389
390 #if YYLSP_NEEDED
391 YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen, yyloc, (yylsp - yylen));
392 #else
393 YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen);
394 #endif
395
396 at the proper place to bison.simple. Ditto for YYACT_PROLOGUE.
397
398 I was wondering what you think about adding YYACT_PROLOGUE/EPILOGUE
399 to bison. If you're interested, I'll work on a patch.
400
401 * Better graphics
402 Equip the parser with a means to create the (visual) parse tree.
403
404 -----
405
406 Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008 Free Software Foundation,
407 Inc.
408
409 This file is part of Bison, the GNU Compiler Compiler.
410
411 This program is free software: you can redistribute it and/or modify
412 it under the terms of the GNU General Public License as published by
413 the Free Software Foundation, either version 3 of the License, or
414 (at your option) any later version.
415
416 This program is distributed in the hope that it will be useful,
417 but WITHOUT ANY WARRANTY; without even the implied warranty of
418 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
419 GNU General Public License for more details.
420
421 You should have received a copy of the GNU General Public License
422 along with this program. If not, see <http://www.gnu.org/licenses/>.