5 > I haven't looked deeply, but it strikes me that gnulib/lib/bitset/array.c
6 > does not make use of the 'ffsl' function, nor or the 'integer_length_l'
7 > function. Maybe because in Bison, all bitsets are so dense that it does
8 > not give a performance advantage?
12 Don't do this (counterexample.c):
14 // This is the fastest way to get the tail node from the gl_list API.
16 list_get_end (gl_list_t list)
18 gl_list_node_t sentinel = gl_list_add_last (list, NULL);
19 gl_list_node_t res = gl_list_previous_node (list, sentinel);
20 gl_list_remove_node (list, sentinel);
24 *** Ambiguous rewriting
25 If the user is stupid enough to have equal rules, then the derivations are
28 Reduce/reduce conflict on tokens $end, "+", "⊕":
32 First derivation exp ::=[ exp "+" exp • ]
34 Second derivation exp ::=[ exp "+" exp • ]
36 Do we care about this? In color, we use twice the same color here, but we
37 could try to use the same color for the same rule.
40 Show the counterexamples. This is going to be really hard and/or painful.
41 Unless we play it dumb (little structure).
44 - How about not evaluating incomplete lines when the text is not finished
49 - Should i18n be part of the Lexer? Currently it's a static method of
52 - is there a migration path that would allow to use TokenKinds in
55 - define the tokens as an enum too.
57 - promote YYEOF rather than EOF.
60 https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-runtime/intl/plural.y;h=a712255af4f2f739c93336d4ff6556d932a426a5;hb=HEAD
62 should be updated to not use YYERRCODE. Returning an undef token is good
67 Stop hard-coding "Calc". Adjust local.at (look for FIXME).
69 ** A dev warning for b4_
70 Maybe we should check for m4_ and b4_ leaking out of the m4 processing, as
71 Autoconf does. It would have caught over-quotation issues.
74 I feel it's ugly to use the GNU style to declare functions in the doc. It
75 generates tons of white space in the page, and may contribute to bad page
82 The YYUNDEFTOK could be assigned a semantic value so that yyerror could be
83 used to report invalid lexemes.
86 Consider deprecating impure push parsers. They add a lot of complexity, for
87 a bad feature. On the other hand, that would make it much harder to sit
88 push parsers on top of pull parser. Which is currently not relevant, since
89 push parsers are measurably slower.
91 ** %define parse.error formatted
92 How about pushing Bistromathic's yyreport_syntax_error as another standard
93 way to generate the error message, and leave to the user the task of
94 providing the message formats? Currently in bistro, it reads:
97 error_format_string (int argc)
101 default: /* Avoid compiler warnings. */
102 case 0: return _("%@: syntax error");
103 case 1: return _("%@: syntax error: unexpected %u");
104 // TRANSLATORS: '%@' is a location in a file, '%u' is an
105 // "unexpected token", and '%0e', '%1e'... are expected tokens
108 // For instance on the expression "1 + * 2", you'd get
110 // 1.5: syntax error: expected - or ( or number or function or variable before *
111 case 2: return _("%@: syntax error: expected %0e before %u");
112 case 3: return _("%@: syntax error: expected %0e or %1e before %u");
113 case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
114 case 5: return _("%@: syntax error: expected %0e or %1e or %2e or %3e before %u");
115 case 6: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e before %u");
116 case 7: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e before %u");
117 case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e or %6e before %u");
121 The message would have to be generated in a string, and pushed to yyerror.
122 Which will be a pain in the neck in yacc.c.
124 If we want to do that, we should think very carefully about the syntax of
127 ** yyclearin does not invoke the lookahead token's %destructor
128 https://lists.gnu.org/r/bug-bison/2018-02/msg00000.html
131 > Modifying yyclearin so that it calls yydestruct seems like the simplest
132 > solution to this issue, but it is conceivable that such a change would
133 > break programs which already perform some kind of workaround in order to
134 > destruct the lookahead symbol. So it might be necessary to use some kind of
135 > compatibility %define, or to create a new replacement macro with a
136 > different name such as yydiscardin.
138 > At a minimum, the fact that yyclearin does not invoke the %destructor
139 > should be highlighted in the documentation, since it is not at all obvious.
143 Les catégories d'avertissements incluent :
144 conflicts-sr conflits S/R (activé par défaut)
145 conflicts-rr conflits R/R (activé par défaut)
146 dangling-alias l'alias chaîne n'est pas attaché à un symbole
147 deprecated construction obsolète
148 empty-rule règle vide sans %empty
149 midrule-values valeurs de règle intermédiaire non définies ou inutilisées
150 precedence priorité et associativité inutiles
151 yacc incompatibilités avec POSIX Yacc
152 other tous les autres avertissements (activé par défaut)
153 all tous les avertissements sauf « dangling-alias » et « yacc »
154 no-CATEGORY désactiver les avertissements dans CATEGORIE
155 none désactiver tous les avertissements
156 error[=CATEGORY] traiter les avertissements comme des erreurs
158 Line -1 and -3 should mention CATEGORIE, not CATEGORY.
162 Get rid of scaffolding in glr.c.
164 ** Unit rules / Injection rules (Akim Demaille)
165 Maybe we could expand unit rules (or "injections", see
166 https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
175 exp: exp '+' exp | exp '&' exp;
177 when there are no actions. This can significantly speed up some grammars.
178 I can't find the papers. In particular the book 'LR parsing: Theory and
179 Practice' is impossible to find, but according to 'Parsing Techniques: a
180 Practical Guide', it includes information about this issue. Does anybody
183 ** clean up (Akim Demaille)
184 Do not work on these items now, as I (Akim) have branches with a lot of
185 changes in this area (hitting several files), and no desire to have to fix
186 conflicts. Addressing these items will happen after my branches have been
190 Introduce a goto struct, and use it in place of from_state/to_state.
191 Rename states1 as path, length as pathlen.
192 Introduce inline functions for things such as nullable[*rp - ntokens]
193 where we need to map from symbol number to nterm number.
195 There are probably a significant part of the relations management that
196 should be migrated on top of a bitsetv.
199 It should probably take a "state*" instead of two arguments.
202 The "automaton" and "set" categories are not so useful. We should probably
203 introduce lr(0) and lalr, just the way we have ielr categories. The
204 "closure" function is too verbose, it should probably have its own category.
206 "set" can still be used for summarizing the important sets. That would make
207 tests easy to maintain.
210 Rename these guys as "diagnostics.*" (or "diagnose.*"), since that's the
211 name they have in GCC, clang, etc. Likewise for the complain_* series of
215 states/nstates, rules/nrules, ..., ritem/nritems
218 * D programming language
219 There's a number of features that are missing, here sorted in _suggested_
220 order of implementation.
222 When copying code from other skeletons, keep the comments exactly as they
223 are. Keep the same variable names. If you change the wording in one place,
224 do it in the others too. In other words: make sure to keep the
225 maintenance *simple* by avoiding any gratuitous difference.
227 ** Rename the D example
228 Move the current content of examples/d into examples/d/simple.
230 ** Create a second example
231 Duplicate examples/d/simple into examples/d/calc.
233 ** Add location tracking to d/calc
234 Look at the examples in the other languages to see how to do that.
237 The SymbolKind is an enum. For a given SymbolKind we want to get its string
238 representation. Currently it's a separate table in the parser that does
242 public enum SymbolKind
244 S_YYEMPTY = -2, /* No symbol. */
245 S_YYEOF = 0, /* "end of file" */
246 S_YYerror = 1, /* error */
247 S_YYUNDEF = 2, /* "invalid token" */
250 S_input = 14, /* input */
251 S_line = 15, /* line */
252 S_exp = 16, /* exp */
257 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
258 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
259 private static immutable string[] yytname_ =
261 "\"end of file\"", "error", "\"invalid token\"", "\"=\"", "\"+\"",
262 "\"-\"", "\"*\"", "\"/\"", "\"(\"", "\")\"", "\"end of line\"",
263 "\"number\"", "UNARY", "$accept", "input", "line", "exp", null
268 So to get a symbol kind, one runs `yytname_[yykind]`.
270 Is there a way to attach this conversion to string to SymbolKind? In Java
271 for instance, we have:
273 public enum SymbolKind
275 S_YYEOF(0), /* "end of file" */
276 S_YYerror(1), /* error */
277 S_YYUNDEF(2), /* "invalid token" */
279 S_input(16), /* input */
280 S_line(17), /* line */
283 private final int yycode_;
289 /* YYNAMES_[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
290 First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
291 private static final String[] yynames_ = yynames_init();
292 private static final String[] yynames_init()
296 i18n("end of file"), i18n("error"), i18n("invalid token"), "!", "+", "-", "*",
297 "/", "^", "(", ")", "=", i18n("end of line"), i18n("number"), "NEG",
298 "$accept", "input", "line", "exp", null
302 /* The user-facing name of this symbol. */
303 public final String getName() {
304 return yynames_[yycode_];
308 which allows to write more naturally `yykind.getName()` rather than
309 `yytname_[yykind]`. Is there something comparable in (idiomatic) D?
311 ** Change the return value of yylex
312 Historically people were allowed to return any int from the scanner (which
313 is convenient and allows `return '+'` from the scanner). Akim tends to see
314 this as an error, we should restrict the return values to TokenKind (not to
315 be confused with SymbolKind).
317 In the case of D, without the history, we have the choice to support or not
318 `int`. If we want to _keep_ `int`, is there a way, say via introspection,
319 to support both signatures of yylex? If we don't keep `int`, just move to
323 Write documentation about D support in doc/bison.texi. Imitate the Java
324 documentation. You should be more succinct IMHO.
327 The current interface from the scanner to the parser is somewhat clumsy: the
328 token kind is returned by yylex, but the value and location are stored in
329 the scanner. This reflects the fact that the implementation of the parser
330 uses three variables to deal with each parsed symbol: its kind, its value,
333 So today the scanner of examples/d/calc.d (no locations) looks like:
335 if (input.front.isNumber)
337 import std.conv : parse;
338 semanticVal_.ival = input.parse!int;
339 return TokenKind.NUM;
342 and the generated parser:
344 /* Read a lookahead token. */
345 if (yychar == TokenKind.YYEMPTY)
348 yylval = yylexer.semanticVal;
351 The parser class should feature a `Symbol` type which binds together kind,
352 value and location, and the scanner should be able to return an instance of
353 that type. Something like
355 if (input.front.isNumber)
357 import std.conv : parse;
358 return parser.Symbol (TokenKind.NUM, input.parse!int);
361 ** Token Constructors
362 In the previous example it is possible to mix incorrectly kinds and values,
365 return parser.Symbol (TokenKind.NUM, "Hello, World!\n");
367 attaches a string value to NUM kind (wrong, of course). When
368 api.token.constructor is set, in C++, Bison generated "token constructors":
369 parser.make_NUM. parser.make_PLUS, parser.make_STRING, etc. The previous
372 return parser.make_NUM ("Hello, World!\n");
374 which would easily be caught by the type checker.
376 ** Lookahead Correction
377 Add support for LAC to the D skeleton. It should not be too hard: look how
378 this is done in lalr1.cc, and mock it.
381 Add support for push parser. Do not start a nice skeleton, just enhance the
382 current one to support push parsers. This is going to be a tougher nut to
385 First, you need to understand well how the push parser is expected to work.
388 - look at examples/c/pushcalc
389 - create an example of a Java push parser.
390 - have a look at the generated parser in Java, which has the advantage of
391 being already based on a parser object, instead of just a function.
393 The C case is harder to read, but it may help too. Keep in mind that
394 because there's no object to maintain state, the C push parser uses some
395 struct (yypstate) to preserve this state. We don't need this in D, the
396 parser object will suffice.
398 I think working directly on the skeleton to add push-parser support is not
399 the simplest path. I suggest that you (1) transform a generated parser into
400 a push parser by hand, and then (2) transform lalr1.d to generate such a
403 Use `git commit` frequently to make sure you keep track of your progress.
405 *** (1.a) Prepare pull parser by hand
406 Copy again one of the D examples into say examples/d/pushcalc. Also
407 check-in the generated parser to facilitate experimentation.
409 - find local variables of yyparse should become members of the parser object
410 (so that we preserve state from one call to the next).
412 - do it in your generated D parser. We don't need an equivalent for
413 yypstate, because we already have it: that the parser object itself.
415 - have your *pull*-parser (i.e., the good old yy::parser::parse()) work
416 properly this way. Write and run tests. That's one of the reasons I
417 suggest using examples/d/calc as a starting point: it already has tests,
418 you can/should add more.
420 At this point you have a pull-parser which you prepared to turn into a
423 *** (1.b) Turn pull parser into push parser by hand
425 - look again at how push parsers are implemented in Java/C to see what needs
426 to change in yyparse so that the control is inverted: parse() will
427 be *given* the tokens, instead of having to call yylex itself. When I say
428 "look at C", I think your best option are (i) yacc.c (look for b4_push_if)
429 and (ii) examples/c/pushcalc.
431 - rename parse() as push_parse(Symbol yyla) (or push_parse(TokenKind, Value,
432 Location)) that takes the symbol as argument. That's the push parser we
435 - define a new parse() function which has the same signature as the usual
436 pull-parser, that repeatedly calls the push_parse function. Something
443 status = this->push_parse (yylex());
444 } while (status == YYPUSH_MORE);
448 - show me that parser, so that we can validate the approach.
450 *** (2) Port that into the skeleton
451 - once we agree on the API of the push parser, implement it into lalr1.d.
452 You will probaby need help on this regard, but imitation, again, should
455 - have example/d/pushcalc work properly and pass tests
457 - add tests in the "real" test suite. Do that in tests/calc.at. I can
463 This is very ambitious. That's the final boss. There are currently no
464 "clean" implementation to get inspiration from.
466 glr.c is very clean but:
468 - is a different skeleton from yacc.c
470 glr.cc is (currently) an ugly hack: a C++ shell around glr.c. Valentin
471 Tolmer is currently rewriting glr.cc to be clean C++, but he is not
472 finished. There will be a lot a common code between lalr1.cc and glr.cc, so
473 eventually I would like them to be fused into a single skeleton, supporting
474 both deterministic and generalized parsing.
476 It would be great for D to also support this.
478 The basic ideas of GLR are explained here:
480 https://www.codeproject.com/Articles/5259825/GLR-Parsing-in-Csharp-How-to-Use-The-Most-Powerful
482 * Better error messages
483 The users are not provided with enough tools to forge their error messages.
484 See for instance "Is there an option to change the message produced by
485 YYERROR_VERBOSE?" by Simon Sobisch, on bison-help.
488 https://www.cs.tufts.edu/~nr/cs257/archive/clinton-jefferey/lr-error-messages.pdf
489 https://research.swtch.com/yyerror
490 http://gallium.inria.fr/~fpottier/publis/fpottier-reachability-cc2016.pdf
493 Fix data/skeletons/yacc.c so that it defines YYPTRDIFF_T properly for modern
494 and older C++ compilers. Currently the code defaults to defining it to
495 'long' for non-GCC compilers, but it should use the proper C++ magic to
496 define it to the same type as the C ptrdiff_t type.
499 Several features are not available in all the back-ends.
501 - lac: D, Java (easy)
502 - push parsers: glr.c, glr.cc, lalr1.cc (not very difficult)
503 - token constructors: Java, C, D (a bit difficult)
504 - glr: D, Java (super difficult)
507 ** Autotest has quotation issues
508 tests/input.at:1730:AT_SETUP([%define errors])
512 $ ./tests/testsuite -l | grep errors | sed q
513 38: input.at:1730 errors
516 ** Get rid of YYPRINT and b4_toknum
517 Besides yytoknum is wrong when api.token.raw is defined.
519 ** Better design for diagnostics
520 The current implementation of diagnostics is ad hoc, it grew organically.
521 It works as a series of calls to several functions, with dependency of the
522 latter calls on the former. For instance:
524 complain (&sym->location,
525 sym->content->status == needed ? complaint : Wother,
526 _("symbol %s is used, but is not defined as a token"
527 " and has no rules; did you mean %s?"),
528 quote_n (0, sym->tag),
529 quote_n (1, best->tag));
530 if (feature_flag & feature_caret)
531 location_caret_suggestion (sym->location, best->tag, stderr);
533 We should rewrite this in a more FP way:
535 1. build a rich structure that denotes the (complete) diagnostic.
536 "Complete" in the sense that it also contains the suggestions, the list
537 of possible matches, etc.
539 2. send this to the pretty-printing routine. The diagnostic structure
540 should be sufficient so that we can generate all the 'format' of
541 diagnostics, including the fixits.
543 If properly done, this diagnostic module can be detached from Bison and be
544 put in gnulib. It could be used, for instance, for errors caught by
547 There's certainly already something alike in GCC. At least that's the
548 impression I get from reading the "-fdiagnostics-format=FORMAT" part of this
551 https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
553 ** Graphviz display code thoughts
554 The code for the --graph option is over two files: print_graph, and
555 graphviz. This is because Bison used to also produce VCG graphs, but since
556 this is no longer true, maybe we could consider these files for fusion.
558 An other consideration worth noting is that print_graph.c (correct me if I
559 am wrong) should contain generic functions, whereas graphviz.c and other
560 potential files should contain just the specific code for that output
561 format. It will probably prove difficult to tell if the implementation is
562 actually generic whilst only having support for a single format, but it
563 would be nice to keep stuff a bit tidier: right now, the construction of the
564 bitset used to show reductions is in the graphviz-specific code, and on the
565 opposite side we have some use of \l, which is graphviz-specific, in what
566 should be generic code.
568 Little effort seems to have been given to factoring these files and their
569 print{,-xml} counterpart. We would very much like to re-use the pretty format
570 of states from .output for the graphs, etc.
572 Since graphviz dies on medium-to-big grammars, maybe consider an other tool?
575 Check it too when checking the different kinds of parsers. And be
576 sure to check that the initial-action is performed once per parsing.
579 b4_shared_declarations is no longer what it is. Make it
580 b4_parser_declaration for instance.
582 ** yychar in lalr1.cc
583 There is a large difference bw maint and master on the handling of
584 yychar (which was removed in lalr1.cc). See what needs to be
588 /* User semantic actions sometimes alter yychar, and that requires
589 that yytoken be updated with the new translation. We take the
590 approach of translating immediately before every use of yytoken.
591 One alternative is translating here after every semantic action,
592 but that translation would be missed if the semantic action
593 invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
594 yychar. In the case of YYABORT or YYACCEPT, an incorrect
595 destructor might then be invoked immediately. In the case of
596 YYERROR, subsequent parser actions might lead to an incorrect
597 destructor call or verbose syntax error message before the
598 lookahead is translated. */
600 /* Make sure we have latest lookahead translation. See comments at
601 user semantic actions for why this is necessary. */
602 yytoken = yytranslate_ (yychar);
605 ** Get rid of fake #lines [Bison: ...]
606 Possibly as simple as checking whether the column number is nonnegative.
608 I have seen messages like the following from GCC.
610 <built-in>:0: fatal error: opening dependency file .deps/libltdl/argz.Tpo: No such file or directory
613 ** Discuss about %printer/%destroy in the case of C++.
614 It would be very nice to provide the symbol classes with an operator<<
615 and a destructor. Unfortunately the syntax we have chosen for
616 %destroy and %printer make them hard to reuse. For instance, the user
617 is invited to write something like
619 %printer { debug_stream() << $$; } <my_type>;
621 which is hard to reuse elsewhere since it wants to use
622 "debug_stream()" to find the stream to use. The same applies to
623 %destroy: we told the user she could use the members of the Parser
624 class in the printers/destructors, which is not good for an operator<<
625 since it is no longer bound to a particular parser, it's just a
629 ** Rewrite glr.cc in C++ (Valentin Tolmer)
630 As a matter of fact, it would be very interesting to see how much we can
631 share between lalr1.cc and glr.cc. Most of the skeletons should be common.
632 It would be a very nice source of inspiration for the other languages.
634 Valentin Tolmer is working on this.
637 The code in yyerrlab reads:
641 /* Return failure if at end of input. */
646 There are only two yychar that can be <= YYEOF: YYEMPTY and YYEOF.
647 But I can't produce the situation where yychar is YYEMPTY here, is it
648 really possible? The test suite does not exercise this case.
650 This shows that it would be interesting to manage to install skeleton
651 coverage analysis to the test suite.
653 * From lalr1.cc to yacc.c
655 Merging the three stacks in lalr1.cc simplified the code, prompted for
656 other improvements and also made it faster (probably because memory
657 management is performed once instead of three times). I suggest that
658 we do the same in yacc.c.
660 (Some time later): it's also very nice to have three stacks: it's more dense
661 as we don't lose bits to padding. For instance the typical stack for states
662 will use 8 bits, while it is likely to consume 32 bits in a struct.
664 We need trustworthy benchmarks for Bison, for all our backends. Akim has a
665 few things scattered around; we need to put them in the repo, and make them
671 Some statistics about the grammar and the parser would be useful,
672 especially when asking the user to send some information about the
673 grammars she is working on. We should probably also include some
674 information about the variables (I'm not sure for instance we even
675 specify what LR variant was used).
678 How would Paul like to display the conflicted actions? In particular,
679 what when two reductions are possible on a given lookahead token, but one is
680 part of $default. Should we make the two reductions explicit, or just
681 keep $default? See the following point.
683 ** Disabled Reductions
684 See 'tests/conflicts.at (Defaulted Conflicted Reduction)', and decide
688 Extend with error productions. The hard part will probably be finding
689 the right rule so that a single state does not exhibit too many yet
690 undocumented ''features''. Maybe an empty action ought to be
691 presented too. Shall we try to make a single grammar with all these
692 features, or should we have several very small grammars?
696 Well, only if there is really some demand for it.
699 https://github.com/scfc/bison-php/blob/master/data/lalr1.php
702 https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
704 ** Multiple start symbols
705 Would be very useful when parsing closely related languages. The idea is to
706 declare several start symbols, for instance
713 and to generate parse(), parse_stmt() and parse_expr(). Technically, the
714 above grammar would be transformed into
717 %token YY_START_STMT YY_START_EXPR
719 yy_start: YY_START_STMT stmt | YY_START_EXPR expr
721 so that there are no new conflicts in the grammar (as would undoubtedly
722 happen with yy_start: stmt | expr). Then adjust the skeletons so that this
723 initial token (YY_START_STMT, YY_START_EXPR) be shifted first in the
724 corresponding parse function.
727 This is a popular demand. We already made many changes in the parser that
728 should make this reasonably easy to implement.
730 Bruce Mardle <marblypup@yahoo.co.uk>
731 https://lists.gnu.org/archive/html/bison-patches/2015-09/msg00000.html
733 However, there are many other things to do before having such a feature,
734 because I don't want a % equivalent to #include (which we all learned to
735 hate). I want something that builds "modules" of grammars, and assembles
736 them together, paying attention to keep separate bits separated, in pseudo
740 There is demand for push parsers in Java and C++. And GLR I guess.
742 ** Generate code instead of tables
743 This is certainly quite a lot of work. See
744 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.4539.
747 We should find a means to provide an access to values deep in the
748 stack. For instance, instead of
750 baz: qux { $$ = $<foo>-1 + $<bar>0 + $1; }
752 we should be able to have:
754 foo($foo) bar($bar) baz($bar): qux($qux) { $baz = $foo + $bar + $qux; }
756 Or something like this.
759 It should be possible to have %if/%else/%endif. The implementation is
760 not clear: should it be lexical or syntactic. Vadim Maslow thinks it
761 must be in the scanner: we must not parse what is in a switched off
762 part of %if. Akim Demaille thinks it should be in the parser, so as
763 to avoid falling into another CPP mistake.
765 (Later): I'm sure there's actually good case for this. People who need that
766 feature can use m4/cpp on top of Bison. I don't think it is worth the
767 trouble in Bison itself.
770 There are couple of available extensions of Bison targeting some XML
771 output. Some day we should consider including them. One issue is
772 that they seem to be quite orthogonal to the parsing technique, and
773 seem to depend mostly on the possibility to have some code triggered
774 for each reduction. As a matter of fact, such hooks could also be
775 used to generate the yydebug traces. Some generic scheme probably
778 XML output for GNU Bison and gcc
779 http://www.cs.may.ie/~jpower/Research/bisonXML/
781 XML output for GNU Bison
782 http://yaxx.sourceforge.net/
784 * Coding system independence
787 Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
788 255). It also assumes that the 8-bit character encoding is
789 the same for the invocation of 'bison' as it is for the
790 invocation of 'cc', but this is not necessarily true when
791 people run bison on an ASCII host and then use cc on an EBCDIC
792 host. I don't think these topics are worth our time
793 addressing (unless we find a gung-ho volunteer for EBCDIC or
794 PDP-10 ports :-) but they should probably be documented
797 More importantly, Bison does not currently allow NUL bytes in
798 tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
799 the source code. This should get fixed.
804 Must we keep %token-table?
809 It is unfortunate that there is a total order for precedence. It
810 makes it impossible to have modular precedence information. We should
811 move to partial orders (sounds like series/parallel orders to me).
813 This is a prerequisite for modules.
815 * Pre and post actions.
816 From: Florian Krohm <florian@edamail.fishkill.ibm.com>
817 Subject: YYACT_EPILOGUE
818 To: bug-bison@gnu.org
819 X-Sent: 1 week, 4 days, 14 hours, 38 minutes, 11 seconds ago
821 The other day I had the need for explicitly building the parse tree. I
822 used %locations for that and defined YYLLOC_DEFAULT to call a function
823 that returns the tree node for the production. Easy. But I also needed
824 to assign the S-attribute to the tree node. That cannot be done in
825 YYLLOC_DEFAULT, because it is invoked before the action is executed.
826 The way I solved this was to define a macro YYACT_EPILOGUE that would
827 be invoked after the action. For reasons of symmetry I also added
828 YYACT_PROLOGUE. Although I had no use for that I can envision how it
829 might come in handy for debugging purposes.
830 All is needed is to add
833 YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen, yyloc, (yylsp - yylen));
835 YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen);
838 at the proper place to bison.simple. Ditto for YYACT_PROLOGUE.
840 I was wondering what you think about adding YYACT_PROLOGUE/EPILOGUE
841 to bison. If you're interested, I'll work on a patch.
844 Equip the parser with a means to create the (visual) parse tree.
849 # LocalWords: Cex gnulib gl Bistromathic TokenKinds yylex enum YYEOF EOF
850 # LocalWords: YYerror gettext af hb YYERRCODE undef calc FIXME dev yyerror
851 # LocalWords: Autoconf YYUNDEFTOK lexemes parsers Bistromathic's yyreport
852 # LocalWords: const argc yacc yyclearin lookahead destructor Rici incluent
853 # LocalWords: yydestruct yydiscardin catégories d'avertissements sr activé
854 # LocalWords: conflits défaut rr l'alias chaîne n'est attaché un symbole
855 # LocalWords: obsolète règle vide midrule valeurs de intermédiaire ou avec
856 # LocalWords: définies inutilisées priorité associativité inutiles POSIX
857 # LocalWords: incompatibilités tous les autres avertissements sauf dans rp
858 # LocalWords: désactiver CATEGORIE traiter comme des erreurs glr Akim bool
859 # LocalWords: Demaille arith lalr goto struct pathlen nullable ntokens lr
860 # LocalWords: nterm bitsetv ielr ritem nstates nrules nritems yysymbol EQ
861 # LocalWords: SymbolKind YYEMPTY YYUNDEF YYTNAME NUM yyntokens yytname sed
862 # LocalWords: nonterminals yykind yycode YYNAMES yynames init getName conv
863 # LocalWords: TokenKind semanticVal ival yychar yylval yylexer Tolmer hoc
864 # LocalWords: Sobisch YYPTRDIFF ptrdiff Autotest YYPRINT toknum yytoknum
865 # LocalWords: sym Wother stderr FP fixits xgettext fdiagnostics Graphviz
866 # LocalWords: graphviz VCG bitset xml bw maint yytoken YYABORT deps
867 # LocalWords: YYACCEPT yytranslate nonnegative destructors yyerrlab repo
868 # LocalWords: backends stmt expr yy Mardle baz qux Vadim Maslow CPP cpp
869 # LocalWords: yydebug gcc UCHAR EBCDIC gung PDP NUL Pre Florian Krohm utf
870 # LocalWords: YYACT YYLLOC YYLSP yyval yyvsp yylen yyloc yylsp endif
871 # LocalWords: ispell american
877 ispell-dictionary: "american"
880 Copyright (C) 2001-2004, 2006, 2008-2015, 2018-2020 Free Software
883 This file is part of Bison, the GNU Compiler Compiler.
885 Permission is granted to copy, distribute and/or modify this document
886 under the terms of the GNU Free Documentation License, Version 1.3 or
887 any later version published by the Free Software Foundation; with no
888 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
889 Texts. A copy of the license is included in the "GNU Free
890 Documentation License" file as part of this distribution.