platform/upstream/bison.git
11 years agom4: allow the definition of side-effect only macros
Akim Demaille [Mon, 8 Apr 2013 18:37:09 +0000 (20:37 +0200)]
m4: allow the definition of side-effect only macros

* data/bison.m4 (b4_divert_kill, b4_define_silent): New.
* data/c.m4: Comment change.

11 years agovariant: fix inconsistent quotation
Akim Demaille [Mon, 8 Apr 2013 18:22:04 +0000 (20:22 +0200)]
variant: fix inconsistent quotation

* data/variant.hh (b4_char_sizeof): De-overquote.
(b4_value_type_declare): De-underquote.

11 years agom4: style changes in error messages
Akim Demaille [Fri, 5 Apr 2013 12:00:49 +0000 (14:00 +0200)]
m4: style changes in error messages

* data/bison.m4: Use $0 to denote the current macro's name.

11 years agoapi.namespace: demonstrate and use {...} values instead of "..." values
Akim Demaille [Thu, 4 Apr 2013 15:27:36 +0000 (17:27 +0200)]
api.namespace: demonstrate and use {...} values instead of "..." values

* tests/c++.at, tests/input.at: Use "%define api.namespace {foo}" instead
of using quotes.
* tests/local.at (AT_SETUP_STRIP, AT_NAME_PREFIX): Recognize uses of
braces instead of quotes.
* doc/bison.texi: Use braces for api.namespace's values.

11 years agogrammar: do not add a \n at the end of blocks of code
Akim Demaille [Thu, 4 Apr 2013 15:21:55 +0000 (17:21 +0200)]
grammar: do not add a \n at the end of blocks of code

Now that we use "braceless" (which is {...} blocks of code with
initial and final braces stripped) to denote "short" values (such as
api.namespaces), the added end-of-line is a nuisance.  As a matter of
fact, this extra-safety was useless, as every expansion of "braceless"
(aka, "user code") is followed by an end of line.

* src/parse-gram.y, src/parse-gram.c (braceless): Instead of replacing
the final brace by \n, just delete the brace.

11 years agoregen
Akim Demaille [Thu, 4 Apr 2013 14:50:30 +0000 (16:50 +0200)]
regen

11 years agogrammar: record the kind of %define variable values
Akim Demaille [Thu, 4 Apr 2013 14:38:17 +0000 (16:38 +0200)]
grammar: record the kind of %define variable values

Provide a means to tell the difference between "keyword" values (e.g.,
%define api.pull both), "string" values (e.g., %define file.name
"foo"), and "code" values (e.g., %define api.namespace {calc}).

Suggested by Joel E. Denny.
http://lists.gnu.org/archive/html/bison-patches/2013-03/msg00016.html

* src/muscle-tab.h, src/muscle-tab.c (muscle_kind, muscle_kind_new)
(muscle_kind_string): New.
(muscle_percent_define_insert): Take the kind as new argument.
Insert it in the muscle table.
Adjust callers.
* src/getargs.c: Adjust callers.
* src/parse-gram.y: Ditto.
(content.opt): Remove, replaced by...
(value): this new non-terminal, whose semantics value is stored
in the new "value" union member.
Provide a printer.
Support values in braces in additions to keyword and string values.

fuse me

11 years agostyle: fix comments
Akim Demaille [Thu, 4 Apr 2013 14:27:54 +0000 (16:27 +0200)]
style: fix comments

* src/muscle-tab.c (muscle_percent_define_ensure): Update obsolete
comments.

11 years agoregen
Akim Demaille [Thu, 4 Apr 2013 13:48:08 +0000 (15:48 +0200)]
regen

11 years agogrammar: style changes
Akim Demaille [Thu, 4 Apr 2013 13:41:49 +0000 (15:41 +0200)]
grammar: style changes

* src/parse-gram.y (PARAM_TYPE): Remove useless typedef guard.
There's a header guard.
Use 'yyo' with %printer.
Use a consistent style for %union one-liners.

11 years agogrammar: split %union to group together related aspects
Akim Demaille [Thu, 4 Apr 2013 13:32:49 +0000 (15:32 +0200)]
grammar: split %union to group together related aspects

* src/parse-gram.y (INT): Fuse the %type and %token declaration.
Move its %union right before its introduction.
(%union): Split in several %unions, right before their use.

11 years agomuscle: refactor
Akim Demaille [Thu, 4 Apr 2013 13:18:29 +0000 (15:18 +0200)]
muscle: refactor

* src/muscle-tab.c (muscle_lookup, muscle_entry_new): New.
(muscle_insert, muscle_grow, muscle_find_const, muscle_find): Use them.

11 years agostyle: comment changes
Akim Demaille [Wed, 3 Apr 2013 15:07:56 +0000 (17:07 +0200)]
style: comment changes

* src/muscle-tab.c: Move the documentation of public functions to...
* src/muscle-tab.h: here.
Fix comment consistency issues.

11 years agomuscle: minor refactoring
Akim Demaille [Wed, 3 Apr 2013 15:07:22 +0000 (17:07 +0200)]
muscle: minor refactoring

* src/muscle-tab.h (MUSCLE_INSERT_C_STRING): Use MUSCLE_INSERT_STRING.

11 years agoregen
Akim Demaille [Wed, 6 Mar 2013 09:28:16 +0000 (10:28 +0100)]
regen

11 years agogram: correct token numbering in precedence declarations
Valentin Tolmer [Tue, 5 Mar 2013 11:29:50 +0000 (12:29 +0100)]
gram: correct token numbering in precedence declarations

In a precedence declaration, when tokens are declared with a litteral
character (e.g., 'a') or with a identifier (e.g., B), Bison behaved
differently: the litteral tokens would be numbered first, and then the
other ones, leading to the following grammar:

  %right A B 'c' 'd'

being numbered as such: 'c' 'd' A B.

* src/parse-gram.y (symbol.prec): Set the symbol number when reading the
symbols.
* tests/conflicts.at (Token declaration order: literals vs. identifiers):
New.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
11 years agomaint: update autoconf submodule
Akim Demaille [Mon, 4 Mar 2013 17:26:25 +0000 (18:26 +0100)]
maint: update autoconf submodule

* submodules/autoconf: Up to master.
No significant changes in the files we use (m4sugar.m4 and foreach.m4).

11 years agodiagnostics: no longer include the yacc category in -Wall
Akim Demaille [Mon, 4 Mar 2013 17:15:49 +0000 (18:15 +0100)]
diagnostics: no longer include the yacc category in -Wall

It would be a pity to warn the users against Bison features...
http://lists.gnu.org/archive/html/bison-patches/2013-02/msg00107.html

* src/complain.h, src/complain.c (Wall): Disable Wyacc.
(Weverything): New (hidden so far) category which really denotes all
the categories (what used to be Wall).
(warnings_args, warnings_types): Adjust.
(warning_argmatch): Now !none = Weverything and conversely, no longer Wall.
* NEWS, doc/bison.texi, src/getargs.c: Adjust the documentation.
* tests/input.at (-Werror is not affected by -Wnone and -Wall): Adjust
by not using a -Wyacc type of warning.

11 years agogrammar: no longer detect and cure missing semicolon at end of actions
Akim Demaille [Mon, 25 Feb 2013 14:33:55 +0000 (15:33 +0100)]
grammar: no longer detect and cure missing semicolon at end of actions

Bison 3.0 is already breaking backward compatibility with other
features.  It is an appropriate time to drop this feature.  Note that
it was disabled when --yacc is passed.  See
http://lists.gnu.org/archive/html/bison-patches/2013-02/msg00102.html

Basically, revert e8cd1ad655bcc704b06fb2f191dc3ac1df32b796.

* src/scan-code.l (braces_level, need_semicolon, in_cpp): Remove.
Remove every rule needed to detect and add missing semicolon.
* tests/actions.at (Fix user actions without a trailing semicolon):
Remove.
* NEWS: Adjust.

11 years agobuild: stop using bison -y
Akim Demaille [Wed, 27 Feb 2013 14:41:55 +0000 (15:41 +0100)]
build: stop using bison -y

* Makefile.am (YACC): Pass -o y.tab.c, so that ylwrap is happy, and
yet we don't pass --yacc to bison.
(AM_YFLAGS): Disable Yacc warnings.

11 years agoc++: rename b4_semantic_type_declare as b4_value_type_declare
Akim Demaille [Fri, 8 Feb 2013 16:09:33 +0000 (17:09 +0100)]
c++: rename b4_semantic_type_declare as b4_value_type_declare

This is to match the names used in C and api.value.type, even if the
parser actually defines semantic_type.

* data/c++.m4 (b4_semantic_type_declare): Rename as...
(b4_value_type_declare): this.
* data/variant.hh: Likewise.

11 years agonews: typo
Akim Demaille [Sat, 23 Feb 2013 13:37:27 +0000 (14:37 +0100)]
news: typo

* NEWS: here.

11 years agostyle: space changes in the tests
Akim Demaille [Sat, 23 Feb 2013 13:44:33 +0000 (14:44 +0100)]
style: space changes in the tests

* tests/local.at: here.

11 years agostyle: formatting changes in the doc
Akim Demaille [Fri, 22 Feb 2013 12:18:17 +0000 (13:18 +0100)]
style: formatting changes in the doc

* doc/bison.texi: Use @file where appropriate.

11 years agotests: fix invalid C++11 code
Akim Demaille [Tue, 19 Feb 2013 16:44:08 +0000 (17:44 +0100)]
tests: fix invalid C++11 code

* tests/c++.at (Object): Somehow instances of Object were assigned
YY_NULL, which is 0 most of the time (that case passes), but is
nullptr in C++11, and there is nothing in Object to support such an
assignment (failure).  Use 0 as value, and provide the needed
assignment operator.
Also, use a more natural order within the class definition.

11 years agotests: fix failures with G++ 4.8 in Flex scanner
Akim Demaille [Tue, 19 Feb 2013 16:42:33 +0000 (17:42 +0100)]
tests: fix failures with G++ 4.8 in Flex scanner

* configure.ac (WARN_NO_NULL_CONVERSION_CXXFLAGS): Rename as...
(FLEX_SCANNER_CXXFLAGS): this.
Pass -Wno-zero-as-null-pointer-constant to G++ if it supports it.
* examples/calc++/local.mk: Adjust.

11 years agoregen
Akim Demaille [Tue, 19 Feb 2013 09:07:37 +0000 (10:07 +0100)]
regen

11 years agognulib: update
Akim Demaille [Tue, 19 Feb 2013 08:32:43 +0000 (09:32 +0100)]
gnulib: update

11 years agostyle: rename variant private members
Akim Demaille [Tue, 19 Feb 2013 08:25:58 +0000 (09:25 +0100)]
style: rename variant private members

* data/variant.hh (buffer, tname, as_, raw, align_me): Rename as...
(yybuffer_, yytname_,yyas_, yyraw, yyalign_me): these.

11 years agostyle: space changes
Akim Demaille [Tue, 19 Feb 2013 08:21:26 +0000 (09:21 +0100)]
style: space changes

* data/variant.hh: Be sure to leave a space before arguments in function
calls.

11 years agovariant: fix G++ 4.4 warnings
Akim Demaille [Tue, 19 Feb 2013 07:55:15 +0000 (08:55 +0100)]
variant: fix G++ 4.4 warnings

The changes by Théophile Ranquet about type punning issues need
to be extend to in-place new to please G++ 4.4.7.

* data/variant.hh (variant::as_): New, factors the casts that avoid
compiler warnings.
(as, build): Use them.

11 years agonews: spell fixes
Akim Demaille [Mon, 18 Feb 2013 13:29:43 +0000 (14:29 +0100)]
news: spell fixes

* NEWS: here.

11 years agodiagnostics: factor and enhance messages about duplicate rule directives
Akim Demaille [Sun, 17 Feb 2013 11:47:35 +0000 (12:47 +0100)]
diagnostics: factor and enhance messages about duplicate rule directives

When reporting a duplicate directive on a rule, point to its first
occurrence:

one.y:11.10-15: error: only one %empty allowed per rule
   %empty {} %empty
             ^^^^^^
one.y:11.3-8: previous declaration
   %empty {} %empty
   ^^^^^^

And consistently discard the second one.

* src/complain.h, src/complain.c (duplicate_directive): New.
* src/reader.c: Use it where appropriate.
* src/symlist.h, src/symlist.c (symbol_list): Add a dprec_location member.
* tests/actions.at: Adjust expected output.

11 years agostyle: no longer use backquotes
Akim Demaille [Sat, 16 Feb 2013 13:21:09 +0000 (14:21 +0100)]
style: no longer use backquotes

* tests/actions.at, tests/atlocal.in, tests/c++.at, tests/calc.at,
* tests/conflicts.at, tests/existing.at, tests/glr-regression.at,
* tests/input.at, tests/java.at, tests/local.at, tests/sets.at,
* tests/synclines.at, doc/bison.texi, lib/libiberty.h, lib/timevar.h:
Use single quotes.

11 years agostyle: no longer use backquotes
Akim Demaille [Sat, 16 Feb 2013 13:07:25 +0000 (14:07 +0100)]
style: no longer use backquotes

* README, REFERENCES, TODO, configure.ac, data/README, data/bison.m4,
* data/c++.m4, data/c.m4, data/java.m4, data/lalr1.cc,
* data/lalr1.java, data/yacc.c, doc/local.mk, etc/bench.pl.in,
* src/conflicts.c, src/files.c, src/getargs.c, src/gram.h, src/lalr.c,
* src/location.c, src/location.h, src/muscle-tab.c, src/muscle-tab.h,
* src/output.c, src/parse-gram.c, src/parse-gram.y, src/print-xml.c,
* src/print.c, src/reader.c, src/reduce.c, src/scan-skel.l,
* src/symtab.h, src/system.h, src/tables.c:
Use single quotes, as currently recommended by the GNU Coding Standards.

11 years agostyle: no longer use backquotes in messages
Akim Demaille [Sat, 16 Feb 2013 13:04:46 +0000 (14:04 +0100)]
style: no longer use backquotes in messages

* src/getargs.c (usage): Use single quotes.

11 years agodoc: use %empty instead of /* empty */
Akim Demaille [Sat, 16 Feb 2013 12:49:04 +0000 (13:49 +0100)]
doc: use %empty instead of /* empty */

* doc/bison.texi: Change the comments into explicit %empty.

11 years agodoc: introduce %empty and -Wempty-rule
Akim Demaille [Sat, 16 Feb 2013 12:23:23 +0000 (13:23 +0100)]
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.

11 years agoreport: use %empty to denote empty rules
Akim Demaille [Sat, 16 Feb 2013 11:46:09 +0000 (12:46 +0100)]
report: use %empty to denote empty rules

* src/gram.c (rule_rhs_print): Use %empty for empty rules.
* tests/conflicts.at, tests/regression.at, tests/sets.at: Adjust.

11 years agodiagnostics: %empty enables -Wempty-rule
Akim Demaille [Sat, 16 Feb 2013 08:23:48 +0000 (09:23 +0100)]
diagnostics: %empty enables -Wempty-rule

* src/complain.h, src/complain.c (warning_is_unset): New.
* src/reader.c (grammar_current_rule_empty_set): If enabled -Wempty-rule,
if not disabled.
* tests/actions.at (Implicitly empty rule): Check this feature.
Also check that -Wno-empty-rule does disable this warning.

11 years ago-Wempty-rule: diagnose empty rules without %empty
Akim Demaille [Sat, 9 Feb 2013 17:26:38 +0000 (18:26 +0100)]
-Wempty-rule: diagnose empty rules without %empty

* src/complain.h, src/complain.c (warning_empty_rule, Wempty_rule):
New warning category.
(warnings_args, warnings_types): Adjust.
* src/reader.c (grammar_rule_check): Check the empty rules are
flagged by %empty.
* tests/actions.at (Implicitly empty rule): New.
* tests/existing.at: Add expected warnings.

11 years agotests: use %empty
Akim Demaille [Sat, 16 Feb 2013 11:57:31 +0000 (12:57 +0100)]
tests: use %empty

* tests/actions.at, tests/input.at, tests/reduce.at,
* tests/regression.at:
here.

11 years agoregen
Akim Demaille [Sat, 9 Feb 2013 17:42:07 +0000 (18:42 +0100)]
regen

11 years agoparser: use %empty
Akim Demaille [Sat, 9 Feb 2013 12:47:14 +0000 (13:47 +0100)]
parser: use %empty

Avoid that Bison's own use of "bison -Wall" trigger warnings.

* src/parse-gram.y: Use %empty for every empty rule.

11 years agogrammar: introduce %empty
Akim Demaille [Tue, 29 Jan 2013 13:19:40 +0000 (14:19 +0100)]
grammar: introduce %empty

Provide a means to explicitly denote empty right-hand sides of rules:
instead of

  exp:  { ... }

allow

  exp: %empty { ... }

Make sure that %empty is properly used.

With help from Joel E. Denny and Gabriel Rassoul.
http://lists.gnu.org/archive/html/bison-patches/2013-01/msg00142.html

* src/reader.h, src/reader.c (grammar_current_rule_empty_set): New.
* src/parse-gram.y (%empty): New token.
Use it.
* src/scan-gram.l (%empty): Scan it.
* src/reader.c (grammar_rule_check): Check that %empty is properly used.
* tests/actions.at (Invalid uses of %empty, Valid uses of %empty): New.

11 years agogetargs: minor simplification
Akim Demaille [Thu, 14 Feb 2013 13:57:18 +0000 (14:57 +0100)]
getargs: minor simplification

* src/getargs.c (flag_argmatch): Simplify the handling of "none".

11 years agostyle: move argument handling of -W into the diagnostics module
Akim Demaille [Thu, 14 Feb 2013 13:35:24 +0000 (14:35 +0100)]
style: move argument handling of -W into the diagnostics module

This allows to reduce the number of public interfaces.

* src/getargs.c (--yacc): Use warning_argmatch instead of tweaking
directly warnings_flag (which will be private).
(warning_argmatch, warnings_argmatch): Move to...
* src/complain.h, src/complain.c: here.

* src/getargs.h, src/getargs.c (warnings_args, warnings_types): Move to...
* src/complain.c: here, now private.

* src/complain.h (severity, warnings_flag): Move to...
* src/complain.c: here, now private.

11 years agodiagnostics: revamp the handling of -Werror
Akim Demaille [Thu, 14 Feb 2013 08:25:36 +0000 (09:25 +0100)]
diagnostics: revamp the handling of -Werror

Recent discussions with Joel E. Denny
(http://lists.gnu.org/archive/html/bison-patches/2013-02/msg00026.html)
show that it is desirable to tell the difference between an option
that was explicitly disabled with -Wno-foo, as opposed to be left
unset.  The current framework does not allow this.

Instead of having a first int to store which options are enabled, and
another to store which are turned into errors, use an array that for
each warning category tells its status: disabled, unset, warning,
error.

* src/complain.h, src/complain.c (warning_bit): New enum.
(warnings): Use it.
(severity): New enum.
(warnings_flag): Now an array of severity.
(errors_flag): Remove, now done by warnings_flag.
(complain_init): New function, to initialie warnings_flag.
(warnings_are_errors): New Boolean, for -Werror.
* src/complain.c (warning_severity): New.
(warnings_print_categories, complains): Use it.
* src/getargs.c (warning_argmatch): Adjust to use warnings_flag.
(warnings_argmatch): Ditto.
Handle -Werror and -Wno-error here.
(getargs): Adjust.
* src/main.c (main): Call complain_init.
* tests/input.at (Invalid options): Add more corner cases.

11 years agooptions: simplify the handling of -W
Akim Demaille [Wed, 13 Feb 2013 20:11:10 +0000 (21:11 +0100)]
options: simplify the handling of -W

* src/getargs.c (warnings_argmatch, warning_argmatch): Simplify by
replacing function arguments with their actual values.
(WARNING_ARGMATCH): Remove, useless.
Adjust callers.

11 years agooptions: don't accept "error=" for -f and -r
Akim Demaille [Wed, 13 Feb 2013 16:29:42 +0000 (17:29 +0100)]
options: don't accept "error=" for -f and -r

* src/getargs.c (warning_argmatch, warnings_argmatch, WARNINGS_ARGMATCH):
New.
Use them for -W/--warning.
They are copied from...
(flag_argmatch, flags_argmatch, FLAGS_ARGMATCH): these.
Simplify by removing the support for "error".
* tests/input.at (Invalid options): New.
* TODO (Laxism in Bison invocation arguments): Remove.

11 years agodiagnostics: factor the list of warning names
Akim Demaille [Mon, 11 Feb 2013 09:25:08 +0000 (10:25 +0100)]
diagnostics: factor the list of warning names

* src/getargs.h, src/getargs.c (warnings_args, warnings_types): Make
them public.
* src/complain.h, src/complain.c (warnings_print_categories): Its
only use outside complain.c was removed in a recent commit, so
make it static.
Simplify its implementation.
Use warnings_args and warnings_types.
* src/muscle-tab.c (muscle_percent_define_check_values): Make it
silent.

11 years agodiagnostics: no longer pretty-print rules in error messages, carets suffice
Akim Demaille [Mon, 11 Feb 2013 09:17:36 +0000 (10:17 +0100)]
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.

11 years agooptions: no longer document warnings when diagnosing an invalid -W
Akim Demaille [Mon, 11 Feb 2013 08:34:22 +0000 (09:34 +0100)]
options: no longer document warnings when diagnosing an invalid -W

The argmatch functions accept prefixes of the alternatives (like
getopt does for long options).  Bison uses this to document the
warning categories.  This is troublesome: it duplicates the --help
documentation, it is not gettextized, it is displayed with ugly quotes
(because argmatch uses it to display the list of possible answers),
and it prevents straighforward uses of the tables of valid warning
categories (for instance so that warning diagnostics end with the name
of the warning).

The "hidden" option --trace uses the same trick, but it does not need
to be translated, nor to be described in --help.

* src/getargs.c (warnings_args): Remove pseudo documentation.
Comment changes.

11 years agotests: enlarge the allowed duration for calc tests
Akim Demaille [Mon, 11 Feb 2013 08:07:25 +0000 (09:07 +0100)]
tests: enlarge the allowed duration for calc tests

Hydra "often" fails on this test:

252. calc.at:658: 252. Calculator %glr-parser api.pure
parse.error=verbose %debug %locations %defines api.prefix="calc"
%verbose %yacc %parse-param {semantic_value *result}
%parse-param {int *count} (calc.at:658): FAILED

* tests/calc.at: Give 200s instead of 100s.
Use AT_DEBUG_IF.

11 years agodebug: improve the display of symbol lists
Akim Demaille [Sat, 9 Feb 2013 15:07:09 +0000 (16:07 +0100)]
debug: improve the display of symbol lists

* src/symtab.c (symbol_print): Remove useless quotes (the symbol already
has quotes).
Prefer fputs.
* src/symlist.c (symbol_list_syms_print): Likewise.
Fix separators.

11 years agostyle: minor changes
Akim Demaille [Sat, 9 Feb 2013 17:25:15 +0000 (18:25 +0100)]
style: minor changes

* src/complain.c: Space changes.
* src/reader.c: Comment changes.
Avoid && in assertions.
* src/location.c: Move comments to...
* src/location.h: here.
* src/symlist.h, src/symlist.c: Create a pseudo section for members
that apply to the rule.

11 years agonews: restructure, document variants for C++
Akim Demaille [Fri, 8 Feb 2013 16:01:23 +0000 (17:01 +0100)]
news: restructure, document variants for C++

* NEWS: here.

11 years agoc++: api.token.constructor requires api.value.type=variant
Akim Demaille [Fri, 8 Feb 2013 14:25:18 +0000 (15:25 +0100)]
c++: api.token.constructor requires api.value.type=variant

Eventually it should also support "union".

* data/glr.cc: Move this check to...
* data/c++.m4: here, as lalr1.cc is affected too.

11 years agobuild: restore C90 compatibility
Akim Demaille [Tue, 5 Feb 2013 13:37:55 +0000 (14:37 +0100)]
build: restore C90 compatibility

* src/parse-gram.y, src/parse-gram.c: Don't use // comments.

11 years agodoc: use @group to improve page breaking
Akim Demaille [Mon, 4 Feb 2013 16:55:27 +0000 (17:55 +0100)]
doc: use @group to improve page breaking

* doc/bison.texi: here.

11 years agostyle: rename internal "stype" as "union_members" for clarity
Akim Demaille [Mon, 4 Feb 2013 17:35:51 +0000 (18:35 +0100)]
style: rename internal "stype" as "union_members" for clarity

"stype" is quite unclear, and it also collides with the former %define
variable that had the same name (replaced by api.value.type).

* src/parse-gram.y (stype): Rename as...
(union_members): this.
* data/bison.m4: Adjust.
(b4_user_stype): Rename as...
(b4_user_union_members): this.
* data/c++.m4, data/c.m4: Adjust.
* src/parse-gram.c: regen.

11 years agotests: improve the language independance layer
Akim Demaille [Mon, 4 Feb 2013 15:13:02 +0000 (16:13 +0100)]
tests: improve the language independance layer

* tests/local.at (_AT_LANG_DISPATCH): New, shamelessly stolen from
Autoconf's _AT_LANG_DISPATCH.
(AT_LANG_DISPATCH): New.
(AT_YYERROR_FORMALS, AT_YYERROR_PROTOTYPE, AT_YYERROR_DECLARE_EXTERN)
(AT_YYERROR_DECLARE, AT_YYERROR_DEFINE, AT_MAIN_DEFINE, AT_COMPILE)
(AT_FULL_COMPILE):
Use AT_LANG_DISPATCH instead of an ad hoc m4_case.

11 years agoregen
Akim Demaille [Mon, 4 Feb 2013 14:46:47 +0000 (15:46 +0100)]
regen

11 years agostyle: space changes in the parser
Akim Demaille [Mon, 4 Feb 2013 14:52:38 +0000 (15:52 +0100)]
style: space changes in the parser

* src/parse-gram.y: Fix spaces.

11 years agoparser: use api.pure full
Akim Demaille [Mon, 4 Feb 2013 14:44:26 +0000 (15:44 +0100)]
parser: use api.pure full

* src/parse-gram.y: Use api.pure full instead of silly macro tricks.

11 years agostyle: use a for loop instead of a while loop, and scope reduction
Akim Demaille [Fri, 1 Feb 2013 16:52:01 +0000 (17:52 +0100)]
style: use a for loop instead of a while loop, and scope reduction

* src/reader.c (packgram): Improve readability.
The parser calls grammar_current_rule_end at the end of every rhs,
which adds a NULL to separate the rules.  So there is no need to
check whether "p" is non-null before proceeding.

11 years agovariants: stylistic change
Theophile Ranquet [Fri, 1 Feb 2013 14:07:54 +0000 (15:07 +0100)]
variants: stylistic change

* data/variant.hh (tname): Respect the GNU Coding Standards for this
pointer's declaration.

11 years agogrammar: free the association tracking graph
Theophile Ranquet [Thu, 31 Jan 2013 23:49:59 +0000 (00:49 +0100)]
grammar: free the association tracking graph

The graph introduced by Valentin wasn't free'd after use.

* src/symtab.c (assoc_free): New, clear the array of linked lists with...
(linkedlist_free): This, new.
(print_precedence_warnings): Call assoc_free when done.
(print_assoc_warnings): Free used_assoc after use.

11 years agotests: use AT_FULL_COMPILE where possible
Theophile Ranquet [Thu, 31 Jan 2013 21:16:14 +0000 (22:16 +0100)]
tests: use AT_FULL_COMPILE where possible

* tests/c++.at (C++ Variant-based Symbol, Variants): Here.  Rename the
generated input files to use .y instead of .yy, as a requirement for using
AT_FULL_COMPILE instead of a combination of AT_BISON_CHECK and
AT_BISON_COMPILE_CXX.

11 years agovariants: avoid type punning issue
Theophile Ranquet [Tue, 29 Jan 2013 21:35:04 +0000 (22:35 +0100)]
variants: avoid type punning issue

This is based on what is recommended by both Scott Meyers, in 'Effective
C++', and Andrei Alexandrescu and Herb Sutter in 'C++ Coding Standards'.

Use a static_cast on void* rather than directly use a reinterpret_cast,
which can have nefarious effects on objects.  However, even though following
this guideline is good practice in general, I am not quite sure how relevant
it is when applied to conversions from POD to objects.  Actually, it might
very well be the opposite: isn't this exactly what reinterpret_cast is for?
What we really want *is* to transmit the memory map as a series of bytes,
which, if I am correct, falls into the kind of "low level" hack for which
this cast is meant.

In any case, this silences the warning, which will be greatly appreciated by
anyone using variants with a compiler supporting -fstrict-aliasing.

* data/variant.hh (as): Here.
* tests/c++.at (Exception safety, C++ Variant-based Symbols, Variants):
Don't use NO_STRICT_ALIAS_CXXFLAGS (revert commit ddb9db15), as type punning
is no longer an issue.
* tests/atlocal.in, configure.ac (NO_STRICT_ALIAS_CXXFLAGS): Remove
definition.
* examples/local.mk (NO_STRICT_ALIAS_CXXFLAGS): Remove from AM_CXXFLAGS.
* doc/bison.texi: Don't mention type punning issues.

11 years agotodo: update
Theophile Ranquet [Thu, 31 Jan 2013 11:18:37 +0000 (12:18 +0100)]
todo: update

Reformulate and give more details on my thoughts concerning the graphical
visualization, and add an entry about a bug in the options processing for
warnings as errors.

* TODO: Here.

11 years agoregen
Akim Demaille [Fri, 1 Feb 2013 13:26:29 +0000 (14:26 +0100)]
regen

11 years agolocation: pass the location first
Akim Demaille [Fri, 1 Feb 2013 13:24:48 +0000 (14:24 +0100)]
location: pass the location first

* src/location.h, src/location.c (location_print): For consistency
with other data structures and other location_* routines, pass the
location argument first.
* src/complain.c: Adjust.
(location_caret): Likewise.
* src/parse-gram.y: Adjust.

11 years agosymlist: use the right stream
Akim Demaille [Fri, 1 Feb 2013 13:23:49 +0000 (14:23 +0100)]
symlist: use the right stream

* src/symlist.c (symbol_list_syms_print): Use "f", not stderr.

11 years agotests: put two related tests together
Akim Demaille [Wed, 30 Jan 2013 20:41:41 +0000 (21:41 +0100)]
tests: put two related tests together

* tests/conflicts.at (Useless associativity warning): Move next
to "Useless precedence warning".

11 years agonews: name contributors
Akim Demaille [Wed, 30 Jan 2013 20:40:47 +0000 (21:40 +0100)]
news: name contributors

* NEWS: here.

11 years agowarnings: introduce -Wprecedence
Valentin Tolmer [Wed, 30 Jan 2013 10:30:15 +0000 (11:30 +0100)]
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).

11 years agobuild: avoid clang's colored diagnostics in the test suite
Akim Demaille [Wed, 30 Jan 2013 14:52:34 +0000 (15:52 +0100)]
build: avoid clang's colored diagnostics in the test suite

The syncline tests, which try to recognize compiler diagnostics,
are confused by escapes for colors.

* configure.ac (warn_tests): New, to factor the warnings for both
C and C++ tests.
Add -fno-color-diagnostics to it.
* tests/local.at (AT_TEST_TABLES_AND_PARSE): Do not remove glue
together compiler flags.

11 years agobuild: please Clang++ 3.2+ on Flex scanners
Akim Demaille [Wed, 30 Jan 2013 14:28:08 +0000 (15:28 +0100)]
build: please Clang++ 3.2+ on Flex scanners

Clang++, with -Wall, rejects code generated by Flex (for C scanners):

  CXX      examples/calc++/examples_calc___calc__-calc++-scanner.o
  In file included from examples/calc++/calc++-scanner.cc:1:
  error: implicit conversion of NULL constant to 'bool' [-Werror,-Wnull-conversion]
  if ( ! ( (yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : __null) ) {
       ~                                                                  ^~~~~~
                                                                          false
* configure.ac (WARN_NO_NULL_CONVERSION_CXXFLAGS): Compute it.
* examples/calc++/local.mk (examples_calc___calc___CXXFLAGS): Use it.

11 years agogrammar: record used associativity and print useless ones
Valentin Tolmer [Tue, 29 Jan 2013 15:27:04 +0000 (16:27 +0100)]
grammar: record used associativity and print useless ones

Record which symbol associativity is used, and display useless ones.

* src/symtab.h, src/symtab.c (register_assoc, print_assoc_warnings): New
* src/symtab.c (init_assoc, is_assoc_used): New
* src/main.c: Use print_assoc_warnings
* src/conflicts.c: Use register_assoc
* tests/conflicts.at (Useless associativity warning): New.

Due to the new warning, many tests had to be updated.

* tests/conflicts.at tests/existing.at tests/regression.at:
Add the associativity warning in the expected results.
* tests/java.at: Fix the java calculator's grammar to remove a useless
associativity.
* doc/bison.texi (mfcalc example): Fix associativity to remove
warning.

11 years agogrammar: warn about unused precedence for symbols
Valentin Tolmer [Tue, 29 Jan 2013 13:55:53 +0000 (14:55 +0100)]
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.

11 years agovariants: remove the 'built' assertions
Theophile Ranquet [Tue, 29 Jan 2013 13:53:35 +0000 (14:53 +0100)]
variants: remove the 'built' assertions

When using %define parse.assert, the variants come with additional variables
that are useful for development purposes. One is a Boolean indicating if the
variant is built (to make sure we don't read a non-built variant), and the
other is a string describing the stored type. There is no need to have both of
these, the string is enough.

* data/variant.hh (built): Remove.

11 years agostyle: indentation fixes
Akim Demaille [Tue, 29 Jan 2013 13:23:44 +0000 (14:23 +0100)]
style: indentation fixes

* src/parse-gram.y: here.

11 years agomaint: be sure to neutralize out-of-tree paths from our parser
Akim Demaille [Tue, 29 Jan 2013 13:11:46 +0000 (14:11 +0100)]
maint: be sure to neutralize out-of-tree paths from our parser

* tests/bison.in: Adjust to support fixed versions of ylwrap.

11 years agom4: generate a basic_symbol constructor for each symbol type
Theophile Ranquet [Mon, 28 Jan 2013 17:26:04 +0000 (18:26 +0100)]
m4: generate a basic_symbol constructor for each symbol type

Recently, there was a slightly vicious bug hidden in the make_ functions:

  parser::symbol_type
  parser::make_TEXT (const ::std::string& v)
  {
    return symbol_type (token::TOK_TEXT, v);
  }

The constructor for symbol_type doesn't take an ::std::string& as
argument, but a constant variant.  However, because there is a variant
constructor which takes an ::std::string&, this caused the implicit
construction of a built variant.  Considering that the variant argument
for the symbol_type constructor was cv-qualified, this temporary variant
was never destroyed.

As a temporary solution, the symbol was built in two stages:

  symbol_type res (token::TOK_TEXT);
  res.value.build< ::std::string&> (v);
  return res;

However, the solution introduced in this patch contributes to letting
the symbols handle themselves, by supplying them with constructors that
take a non-variant value and build the symbol's own variant with that
value.

* data/variant.hh (b4_symbol_constructor_define_): Use the new
constructors rather than building in a temporary symbol.
(b4_basic_symbol_constructor_declare,
b4_basic_symbol_constructor_define): New macros generating the
constructors.
* data/c++.m4 (basic_symbol): Invoke the macros here.

11 years agoc++: minor stylistic changes
Theophile Ranquet [Mon, 28 Jan 2013 17:03:58 +0000 (18:03 +0100)]
c++: minor stylistic changes

* data/c++m4: Remove useless comment lines.
* data/variant.hh (self_type): Use this typedef instead of variant<S>.
(b4_symbol_constructor_define_): Remove commented-out line, and stylistic
change (avoid blank line).

11 years agoc++: please G++ 4.8 with -O3: type puning issue
Akim Demaille [Tue, 29 Jan 2013 07:58:51 +0000 (08:58 +0100)]
c++: please G++ 4.8 with -O3: type puning issue

* tests/c++.at (Exception safety): Now that this test covers
variants, pass -fno-strict-aliasing to g++.

11 years agoc++: please G++ 4.8 with -O3: array bounds
Akim Demaille [Tue, 29 Jan 2013 07:52:57 +0000 (08:52 +0100)]
c++: please G++ 4.8 with -O3: array bounds

* data/c++.m4, data/lalr1.cc (by_state, by_type): Do not use -1 to
denote the absence of value, as GCC then fears that this -1 might
be used to dereference arrays (such as yytname).
Use 0, which corresponds to $accept, which is valueless (the needed
property: the symbol destructor must not try to reclaim the memory
associated with the symbol).

11 years agoc++: use more explicit types than int
Akim Demaille [Tue, 29 Jan 2013 07:16:15 +0000 (08:16 +0100)]
c++: use more explicit types than int

* data/c++.m4 (b4_public_types_declare): Declare token_number_type soon.
Introduce symbol_number_type (wider than token_number_type).
Clarify the requirement that kind_type from by_state and by_type
denote the _input_ type (required by the constructor), not the stored type.
Use symbol_number_type and token_number_type where appropriate, instead
of int.
* data/lalr1.cc: Adjust to these changes.
Propagate "symbol_number_type".
Invoke "type_get ()" instead of read "type" directly.

11 years agoc++: value_type -> kind_type
Akim Demaille [Tue, 29 Jan 2013 06:07:45 +0000 (07:07 +0100)]
c++: value_type -> kind_type

* data/c++.m4, data/lalr1.cc (by_type, by_state): Rename 'value_type'
as 'kind_type', as it is clearer.

11 years agoc++: improve the signature of yysyntax_error_
Akim Demaille [Tue, 29 Jan 2013 07:14:15 +0000 (08:14 +0100)]
c++: improve the signature of yysyntax_error_

* data/lalr1.cc: This function is const.
It takes a symbol_number_type.

11 years agoc++: style changes
Akim Demaille [Tue, 29 Jan 2013 07:15:37 +0000 (08:15 +0100)]
c++: style changes

* data/lalr1.cc: Formatting changes.
And name changes.

11 years agodoxygen: upgrade Doxyfile, and complete it
Akim Demaille [Mon, 28 Jan 2013 17:27:15 +0000 (18:27 +0100)]
doxygen: upgrade Doxyfile, and complete it

* doc/Doxyfile.in: Let doxygen upgrade it.
(INCLUDE_PATH): Point to lib too.
(PROJECT_BRIEF): New.
(EXCLUDE): Update to reflect the current file hierarchy.

11 years agomaint: fix syntax-check issues
Akim Demaille [Mon, 28 Jan 2013 16:17:12 +0000 (17:17 +0100)]
maint: fix syntax-check issues

* cfg.mk: Ignore strcmp in local.at.
* tests/conflicts.at: Use AT_PARSER_CHECK.
* tests/regression.at: Preserve the exit status of the generated parsers.

* tests/local.mk ($(TESTSUITE)): Map @tb@ to a tabulation.
* tests/c++.at, tests/input.at, tests/regression.at: Use @tb@.
* cfg.mk: (space-tab): There are no longer exceptions.

11 years agotests: please C90 compilers
Akim Demaille [Mon, 28 Jan 2013 16:10:30 +0000 (17:10 +0100)]
tests: please C90 compilers

* tests/actions.at, tests/conflicts.at: Use /* ... */ comments.
Let "main" return a value.

11 years agomaint: update todo
Akim Demaille [Mon, 28 Jan 2013 16:08:45 +0000 (17:08 +0100)]
maint: update todo

* TODO: Remove fixed items.

11 years agonews: minor improvements
Akim Demaille [Mon, 28 Jan 2013 16:02:55 +0000 (17:02 +0100)]
news: minor improvements

* NEWS: Name some more contributors.
Restructure slightly.

11 years agotests: please clang and use ".cc", not ".c", for C++ input
Akim Demaille [Mon, 28 Jan 2013 15:50:50 +0000 (16:50 +0100)]
tests: please clang and use ".cc", not ".c", for C++ input

When fed with foo.c, clang++ 3.2 answers:

  clang: error: treating 'c' input as 'c++' when in C++ mode,
                this behavior is deprecated

* tests/output.at (AT_CHECK_OUTPUT_FILE_NAME): Use *.cc and *.hh
for C++.

11 years agotests: formatting changes
Akim Demaille [Mon, 28 Jan 2013 15:44:00 +0000 (16:44 +0100)]
tests: formatting changes

* tests/local.at: Restore proper indentation.

11 years agoc++: better inline expansion
Theophile Ranquet [Mon, 28 Jan 2013 16:41:31 +0000 (17:41 +0100)]
c++: better inline expansion

Many 'inline' keywords were in the declarations.  They rather belong in
definitions, so move them.

* data/c++.m4 (basic_symbol, by_type): Many inlines here.
* data/lalr1.cc (yytranslate_, yy_destroy_, by_state, yypush_, yypop_): Inline
these as well.
(move): Move the definition outside the struct, where it belongs.