Commit Graph

719 Commits

Author SHA1 Message Date
Akim Demaille
6240346aa0 doc: use %empty instead of /* empty */
* doc/bison.texi: Change the comments into explicit %empty.
2013-02-18 10:01:28 +01:00
Akim Demaille
09add9c24f doc: introduce %empty and -Wempty-rule
* doc/bison.texi (Grammar Rules): Make it a @section which
contains...
(Rules Syntax): this new subsection (with the previous contents of
"Grammar Rules".
(Empty Rules): New subsection, extracted from the former
"Grammar Rules".
Document %empty.
(Recursion): New a subsection of "Grammar Rules".
Complete a few index entries.
(Bison Options): Document -Wempty-rule.
2013-02-18 10:01:28 +01:00
Akim Demaille
fec5f3c0cc diagnostics: no longer pretty-print rules in error messages, carets suffice
* src/gram.c (grammar_rules_useless_report): Let -fcaret handle the
pretty-printing of the guilty rules.
(rule_print): Inline in its only use.
* tests/conflicts.at, tests/existing.at, tests/reduce.at,
* tests/regression.at: Adjust.
* NEWS: Document.
2013-02-14 15:00:51 +01:00
Akim Demaille
c21e515e05 news: restructure, document variants for C++
* NEWS: here.
2013-02-08 17:28:06 +01:00
Akim Demaille
d2f9ae18be news: name contributors
* NEWS: here.
2013-01-30 21:40:47 +01:00
Valentin Tolmer
cc2235ace2 warnings: introduce -Wprecedence
The new warning category "precedence" flags useless precedence and
associativity.  -Wprecedence can now be used, it is disabled by default.
The warnings about precedence and associativity are grouped into one, and
the testsuite was corrected accordingly.

* src/complain.h (warnings): Introduce "precedence".
* src/complain.c (warnings_print_categories): Adjust.
* src/getargs.c (warnings_args, warning_types): Likewise.
* src/symtab.h, src/symtab.c (print_associativity_warnings): Remove.
* src/symtab.h (register_assoc): Correct arguments.
* src/symtab.c (print_precedence_warnings): Print both warnings together.
* doc/bison.texi (Bison options): Document the warnings and provide an
example.
* tests/conflicts.at, tests/existing.at, tests/local.at,
* tests/regression.at: Adapt the testsuite for the new category
(-Wprecedence instead of -Wother where appropriate).
2013-01-30 21:39:08 +01:00
Valentin Tolmer
284bc49c83 grammar: warn about unused precedence for symbols
Symbols with precedence but no associativity, and whose precedence is
never used, can be declared with %token instead.  The used precedence
relationships are recorded and a warning about useless ones is issued.

* src/conflicts.c (resolve_sr_conflict): Record precedence relation.
* src/symtab.c, src/symtab.h (prec_nodes, init_prec_nodes)
(symgraphlink_new, register_precedence_second_symbol)
(print_precedence_warnings): New.
Record relationships in a graph and warn about useless ones.
* src/main.c (main): Print precedence warnings.
* tests/conflicts.at: New.
2013-01-29 15:11:35 +01:00
Akim Demaille
8458a41144 news: minor improvements
* NEWS: Name some more contributors.
Restructure slightly.
2013-01-28 17:46:13 +01:00
Valentin Tolmer
93561c21e8 grammar: preserve token declaration order
In a declaration %token A B, the token A is declared before B, but in %left
A B (or with %precedence or %nonassoc or %right), the token B was declared
before A (tokens were declared in reverse order).

* src/symlist.h, src/symlist.c (symbol_list_append): New.
* src/parse-gram.y: Use it instead of symbol_list_prepend.
* tests/input.at: Adjust expectations.
2013-01-27 10:37:12 +01:00
Akim Demaille
f0f95a50ee c: no longer require stdio.h when locations are enabled
Recent changes (in 2.7) introduced a dependency on both FILE and
fprintf, which are "available" only in %debug mode.  This was to
define yy_location_print_, which is used only in %debug mode by the
parser, but massively used by the test suite to output the locations
in yyerror.

Break this dependency: the test suite should define its own routines
to display the locations.  Eventually Bison will provide the user with
a means to display locations, but not yet.

* data/c.m4 (b4_yy_location_print_define): Use YYFPRINTF instead of
fprintf directly.
* data/yacc.c (b4_yy_location_print_define): Invoke it only in %debug
mode, so that stdio.h is included (needed for FILE*), and YYFPRINTF
is defined.

* tests/local.at (AT_YYERROR_DECLARE, AT_YYERROR_DEFINE): Declare
and define location_print and LOCATION_PRINT.

* tests/actions.at, tests/existing.at, tests/glr-regression.at,
* tests/input.at, tests/named-refs.at, tests/regression.at: Adjust
to use them.
Fix the expected line numbers (as the prologue's length has changed).
2013-01-25 16:45:17 +01:00
Akim Demaille
597afd73d7 news: prepare for 2.8
* NEWS: Restructure.
Name contributors.
2013-01-25 16:35:35 +01:00
Theophile Ranquet
8b4499ad04 news: typos
* NEWS: Fix a typo, use YYSTYPE rather than semantic_type.
2013-01-14 11:02:12 +01:00
Akim Demaille
7d6bad1959 maint: update copyright years
Suggested by Stefano Lattarini.
Run "make update-copyright".
2013-01-12 16:14:16 +01:00
Theophile Ranquet
016426c195 carets: document default activation
* NEWS: Announce it.
* doc/bison.texi: Adjust.
2013-01-11 19:11:21 +01:00
Theophile Ranquet
99d795e8f2 skel: better aliasing of identifiers
* data/glr.c, data/yacc.c: Avoid emitting useless defines.
* data/glr.cc: Restore prefixes for epilogue.
2013-01-11 18:57:09 +01:00
Akim Demaille
4119d1ea60 java: stype is obsoleted by api.value.type
This is consistent with the other %define variable names.

* data/java.m4: Use api.value.type instead of stype.
* doc/bison.texi, NEWS: Document that change.
* src/muscle-tab.c (muscle_percent_variable_update): Provide backward
compatibility.
* tests/java.at: Adjust.
2012-12-31 16:32:12 +01:00
Akim Demaille
40bb6f78f8 YYLEX_PARAM: drop support
* data/yacc.c, doc/bison.texi: Remove YYLEX_PARAM support.
* NEWS: Document it.
2012-12-26 10:38:59 +01:00
Akim Demaille
b9278c7d17 Merge branch 'origin/maint'
* origin/maint:
  maint: credit Wojciech Polak
  maint: post-release administrivia
  version 2.7
  yacc.c: scope reduction
  tests: C90 compliance
  fix C90 compliance
  glr.c: scope reduction
  gnulib: update

Conflicts:
	NEWS
	gnulib
	src/scan-gram.l
	src/system.h
2012-12-14 13:58:04 +01:00
Akim Demaille
2bd435c36c maint: credit Wojciech Polak
* NEWS, THANKS: He is the author of XML support (including XSLTs).
2012-12-13 09:29:18 +01:00
Akim Demaille
0a7b855930 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-12-12 16:23:44 +01:00
Akim Demaille
c13bb3484c version 2.7
* NEWS: Record release date.
2012-12-12 16:07:46 +01:00
Akim Demaille
1127a75a72 fix C90 compliance
* data/glr.c, src/graphviz.h, src/ielr.c, src/scan-gram.l,
* src/system.h, tests/actions.at, tests/glr-regression.at: Do not
use // comments.
Do not introduce variables after statements.
Provide "main" with a return value.
2012-12-12 11:44:39 +01:00
Theophile Ranquet
0906b12cd5 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  news: prepare for forthcoming release
  doc: explain how mid-rule actions are translated
  error: use better locations for unused midrule values
  doc: various minor improvements and fixes
  tests: ignore more useless compiler warnings
  tests: be robust to C being compiled with a C++11 compiler
  build: beware of Clang++ not supporting POSIXLY_CORRECT
  maint: post-release administrivia
  version 2.6.90
  build: fix syntax-check error.
  cpp: simplify the Flex version checking macro
  news: improve the carets example and fix a typo
  cpp: improve the Flex version checking macro
  carets: improve the code
  maint: update news
  build: keep -Wmissing-declarations and -Wmissing-prototypes for modern GCCs
  build: drop -Wcast-qual
  gnulib: update

Conflicts:
	NEWS
	doc/Makefile.am
	doc/bison.texi
	gnulib
	src/reader.c
	tests/actions.at
	tests/atlocal.in
	tests/input.at
2012-12-10 17:01:55 +01:00
Akim Demaille
d4fe9e88f3 news: prepare for forthcoming release
* NEWS: Fill paragraph.
Reorder.
Update examples.
Remove line for 2.6.90.
2012-12-09 17:12:55 +01:00
Akim Demaille
be22823e78 doc: explain how mid-rule actions are translated
* doc/bison.texi (Actions in Mid-Rule): Mention and use named references.
Split into three subsections, among which...
(Mid-Rule Action Translation): this new section.
2012-12-09 16:49:58 +01:00
Akim Demaille
09a1cd5e58 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-12-07 11:49:12 +01:00
Akim Demaille
a24e6b0d21 version 2.6.90
* NEWS: Record release date.
2012-12-07 11:37:14 +01:00
Theophile Ranquet
fb6040f0a8 news: improve the carets example and fix a typo
* NEWS: Here.
2012-12-07 12:02:00 +01:00
Akim Demaille
edf9a06f27 maint: update news
* NEWS: There is no 2.6.6, remove its stub.
2012-12-07 10:40:31 +01:00
Theophile Ranquet
f3ead217b8 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  misc: pacify the Tiny C Compiler
  cpp: make the check of Flex version portable
  misc: require getline
  c++: support wide strings for file names
  doc: document carets
  tests: enhance existing tests with carets
  errors: show carets
  getargs: add support for --flags/-f

Conflicts:
	doc/bison.texi
	m4/.gitignore
	src/complain.c
	src/flex-scanner.h
	src/getargs.c
	src/getargs.h
	src/gram.c
	src/main.c
	tests/headers.at
2012-12-06 13:38:43 +01:00
Theophile Ranquet
7bada5355e doc: document carets
* NEWS: Announce it.
* doc/bison.texi (Bison Options):  Here.
2012-12-05 13:46:01 +01:00
Akim Demaille
d6dc4d36d1 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  getargs: don't label --language/-l as experimental
  getargs: fix the locations of command-line input
  errors: indent missing action code semicolon warning

Conflicts:
	NEWS
	src/scan-code.l
	tests/actions.at
2012-12-05 11:03:08 +01:00
Theophile Ranquet
effd30c08d getargs: don't label --language/-l as experimental
* NEWS: Announce it.
* doc/bison.texi, src/getargs.c (usage): Here.
2012-12-04 15:54:43 +01:00
Akim Demaille
5807bb9156 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  doc: minor fixes
  doc: improve the index
  doc: introduce api.pure full, rearrange some examples
  yacc.c: support "%define api.pure full"
  local.at: improvements

Conflicts:
	NEWS
	data/yacc.c
	doc/bison.texi
	tests/calc.at
2012-11-29 15:20:03 +01:00
Theophile Ranquet
1f1bd57297 doc: introduce api.pure full, rearrange some examples
* NEWS: Add entry.
* doc/bison.texi (%define Summary): Show the old Yacc behaviour.
(Parser Function): Move parse-param examples here.
(Pure Calling): Remove parse-param examples.
(Error Reporting): Don't show the old behavior, stick to 'full'.
2012-11-29 11:08:58 +01:00
Akim Demaille
c6b1772473 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  yacc.c: always initialize yylloc
  scanner: issue a single error for groups of invalid characters
  tests: formatting changes
  doc: one of the fixes for an ambiguous grammar was ambiguous too
  doc: fix the dangling else with precedence directives
  doc: prefer "token" to TOKEN
  doc: formatting changes
  scanner: use explicit "ignore" statements

Conflicts:
	src/scan-gram.l
2012-11-26 09:41:35 +01:00
Akim Demaille
c6bf97ccb4 Merge remote-tracking branch 'origin/branch-2.6' into maint
* origin/branch-2.6:
  yacc.c: always initialize yylloc
  doc: one of the fixes for an ambiguous grammar was ambiguous too
  doc: fix the dangling else with precedence directives
  doc: prefer "token" to TOKEN
  doc: formatting changes

Conflicts:
	NEWS
	doc/bison.texi
2012-11-26 09:05:28 +01:00
Theophile Ranquet
fb4c8a7cb9 yacc.c: always initialize yylloc
The initial location might be used if the parser starts by an empty
reduction, so really ensure proper initialization of the initial
location.  The previous approach fails for PostgreSQL, which uses
Reported by Peter Eisentraut.
http://lists.gnu.org/archive/html/bug-bison/2012-11/msg00023.html
With help from Théophile Ranquet.

* data/yacc.c (b4_declare_scanner_communication_variables): Be sure
to initialize yylloc, even when its structure is unknown.
(yyparse): Simplify the call to b4_dollar_pushdef.
* tests/actions.at (Initial location): Check of similar pattern
as in the case of PostgreSQL.
2012-11-23 15:44:19 +01:00
Akim Demaille
53e2cd1ebd doc: one of the fixes for an ambiguous grammar was ambiguous too
Reported by Аскар Сафин.
http://lists.gnu.org/archive/html/bug-bison/2012-11/msg00024.html

* doc/bison.texi (Reduce/Reduce): Fix the resulting ambiguity using
precedence/associativity directives.
2012-11-23 09:47:20 +01:00
Akim Demaille
06ec0105b1 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  tests: close files in glr-regression
  xml: match DOT output and xml2dot.xsl processing
  xml: factor xslt space template
  graph: fix a memory leak
  xml: documentation
  output: capitalize State
2012-11-13 10:59:55 +01:00
Theophile Ranquet
9c16d39944 xml: documentation
The XML output combined with the XSL Transformations provided in data/ are
incredibly useful, they should be documented.

* doc/bison.texi (Xml): New node.
2012-11-12 16:44:54 +01:00
Akim Demaille
6d58c63202 Merge branch 'maint'
* origin/maint:
  regen
  maint: post-release administrivia
  version 2.6.5
  regen
  tests: syntax-check
  tests: beware of compilers that do not support POSIXLY_CORRECT
  gnulib: update

Conflicts:
	src/parse-gram.c
	src/parse-gram.h
	tests/atlocal.in
2012-11-08 09:26:44 +01:00
Akim Demaille
3ada393894 Merge branch 'branch-2.6' into maint
* origin/branch-2.6:
  maint: post-release administrivia
  version 2.6.5
  regen
  tests: syntax-check
  tests: beware of compilers that do not support POSIXLY_CORRECT
  gnulib: update

Conflicts:
	NEWS
	src/parse-gram.c
	src/parse-gram.h
2012-11-08 09:20:48 +01:00
Akim Demaille
9d2423f55d maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2012-11-07 18:35:36 +01:00
Akim Demaille
9d3f7eaf1d version 2.6.5
* NEWS: Record release date.
2012-11-07 18:09:46 +01:00
Akim Demaille
e42906f790 Merge remote-tracking branch 'origin/maint'
* origin/maint: (24 commits)
  tests: calc: modernize the use of locations
  tests: remove useless location initializations
  lalr1.cc: always initialize yylval.
  tests: check that C and C++ objects can be linked together.
  yacc.c: also disable -Wuninitialized.
  glr.cc, yacc.c: initialize yylloc properly
  yacc.c, glr.c: a better YY_LOCATION_PRINT
  yacc.c: simplify initialization
  doc: formatting changes
  c++: fix position operator signatures
  tests: remove useless location initialization.
  tests: fix locations in C
  tests: handle %parse-param in the generated yyerror
  tests: simplifications
  grammars: fix display of nul character in error message
  tests: sort
  tests: cosmetic changes
  comment changes
  autoconf: update
  gnulib: update
  ...

Conflicts:
	data/lalr1.cc
	gnulib
	src/scan-gram.l
	submodules/autoconf
	tests/calc.at
2012-11-06 18:30:16 +01:00
Akim Demaille
049016237e Merge branch 'branch-2.6' into maint
* origin/branch-2.6: (24 commits)
  tests: calc: modernize the use of locations
  tests: remove useless location initializations
  lalr1.cc: always initialize yylval.
  tests: check that C and C++ objects can be linked together.
  yacc.c: also disable -Wuninitialized.
  glr.cc, yacc.c: initialize yylloc properly
  yacc.c, glr.c: a better YY_LOCATION_PRINT
  yacc.c: simplify initialization
  doc: formatting changes
  c++: fix position operator signatures
  tests: remove useless location initialization.
  tests: fix locations in C
  tests: handle %parse-param in the generated yyerror
  tests: simplifications
  grammars: fix display of nul character in error message
  tests: sort
  tests: cosmetic changes
  comment changes
  autoconf: update
  gnulib: update
  ...

Conflicts:
	NEWS
	gnulib
	tests/named-refs.at
	tests/regression.at
2012-11-06 18:12:05 +01:00
Akim Demaille
a1d1ab50a0 glr.cc, yacc.c: initialize yylloc properly
There are several issues to address here.  One is that yylloc should
be initialized when possible.  Another is that the push parser needs
to update yypushed_loc when the user modified it.  And if the parser
starts by a reduction of an empty, it uses the first location on the
stack, which, therefore, must also be initialized to this initial
location.

This is getting complex, especially since because initializing a
global (impure interface) is different from initializing a local
variable.  To simplify, the local yylloc is not initialized during its
definition.

* data/c.m4 (b4_yyloc_default_define): Replace by...
(b4_yyloc_default): this.
Adjust dependencies.
* data/glr.cc: Initialize yylloc.
* data/yacc.c (b4_declare_scanner_communication_variables):
Initialize yylloc during its definition.
Don't define yyloc_default.
(yypush_parse): The location formal is not const, as we might
initialize it.
(yyparse): Define yyloc_default.
Use it before running the user initial action.
Possibly update the first location on the stack, and the pushed
location after the user initial action.
* tests/actions.at (Initial locations): Check that the initial
location is correct.
2012-11-06 17:35:38 +01:00
Akim Demaille
95066e9208 grammars: fix display of nul character in error message
Reported by Marc Mendiola.
http://lists.gnu.org/archive/html/help-bison/2012-10/msg00017.html

* gnulib: Update to get quote_mem.
* src/scan-gram.l: Use it.
* tests/input.at (Invalid inputs): Additional checks.
* tests/named-refs.at: Likewise.
2012-11-01 16:14:14 +01:00
Akim Demaille
a68b1f237e yacc.c: initialize yylval and yylloc.
When generating a pure push parser, the initialization of yylval and
yylloc may not be visible to the compiler.  With warnings enabled, GCC
4.3.6, 4.4.7, 4.5.4, and 4.6.3 report uninitialized uses of
yylval/yylloc.  Using local pragmas to disable these warnings is not
supported before 4.6, and 4.6 does not support it properly.  So
initialize yylval and yylloc at their definition.  Reported by Peter
Simons.  See
http://lists.gnu.org/archive/html/bison-patches/2012-10/msg00133.html

* data/c.m4 (b4_yyloc_default_define): New.
* data/yacc.c: Use it when locations are requested.
(YYLVAL_INITIALIZE): Replace by...
(YY_INITIAL_VALUE): this.
(yyparse): Initialize yylloc and yylval.
Therefore, remove the initialization of yylloc's field.
* data/glr.c: Likewise.
2012-10-28 16:53:18 +01:00