platform/upstream/bison.git
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.

11 years agotests: check that using variants is exception safe
Akim Demaille [Mon, 28 Jan 2013 15:05:09 +0000 (16:05 +0100)]
tests: check that using variants is exception safe

* tests/local.at: (Slightly) improve the regexp by escaping '.'
when it denotes a point.
(AT_VARIANT_IF): New.
* tests/c++.at (Exception Safety): Run it for variants too.

11 years agotests: remove useless %defines
Akim Demaille [Mon, 28 Jan 2013 14:37:49 +0000 (15:37 +0100)]
tests: remove useless %defines

Many tests were using %defines because C++ skeletons used to require
it.

* tests/actions.at, tests/c++.at, tests/input.at, tests/regression.at:
Remove useless %defines.

11 years agoc++: remove now-useless operators
Akim Demaille [Mon, 28 Jan 2013 13:56:16 +0000 (14:56 +0100)]
c++: remove now-useless operators

Now that symbols behaves properly, we can eliminate special routines
that are no longer needed.

* data/c++.m4, data/glr.cc, data/lalr1.cc, data/variant.hh:
Remove useless assignment operators and copy constructors.
As a consequence, remove useless includes for "abort".

11 years agotests: enable support for --debug
Akim Demaille [Mon, 28 Jan 2013 13:55:14 +0000 (14:55 +0100)]
tests: enable support for --debug

* tests/c++.at (Variants): Here.
And remove useless clutter when api.token.constructor is enabled.

11 years agoc++: revamp the support for variants
Akim Demaille [Mon, 28 Jan 2013 13:29:43 +0000 (14:29 +0100)]
c++: revamp the support for variants

The current approach was too adhoc: the symbols were not sufficiently
self-contained, in particular wrt memory management.  The "new"
guideline is the one that should have been followed from the start:
let the symbols handle themslves, instead of leaving their users to
it.  It was justified by the will to avoid gratuitious moves and
copies, but the current approach does not seem to be slower, yet it
will probably be simpler to adjust to support move semantics from
C++11.

The documentation says that the %parse-param are available from the
%destructor.  In retrospect, that was a silly design decision, which
we can break for variants, as its a new feature.  It should be phased
out for non-variants too.

* data/variant.hh: A variant never knows if it stores something or
not, it is up to its users to store this information.
Yet, in parse.assert mode, make sure the empty/filled variants
are properly used.
(b4_symbol_constructor_define_): Don't call directly the symbol
constructor, to save a useless temporary.
* data/stack.hh (push): Steal the pushed value instead of duplicating
it.
This will simplify the callers of push, who handled this "move"
approach themselves.
* data/c++.m4 (basic_symbol): Let -1, as kind, denote the fact that
a symbol is empty.
This is needed for instance when shifting the lookahead: yyla
is given as argument to "push", and its value is then moved on
the stack.  But then yyla must be declared "empty" so that its
destructor won't be called.
(basic_symbol::move): New.
Move the responsibility of calling the destructor from yy_destroy
to ~basic_symbol in the case of variants.
* data/lalr1.cc (stack_symbol_type): Now a derived class from its
previous value, so that we can add a constructor from a symbol_type.
(by_state): State -1 means empty.
(yypush_): Factor, by calling one overload from the other one, and
using the new semantics of stack::push.
No longer reclaim by hand the memory from rhs symbols, since now
that we store objects with proper destructors, they will be reclaimed
automatically.
Conversely, be sure to delete yylhs.
* tests/c++.at (C++ Variant-based Symbols): New "unit" test for
symbols.

11 years agoc++: formatting and comment changes
Akim Demaille [Mon, 28 Jan 2013 13:22:51 +0000 (14:22 +0100)]
c++: formatting and comment changes

* data/c++.m4, data/lalr1.cc, data/stack.hh, data/variant.hh:
Fix indentation.
Fix some comments.

11 years agotests: add token declaration order test
Valentin Tolmer [Fri, 25 Jan 2013 10:12:49 +0000 (11:12 +0100)]
tests: add token declaration order test

* tests/conflicts.at: New test.

11 years agoregen
Akim Demaille [Sun, 27 Jan 2013 09:41:16 +0000 (10:41 +0100)]
regen

11 years agogrammar: preserve token declaration order
Valentin Tolmer [Fri, 25 Jan 2013 10:12:47 +0000 (11:12 +0100)]
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.

11 years agotests: improve test group titles
Akim Demaille [Fri, 25 Jan 2013 10:06:32 +0000 (11:06 +0100)]
tests: improve test group titles

* tests/local.at (AT_SETUP_STRIP): AT_SETUP does not behave properly
with new-lines in its argument.
Remove them.
Fix the handling of %define with quotes.

11 years agoc: no longer require stdio.h when locations are enabled
Akim Demaille [Fri, 25 Jan 2013 12:51:33 +0000 (13:51 +0100)]
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).

11 years agoc: minor simplification in the debug code
Akim Demaille [Fri, 25 Jan 2013 13:57:42 +0000 (14:57 +0100)]
c: minor simplification in the debug code

* data/c.m4 (yy_symbol_print): Minor factoring.

11 years agoc++: display locations as C does
Akim Demaille [Fri, 25 Jan 2013 13:14:01 +0000 (14:14 +0100)]
c++: display locations as C does

See commit 3804aa260b956dd012adde3894767254422a5fcf.

* data/location.cc (operator<<): Display location exactly as is
done in C skeletons.
* tests/local.at (AT_LOC_PUSHDEF, AT_LOC_POPDEF): Also define
AT_FIRST_LINE, AT_LAST_LINE, AT_FIRST_COLUMN, AT_LAST_COLUMN.
* tests/actions.at (Location Print): Also check C++ skeletons.

11 years agotests: highlight empty right-hand sides
Akim Demaille [Fri, 25 Jan 2013 11:01:10 +0000 (12:01 +0100)]
tests: highlight empty right-hand sides

* tests/actions.at, tests/c++.at, tests/headers.at,
* tests/input.at: here.

11 years agonews: prepare for 2.8
Akim Demaille [Fri, 25 Jan 2013 15:30:56 +0000 (16:30 +0100)]
news: prepare for 2.8

* NEWS: Restructure.
Name contributors.

11 years agotests: generalize default main for api.namespace
Akim Demaille [Mon, 21 Jan 2013 15:01:53 +0000 (16:01 +0100)]
tests: generalize default main for api.namespace

* tests/local.at (AT_NAME_PREFIX): Also match api.namespace.
(AT_MAIN_DEFINE): Take it into account.
* tests/c++.at, tests/headers.at: Use AT_NAME_PREFIX.
(AT_CHECK_NAMESPACE): Rename as...
(AT_TEST): this.

11 years agotests: improve factoring of the main function
Akim Demaille [Mon, 21 Jan 2013 14:38:49 +0000 (15:38 +0100)]
tests: improve factoring of the main function

* tests/local.at (AT_MAIN_DEFINE): If %debug is used, check if
-d/--debug is passed to the generated parser, and enable the traces.
Return exactly the result of yyparse, so that we can check exit code
2 too.
* tests/actions.at, tests/glr-regression.at, tests/regression.at:
Use AT_MAIN_DEFINE, helping AT_BISON_OPTION_PUSHDEFS where needed,
preferably to option -t.

11 years agotests: factor the definition of main
Akim Demaille [Tue, 15 Jan 2013 17:29:45 +0000 (18:29 +0100)]
tests: factor the definition of main

With Théophile Ranquet.

* tests/local.at (AT_MAIN_DEFINE): New.
(AT_YYERROR_DEFINE): Improve formatting.
* tests/actions.at, tests/c++.at, tests/conflicts.at,
* tests/glr-regression.at, tests/input.at, tests/regression.at,
* tests/skeletons.at, tests/torture.at: Adjust.
* tests/c++.at: Add missing %skeleton for a PUSHDEFS, and a missing
PUSH/POPDEFS for another test.

11 years agotests: minor refactoring
Akim Demaille [Wed, 16 Jan 2013 07:25:50 +0000 (08:25 +0100)]
tests: minor refactoring

* tests/named-refs.at: Use AT_FULL_COMPILE where applicable.

11 years agodiagnostics: avoid useless caret stuttering
Akim Demaille [Tue, 15 Jan 2013 16:02:03 +0000 (17:02 +0100)]
diagnostics: avoid useless caret stuttering

* src/scan-code.l: When reporting a missing ending ';', don't display
the guilty action twice.

11 years agoexamples: please clang
Theophile Ranquet [Tue, 15 Jan 2013 16:51:45 +0000 (17:51 +0100)]
examples: please clang

* doc/bison.texi (calc++-scanner.ll): Don't output useless yyinput function.

11 years agotests: better silencing of unused argument warnings
Theophile Ranquet [Tue, 15 Jan 2013 17:03:39 +0000 (18:03 +0100)]
tests: better silencing of unused argument warnings

input.yy:35:44: error: unused parameter 'msg' [-Werror,-Wunused-parameter]
void yy::parser::error (std::string const& msg)
                                           ^

* tests/c++.at (C++ GLR parser identifier shadowing): Don't name unused
argument, use YYUSE instead of a direct cast to void.

11 years agobench: compatibility for Bison <= 2.7
Theophile Ranquet [Tue, 15 Jan 2013 16:54:44 +0000 (17:54 +0100)]
bench: compatibility for Bison <= 2.7

There used to be a bug in some skeletons, which caused the expansion of
'yylval' and 'yylloc', generating these errors:

input.cc:547:16: error: expected ',' or '...' before '(' token
 #define yylval (yystackp->yyval)
                ^
input.yy:29:39: note: in expansion of macro 'yylval'
 int yylex (yy::parser::semantic_type *yylval)
                                       ^

This bug is fixed by 'skel: better aliasing of identifiers', but a workaround
is useful when benchmarking against older versions of Bison, which are still
affected by the bug.

* etc/bench.pl.in: Rename yylval to yylvalp and yylloc to yyllocp in base
grammar 'list'.

11 years agoc++: remove useless inlines
Theophile Ranquet [Tue, 15 Jan 2013 12:05:21 +0000 (13:05 +0100)]
c++: remove useless inlines

* data/c++.m4 (basic_symbol): Keep 'inline' in the prototypes, but don't
duplicate it in the implementation.
* data/variant.hh (variant): 'inline' is not needed when the implementation is
provided in the class definition.

11 years agoc++: m4 stylistic change
Theophile Ranquet [Tue, 15 Jan 2013 11:44:37 +0000 (12:44 +0100)]
c++: m4 stylistic change

* data/c++.m4 (syntax_error): Fix the indentation of 'inline'.

11 years agoc++: silence warnings
Theophile Ranquet [Mon, 14 Jan 2013 18:25:35 +0000 (19:25 +0100)]
c++: silence warnings

* data/c++.m4 (basic_symbol<Base>::operator=): Unused parameter.
* tests/c++.at (C++ GLR parser identifier shadowing): Here too.
-

11 years agonews: typos
Theophile Ranquet [Mon, 14 Jan 2013 10:02:12 +0000 (11:02 +0100)]
news: typos

* NEWS: Fix a typo, use YYSTYPE rather than semantic_type.

11 years agoregen
Akim Demaille [Sat, 12 Jan 2013 15:22:13 +0000 (16:22 +0100)]
regen

11 years agomaint: update copyright years
Akim Demaille [Sat, 12 Jan 2013 15:14:04 +0000 (16:14 +0100)]
maint: update copyright years

Suggested by Stefano Lattarini.
Run "make update-copyright".

11 years agobuild: fix VPATH issue
Akim Demaille [Sat, 12 Jan 2013 15:03:15 +0000 (16:03 +0100)]
build: fix VPATH issue

* Makefile.am (update-b4-copyright, update-package-copyright-year): Fix
path to build-aux.

11 years agocarets: document default activation
Theophile Ranquet [Fri, 11 Jan 2013 12:47:57 +0000 (13:47 +0100)]
carets: document default activation

* NEWS: Announce it.
* doc/bison.texi: Adjust.

11 years agocarets: show them in more tests
Theophile Ranquet [Fri, 28 Dec 2012 12:33:04 +0000 (13:33 +0100)]
carets: show them in more tests

* tests/input.at, tests/named-refs.at: Here.

11 years agocarets: activate by default
Theophile Ranquet [Fri, 28 Dec 2012 12:32:14 +0000 (13:32 +0100)]
carets: activate by default

* src/getargs.c (feature_flag): Here.
* tests/local.at (AT_BISON_CHECK_, AT_BISON_CHECK_NO_XML): Deactivate carets
for the testsuite, by default.
* tests/input.at: Adjust the locations for command line definitions.

11 years agovariants: document move and swap
Theophile Ranquet [Fri, 11 Jan 2013 11:38:35 +0000 (12:38 +0100)]
variants: document move and swap

* data/variant.hh (swap): Doc.
(build): Rename as...
(move): This, more coherent naming with clearer meaning.
* data/c++.m4 (move): Adjust.

11 years agoc++: privatize variant blind copies
Theophile Ranquet [Fri, 11 Jan 2013 10:41:07 +0000 (11:41 +0100)]
c++: privatize variant blind copies

* data/variant.hh (variant, operator=): Make private.
* data/c++.m4 (operator=): New, to avoid needing a definition of that operator
for each class member (such as a possible variant).
* data/glr.cc, data/lalr.cc: Add the necessary include for the abort.

11 years agoglr.c: fix an unused argument issue
Akim Demaille [Fri, 4 Jan 2013 15:01:07 +0000 (16:01 +0100)]
glr.c: fix an unused argument issue

* data/glr.c (yyuserAction): "Use" yyrhslen, as in variant mode, we might
not use it.

11 years agoglr.c: style changes
Akim Demaille [Fri, 4 Jan 2013 15:00:59 +0000 (16:00 +0100)]
glr.c: style changes

* data/glr.c (yyuserAction): Use a size_t for sizes.

11 years agoc.m4: style fix
Akim Demaille [Fri, 4 Jan 2013 14:58:50 +0000 (15:58 +0100)]
c.m4: style fix

* data/c.m4 (b4_parse_param_use): Add missing space before paren.

11 years agoskel: better aliasing of identifiers
Theophile Ranquet [Fri, 4 Jan 2013 11:30:01 +0000 (12:30 +0100)]
skel: better aliasing of identifiers

* data/glr.c, data/yacc.c: Avoid emitting useless defines.
* data/glr.cc: Restore prefixes for epilogue.

11 years agoglr.cc: fatal if using api.token.ctor without variants
Theophile Ranquet [Fri, 4 Jan 2013 17:52:21 +0000 (18:52 +0100)]
glr.cc: fatal if using api.token.ctor without variants

* data/glr.cc: Here.

11 years agoskel: correctly indent switch cases
Theophile Ranquet [Wed, 9 Jan 2013 11:46:55 +0000 (12:46 +0100)]
skel: correctly indent switch cases

* data/bison.m4 (b4_type_action_): Here.

11 years agovariants: assert changes
Theophile Ranquet [Fri, 21 Dec 2012 15:48:54 +0000 (16:48 +0100)]
variants: assert changes

* data/variant.hh (swap): More asserts can't hurt. Don't perform useless swaps.
(build): Deactivate problematic asserts, pending further investigation.
(variant): Prohibit copy construction.

11 years agolalr1.cc: use a vector for the symbol stack
Theophile Ranquet [Fri, 21 Dec 2012 15:46:05 +0000 (16:46 +0100)]
lalr1.cc: use a vector for the symbol stack

* data/lalr1.cc: Adjust includes.
* data/stack.hh (push, pop): Use push_back and pop_back.
(operator []): Access vector from the end.

11 years agolalr1.cc: change symbols implementation
Theophile Ranquet [Fri, 21 Dec 2012 15:49:48 +0000 (16:49 +0100)]
lalr1.cc: change symbols implementation

A "symbol" groups together the symbol type (INT, PLUS, etc.), its
possible semantic value, and its optional location.  The type is
needed to access the value, as it is stored as a variant/union.

There are two kinds of symbols. "symbol_type" are "external symbols":
they have type, value and location, and are returned by yylex.
"stack_symbol_type" are "internal symbols", they group state number,
value and location, and are stored in the parser stack.  The type of
the symbol is computed from the state number.

The class template symbol_base_type<Exact> factors the code common to
stack_symbol_type and symbol_type.  It uses the Curiously Recurring
Template pattern so that we can always (static_) downcast to the exact
type.  symbol_base_type features value and location, and delegates the
handling of the type to its parameter.

When trying to generalize the support for variant, a significant issue
was revealed: because stack_symbol_type and symbol_type _derive_ from
symbol_base_type, the type/state member is defined _after_ the value
and location.  In C++ the order of the definition of the members
defines the order in which they are initialized, things go backward:
the value is initialized _before_ the type.  This is wrong, since the
type is needed to access the value.

Therefore, we need another means to factor the common code, one that
ensures the order of the members.

The idea is simple: define two (base) classes that code the symbol
type ("by_type" codes it by its type, and "by_state" by the state
number).  Define basic_symbol<Base> as the class template that
provides value and location support.  Make it _derive_ from its
parameter, by_type or by_state.  Then define stack_symbol_type and
symbol_type as basic_symbol<by_state>, basic_symbol<by_type>.  The
name basic_symbol was chosen by similarity with basic_string and
basic_ostream.

* data/c++.m4 (symbol_base_type<Exact>): Remove, replace by...
(basic_symbol<Base>): which derives from its parameter, one of...
(by_state, by_type): which provide means to retrieve the actual type of
symbol.
(symbol_type): Is now basic_symbol<by_type>.
(stack_symbol_type): Is now basic_symbol<by_state>.
* data/lalr1.cc: Many adjustments.

11 years agobench: add %b directive to use a specific Bison
Theophile Ranquet [Wed, 26 Dec 2012 15:26:17 +0000 (16:26 +0100)]
bench: add %b directive to use a specific Bison

For example,
  $ bench.pl -v '%s lalr1.cc & %d variant & ( %b ~/old-bison/bin/bison
    | %b ~/new-bison/bin/bison )' -g list -i 10000

* etc/bench.pl.in: Here.

11 years agoregen
Akim Demaille [Fri, 4 Jan 2013 15:30:16 +0000 (16:30 +0100)]
regen

11 years agognulib: update
Akim Demaille [Fri, 28 Dec 2012 10:49:19 +0000 (11:49 +0100)]
gnulib: update

11 years agodoc: use deffn to declare the list of %define variables
Akim Demaille [Mon, 31 Dec 2012 15:21:34 +0000 (16:21 +0100)]
doc: use deffn to declare the list of %define variables

* doc/bison.texi (%define Summary): Use @deffn instead of @table, it
spares a lot of width, especially in PDF, and looks nicer in the other
formats too.
It is also more consistent with the rest of the document.

11 years agodoc: minor completion and fixes
Akim Demaille [Mon, 31 Dec 2012 10:18:48 +0000 (11:18 +0100)]
doc: minor completion and fixes

* doc/bison.texi (%define Summary): Provide more history to some
variables.

11 years agojava: stype is obsoleted by api.value.type
Akim Demaille [Mon, 31 Dec 2012 10:13:50 +0000 (11:13 +0100)]
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.

11 years agodoc: fix html build
Akim Demaille [Mon, 31 Dec 2012 15:31:14 +0000 (16:31 +0100)]
doc: fix html build

* doc/local.mk (bison.html): Fix dependencies.

11 years agotodo: remove erroneous task
Akim Demaille [Sun, 30 Dec 2012 08:28:42 +0000 (09:28 +0100)]
todo: remove erroneous task

* tests/input.at: Check that there are no warnings about stray $ and @
in the epilogue.
* TODO: Remove the correponding task.

11 years agognulib: update
Akim Demaille [Fri, 28 Dec 2012 10:49:19 +0000 (11:49 +0100)]
gnulib: update

11 years agoregen
Akim Demaille [Fri, 28 Dec 2012 10:28:36 +0000 (11:28 +0100)]
regen

11 years agosyncline: one line is enough
Akim Demaille [Fri, 28 Dec 2012 10:25:02 +0000 (11:25 +0100)]
syncline: one line is enough

So far we were issuing two lines for each syncline change:

  /* Line 356 of yacc.c  */
  #line 1 "src/parse-gram.y"

This is a lot of clutter, especially when reading diffs, as these
lines change often.  Fuse them into a single, shorter, line:

  #line 1 "src/parse-gram.y" /* yacc.c:356  */

* data/bison.m4 (b4_syncline): Issue a single line.
Comment improvements.
(b4_sync_start, b4_sync_end): Issue a shorter comment.
* data/c++.m4 (b4_semantic_type_declare): b4_user_code must be
on its own line as it might start with a "#line" directive.

11 years agoregen
Akim Demaille [Fri, 28 Dec 2012 10:07:17 +0000 (11:07 +0100)]
regen

11 years agomaint: restore ANSI 89 compliance
Akim Demaille [Fri, 28 Dec 2012 10:04:37 +0000 (11:04 +0100)]
maint: restore ANSI 89 compliance

* data/bison.m4, src/conflicts.c, src/files.c, src/output.c,
* src/symtab.c: Use /* ... */ comments only.
Declare variables before statements.

11 years agograph: minor simplification
Akim Demaille [Fri, 28 Dec 2012 09:04:49 +0000 (10:04 +0100)]
graph: minor simplification

* src/gram.c (print_lhs): Use %*s to indent.
* src/print_graph.c (print_lhs): Use obstack_printf.
Became simple enough to be inlined in...
(print_core): here.
Use a "rule*" instead of an index in "rules[]".

11 years agoclosure, gram: add missing const
Akim Demaille [Fri, 28 Dec 2012 09:16:37 +0000 (10:16 +0100)]
closure, gram: add missing const

* src/closure.h, src/closure.c, src/gram.h, src/gram.c: Add some missing
const where appropriate.

11 years agocarets: properly display when no line feed is present
Theophile Ranquet [Thu, 13 Dec 2012 10:28:11 +0000 (11:28 +0100)]
carets: properly display when no line feed is present

* src/location.c (location_caret): finish the line with one whether or not it
is present in input. Rewrite code without getline.
(cleanup_caret): Reset the caret_info global.
* bootstrap.conf: No longer require getline.

11 years agoscanner: reintroduce unput for missing end tokens
Theophile Ranquet [Thu, 15 Nov 2012 17:10:35 +0000 (17:10 +0000)]
scanner: reintroduce unput for missing end tokens

Unput was no longer used since a POSIX-compatiblity issue with Flex 2.5.31,
which has been adressed in newer versions of Flex.  See this discussion:
<http://lists.gnu.org/archive/html/bug-bison/2003-04/msg00029.html>

This partially reverts commit aa4180418fff518198e1b0f2c43fec6432210dc7.

* src/scan-gram.l (unexpected_end): Here.
* tests/input.at: Adjust for new order of error reports.

11 years agotables: scope reduction
Akim Demaille [Thu, 27 Dec 2012 09:52:42 +0000 (10:52 +0100)]
tables: scope reduction

* src/tables.c (default_goto): Make it easier to understand.

11 years agoregen
Akim Demaille [Thu, 27 Dec 2012 09:33:46 +0000 (10:33 +0100)]
regen

11 years agoskeletons: fix comments
Akim Demaille [Thu, 27 Dec 2012 09:01:58 +0000 (10:01 +0100)]
skeletons: fix comments

The commit 38de4e570fdc7c8db9633c3b2054e565d8c1c6b9 underquoted the
content of the comments, which resulted in losing square brackets in
the comments.  Besides, some other invocations were underquoting the
effective arguments.

* data/c.m4 (b4_comment_): Properly quote the comment.
(b4_comment_, b4_comment): Move to...
* data/c-like.m4: here, so that...
* data/java.m4: can use it instead of its own copy.
* data/bison.m4 (b4_integral_parser_tables_map): Fix some comments.

* data/lalr1.cc, data/lalr1.java, data/yacc.c: Comment fixes.

* data/lalr1.cc: Reorder a bit to factor some CPP directives.

11 years agomaint: which -> whose
Akim Demaille [Thu, 27 Dec 2012 08:45:17 +0000 (09:45 +0100)]
maint: which -> whose

Apparently, I was confusing both.

* data/bison.m4, data/c.m4, data/glr.c, data/lalr1.cc, data/yacc.c:
Use "whose" where appropriate.

11 years agotables: scope reduction
Akim Demaille [Wed, 26 Dec 2012 17:16:55 +0000 (18:16 +0100)]
tables: scope reduction

* src/tables.c (matching_state): here.

11 years agotables: scope reduction
Akim Demaille [Wed, 26 Dec 2012 17:15:21 +0000 (18:15 +0100)]
tables: scope reduction

* src/tables.c (token_actions): here.

11 years agotables: scope reduction
Akim Demaille [Wed, 26 Dec 2012 17:14:47 +0000 (18:14 +0100)]
tables: scope reduction

* src/tables.c (save_row): here.

11 years agotables: scope reduction
Akim Demaille [Wed, 26 Dec 2012 16:56:20 +0000 (17:56 +0100)]
tables: scope reduction

* src/tables.c (save_column, pack_vector): Reduce the scope to
emphasize the structure of the code.
Rename the returned value "res" to make understanding easier.

11 years agotables: use size_t where appropriate
Akim Demaille [Wed, 26 Dec 2012 16:55:02 +0000 (17:55 +0100)]
tables: use size_t where appropriate

These changes aim at making the code easier to understand.

* src/tables.c (tally): This is a size, always >= 0, so make it
a size_t.

11 years agotables: style changes
Akim Demaille [Wed, 26 Dec 2012 16:53:01 +0000 (17:53 +0100)]
tables: style changes

* src/tables.c: Prefer < to >.
Fix/complete some comments.
Remove useless parens.

11 years agoskeletons: no longer call yylex via a CPP macro
Akim Demaille [Wed, 26 Dec 2012 07:18:03 +0000 (08:18 +0100)]
skeletons: no longer call yylex via a CPP macro

The YYLEX existed only to support YYLEX_PARAM, which is now removed.
This macro was a nuisance, since incorrect yylex calls where pointed
the macro _use_, instead of its definition.

* data/c.m4 (b4_lex_formals, b4_lex): New.
* data/glr.c, data/yacc.c: Use it.
* data/lalr1.cc (b4_lex): New.
Use it.

squash! skeletons: no longer call yylex via a CPP macro

11 years agoYYLEX_PARAM: drop support
Akim Demaille [Tue, 25 Dec 2012 16:13:39 +0000 (17:13 +0100)]
YYLEX_PARAM: drop support

* data/yacc.c, doc/bison.texi: Remove YYLEX_PARAM support.
* NEWS: Document it.

11 years agoexamples: minor improvements
Akim Demaille [Wed, 26 Dec 2012 07:12:38 +0000 (08:12 +0100)]
examples: minor improvements

* examples/variant.yy: Don't use debug_stream(), obsoleted.
Use <*>.

11 years agoskeletons: factor comments about symbols
Akim Demaille [Tue, 25 Dec 2012 15:27:16 +0000 (16:27 +0100)]
skeletons: factor comments about symbols

* data/variant.hh (b4_char_sizeof_): Rename as...
* data/bison.m4 (b4_symbol_tag_comment): this.
Provide more documentation about b4_symbol_*.

11 years agoc: improve the definition of public types
Akim Demaille [Sun, 23 Dec 2012 16:54:59 +0000 (17:54 +0100)]
c: improve the definition of public types

* data/c.m4 (b4_token_enum): Improve comments.
(b4_value_type_define, b4_location_type_define): New, extracted
from...
(b4_declare_yylstype): here.
Separate the typedefs from the union/struct definitions.

11 years agodoc: update variant usage
Akim Demaille [Sun, 23 Dec 2012 11:47:31 +0000 (12:47 +0100)]
doc: update variant usage

* doc/bison.texi, examples/variant.yy: Use "%define api.value.type variant",
instead of "%define variant".

11 years agotests: check the "%define variant" is deprecated.
Akim Demaille [Sun, 23 Dec 2012 09:52:23 +0000 (10:52 +0100)]
tests: check the "%define variant" is deprecated.

* tests/input.at: Rename some AT_SETUP to avoid that
AT_SETUP_STRIP thinks they contain %define directives.
("%define" backward compatibility): Merge tests together
to speed up the test suite, and to make maintenance easier
(multiple AT_CHECK means multiple runs of the test suite to
be sure to have updated all the error messages).
Check the "%define variant" is properly obsoleted.