summaryrefslogtreecommitdiff
path: root/data
Commit message (Collapse)AuthorAgeFilesLines
...
* | glr2.cc: no longer be part of b4_glr_cc_ifAkim Demaille2021-01-311-1/+1
| | | | | | | | | | | | | | We are fully independant of glr.c/glr.cc, we no longer need to pretend we are glr.cc. * data/skeletons/bison.m4: here.
* | m4: provide macros for api.value.type=unionAkim Demaille2021-01-311-3/+7
| | | | | | | | | | | | * data/skeletons/bison.m4 (b4_union_if): New. Remove support for "%define variant", which was deprecated long ago. * tests/local.at (AT_UNION_IF): New.
* | Update URLs to prefer https: to http:Paul Eggert2021-01-2926-32/+32
| | | | | | | | Also, fix a few http: URLs that were no longer working.
* | glr2.cc: fix destructor supportAkim Demaille2021-01-241-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently glr2.cc does not use 'symbol's everywhere, in various places it also uses yykind, yyval and yyloc "by hand". So we need two different calls for user-defined constructors: once for ~symbol, another for yy_destroy_. Both need to call the user destructors with different calling conventions. * data/skeletons/glr2.cc (b4_symbol_action): Rename as... (b4_symbol_action_for_yyval): this. (b4_symbol_action): New, taken from lalr1.cc. (yy_destroy_, yy_symbol_value_print_): Use b4_symbol_action_for_yyval.
* | glr2.cc: beware of types with angle bracketsAkim Demaille2021-01-241-1/+1
| | | | | | | | | | | | For C++98, avoid "yyval.as<std::list<int>>". * data/skeletons/glr2.cc (b4_call_merger): Add spaces within "<...>".
* | Merge tag 'v3.7.5'Akim Demaille2021-01-241-0/+12
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Three new commits: commit 8358090292e21c61a583da542bad9099ad65f355 Author: Paul Eggert <eggert@cs.ucla.edu> Date: Wed Jan 20 18:30:16 2021 -0800 c: port to HP-UX 11.23 commit 2c294c132528ede23d8ae4959783a67e9ff05ac5 Author: Vincent Imbimbo <vmi6@cornell.edu> Date: Sat Jan 23 13:25:18 2021 -0500 cex: fix state-item pruning commit c22902e360e0fbbe9fd5657dcf107e03166da309 Author: Akim Demaille <akim.demaille@gmail.com> Date: Sat Jan 23 18:40:15 2021 +0100 tables: fix handling for useless tokens
| * package: bump copyrights to 2021Akim Demaille2021-01-2326-34/+34
| | | | | | | | Run 'make update-copyright'.
| * %merge: fix compatibility with api.value.type=unionAkim Demaille2021-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | Reported by Jot Dot. https://lists.gnu.org/r/help-bison/2020-12/msg00014.html * data/skeletons/glr.c, data/skeletons/glr2.cc (b4_call_merger): Use the symbol's slot, not its type. * examples/c/glr/c++-types.y: Use explicit per-symbol typing together with api.value.type=union. (yylex): Use yytoken_kind_t.
| * %merge: delegate the generation of calls to mergers to m4Akim Demaille2021-01-231-1/+10
| | | | | | | | | | | | | | Don't generate C code from bison, leave that to the skeletons. * src/output.c (merger_output): Emit invocations to b4_call_merger. * data/skeletons/glr.c (b4_call_merger): New.
| * skeletons: introduce "slot"s for symbolsAkim Demaille2021-01-232-1/+21
| | | | | | | | | | | | | | | | Extracted from d9cf99b6a5cb0345e91dfb90fe6d6473024ea97a, in the master branch. * data/skeletons/bison.m4 (b4_symbol_slot): New, with safer semantics than type and type_tag.
| * style: YYUSE is private, make it YY_USEAkim Demaille2021-01-235-19/+19
| | | | | | | | | | | | | | | | | | | | This macro is not exposed to users, make start it with 'YY_'. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.c, * data/skeletons/glr.cc, data/skeletons/lalr1.cc, * src/parse-gram.c, tests/actions.at, tests/c++.at, tests/headers.at, * tests/local.at (YYUSE): Rename as... (YY_USE): this.
| * glr.cc: don't "leak" yyparseAkim Demaille2021-01-232-3/+3
| | | | | | | | | | | | | | | | When using glr.cc, the C function yyparse is an internal detail that should not be exposed. Users might call it by accident (I did). * data/skeletons/glr.c (yyparse): When used for glr.cc, rename as yy_parse_impl. * data/skeletons/glr.cc: Adjust.
| * c++: use noexcept where appropriateAkim Demaille2021-01-232-6/+6
| | | | | | | | | | | | | | | | Reported by Don Macpherson. https://github.com/akimd/bison/issues/63 https://github.com/akimd/bison/issues/64 * data/skeletons/c++.m4, data/skeletons/lalr1.cc: here.
| * c: adjust _Noreturn to pedantic clangAkim Demaille2021-01-231-7/+9
| | | | | | | | | | | | | | | | | | | | Reported by Joe Nelson <joe@begriffs.com>. https://lists.gnu.org/r/help-bison/2021-01/msg00004.html Fixed by Paul Eggert in gnulib. https://lists.gnu.org/r/bug-gnulib/2021-01/msg00156.html * data/skeletons/c.m4 (b4_attribute_define): Adjust _Noreturn to pedantic clang.
| * c: port to HP-UX 11.23Paul Eggert2021-01-211-0/+12
| | | | | | | | | | | | | | Problem reported by Albert Chin in: https://lists.gnu.org/r/bug-bison/2021-01/msg00029.html * data/skeletons/c.m4 (b4_c99_int_type_define): Work around HP-UX bug.
* | d: examples: reduce scopesAkim Demaille2021-01-171-3/+13
| | | | | | | | | | | | | | | | * data/skeletons/lalr1.d (YYLocation.step): New. * examples/d/calc/calc.y (Lexer): Reduce scopes to avoid uninitialized varibles. Factor the handling of locations. We don't need lenChars.
* | package: codespellAkim Demaille2021-01-161-4/+4
| | | | | | | | * data/skeletons/glr2.cc, src/parse-gram.y: Fix spelling.
* | package: bump copyrights to 2021Akim Demaille2021-01-1627-37/+37
| | | | | | | | Run 'make update-copyright'.
* | c: add support for YYNOMEMAkim Demaille2021-01-162-14/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Suggested by Joe Nelson <joe@begriffs.com>. https://lists.gnu.org/r/help-bison/2020-12/msg00020.html * data/skeletons/glr.c, data/skeletons/yacc.c (YYNOMEM): New. Use it. (yyexhaustedlab): Rename as... (yynomemlab): this. * tests/calc.at: Check it. * doc/bison.texi: Document it. Fix incorrect statements about non-existing constants for YYERROR etc.
* | yacc.c, glr.c: style: rename yyreturn and yyreturnlabAkim Demaille2021-01-162-11/+11
| | | | | | | | * data/skeletons/glr.c, data/skeletons/yacc.c: here.
* | glr.c: style: formatting changesAkim Demaille2021-01-161-14/+9
| | | | | | | | * data/skeletons/glr.c (YYCHK1): here.
* | glr2.cc: don't prepare for subclassingAkim Demaille2021-01-161-9/+9
| | | | | | | | | | | | | | | | | | I am not aware of people subclassing the parser class, and I fail to see how this could be useful. Rather than leaving a badly baked feature (as in glr.cc currently), let's not support it at all, until someone comes and explains why and how it would be useful. * data/skeletons/glr2.cc (parser): We need no virtual function members.
* | glr2.cc: formatting changesAkim Demaille2021-01-161-21/+28
| | | | | | | | * data/skeletons/glr2.cc: here.
* | glr2.cc: move strong_index_alias into implementation fileAkim Demaille2021-01-161-77/+89
| | | | | | | | | | * data/skeletons/glr2.cc: here. Fix coding style issues.
* | glr2.cc: remove some useless qualificationsAkim Demaille2021-01-161-14/+13
| | | | | | | | | | * data/skeletons/glr2.cc: Rely on the type-aliases provided by glr_stack.
* | glr2.cc: more free functions about the automaton into glr_stackAkim Demaille2021-01-161-43/+49
| | | | | | | | | | | | | | | | | | * data/skeletons/glr2.cc (yypact_value_is_default) (yytable_value_is_error, yyisShiftAction, yyisErrorAction) (yyisDefaultedState, yydefaultAction): Move into... (glr_stack): here. Fix naming conventions.
* | glr2.cc: move free-functions into glr_stackAkim Demaille2021-01-161-93/+80
| | | | | | | | | | * data/skeletons/glr2.cc (yypreference, yyLRgotoState): Move into... (glr_stack): here.
* | glr2.cc: make yygetToken a member of glr_stackAkim Demaille2021-01-161-56/+51
| | | | | | | | | | | | | | | | | | It's on purpose that I keep the `this->` now. We'll see later if we want to remove them. * data/skeletons/glr2.cc (yygetToken): Move into... (glr_stack::yyget_token): this. (b4_lex): Adjust.
* | glr2.cc: move parser::parse into glr_stackAkim Demaille2021-01-161-199/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we have two classes that actually should be fused together: parser and glr_stack. Both carry part of the parsing: (i) parser contains `parse`, which is the top-level of the parsing process, it uses yygetToken, etc., and (ii) glr_stack takes care of all the details (dealing with the stack), and also calls yygetToken. However if we fuse them together, we would get a large parser class, in the header file. So it is probably better to split this large class using the pimpl idiom. But then it appears that glr_stack is very close from being the impl of parser. Let's improve this. For a start... * data/skeletons/glr2.cc (parser::parse): Move to... (glr_stack::parse): here. (parser::parse): Use it.
* | c: adjust _Noreturn to pedantic clangAkim Demaille2021-01-131-7/+9
| | | | | | | | | | | | | | | | | | | | Reported by Joe Nelson <joe@begriffs.com>. https://lists.gnu.org/r/help-bison/2021-01/msg00004.html Fixed by Paul Eggert in gnulib. https://lists.gnu.org/r/bug-gnulib/2021-01/msg00156.html * data/skeletons/c.m4 (b4_attribute_define): Adjust _Noreturn to pedantic clang.
* | glr2.cc: remove remains from glr.ccAkim Demaille2021-01-101-19/+4
| | | | | | | | | | | | | | * data/skeletons/glr2.cc: We no longer play dirty tricks with parse-params, remove the now useless dance around them. We now have genuine objects for locations, leave the initial action alone.
* | glr2.cc: add support for api.token.constructorAkim Demaille2021-01-101-5/+20
| | | | | | | | | | | | | | * data/skeletons/glr2.cc: Add support for api.token.constructor. * examples/c++/glr/c++-types.yy: Use it. * examples/c++/glr/c++-types.test: Adjust expectations for error messages.
* | glr2.cc: introduce the yytranslate_ member functionAkim Demaille2021-01-102-23/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | * data/skeletons/c++.m4 (b4_yytranslate_define): Use static_cast rather than the YY_CAST macro. Avoids the need to define YY_CAST in the header. * data/skeletons/glr2.cc: Fix calls to b4_shared_declarations: pass the type of file we are in. Don't define YYTRANSLATE. (parser::yytranslate_): New, as in lalr1.cc. Adjust to use it. * tests/glr-regression.at: Adjust.
* | glr2.cc: rely on symbol kinds rather than token kindsAkim Demaille2021-01-101-77/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of tracking the lookahead with yychar, use yytoken. This is consistent with lalr1.cc, saves us from calls to YYTRANSLATE (except when calling yylex), and makes it easier to migrate to using symbol_type. * data/skeletons/glr2.cc: Replace all uses of `int yychar` with `symbol_kind_type yytoken`. (yygetToken): Don't take/return the lookahead's token-kind and symbol-kind, just work directly on yystack's `yytoken` member. * tests/glr-regression.at (AT_PRINT_LOOKAHEAD_DECLARE) (AT_PRINT_LOOKAHEAD_DEFINE): New. Adjust to the fact that we have yytoken, not yychar, in glr2.cc.
* | glr2.cc: use references to print symbolsAkim Demaille2021-01-101-42/+67
| | | | | | | | | | | | | | | | | | | | | | | | * data/skeletons/glr2.cc (b4_symbol_action): New, so that we use `yyval` and `yyloc` rather than the `yyvaluep` and `yylocationp` pointers. (yy_symbol_value_print_, yy_symbol_print_, yy_destroy_): Use references rather than pointers. Drop support for the undocumented, obsolete, `yyoutput` variable. Adjust callers. (glr_state::destroy): Don't use yy_symbol_print_ when we don't have a symbol. Rather, write dedicated code.
* | glr2.cc: fix memory leakAkim Demaille2021-01-101-8/+8
| | | | | | | | | | * data/skeletons/glr2.cc (glr_stack_item::setState): Free the previous state before installing the new one.
* | d: create getter for the number of errors from the parserAdela Vais2021-01-071-1/+7
| | | | | | | | * data/skeletons/lalr1.d: Here.
* | d: remove support for parse.error verboseAdela Vais2021-01-071-2/+2
| | | | | | | | | | | | | | | | | | Without the history, D should not support this option. Before the removal, 'detailed' and 'verbose' options generated the same code. * data/skeletons/lalr1.d: Here. * doc/bison.texi: Adapt tests to use 'detailed' instead of 'verbose'. * tests/calc.at: Document it.
* | d: add support for %printerAkim Demaille2021-01-074-33/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we display the addresses of the semantic values. Instead, print the values. Add support for YY_USE across languages. * data/skeletons/c.m4, data/skeletons/d.m4 (b4_use): New. * data/skeletons/bison.m4 (b4_symbol_actions): Use b4_use to be portable to D. Add support for %printer, and use it. * data/skeletons/d.m4: Instead of duplicating what's already in c-like.m4, include it. (b4_symbol_action): New. Differs from the one in bison.m4 in that it uses yyval/yyloc instead of *yyvaluep and *yylocationp. * data/skeletons/lalr1.d (yy_symbol_print): Avoid calls to formatting, just call write directly. Use the %printer. * examples/d/calc/calc.y: Specify a printer. Enable traces when $YYDEBUG is set. * tests/calc.at: Fix the use of %printer with D.
* | d: remove unnecessary importsAdela Vais2021-01-061-5/+0
| | | | | | | | * data/skeletons/lalr1.d: Here.
* | d: remove yytnamerr usageAdela Vais2021-01-061-37/+3
| | | | | | | | | | | | | | It is a backwards-compatible feature for the other parsers. D should not support this option. * data/skeletons/d.m4: Here.
* | d: add internationalisation supportAdela Vais2021-01-062-14/+67
| | | | | | | | | | | | | | | | | | | | | | | | The D parser implements this feature similarly to the C parser, by using Gettext. Functions gettext() and dgettext() are imported using extern(C). The internationalisation uses yysymbol_name to report the name of the SymbolKinds. * data/skeletons/d.m4 (SymbolKind.toString.yytranslatable, SymbolKind.toString.yysymbol_name: New), data/skeletons/lalr1.d: Here. * doc/bison.texi: Document it. * tests/calc.at: Test it.
* | glr2.cc: add support for variantsAkim Demaille2021-01-051-44/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Bison) Variants are extremely picky, which makes them both annoying (lots of micro-details must be taken care of) and precious (all the micro-details must be taken care of, in particular object lifetime). So (i) each time a semantic value is stored, it must be stored in a place that exists, and (ii) each time a semantic value is discarded, its place must have been emptied. Example of (i) - new (&yys.value ()) value_type (s->value ()); + {]b4_variant_if([[ + new (&yys.value ()) value_type (); + ]b4_symbol_variant([yy_accessing_symbol (s->yylrState)], + [yys.value ()], [copy], [s->value ()])], [[ + new (&yys.value ()) value_type (s->value ());]])[ + } Example of (ii) yyparser.yy_destroy_ ("Error: discarding", - yytoken, &yylval]b4_locations_if([, &yylloc])[); + yytoken, &yylval]b4_locations_if([, &yylloc])[);]b4_variant_if([[ + // Value type destructor. + ]b4_symbol_variant([[YYTRANSLATE (this->yychar)]], [[yylval]], [[template destroy]])])[ this->yychar = ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(empty, id)[; However, in some places we must not be "pure". In particular: glr_stack_item (const glr_stack_item& other) YY_NOEXCEPT YY_NOTHROW : is_state_ (other.is_state_) { std::memcpy (raw_, other.raw_, union_size); } still must use memcpy, because the constructor would change pred, and it must not. This constructor is used only when resizing the stack, in which case pred (which is relative) must not be "adjusted". The result works, but is messy. Its verbosity comes from at least two factors: - we don't have support for complete symbols (binding kind, value and location), and we should at least try to have it. That simplified lalr1.cc a lot. - I have not tried to be smart and use 'move' when possible. As a consequence many places have 'copy' and then 'destroy'. That kind of clean up can be done once everything appears to be solid. * data/skeletons/glr2.cc: Be more rigorous in object lifetime. In particular, don't forget to discard the lookahead when we're done with it. Call variant routines where needed. Deal with plenty of details. (b4_call_merger): Add support for variants. Use references in mergers, rather than pointers. * examples/c++/glr/c++-types.yy: Exercise variants.
* | style: YYUSE is private, make it YY_USEAkim Demaille2021-01-036-32/+32
| | | | | | | | | | | | | | | | | | | | This macro is not exposed to users, make start it with 'YY_'. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.c, * data/skeletons/glr.cc, data/skeletons/glr2.cc, data/skeletons/lalr1.cc, * src/parse-gram.c, tests/actions.at, tests/c++.at, tests/headers.at, * tests/local.at (YYUSE): Rename as... (YY_USE): this.
* | glr: consistently use the same wording in tracesAkim Demaille2021-01-032-2/+2
| | | | | | | | | | * data/skeletons/glr.c, data/skeletons/glr2.cc (yyglrReduce): Traces refer to "state 42", not to "state #42".
* | glr2.cc: also equip semantic_option with self checkAkim Demaille2021-01-021-7/+28
| | | | | | | | | | | | * data/skeletons/glr2.cc (semantic_option): Add MAGIC_, magic_ and check_ members. Use it.
* | glr2.cc: log the execution of deferred actionsAkim Demaille2021-01-021-16/+23
| | | | | | | | | | | | | | | | | | See "glr.c: log the execution of deferred actions". * data/skeletons/glr2.cc (yyuserAction): Take yyk as a new argument. Rename argument yyn as yyrule for clarity. Log before and after the user action. Adjust callers to not call YY_REDUCE_PRINT and YY_SYMBOL_PRINT.
* | glr2.cc: minor clean upAkim Demaille2021-01-021-43/+38
| | | | | | | | | | * data/skeletons/glr2.cc (YYUNDEFTOK): Now useless. Formatting/coding style changes.
* | glr.c: log the execution of deferred actionsAkim Demaille2021-01-021-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently deferred reductions are not "verbose" at all: only immediate reductions are displayed in the YYDEBUG traces. I don't understand why. Besides it seems actually simpler the install the reduction traces right around the user action inside yyuserAction rather that around calls to yyuserAction. This only trouble is that yyuserAction does not know the stack number it works on, so we have to pass it. And pass -1 when we are actually running on a temporary stack. The glr example, on "T(x) + y;" as input, adds these logs, which allow to see when the `<cast>` is built: Stack 0 Entering state 26 Reduced stack 0 by rule 7 (line 108); action deferred. Now in state 7. Stack 0 Entering state 7 Reading a token Next token is token '+' (1.6: ) Stack 1 Entering state 27 Reduced stack 1 by rule 13 (line 123); action deferred. Now in state 12. Stack 1 Entering state 12 Next token is token '+' (1.6: ) Stack 1 dies. Removing dead stacks. On stack 0, shifting token '+' (1.6: ) Stack 0 now in state #14 +Reducing stack -1 by rule 6 (line 107): + $1 = token identifier (1.3: x) +-> $$ = nterm expr (1.3: x) +Reducing stack -1 by rule 7 (line 108): + $1 = token typename (1.0: T) + $2 = token '(' (1.2: ) + $3 = nterm expr (1.3: x) + $4 = token ')' (1.4: ) +-> $$ = nterm expr (1.0-3: <cast>(x,T)) Returning to deterministic operation. * data/skeletons/glr.c (yyuserAction): Take yyk as a new argument. Rename argument yyn as yyrule for clarity. Log before and after the user action. Adjust callers to not call YY_REDUCE_PRINT and YY_SYMBOL_PRINT.
* | glr.c: reorder routinesAkim Demaille2021-01-021-19/+22
| | | | | | | | | | | | | | | | The next commit wants to use YY_REDUCE_PRINT above its current definition. Move it higher. * data/skeletons/glr.c (yylhsNonterm, YY_REDUCE_PRINT): Make available earlier.