gnulib: update
[bison.git] / TODO
blob781a42407bb40e3d641329ae2a4990d718ec030b
1 * Soon
2 ** yyerror_range in GLR
3 It seems useless that it is based on glr_stack_item, it should be doable
4 with location only.
6 ** scan-code
7 The default case is scanning char-per-char.
9     /* By default, grow the string obstack with the input.  */
10     .|\n        STRING_GROW ();
12 make it more eager?
14 ** Missing tests
15 commit 2c294c132528ede23d8ae4959783a67e9ff05ac5
16 Author: Vincent Imbimbo <vmi6@cornell.edu>
17 Date:   Sat Jan 23 13:25:18 2021 -0500
19     cex: fix state-item pruning
21 See https://lists.gnu.org/r/bug-bison/2021-01/msg00002.html
23 ** pos_set_set
24 The current approach is correct, but with poor performances.  Bitsets need
25 to support 'assign' and 'shift'.  And instead of extending POS_SET just for
26 the out-of-range new values, we need something like doubling the size.
28 ** glr
29 There is no test with "Parse on stack %ld rejected by rule %d" in it.
31 ** yyrline etc.
32 Clarify that rule numbers in the skeletons are 1-based.
34 ** Macros in C++
35 There are many macros that should obey api.prefix: YY_CPLUSPLUS, YY_MOVE,
36 etc.
38 ** yyerrok in Java
39 And add tests in calc.at, to prepare work for D.
41 ** YYERROR and yynerrs
42 We are missing some cases.  Write a test case, and check all the skeletons.
44 ** Cex
45 *** Improve gnulib
46 Don't do this (counterexample.c):
48 // This is the fastest way to get the tail node from the gl_list API.
49 gl_list_node_t
50 list_get_end (gl_list_t list)
52   gl_list_node_t sentinel = gl_list_add_last (list, NULL);
53   gl_list_node_t res = gl_list_previous_node (list, sentinel);
54   gl_list_remove_node (list, sentinel);
55   return res;
58 *** Ambiguous rewriting
59 If the user is stupid enough to have equal rules, then the derivations are
60 harder to read:
62     Reduce/reduce conflict on tokens $end, "+", "⊕":
63         2 exp: exp "+" exp .
64         3 exp: exp "+" exp .
65       Example                  exp "+" exp •
66       First derivation         exp ::=[ exp "+" exp • ]
67       Example                  exp "+" exp •
68       Second derivation        exp ::=[ exp "+" exp • ]
70 Do we care about this?  In color, we use twice the same color here, but we
71 could try to use the same color for the same rule.
73 *** XML reports
74 Show the counterexamples.  This is going to be really hard and/or painful.
75 Unless we play it dumb (little structure).
77 ** Bistromathic
78 - How about not evaluating incomplete lines when the text is not finished
79   (as shells do).
81 ** Questions
82 *** Java
83 - Should i18n be part of the Lexer?  Currently it's a static method of
84   Lexer.
86 - is there a migration path that would allow to use TokenKinds in
87   yylex?
89 - define the tokens as an enum too.
91 - promote YYEOF rather than EOF.
93 ** YYerror
94 https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-runtime/intl/plural.y;h=a712255af4f2f739c93336d4ff6556d932a426a5;hb=HEAD
96 should be updated to not use YYERRCODE.  Returning an undef token is good
97 enough.
99 ** Java
100 *** calc.at
101 Stop hard-coding "Calc".  Adjust local.at (look for FIXME).
103 ** doc
104 I feel it's ugly to use the GNU style to declare functions in the doc.  It
105 generates tons of white space in the page, and may contribute to bad page
106 breaks.
108 ** consistency
109 token vs terminal.
111 ** api.token.raw
112 The YYUNDEFTOK could be assigned a semantic value so that yyerror could be
113 used to report invalid lexemes.
115 ** push parsers
116 Consider deprecating impure push parsers.  They add a lot of complexity, for
117 a bad feature.  On the other hand, that would make it much harder to sit
118 push parsers on top of pull parser.  Which is currently not relevant, since
119 push parsers are measurably slower.
121 ** %define parse.error formatted
122 How about pushing Bistromathic's yyreport_syntax_error as another standard
123 way to generate the error message, and leave to the user the task of
124 providing the message formats?  Currently in bistro, it reads:
126     const char *
127     error_format_string (int argc)
128     {
129       switch (argc)
130         {
131         default: /* Avoid compiler warnings. */
132         case 0: return _("%@: syntax error");
133         case 1: return _("%@: syntax error: unexpected %u");
134           // TRANSLATORS: '%@' is a location in a file, '%u' is an
135           // "unexpected token", and '%0e', '%1e'... are expected tokens
136           // at this point.
137           //
138           // For instance on the expression "1 + * 2", you'd get
139           //
140           // 1.5: syntax error: expected - or ( or number or function or variable before *
141         case 2: return _("%@: syntax error: expected %0e before %u");
142         case 3: return _("%@: syntax error: expected %0e or %1e before %u");
143         case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
144         case 5: return _("%@: syntax error: expected %0e or %1e or %2e or %3e before %u");
145         case 6: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e before %u");
146         case 7: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e before %u");
147         case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e or %6e before %u");
148         }
149     }
151 The message would have to be generated in a string, and pushed to yyerror.
152 Which will be a pain in the neck in yacc.c.
154 If we want to do that, we should think very carefully about the syntax of
155 the format string.
157 ** yyclearin does not invoke the lookahead token's %destructor
158 https://lists.gnu.org/r/bug-bison/2018-02/msg00000.html
159 Rici:
161 > Modifying yyclearin so that it calls yydestruct seems like the simplest
162 > solution to this issue, but it is conceivable that such a change would
163 > break programs which already perform some kind of workaround in order to
164 > destruct the lookahead symbol. So it might be necessary to use some kind of
165 > compatibility %define, or to create a new replacement macro with a
166 > different name such as yydiscardin.
168 > At a minimum, the fact that yyclearin does not invoke the %destructor
169 > should be highlighted in the documentation, since it is not at all obvious.
171 ** Issues in i18n
173 Les catégories d'avertissements incluent :
174   conflicts-sr      conflits S/R (activé par défaut)
175   conflicts-rr      conflits R/R (activé par défaut)
176   dangling-alias    l'alias chaîne n'est pas attaché à un symbole
177   deprecated        construction obsolète
178   empty-rule        règle vide sans %empty
179   midrule-values    valeurs de règle intermédiaire non définies ou inutilisées
180   precedence        priorité et associativité inutiles
181   yacc              incompatibilités avec POSIX Yacc
182   other             tous les autres avertissements (activé par défaut)
183   all               tous les avertissements sauf « dangling-alias » et « yacc »
184   no-CATEGORY       désactiver les avertissements dans CATEGORIE
185   none              désactiver tous les avertissements
186   error[=CATEGORY]  traiter les avertissements comme des erreurs
188 Line -1 and -3 should mention CATEGORIE, not CATEGORY.
190 * Bison 3.9
191 ** Rewrite glr.cc (currently glr2.cc)
192 *** custom error messages
194 *** Remove jumps
195 We can probably replace setjmp/longjmp with exceptions.  That would help
196 tremendously other languages such as D and Java that probably have no
197 similar feature.  If we remove jumps, we probably no longer need _Noreturn,
198 so simplify `b4_attribute_define([noreturn])` into `b4_attribute_define`.
200 After discussing with Valentin, it was decided that it's better to stay with
201 jumps, since in some places exceptions are ruled out from C++.
203 *** Coding style
204 Move to our coding conventions.  In particular names such as yy_glr_stack,
205 not yyGLRStack.
207 *** yydebug
208 It should be a member of the parser object, see lalr1.cc.  Let the parser
209 object decide what the debug stream is, rather than open coding std::cerr.
211 *** Avoid pointers
212 There are many places where pointers should be replaced with references.
213 Some occurrences were fixed, but now some have improper names:
215 -yygetToken (int *yycharp, ]b4_namespace_ref[::]b4_parser_class[& yyparser][]b4_pure_if([, glr_stack* yystackp])[]b4_user_formals[)
216 +yygetToken (int& yycharp, ]b4_namespace_ref[::]b4_parser_class[& yyparser][]b4_pure_if([, glr_stack* yystackp])[]b4_user_formals[)
218 yycharp is no longer a Pointer.  And yystackp should probably also be a reference.
220 *** parse.assert
221 Currently all the assertions are enabled.  Once we are confident in glr2.cc,
222 let parse.assert use the same approach as in lalr1.cc.
224 *** debug_stream
225 Stop using std::cerr everywhere.
227 *** glr.c
228 When glr2.cc fully replaces glr.cc, get rid of the glr.cc scaffolding in
229 glr.c.
231 * Chains
232 ** Unit rules / Injection rules (Akim Demaille)
233 Maybe we could expand unit rules (or "injections", see
234 https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
235 transform
237         exp: arith | bool;
238         arith: exp '+' exp;
239         bool: exp '&' exp;
241 into
243         exp: exp '+' exp | exp '&' exp;
245 when there are no actions.  This can significantly speed up some grammars.
246 I can't find the papers.  In particular the book 'LR parsing: Theory and
247 Practice' is impossible to find, but according to 'Parsing Techniques: a
248 Practical Guide', it includes information about this issue.  Does anybody
249 have it?
251 ** clean up (Akim Demaille)
252 Do not work on these items now, as I (Akim) have branches with a lot of
253 changes in this area (hitting several files), and no desire to have to fix
254 conflicts.  Addressing these items will happen after my branches have been
255 merged.
257 *** lalr.c
258 Introduce a goto struct, and use it in place of from_state/to_state.
259 Rename states1 as path, length as pathlen.
260 Introduce inline functions for things such as nullable[*rp - ntokens]
261 where we need to map from symbol number to nterm number.
263 There are probably a significant part of the relations management that
264 should be migrated on top of a bitsetv.
266 *** closure
267 It should probably take a "state*" instead of two arguments.
269 *** traces
270 The "automaton" and "set" categories are not so useful.  We should probably
271 introduce lr(0) and lalr, just the way we have ielr categories.  The
272 "closure" function is too verbose, it should probably have its own category.
274 "set" can still be used for summarizing the important sets.  That would make
275 tests easy to maintain.
277 *** complain.*
278 Rename these guys as "diagnostics.*" (or "diagnose.*"), since that's the
279 name they have in GCC, clang, etc.  Likewise for the complain_* series of
280 functions.
282 *** ritem
283 states/nstates, rules/nrules, ..., ritem/nritems
284 Fix the latter.
286 *** m4: slot, type, type_tag
287 The meaning of type_tag varies depending on api.value.type.  We should avoid
288 that and using clear definitions with stable semantics.
290 * D programming language
291 There's a number of features that are missing, here sorted in _suggested_
292 order of implementation.
294 When copying code from other skeletons, keep the comments exactly as they
295 are.  Keep the same variable names.  If you change the wording in one place,
296 do it in the others too.  In other words: make sure to keep the
297 maintenance *simple* by avoiding any gratuitous difference.
299 ** CI
300 Check when gdc and ldc.
302 ** GLR Parser
303 This is very ambitious.  That's the final boss.  There are currently no
304 "clean" implementation to get inspiration from.
306 glr.c is very clean but:
307 - is low-level C
308 - is a different skeleton from yacc.c
310 glr.cc is (currently) an ugly hack: a C++ shell around glr.c.  Valentin
311 Tolmer is currently rewriting glr.cc to be clean C++, but he is not
312 finished.  There will be a lot a common code between lalr1.cc and glr.cc, so
313 eventually I would like them to be fused into a single skeleton, supporting
314 both deterministic and generalized parsing.
316 It would be great for D to also support this.
318 The basic ideas of GLR are explained here:
320 https://www.codeproject.com/Articles/5259825/GLR-Parsing-in-Csharp-How-to-Use-The-Most-Powerful
322 * Better error messages
323 The users are not provided with enough tools to forge their error messages.
324 See for instance "Is there an option to change the message produced by
325 YYERROR_VERBOSE?" by Simon Sobisch, on bison-help.
327 See also
328 https://www.cs.tufts.edu/~nr/cs257/archive/clinton-jefferey/lr-error-messages.pdf
329 https://research.swtch.com/yyerror
330 http://gallium.inria.fr/~fpottier/publis/fpottier-reachability-cc2016.pdf
332 * Modernization
333 Fix data/skeletons/yacc.c so that it defines YYPTRDIFF_T properly for modern
334 and older C++ compilers.  Currently the code defaults to defining it to
335 'long' for non-GCC compilers, but it should use the proper C++ magic to
336 define it to the same type as the C ptrdiff_t type.
338 * Completion
339 Several features are not available in all the back-ends.
341 - push parsers: glr.c, glr.cc, lalr1.cc (not very difficult)
342 - token constructors: Java, C, D (a bit difficult)
343 - glr: D, Java (super difficult)
345 * Bugs
346 ** Autotest has quotation issues
347 tests/input.at:1730:AT_SETUP([%define errors])
351 $ ./tests/testsuite -l | grep errors | sed q
352   38: input.at:1730      errors
354 * Short term
355 ** Better design for diagnostics
356 The current implementation of diagnostics is ad hoc, it grew organically.
357 It works as a series of calls to several functions, with dependency of the
358 latter calls on the former.  For instance:
360       complain (&sym->location,
361                 sym->content->status == needed ? complaint : Wother,
362                 _("symbol %s is used, but is not defined as a token"
363                   " and has no rules; did you mean %s?"),
364                 quote_n (0, sym->tag),
365                 quote_n (1, best->tag));
366       if (feature_flag & feature_caret)
367         location_caret_suggestion (sym->location, best->tag, stderr);
369 We should rewrite this in a more FP way:
371 1. build a rich structure that denotes the (complete) diagnostic.
372    "Complete" in the sense that it also contains the suggestions, the list
373    of possible matches, etc.
375 2. send this to the pretty-printing routine.  The diagnostic structure
376    should be sufficient so that we can generate all the 'format' of
377    diagnostics, including the fixits.
379 If properly done, this diagnostic module can be detached from Bison and be
380 put in gnulib.  It could be used, for instance, for errors caught by
381 xgettext.
383 There's certainly already something alike in GCC.  At least that's the
384 impression I get from reading the "-fdiagnostics-format=FORMAT" part of this
385 page:
387 https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
389 ** Graphviz display code thoughts
390 The code for the --graph option is over two files: print_graph, and
391 graphviz. This is because Bison used to also produce VCG graphs, but since
392 this is no longer true, maybe we could consider these files for fusion.
394 An other consideration worth noting is that print_graph.c (correct me if I
395 am wrong) should contain generic functions, whereas graphviz.c and other
396 potential files should contain just the specific code for that output
397 format. It will probably prove difficult to tell if the implementation is
398 actually generic whilst only having support for a single format, but it
399 would be nice to keep stuff a bit tidier: right now, the construction of the
400 bitset used to show reductions is in the graphviz-specific code, and on the
401 opposite side we have some use of \l, which is graphviz-specific, in what
402 should be generic code.
404 Little effort seems to have been given to factoring these files and their
405 print{,-xml} counterpart. We would very much like to re-use the pretty format
406 of states from .output for the graphs, etc.
408 Since graphviz dies on medium-to-big grammars, maybe consider an other tool?
410 ** push-parser
411 Check it too when checking the different kinds of parsers.  And be
412 sure to check that the initial-action is performed once per parsing.
414 ** m4 names
415 b4_shared_declarations is no longer what it is.  Make it
416 b4_parser_declaration for instance.
418 ** yychar in lalr1.cc
419 There is a large difference bw maint and master on the handling of
420 yychar (which was removed in lalr1.cc).  See what needs to be
421 back-ported.
424     /* User semantic actions sometimes alter yychar, and that requires
425        that yytoken be updated with the new translation.  We take the
426        approach of translating immediately before every use of yytoken.
427        One alternative is translating here after every semantic action,
428        but that translation would be missed if the semantic action
429        invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
430        yychar.  In the case of YYABORT or YYACCEPT, an incorrect
431        destructor might then be invoked immediately.  In the case of
432        YYERROR, subsequent parser actions might lead to an incorrect
433        destructor call or verbose syntax error message before the
434        lookahead is translated.  */
436     /* Make sure we have latest lookahead translation.  See comments at
437        user semantic actions for why this is necessary.  */
438     yytoken = yytranslate_ (yychar);
441 ** Get rid of fake #lines [Bison: ...]
442 Possibly as simple as checking whether the column number is nonnegative.
444 I have seen messages like the following from GCC.
446 <built-in>:0: fatal error: opening dependency file .deps/libltdl/argz.Tpo: No such file or directory
449 ** Discuss about %printer/%destroy in the case of C++.
450 It would be very nice to provide the symbol classes with an operator<<
451 and a destructor.  Unfortunately the syntax we have chosen for
452 %destroy and %printer make them hard to reuse.  For instance, the user
453 is invited to write something like
455    %printer { debug_stream() << $$; } <my_type>;
457 which is hard to reuse elsewhere since it wants to use
458 "debug_stream()" to find the stream to use.  The same applies to
459 %destroy: we told the user she could use the members of the Parser
460 class in the printers/destructors, which is not good for an operator<<
461 since it is no longer bound to a particular parser, it's just a
462 (standalone symbol).
464 * Various
465 ** Rewrite glr.cc in C++ (Valentin Tolmer)
466 As a matter of fact, it would be very interesting to see how much we can
467 share between lalr1.cc and glr.cc.  Most of the skeletons should be common.
468 It would be a very nice source of inspiration for the other languages.
470 Valentin Tolmer is working on this.
472 * From lalr1.cc to yacc.c
473 ** Single stack
474 Merging the three stacks in lalr1.cc simplified the code, prompted for
475 other improvements and also made it faster (probably because memory
476 management is performed once instead of three times).  I suggest that
477 we do the same in yacc.c.
479 (Some time later): it's also very nice to have three stacks: it's more dense
480 as we don't lose bits to padding.  For instance the typical stack for states
481 will use 8 bits, while it is likely to consume 32 bits in a struct.
483 We need trustworthy benchmarks for Bison, for all our backends.  Akim has a
484 few things scattered around; we need to put them in the repo, and make them
485 more useful.
487 * Report
489 ** Figures
490 Some statistics about the grammar and the parser would be useful,
491 especially when asking the user to send some information about the
492 grammars she is working on.  We should probably also include some
493 information about the variables (I'm not sure for instance we even
494 specify what LR variant was used).
496 ** GLR
497 How would Paul like to display the conflicted actions?  In particular,
498 what when two reductions are possible on a given lookahead token, but one is
499 part of $default.  Should we make the two reductions explicit, or just
500 keep $default?  See the following point.
502 ** Disabled Reductions
503 See 'tests/conflicts.at (Defaulted Conflicted Reduction)', and decide
504 what we want to do.
506 ** Documentation
507 Extend with error productions.  The hard part will probably be finding
508 the right rule so that a single state does not exhibit too many yet
509 undocumented ''features''.  Maybe an empty action ought to be
510 presented too.  Shall we try to make a single grammar with all these
511 features, or should we have several very small grammars?
513 * Extensions
514 ** More languages?
515 Well, only if there is really some demand for it.
517 *** PHP
518 https://github.com/scfc/bison-php/blob/master/data/lalr1.php
520 *** Python
521 https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
523 ** Multiple start symbols
524 Revert a70e75b8a41755ab96ab211a0ea111ac68a4aadd.
525 Revert tests: disable "Multistart reports".
527 Would be very useful when parsing closely related languages.  The idea is to
528 declare several start symbols, for instance
530     %start stmt expr
531     %%
532     stmt: ...
533     expr: ...
535 and to generate parse(), parse_stmt() and parse_expr().  Technically, the
536 above grammar would be transformed into
538    %start yy_start
539    %token YY_START_STMT YY_START_EXPR
540    %%
541    yy_start: YY_START_STMT stmt | YY_START_EXPR expr
543 so that there are no new conflicts in the grammar (as would undoubtedly
544 happen with yy_start: stmt | expr).  Then adjust the skeletons so that this
545 initial token (YY_START_STMT, YY_START_EXPR) be shifted first in the
546 corresponding parse function.
548 *** Number of useless symbols
549 AT_TEST(
550 [[%start exp;
551 exp: exp;]],
552 [[input.y: warning: 2 nonterminals useless in grammar [-Wother]
553 input.y: warning: 2 rules useless in grammar [-Wother]
554 input.y:2.8-10: error: start symbol exp does not derive any sentence]])
556 We should say "1 nonterminal": the other one is $accept, which should not
557 participate in the count.
559 *** Tokens
560 Do we want to disallow terminal start symbols?  The limitation is not
561 technical.  Can it be useful to someone to "parse" a token?
563 ** %include
564 This is a popular demand.  We already made many changes in the parser that
565 should make this reasonably easy to implement.
567 Bruce Mardle <marblypup@yahoo.co.uk>
568 https://lists.gnu.org/r/bison-patches/2015-09/msg00000.html
570 However, there are many other things to do before having such a feature,
571 because I don't want a % equivalent to #include (which we all learned to
572 hate).  I want something that builds "modules" of grammars, and assembles
573 them together, paying attention to keep separate bits separated, in pseudo
574 name spaces.
576 ** Push parsers
577 There is demand for push parsers in C++.
579 ** Generate code instead of tables
580 This is certainly quite a lot of work.  See
581 https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.4539.
583 ** $-1
584 We should find a means to provide an access to values deep in the
585 stack.  For instance, instead of
587         baz: qux { $$ = $<foo>-1 + $<bar>0 + $1; }
589 we should be able to have:
591   foo($foo) bar($bar) baz($bar): qux($qux) { $baz = $foo + $bar + $qux; }
593 Or something like this.
595 ** %if and the like
596 It should be possible to have %if/%else/%endif.  The implementation is
597 not clear: should it be lexical or syntactic.  Vadim Maslow thinks it
598 must be in the scanner: we must not parse what is in a switched off
599 part of %if.  Akim Demaille thinks it should be in the parser, so as
600 to avoid falling into another CPP mistake.
602 (Later): I'm sure there's actually good case for this.  People who need that
603 feature can use m4/cpp on top of Bison.  I don't think it is worth the
604 trouble in Bison itself.
606 ** XML Output
607 There are couple of available extensions of Bison targeting some XML
608 output.  Some day we should consider including them.  One issue is
609 that they seem to be quite orthogonal to the parsing technique, and
610 seem to depend mostly on the possibility to have some code triggered
611 for each reduction.  As a matter of fact, such hooks could also be
612 used to generate the yydebug traces.  Some generic scheme probably
613 exists in there.
615 XML output for GNU Bison and gcc
616    http://www.cs.may.ie/~jpower/Research/bisonXML/
618 XML output for GNU Bison
619    http://yaxx.sourceforge.net/
621 * Coding system independence
622 Paul notes:
624         Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
625         255).  It also assumes that the 8-bit character encoding is
626         the same for the invocation of 'bison' as it is for the
627         invocation of 'cc', but this is not necessarily true when
628         people run bison on an ASCII host and then use cc on an EBCDIC
629         host.  I don't think these topics are worth our time
630         addressing (unless we find a gung-ho volunteer for EBCDIC or
631         PDP-10 ports :-) but they should probably be documented
632         somewhere.
634         More importantly, Bison does not currently allow NUL bytes in
635         tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
636         the source code.  This should get fixed.
638 * Broken options?
639 ** %token-table
640 ** Skeleton strategy
641 Must we keep %token-table?
643 * Precedence
645 ** Partial order
646 It is unfortunate that there is a total order for precedence.  It
647 makes it impossible to have modular precedence information.  We should
648 move to partial orders (sounds like series/parallel orders to me).
650 This is a prerequisite for modules.
652 * Pre and post actions.
653 From: Florian Krohm <florian@edamail.fishkill.ibm.com>
654 Subject: YYACT_EPILOGUE
655 To: bug-bison@gnu.org
656 X-Sent: 1 week, 4 days, 14 hours, 38 minutes, 11 seconds ago
658 The other day I had the need for explicitly building the parse tree. I
659 used %locations for that and defined YYLLOC_DEFAULT to call a function
660 that returns the tree node for the production. Easy. But I also needed
661 to assign the S-attribute to the tree node. That cannot be done in
662 YYLLOC_DEFAULT, because it is invoked before the action is executed.
663 The way I solved this was to define a macro YYACT_EPILOGUE that would
664 be invoked after the action. For reasons of symmetry I also added
665 YYACT_PROLOGUE. Although I had no use for that I can envision how it
666 might come in handy for debugging purposes.
667 All is needed is to add
669 #if YYLSP_NEEDED
670     YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen, yyloc, (yylsp - yylen));
671 #else
672     YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen);
673 #endif
675 at the proper place to bison.simple. Ditto for YYACT_PROLOGUE.
677 I was wondering what you think about adding YYACT_PROLOGUE/EPILOGUE
678 to bison. If you're interested, I'll work on a patch.
680 * Better graphics
681 Equip the parser with a means to create the (visual) parse tree.
684 -----
686 # LocalWords:  Cex gnulib gl Bistromathic TokenKinds yylex enum YYEOF EOF
687 # LocalWords:  YYerror gettext af hb YYERRCODE undef calc FIXME dev yyerror
688 # LocalWords:  Autoconf YYUNDEFTOK lexemes parsers Bistromathic's yyreport
689 # LocalWords:  const argc yacc yyclearin lookahead destructor Rici incluent
690 # LocalWords:  yydestruct yydiscardin catégories d'avertissements sr activé
691 # LocalWords:  conflits défaut rr l'alias chaîne n'est attaché un symbole
692 # LocalWords:  obsolète règle vide midrule valeurs de intermédiaire ou avec
693 # LocalWords:  définies inutilisées priorité associativité inutiles POSIX
694 # LocalWords:  incompatibilités tous les autres avertissements sauf dans rp
695 # LocalWords:  désactiver CATEGORIE traiter comme des erreurs glr Akim bool
696 # LocalWords:  Demaille arith lalr goto struct pathlen nullable ntokens lr
697 # LocalWords:  nterm bitsetv ielr ritem nstates nrules nritems yysymbol EQ
698 # LocalWords:  SymbolKind YYEMPTY YYUNDEF YYTNAME NUM yyntokens yytname sed
699 # LocalWords:  nonterminals yykind yycode YYNAMES yynames init getName conv
700 # LocalWords:  TokenKind ival yychar yylval yylexer Tolmer hoc
701 # LocalWords:  Sobisch YYPTRDIFF ptrdiff Autotest toknum yytoknum
702 # LocalWords:  sym Wother stderr FP fixits xgettext fdiagnostics Graphviz
703 # LocalWords:  graphviz VCG bitset xml bw maint yytoken YYABORT deps
704 # LocalWords:  YYACCEPT yytranslate nonnegative destructors yyerrlab repo
705 # LocalWords:  backends stmt expr yy Mardle baz qux Vadim Maslow CPP cpp
706 # LocalWords:  yydebug gcc UCHAR EBCDIC gung PDP NUL Pre Florian Krohm utf
707 # LocalWords:  YYACT YYLLOC YYLSP yyval yyvsp yylen yyloc yylsp endif
708 # LocalWords:  ispell american
710 Local Variables:
711 mode: outline
712 coding: utf-8
713 fill-column: 76
714 ispell-dictionary: "american"
715 End:
717 Copyright (C) 2001-2004, 2006, 2008-2015, 2018-2022 Free Software
718 Foundation, Inc.
720 This file is part of Bison, the GNU Compiler Compiler.
722 Permission is granted to copy, distribute and/or modify this document
723 under the terms of the GNU Free Documentation License, Version 1.3 or
724 any later version published by the Free Software Foundation; with no
725 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
726 Texts.  A copy of the license is included in the "GNU Free
727 Documentation License" file as part of this distribution.