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