Commit Graph

2153 Commits

Author SHA1 Message Date
Akim Demaille
71cb558dfe Merge branch 'branch-2.6' into maint
* origin/branch-2.6:
  regen
  yacc.c: do not define location support when not using locations
  maint: be compilable with GCC 4.0
  tests: address a warning from GCC 4.4
  tests: don't use options that Clang does not support
  tests: restore the tests on -Werror
  regen
  parse-gram: update the Bison interface
  fix comment
2012-10-26 16:33:20 +02:00
Akim Demaille
0fb7b95c5f regen 2012-10-26 14:28:34 +02:00
Akim Demaille
bb8674a537 regen 2012-10-26 14:27:32 +02:00
Akim Demaille
e0992e5458 maint: be compilable with GCC 4.0
The "shadows a global declaration" warning in GCC 4.0 was a bit
annoying.  It does not like that a type name be used in a prototype of
a function (not the implementation, just the declaration):

  In file included from src/LR0.c:38:
  src/reader.h:56: warning: declaration of 'named_ref' shadows a
                            global declaration
  src/named-ref.h:35: warning: shadowed declaration is here

It does not like either when a global variable name is used in a
prototype.  Flex 2.5.37 generates this prototype:

  void gram_set_debug (int debug_flag  );

* src/getargs.h, src/getargs.c (debug_flag): Rename as...
(debug): this.
Adjust dependencies.
* src/reader.h: Don't use "named_ref" as a formal argument name.
2012-10-26 14:25:11 +02:00
Akim Demaille
20df0160bc regen 2012-10-25 09:43:52 +02:00
Akim Demaille
e73ac5a09b parse-gram: update the Bison interface
* src/parse-gram.y (%pure-parser, %name-prefix): Replace with...
(%define api.pure, %define api.prefix)
* src/location.h, src/scan-gram.h: Adjust to api.prefix.
2012-10-25 09:43:09 +02:00
Theophile Ranquet
25b27513d9 regen 2012-10-24 14:50:21 +00:00
Theophile Ranquet
2062d72deb deprecation: issue warnings in scanner
* src/parse-gram.y: Move the handling of (three) deprecated constructs ...
* src/scan-gram.l: ...Here, and issue warnings.
(DEPRECATED): New.
2012-10-24 14:49:21 +00:00
Akim Demaille
df04a68ab5 Merge branch 'branch-2.6' into maint
* origin/branch-2.6:
  maint: post-release administrivia
  version 2.6.4
  regen
  2.6.4: botched 2.6.3
2012-10-23 14:03:11 +02:00
Akim Demaille
40a1cd37f3 regen 2012-10-22 18:33:47 +02:00
Akim Demaille
19d9b60787 warnings: avoid warnings from clang
Fix the following warning

  parse-gram.c:2078:14: error: equality comparison with extraneous parentheses
                        [-Werror,-Wparentheses-equality]
    if (((yyn) == (-91)))
         ~~~~~~^~~~~~~~
  parse-gram.c:2078:14: note: remove extraneous parentheses around the
                        comparison to silence this warning
    if (((yyn) == (-91)))
        ~      ^       ~
  parse-gram.c:2078:14: note: use '=' to turn this equality comparison into
                        an assignment
    if (((yyn) == (-91)))
               ^~
               =
  1 error generated.

and the following one:

  input.cc:740:1: error: function declared 'noreturn' should not return
                         [-Werror,-Winvalid-noreturn]
  static void yyMemoryExhausted (yyGLRStack* yystackp)
    __attribute__ ((__noreturn__));
  static void
  yyMemoryExhausted (yyGLRStack* yystackp)
  {
    YYLONGJMP (yystackp->yyexception_buffer, 2);
  }
  ^
  1 warning and 1 error generated.

This is Apple clang version 3.1 (tags/Apple/clang-318.0.61).

* data/c.m4 (b4_table_value_equals): Use (!!(A == B)) instead of (A == B)
to avoid this warning.
Any reasonable compiler should generate the same code.
* src/uniqstr.h (UNIQSTR_EQ): Likewise.
* data/glr.c (LONGJMP): abort after longjmp to pacify clang.
2012-10-22 12:17:17 +02:00
Theophile Ranquet
ce6cf10f73 graphs: change the output format of the rules
Use something similar to the report file.

* src/print_graph.c (print_lhs): New, obstack equivalent of rule_lhs_print.
(print_core): Use here.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-18 16:27:11 +02:00
Theophile Ranquet
8048226f50 graphs: style changes
* src/graphviz.c (start_graph): Use courier font.
(conclude_red): Use commas to separate attributes. Show the acceptation
as a special reduction, with a blue color and an "Acc" label. Show the
lookahead tokens between square brackets.
(output_red): No longer label default reductions.
* src/print_graph.c (print_core): Refactor spacing, and print an
additional space between a rule's rhs and its lookahead tokens. Also,
capitalize "State".
(print_actions): Style, move a declaration.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-18 16:23:27 +02:00
Theophile Ranquet
85935600ad graphs: address an issue with R/R conflicts
All disabled reductions should now be shown as such.

* src/graphviz.c (output_red): Here.
(conclude_red): New.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-18 16:17:10 +02:00
Akim Demaille
f3bc338643 variables: use singular in %define variable names
See http://lists.gnu.org/archive/html/bison-patches/2012-02/msg00045.html

* doc/bison.texi, src/lalr.c, src/main.c, src/muscle-tab.c,
* src/print.c, src/reader.c, src/tables.c, tests/conflicts.at,
* tests/input.at, tests/reduce.at:
s/lr.default-reductions/lr.default-reduction/
s/lr.keep-unreachable-states/lr.keep-unreachable-state/.
* NEWS: Document.
2012-10-16 14:08:21 +02:00
Akim Demaille
2a6b66c5fd api.tokens.prefix -> api.token.prefix
See
http://lists.gnu.org/archive/html/bison-patches/2012-02/msg00045.html
Note that api.tokens.prefix has not been released, yet.

* NEWS, data/bison.m4, doc/bison.texi, tests/c++.at,
* tests/calc.at, tests/java.at, tests/local.at: Do it.
* src/muscle-tab.c (muscle_percent_variable_update): Ensure
backward compatibility.
2012-10-16 10:51:38 +02:00
Theophile Ranquet
f60321dc59 scan-skel.l: shift complain_args arguments
Because argv[0] is never used, shift it out from the argument list.

* src/complain.c (complain_args): Here.
* src/scan-skel.l (at_complain): Adjust argv and argc.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-15 17:11:50 +02:00
Theophile Ranquet
56f0d1d187 scan-skel.l: formatting changes
* src/scan-skel.l (fail_for_at_directive_too_few_args): Here.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-15 17:11:41 +02:00
Akim Demaille
f6b561d9f9 Merge branch 'maint'
* origin/maint:
  tests: check %no-lines
  tests: minor simplification
  graphs: stylistic changes.
  graphs: minor style changes
  graphs: show reductions
  graphs: style: prefix state number with "state"
  graphs: style: use left justification for states
  graphs: style: prefix rules and change shapes
  obstack: import obstack_finish0 from master
  c++: api.location.type
  muscles: a function for backward compatibility
  maint: more macros

Conflicts:
	data/glr.cc
	data/java.m4
	data/lalr1.cc
	doc/bison.texi
	src/muscle-tab.c
	src/system.h
	tests/calc.at
2012-10-12 12:49:57 +02:00
Akim Demaille
43eb7674aa graphs: stylistic changes.
* src/graphviz.c (output_red): Comment and formatting changes.
2012-10-11 16:58:03 +02:00
Theophile Ranquet
d79683fa95 graphs: minor style changes
* src/graphviz.c (output_red): Fix C90 issues.
Reduce variable scopes.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-11 16:50:37 +02:00
Theophile Ranquet
83bae26d3f graphs: show reductions
* src/graphviz.c (output_red): New, show reductions on the graph.
(no_reduce_bitset_init): New, initialize a bitset.
(print_token): New, print a lookahead token.
(escape): New, print "foo" as \"foo\" because Dot doesn't like quotes within
a label.

* src/graphviz.h : Adjust.
* src/print_graph.c (print_actions): Call output_red here.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-11 15:59:55 +02:00
Theophile Ranquet
9fc99ca350 graphs: style: prefix state number with "state"
* src/print_graph.c (print_core): Here.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-11 15:59:35 +02:00
Theophile Ranquet
a13121f759 graphs: style: use left justification for states
The label text of nodes is centered "by default" (by the use of '\n' as
a line feed). This gives bad readability to the grammar rules shown in
state nodes, a left justification is much nicer. This is done by using '\l'
as the line feed.

In order to allow \l in the DOT file, changes to the quoting system seem
necessary.

* src/print_graph.c (print_core): Escape tokens here, instead of...
* src/graphviz.c (output_node): Here...
(escape): Using this, new.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-11 15:46:43 +02:00
Theophile Ranquet
2be37f19fe graphs: style: prefix rules and change shapes
* src/graphviz.c (start_graph): Use box rather than ellipsis.
* src/print_graph.c (print_core): Prefix rules with their number.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-11 09:31:32 +02:00
Theophile Ranquet
47a31596c6 obstack: import obstack_finish0 from master
* src/system.h (obstack_finish0): New.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-11 09:30:18 +02:00
Akim Demaille
23d13411c8 Merge branch 'maint'
* origin/maint:
  NEWS: warnings with clang
  warnings: avoid warnings from clang
  tests: no longer disable -O compiler options
  yacc.c: initialize yylval in pure-parser mode
  skeletons: style changes
  lalr1.cc: document exception safety
  lalr1.cc: check exception safety of error handling
  lalr1.cc: check (and fix) %printer exception safety
  lalr1.cc: check (and fix) %initial-action exception safety
  lalr1.cc: fix exception safety
  lalr1.cc: check exception safety.
  lalr1.cc: indentation fixes.
  lalr1.cc: don't leave macros define to nothing
  tests: minor improvements
  tests: use $PERL instead of perl
  build: look for Perl in configure.
  tests: fix sed portability issues
  tests: diff -u is not portable

Conflicts:
	data/c.m4
	data/glr.c
	data/lalr1.cc
	data/yacc.c
	doc/Makefile.am
	tests/atlocal.in
	tests/calc.at
2012-10-11 09:12:43 +02:00
Akim Demaille
db8ab2be33 c++: api.location.type
This feature was introduced in 95a2de5695
(which is part of 2.5), but not documented.  Give it a proper name, and
make it public.

* data/c++.m4, data/lalr1.cc, data/glr.cc, data/java.m4: Use
api.location.type instead of location_type.
* src/muscle-tab.c (muscle_percent_variable_update): Map the latter to
the former.
* tests/local.at: Adjust.
* tests/calc.at: Use api.location.type.
Leave tests/java.at with location_type, at least for the time being,
to cover both names.
* doc/bison.texi: Document api.location.type.
(User Defined Location Type): New.
* NEWS: Update.
2012-10-09 15:59:18 +02:00
Akim Demaille
2aa5b25995 muscles: a function for backward compatibility
Based on commit 171ad99d64 from master.

* src/muscle-tab.c (muscle_percent_variable_update): New.
(muscle_percent_define_insert): Use it.
Define the variables with their initial value.
2012-10-09 15:58:37 +02:00
Akim Demaille
211c818502 maint: more macros
* src/output.c (ARRAY_CARDINALITY): Move to...
* src/system.h: here.
(STREQ, STRNEQ): new.
2012-10-09 12:13:09 +02:00
Akim Demaille
34076080cd warnings: avoid warnings from clang
Fix the following warning

  parse-gram.c:2078:14: error: equality comparison with extraneous parentheses
                        [-Werror,-Wparentheses-equality]
    if (((yyn) == (-91)))
         ~~~~~~^~~~~~~~
  parse-gram.c:2078:14: note: remove extraneous parentheses around the
                        comparison to silence this warning
    if (((yyn) == (-91)))
        ~      ^       ~
  parse-gram.c:2078:14: note: use '=' to turn this equality comparison into
                        an assignment
    if (((yyn) == (-91)))
               ^~
               =
  1 error generated.

and the following one:

  input.cc:740:1: error: function declared 'noreturn' should not return
                         [-Werror,-Winvalid-noreturn]
  static void yyMemoryExhausted (yyGLRStack* yystackp)
    __attribute__ ((__noreturn__));
  static void
  yyMemoryExhausted (yyGLRStack* yystackp)
  {
    YYLONGJMP (yystackp->yyexception_buffer, 2);
  }
  ^
  1 warning and 1 error generated.

This is Apple clang version 3.1 (tags/Apple/clang-318.0.61).

* data/c.m4 (b4_table_value_equals): Use (!!(A == B)) instead of (A == B)
to avoid this warning.
Any reasonable compiler should generate the same code.
* src/uniqstr.h (UNIQSTR_EQ): Likewise.
* data/glr.c (LONGJMP): abort after longjmp to pacify clang.
2012-10-08 09:51:52 +02:00
Akim Demaille
fc5618b338 scan-skel: use the scanner to reject all invalid directives
* src/scan-skel.l: Use a simpler and more consistent pattern escaping
scheme.
Catch all the invalid directives here by just removing the previous
catch-all-but-alphabetical rule.
2012-10-04 17:13:38 +02:00
Theophile Ranquet
92f39ba6dc scan-skel: recognize the @directives directly in scanner
* src/scan-skel.l (at_directive, at_init): New.
(at_ptr): New, function pointer used to call the right at_directive
function (at_basename, etc.).
(outname): Rename as...
(out_name): this, for consistency with out_lineno.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-04 17:13:38 +02:00
Theophile Ranquet
896517cdf0 scan-skel: split @directive functions
* src/scan-skel.l (at_directive_perform): Split as...
(at_basename, at_complain, at_output): these.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-04 17:13:38 +02:00
Theophile Ranquet
c6c8de1609 errors: support indented context info in m4 macros
* TODO: Address the issue, so remove it.
* data/bison.m4: Use b4_error with [[note]] rather than a complain_at
for context information.
* src/complain.c (complain_args): Take an additional argument, an
indentation pointer, to allow the dispatching of context information.
* src/complain.h (complain_args): Adjust prototype.
* src/scan-skel.l (at_directive_perform): Recognize the new @note mark.
* tests/input.at: Adjust.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-04 17:13:38 +02:00
Theophile Ranquet
0505df0cba errors: factor b4_error @directives
Instead of @complain, @warn, and @fatal, use a unique @complain
directive. This directive's first argument is "complain", "warn", etc.

* data/bison.m4 (m4_error): Here.
* src/scan-skel.l (at_directive_perform): Adjust.
(flag): Replace the switch by safer and more explicit if branches.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-04 17:13:38 +02:00
Theophile Ranquet
b999409e09 errors: pointerize complain_at_indent
* src/complain.c (complain_at_indent): Rename as...
(complaint_indent): This, and take the location as a pointer.
* src/complain.h, src/muscle-tab.c, src/reader.c, src/scan-code.l,
src/symtab.c: Adjust.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-04 17:13:37 +02:00
Akim Demaille
c4e3a1622d warnings: simplify the m4 interface
* data/bison.m4 (error_at): Replace...
(error): this.
(b4_warn, b4_complain, b4_fatal): Bounce to their _at equivalent,
with empty location.
* src/scan-skel.l (at_directive_perform): Simplify accordingly.
2012-10-01 16:47:50 +02:00
Theophile Ranquet
20964c33f9 warnings: separate flags_argmatch
This function is now a mere iterator that calls flag_argmatch,
a new function, that matches a single option parameter.

* src/getargs.c (flag_argmatch): New, taken from...
(flags_argmatch): Here.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-01 15:48:59 +02:00
Theophile Ranquet
a686f6cdc0 warnings: refactoring
The code here was too confusing, this seems more natural.

* src/complain.c (error_message): Move the indentation check and the category
output to complains. Also, no longer take a 'warnings' argument.
(complains): Factor calls to error_message.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-01 15:45:25 +02:00
Theophile Ranquet
46b7d74cb5 formatting changes
* src/complain.c: Here.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-01 15:45:09 +02:00
Theophile Ranquet
782e818718 warnings: organize variadic complaints call
Move the dispatch of variadic complains to complain.c, rather than do
it in a scanner.

* src/complain.h, src/complain.c (complain_args): New.
* src/scan-skel.l (at_directive_perform): Use it.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-01 15:41:35 +02:00
Theophile Ranquet
bb8e56ff67 warnings: fusion of complain and complain_at
These functions are very similar, and keeping them seperate makes
future improvements difficult, so merge them.

This impacts 89 calls.

* src/bootstrap.conf: Adjust.
* src/complain.c (complain, complain_at): Merge into...
(complain): this.
(complain_args): Adjust.
* src/complain.h, src/conflicts.c, src/files.c, src/getargs.c,
* src/gram.c, src/location.c, src/muscle-tab.c, src/parse-gram.y,
* src/reader.c, src/reduce.c, src/scan-code.l, src/scan-gram.l,
* src/scan-skel.l, src/symlist.c, src/symtab.c:
Adjust.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-01 14:15:47 +02:00
Theophile Ranquet
a49f4904c3 warnings: remove spurious suffixes on context
Rectify a bug that introduced suffixes out of place.

* src/complainc.c (complains): Handle all three special warning bits.
* src/scan-code.l (show_sub_message): Remove useless argument.
* tests/named-refs.at: Adjust.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-10-01 14:11:27 +02:00
Akim Demaille
595284e9d0 Merge remote-tracking branch 'origin/maint'
* origin/maint:
  gnulib: update
  errors: indent "user token number redeclaration" context

Conflicts:
	src/symtab.c
2012-10-01 12:12:38 +02:00
Theophile Ranquet
b506d9bfcb errors: indent "user token number redeclaration" context
This is the continuation of the work on the readability of errors
context.

* src/symtab.c (user_token_number_redeclaration): Use
complain_at_indent to output with increased indentation level.
* tests/input:at: Apply this change.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-09-28 14:00:09 +02:00
Theophile Ranquet
46bdb8ec59 errors: don't display "warnings treated as errors"
This line doesn't add any meaningful information anymore, the appended
[-Werror=CATEGORY] is enough.  It is actually more insightful, as it
allows to distinguish warnings treated as errors from those that
aren't.  This line is also removed by gcc 4.8.

* src/complain.c (set_warnings_issued): The only action left was
checking if the error bit corresponding to the warning issued was set,
and that function was only called once. Therefore, remove it, and do
its job directly in the caller...
(complains): here.
* src/complains.h: Adjust.
* tests/input.at: Adjust.
* NEWS: Document this change.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-09-27 12:26:05 +02:00
Akim Demaille
1048a1c901 errors: change output, and improve -y coherence
The prefix of warnings treated as errors is now "error: ". Also, their
suffix now reflects the changes in the Werror option format.

An output for -Werror=other used to be:
  bison: warnings being treated as errors
  input.y:1.1: warning: stray ',' treated as white space [-Wother]

It is now:
  bison: warnings being treated as errors
  input.y:1.1: error: stray ',' treated as white space [-Werror=other]

The line "warnings being treated as errors" no longer adds any info,
it will be removed in a forthcoming change.

* NEWS: Add entry "Enhancement of the -Werror"
* doc/bison.texi: Move the warnings-as-error to a new bullet.
* src/complain.c (complains): Refactor, change the prefix of warnings
that are treated as errors.
(warnings_print_categories): Support for [-Werror=CATEGORY] display
* src/getargc.c (getargs): -y implies -Werror=yacc
* tests/input.at: Update expected --yacc output for coherence.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-09-27 12:19:09 +02:00
Theophile Ranquet
9503b0a4a8 errors: introduce the -Werror=CATEGORY option
This new option is a lot more flexible than the previous one. Its
details will be discussed in the NEWS and info file, in a forthcoming
change.

If no category is specified (ie: used as simply "-Werror"), the
functionality is the same as before.

* src/complain.c (errors_flag): New variable.
(set_warning_issued): Accept warning categories as an argument.
* src/complain.h (Wall): Better definition.
* src/getargs.c (flags_argmatch): Support for the new format.
(usage): Update -Werror to -Werror[=CATEGORY] format.

* src/complain.c (errors_flag): New variable.
(set_warning_issued): Accept warning categories as an argument.
* src/complain.h (Wall): Better definition.
* src/getargs.c (flags_argmatch): Support for the new format.
(usage): Update -Werror to -Werror=[CATEGORY] format.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2012-09-27 11:08:07 +02:00
Akim Demaille
11b192127c Merge branch 'maint'
* maint:
  warnings: introduce -Wdeprecated in the usage info
  errors: prefix the output with "error: "
  errors: indent "invalid value for %define" context
  errors: indent "%define var" redefinition context
  errors: indent "symbol redeclaration" context
  errors: indent "result type clash" error context

Conflicts:
	src/complain.c
	src/muscle-tab.c
	src/reader.c
	src/symtab.c
	tests/conflicts.at
	tests/input.at
	tests/named-refs.at
	tests/output.at
	tests/skeletons.at
2012-09-26 14:51:11 +02:00