summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* style: comment changes and refactoring in state.cAkim Demaille2019-02-054-27/+21
| | | | | | | * src/state.h, src/state.c: Comment changes. (transitions_to): Take a state* as argument. * src/lalr.h, src/lalr.c: Comment changes. (initialize_F): Use clear variable names.
* Merge branch maintAkim Demaille2019-02-034-14/+31
|\ | | | | | | | | | | | | | | | | | | | | * maint: maint: post-release administrivia version 3.3.2 style: minor fixes NEWS: named constructors are preferable to symbol_type ctors gram: fix handling of nterms in actions when some are unused style: rename local variable CI: update the ICC serial number for travis-ci.org
| * style: minor fixesAkim Demaille2019-02-032-2/+2
| | | | | | | | | | * NEWS, src/reduce.c, src/reduce.h: Use 'nonterminal'. Fix comments.
| * gram: fix handling of nterms in actions when some are unusedAkim Demaille2019-02-034-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Bison 3.3, semantic values in rule actions (i.e., '$...') are passed to the m4 backend as the symbol number. Unfortunately, when there are unused symbols, the symbols are renumbered _after_ the numbers were used in the rule actions. As a result, the evaluation of the skeleton failed because it used non existing symbol numbers. Which is the happy scenario: we could use numbers of other existing symbols... Reported by Balázs Scheidler. http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00044.html Translating the rule actions after the symbol renumbering moves too many parts in bison. Relying on the symbol identifiers is more troublesome than it might first seem: some don't have an identifier (tokens with only a literal string), some might have a complex one (tokens with a literal string with characters special for M4). Well, these are tokens, but nterms also have issues: "dummy" nterms (for midrule actions) are named $@32 etc. which is risky for M4. Instead, let's simply give M4 the mapping between the old numbers and the new ones. To avoid confusion between old and new numbers, always emit pre-renumbering numbers as "orig NUM". * data/README: Give details about "orig NUM". * data/skeletons/bison.m4 (__b4_symbol, _b4_symbol): Resolve the "orig NUM". * src/output.c (prepare_symbol_definitions): Pass nterm_map to m4. * src/reduce.h, src/reduce.c (nterm_map): Extract it from nonterminals_reduce, to make it public. (reduce_free): Free it. * src/scan-code.l (handle_action_dollar): When referring to a nterm, use "orig NUM". * tests/reduce.at (Useless Parts): New, based Balázs Scheidler's report.
| * style: rename local variableAkim Demaille2019-02-021-10/+10
| | | | | | | | | | * src/reduce.c (nonterminals_reduce): Rename nontermmap as nterm_map. We will expose it.
* | style: reduce scopesAkim Demaille2019-02-031-7/+6
| | | | | | | | * src/symlist.c (symbol_list_free): New.
* | style: prefer snprintf to sprintfAkim Demaille2019-02-031-3/+4
| | | | | | | | | | | | * src/symtab.c (dummy_symbol_get): There's no need for the buffer to be so big and static. Use snprintf for safety.
* | style: comment and name changesAkim Demaille2019-02-023-10/+8
| | | | | | | | | | | | * src/output.c (prepare_symbol_names): here. * src/reader.c: Remove obsolete comment. * src/scan-code.l: Use || for Boolean or.
* | style: comment changesAkim Demaille2019-02-022-3/+3
| | | | | | | | * src/reader.c, src/scan-code.l: here.
* | gram: detect and report (in debug traces) useless chain rulesAkim Demaille2019-01-302-1/+11
| | | | | | | | | | | | | | | | | | | | A rule is a useless chain iff it's a chain (aka unit, or injection) rule (i.e., the RHS has length 1), and it's useless (it has no used defined semantic action). * src/gram.h, src/gram.c (rule_useless_chain_p): New. (grammar_dump): Report useless chain rules. * tests/sets.at: Check the traces.
* | lr(0): more debug tracesAkim Demaille2019-01-301-7/+48
| | | | | | | | | | * src/lr0.c (core_print, kernel_print): New. Use them.
* | lr(0): remove useless conditionalAkim Demaille2019-01-301-3/+1
| | | | | | | | | | * src/lr0.c (new_itemsets): There's no harm in setting a Boolean several times.
* | style: sort includes and avoid assignmentsAkim Demaille2019-01-302-8/+6
| | | | | | | | | | | | * src/symtab.c: Sort includes. * src/gram.c (grammar_rules_print_xml): Avoid assignments to define 'usefulness'.
* | style: use item_ruleAkim Demaille2019-01-302-17/+7
| | | | | | | | * src/print-graph.c, src/print-xml.c: here.
* | gram: factor the printing of items and the computation of their ruleAkim Demaille2019-01-306-31/+53
| | | | | | | | | | | | | | | | | | | | | | There are several places where we need to recover the rule from an item, let's factor that into item_rule. We also want to print items in a nice way: we do it when generating the *output file, but it is also useful in debug messages. * src/gram.h, src/gram.c (item_rule, item_print): New. * src/print.c (print_core): Use them. * src/state.h, src/state.c: Propagate constness.
* | style: scope reduction in print-xmlAkim Demaille2019-01-302-26/+19
| | | | | | | | * src/print-xml.c: here.
* | style: comment changesAkim Demaille2019-01-283-13/+16
| | | | | | | | * src/lr0.c, src/state.c, src/state.h: here.
* | closure: initialize it once for allAkim Demaille2019-01-286-13/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The memory allocated by 'closure' (and some data such as 'fderives') is used to computed a state's full itemset from its core. This is needed during the construction of the LR(0) automaton, and the memory is reclaimed immediately afterwards. Unfortunately the reports (graph, text, xml) also need this information when describing the states with their full itemsets. As a consequence the memory was allocated again, fderives computed again too, and more --trace reports are generated which only duplicate what was already reported. Stop that. It does mean that we release the memory later (hence the peak memory usage is higher now), but I don't think that's a problem today. * src/lr0.c (generate_states): Don't call closure_free. * src/state.c (states_free): Do it here. (for symmetry with closure_new which is called in generate_states). * src/print-graph.c, src/print-xml.c, src/print.c: You can now expect the closure module to be functional.
* | style: rename closure_* functions as closure_*Akim Demaille2019-01-286-15/+15
| | | | | | | | | | | | | | | | This is more consistent with the other files. * closure.h, closure.c (new_closure, free_closure): Rename as... (closure_new, closure_free): this. Adjust dependencies.
* | lr0: use a bitset for the set of "shiftable symbols"Akim Demaille2019-01-281-40/+30
| | | | | | | | | | | | | | | | | | | | | | This will make it easier to add new elements (that might already be part of shift_symbol) without having to worry about the size of shift_symbol (which is currently a fixed size vector). I could not measure any significant differences in performances in the generation of LR(0) automaton (benched on gramamrs of Ruby, C, and C++). * src/lr0.c (shift_symbol): Make it a bitset.
* | add -fsyntax-onlyAkim Demaille2019-01-283-6/+15
| | | | | | | | | | | | | | | | | | | | When debugging Bison itself, this is very handy, especially when tweaking the frontend badly enough to break the backends. It can also be used to check a grammar. * src/getargs.h, src/getargs.c (feature_syntax_only): New. (feature_args, feature_types): Adjust. * src/main.c (main): Use it.
* | style: beware of collisions on statusAkim Demaille2019-01-271-3/+3
| | | | | | | | | | | | | | * src/symtab.h (status): Rename as... (declaration_status): this, to avoid colliding with status, the argument of 'usage'. 'status' seems a tad too general to be used only here.
* | usage: document -ffixitAkim Demaille2019-01-271-6/+12
| | | | | | | | | | * src/getargs.c (usage): Document -ffixit. Document the aliases of -f.
* | style: reduce scopes in state.c and ielr.cAkim Demaille2019-01-272-63/+51
| |
* | Merge branch 'maint'Akim Demaille2019-01-272-3/+5
|\ \ | |/ | | | | | | | | | | | | | | * maint: maint: post-release administrivia version 3.3.1 yacc: issue warnings, not errors, for Bison extensions style: formatting changes in NEWS and complain.c tests: don't depend on the user's definition of SHELL
| * yacc: issue warnings, not errors, for Bison extensionsAkim Demaille2019-01-271-1/+1
| | | | | | | | | | | | | | | | | | Reported by Kiyoshi Kanazawa. http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00029.html * src/getargs.c (getargs): Let --yacc imply -Wyacc, not -Werror=yacc. * tests/input.at: Adjust. * doc/bison.tex (Bison Options): Document.
| * style: formatting changes in NEWS and complain.cAkim Demaille2019-01-271-2/+4
| |
* | traces: always print the reduced grammar and fix itAkim Demaille2019-01-262-24/+25
| | | | | | | | | | | | | | | | | | * src/gram.c (grammar_dump): Print the effective number first instead of last. And fix it (remove the incorrect "+1"). Use t/f for Booleans. * src/reduce.c: When asked, always print the reduced grammar, even if there was nothing useless. * tests/sets.at (Reduced Grammar): Check that.
* | style: rename LR0.* as lr0.*Akim Demaille2019-01-2610-11/+11
| | | | | | | | | | | | | | Let's stick to lower case for file names. * src/LR0.h, src/LR0.c: Rename as... * src/lr0.h, src/lr0.c: these.
* | style: rename print_graph.* as print-graph.*Akim Demaille2019-01-265-8/+8
| | | | | | | | | | | | | | These are the only files with _. * src/print_graph.h, src/print_graph.c: Rename as... * src/print-graph.h, src/print-graph.c: these.
* | style: various fixesAkim Demaille2019-01-263-25/+19
| | | | | | | | | | | | | | * src/gram.c: Use consistent variable names. Prefix prefix unary operators. (grammar_dump): Use rule_rhs_length instead of duplicating it. * src/reduce.c: Avoid useless variables.
* | style: comment changes in gram.hAkim Demaille2019-01-262-13/+15
|/ | | | * src/gram.h: Shorten comments.
* --update: when used, do not generate the output filesAkim Demaille2019-01-222-28/+34
| | | | | | | | | | | It is inconvenient that we also generate the output files when we update the grammar file, and it's somewhat unexpected. Let's not do that. * src/main.c (main): Skip generation when --update is passed. * src/getargs.c (usage): Update the help message. * doc/bison.texi (Bison Options): Likewise. * tests/input.at: Check that we don't generate the output.
* diagnostics: let redundant definitions be only warningsAkim Demaille2019-01-221-14/+20
| | | | | | | | After all, this is clearly harmless. * src/muscle-tab.c (muscle_percent_define_insert): Let equal definitions of a %define variable be only a warning. Adjust test cases.
* diagnostics: remove redundancyAkim Demaille2019-01-211-2/+5
| | | | | | | | | | | | | | | | Don't repeat the name of the warning in the sub messages. E.g., remove the second "[-Wother]" in the following message foo.y:2.1-27: warning: %define variable 'parse.error' redefined [-Wother] %define parse.error verbose ^~~~~~~~~~~~~~~~~~~~~~~~~~~ foo.y:1.1-27: previous definition [-Wother] %define parse.error verbose ^~~~~~~~~~~~~~~~~~~~~~~~~~~ * src/complain.c (error_message): Don't print the warning type when it's indented. Adjust test cases.
* style: prefer bool to charAkim Demaille2019-01-203-5/+7
| | | | | * src/state.h, src/state.c (state::consistent): Make it a bool. Adjust dependencies.
* style: various fixesAkim Demaille2019-01-181-30/+21
| | | | | | | | | Some reported by syntax-check. * po/POTFILES.in: Add fixits.cc. * src/muscle-tab.c: Don't cast for free. * src/files.c: Reduce scopes. * cfg.mk: We need the cast for free in muscle_percent_define_insert.
* fixits: handle duplicates of %name-prefixAkim Demaille2019-01-174-20/+40
| | | | | | | | | | The test case "Deprecated directives" (currently 56) no longer emits warnings after 'bison -u'! * src/files.h, src/files.c (spec_name_prefix_loc): New. * src/parse-gram.y (handle_name_prefix): Emit fixits for duplicate %name-prefix. * tests/input.at (Deprecated directives): Adjust.
* regenAkim Demaille2019-01-172-318/+357
|
* fixits: handle %file-prefixAkim Demaille2019-01-175-5/+37
| | | | | | | | * src/files.h, src/files.c (spec_file_prefix_loc): New. * src/scan-gram.l (%file-prefix): Delegate diagnostics to... * src/parse-gram.y (handle_file_prefix): here. * src/complain.c (duplicate_directive): Quote the directive. * tests/input.at: Adjust.
* fixits: handle per-rule duplicatesAkim Demaille2019-01-171-0/+1
| | | | | * src/complain.c (duplicate_rule_directive): Here. * tests/actions.at (Invalid uses of %empty): Check it.
* fixits: fix warnings about duplicatesAkim Demaille2019-01-171-1/+1
| | | | | * src/complain.c (duplicate_directive): Fix the complaint level. * tests/input.at: Adjust.
* diagnostics: properly indent the "previous declaration" messageAkim Demaille2019-01-161-5/+7
| | | | | * src/complain.c (duplicate_directive, duplicate_rule_directive): Here.
* regenAkim Demaille2019-01-162-336/+371
|
* style: rename some functions for consistencyAkim Demaille2019-01-161-17/+17
| | | | | | | | | | | "handle_" is the prefix used in scan-code.l for instance. * src/parse-gram.y (do_error_verbose, do_name_prefix, do_require) (do_skeleton, do_yacc): Rename as... (handle_error_verbose, handle_name_prefix, handle_require) (handle_skeleton, handle_yacc): these.
* fixits: report duplicate %yacc directivesAkim Demaille2019-01-1610-12/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We should use -ffixit and --update to clean files with duplicate directives. And we should complain only once about duplicate obsolete directives: keep only the "duplicate" warning. Let's start with %yacc. For instance on: %fixed-output_files %fixed-output-files %yacc %% exp: This run of bison: $ bison /tmp/foo.y -u foo.y:1.1-19: warning: deprecated directive, use '%fixed-output-files' [-Wdeprecated] %fixed-output_files ^~~~~~~~~~~~~~~~~~~ foo.y:2.1-19: warning: duplicate directive [-Wother] %fixed-output-files ^~~~~~~~~~~~~~~~~~~ foo.y:1.1-19: previous declaration %fixed-output_files ^~~~~~~~~~~~~~~~~~~ foo.y:3.1-5: warning: duplicate directive [-Wother] %yacc ^~~~~ foo.y:1.1-19: previous declaration %fixed-output_files ^~~~~~~~~~~~~~~~~~~ bison: file 'foo.y' was updated (backup: 'foo.y~') gives: %fixed-output-files %% exp: * src/location.h, src/location.c (location_empty): New. * src/complain.h, src/complain.c (duplicate_directive): New. * src/getargs.h, src/getargs.c (yacc_flag): Instead of a Boolean, be the location of the definition. Update dependencies. * src/scan-gram.l (%yacc, %fixed-output-files): Move the handling of its warnings to... * src/parse-gram.y (do_yacc): This new function. * tests/input.at (Deprecated Directives): Adjust expectations.
* style: rename duplicate_directive as duplicate_rule_directiveAkim Demaille2019-01-163-14/+13
| | | | | * src/complain.h, src/complain.c: here. Adjust callers.
* fixits: suggest running --update if there are fixitsAkim Demaille2019-01-164-8/+26
| | | | | | | | | | | * src/fixits.h, src/fixits.c (fixits_empty): New. * src/complain.c (deprecated_directive): Register the Wdeprecated fixits only if -Wdeprecated was enabled, so that we don't apply updates if the user didn't ask for them. * src/main.c (main): If there were fixits, issue a warning suggesting running with --update. Free uniqstrs after the fixits, since the latter use the former. * tests/headers.at, tests/input.at: Update expectations.
* fixits: avoid generating empty linesAkim Demaille2019-01-161-0/+15
| | | | | | * src/fixits.c (fixits_run): If erase the content of a line, also erase the following \n. * tests/input.at (Deprecated directives): Update expectations.
* Revert the last two commitsAkim Demaille2019-01-142-9/+2
| | | | | | | | They should not have been pushed, sorry about that. This reverts - commit 8575bd06ae6e65f3a30b21a3e022a968e4c7ae7a. - commit 55bf52860eac5c1394dc344a691220272df32b09.