Commit Graph

6872 Commits

Author SHA1 Message Date
Akim Demaille
6f7f949708 style: remove useless declarations
* src/reader.h: Don't duplicate what parse-gram.h already exposes.
* src/lr0.h: Remove useless include.
2020-02-23 08:25:53 +01:00
Akim Demaille
15e57d9108 examples: fix c/calc
* examples/c/calc/calc.y: Remove experiment traces.
2020-02-19 14:58:39 +01:00
Akim Demaille
30ba94081c todo: update 2020-02-19 14:57:17 +01:00
Akim Demaille
0e7bc7a6d8 doc: update recommandation for libtextstyle
* README: here.
2020-02-15 11:17:33 +01:00
Akimn Demaille
eff4d16175 build: fix typo
* build-aux/cross-options.pl: here.
2020-02-15 10:50:19 +01:00
Akim Demaille
b0e11f4523 doc: simplify the cross references
* doc/bison.texi: here.
2020-02-15 09:59:50 +01:00
Akim Demaille
d9b2270bed doc: document token internationalization
* doc/bison.texi (Parser Internationalization): Move most of its
content into...
(Enabling I18n): this new node.
(Token I18n): New.
(Token Decl): Refer to token internationalization.
(Error Reporting Function): Promote parse.error detailed.
2020-02-15 09:55:59 +01:00
Akim Demaille
7a28659495 regen 2020-02-15 08:28:57 +01:00
Victor Morales Cayuela
e09a72eeb0 diagnostics: modernize the display of submessages
Since Bison 2.7, output was indented four spaces for explanatory
statements.  For example:

    input.y:2.7-13: error: %type redeclaration for exp
    input.y:1.7-11:     previous declaration

Since the introduction of caret-diagnostics, it became less clear.
Remove the indentation and display submessages as in GCC:

    input.y:2.7-13: error: %type redeclaration for exp
        2 | %type <float> exp
          |       ^~~~~~~
    input.y:1.7-11: note: previous declaration
        1 | %type <int> exp
          |       ^~~~~

* src/complain.h (SUB_INDENT): Remove.
(warnings): Add "note" to the enum.
* src/complain.h, src/complain.c (complain_indent): Replace by...
(subcomplain): this.
Adjust all dependencies.
* tests/actions.at, tests/diagnostics.at, tests/glr-regression.at,
* tests/input.at, tests/named-refs.at, tests/regression.at:
Adjust expectations.
2020-02-15 08:28:40 +01:00
Akim Demaille
a09d0ae4d1 doc: simplify uses of references
This reverts "doc: work around problems with PDF generation", commit
d810aa3d8f.  Upstream issue is fixed.
https://lists.gnu.org/r/bug-texinfo/2020-02/msg00006.html

* gnulib: Update.
* doc/bison.texi: Simplify.
2020-02-13 19:22:51 +01:00
Akim Demaille
1e25cb44d1 java: provide a Context ctor
This is really a private auxiliary inner class, so it should not
matter.  But it's better style.

* data/skeletons/lalr1.java: here.
2020-02-13 19:22:10 +01:00
Akim Demaille
3ed42d2487 Merge tag 'v3.5.2'
bison 3.5.2

* tag 'v3.5.2':
  version 3.5.2
  news: 3.5.2
  gnulib: update
  doc: update Doxygen template
  java: avoid trailing white spaces
  m4: fix b4_token_format
  doc: clearly state that %yacc only makes sense with yacc.c
  doc: spell check
  examples: be more robust to spaces in paths
  larlr1.cc: Reject unsupported values for parse.lac
2020-02-13 19:19:11 +01:00
Akim Demaille
7f921d18dd version 3.5.2
* NEWS: Record release date.
v3.5.2
2020-02-13 18:25:21 +01:00
Akim Demaille
cc3760ef51 news: 3.5.2
* NEWS: Update.
2020-02-13 18:25:11 +01:00
Akim Demaille
2f23ca6f65 gnulib: update 2020-02-13 08:18:12 +01:00
Akim Demaille
468b68c5cd doc: update Doxygen template
* Doxyfile.in: Run doxygen -u on it.
2020-02-13 08:18:12 +01:00
Akim Demaille
9ed802a026 java: avoid trailing white spaces
* data/skeletons/java.m4 (b4_maybe_throws): Issue a space before when needed.
* data/skeletons/lalr1.java: Avoid trailing spaces.
2020-02-13 08:18:12 +01:00
Akim Demaille
fb554c2804 m4: fix b4_token_format
We used to emit:

    /** Token number,to be returned by the scanner.  */
    static final int NUM = 258;
    /** Token number,to be returned by the scanner.  */
    static final int NEG = 259;

with no space after the comma.  Fix that.

* data/skeletons/bison.m4 (b4_token_format): Quote where appropriate.
2020-02-13 08:18:11 +01:00
Akim Demaille
47850d4f58 doc: clearly state that %yacc only makes sense with yacc.c
* doc/bison.texi: here.
2020-02-13 08:18:11 +01:00
Akim Demaille
57b035a242 doc: spell check
* doc/bison.texi: here.
2020-02-13 08:18:11 +01:00
Akim Demaille
e7a202d762 examples: bistromathic: demonstrate named references
* examples/c/bistromathic/parse.y: here.
2020-02-12 00:18:47 +01:00
Akim Demaille
11e2b755f0 c++: simplify
* data/skeletons/stack.hh (ssize): Remove, same as size.
2020-02-12 00:09:15 +01:00
Akim Demaille
f3d33c3613 tests: check calls to yyerror from the user actions
This revealed a number of things I had not realized:

- the Java location tracking was aliasing the same pair of positions
  for all the symbols (see previous commit).

- in impure parsers, it's quite easy to use incorrect locations for
  diagnostics, since yyerror uses yylloc, which is the location of the
  lookahead, not that of the current lhs.  So we need something like

    {
      YYLTYPE old_yylloc = yylloc;
      yylloc = @$;
      yyerror (]AT_PARAM_IF([result, count, nerrs, ])[buf);
      yylloc = old_yylloc;
    }

  Maybe we should do that little yylloc dance in the skeleton instead
  of leaving it to the user?  It might be costly...  But that's only
  for users of the impure parsers, which are asking for trouble
  anyway.

- in glr.cc invoking yyerror is somewhat cumbersome: the C++ interface
  is not available as we are in yyparse (which in C), and yyerror is
  used by glr.cc itself to bind it to the user's parser::error.  If we
  call yyerror, we need:

    yyerror (]AT_LOCATION_IF([[&@$, ]])[yyparser, ]AT_PARAM_IF([result, count, nerrs, ])[msg);

  However calling yy::parser::error is easier, once we know that the
  current parser object is available as 'yyparser'.  Which also saves
  us from having to pass the parse-params ourselves:

    yyparser.error (]AT_LOCATION_IF([[@$, ]])[msg);

* tests/calc.at: Invoke yyerror by hand, instead of using fprintf etc.
Adjust expectations.
2020-02-12 00:00:05 +01:00
Akim Demaille
163a35d6dd java: beware not to alias the locations of the various symbols
* examples/java/calc/Calc.y, tests/calc.at, tests/local.at
(getStartPos, getEndPos): Always return a new object.
* doc/bison.texi: Clarify this.
2020-02-11 21:31:44 +01:00
Akim Demaille
cdb42f7730 java: check that parse.error custom|detailed work with push parsers
* tests/calc.at: here.
2020-02-11 08:39:08 +01:00
Akim Demaille
126252333d java: don't expose the Context's members
* data/skeletons/lalr1.java (Context): Make data members private.
(Context.getLocation): New.
* examples/java/calc/Calc.y, tests/java.at, tests/local.at: Adjust.
2020-02-11 08:39:03 +01:00
Akim Demaille
8637f2c7d6 build: pacify syntax-check
* src/complain.c: Fix indentation.
* cfg.mk: Using strcmp is ok in the tests.
Test cases and examples don't need Bison's PO support.
2020-02-10 20:46:56 +01:00
Akim Demaille
6946149701 regen 2020-02-10 20:42:23 +01:00
Akim Demaille
1368b9dbc9 gnulib: update 2020-02-10 20:42:23 +01:00
Akim Demaille
0e96eaf612 build: prefer %D% and %C% to hard coded values
* doc/local.mk: here.
2020-02-10 20:15:46 +01:00
Akim Demaille
77bdcc6f0c parse.error: document and diagnose the incompatibility with %token-table
* doc/bison.texi (Tokens from Literals): Move to code using
%token-table to...
(Decl Summary: %token-table): here.
* data/skeletons/bison.m4: Implement mutual exclusion.
* tests/input.at: Check it.
* doc/local.mk: Be robust to the removal of doc/.
2020-02-10 20:15:46 +01:00
Akim Demaille
57647bb656 doc: spell check
* doc/bison.texi: here.
2020-02-10 20:15:45 +01:00
Akim Demaille
63cd2918ff doc: formatting changes
* doc/bison.texi: here.
2020-02-10 20:15:45 +01:00
Akim Demaille
d810aa3d8f doc: work around problems with PDF generation
With texinfo.tex 2019-09-24.13, node names with + are not properly
handled.
https://lists.gnu.org/r/bug-texinfo/2020-02/msg00004.html

* doc/bison.texi: Always use the three-argument form for references to
node with a + in the name.
2020-02-10 20:15:41 +01:00
Akim Demaille
ed1eedbbcb java: revert "style: avoid useless initializers"
This reverts commit ebab1ffca8.
This commit removed "useless" initializers, going from

    /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
       STATE-NUM.  */
    private static final byte yypact_[] = yypact_init ();
    private static final byte[] yypact_init ()
    {
      return new byte[]
      {
        25,    -7,    -8,    37,    -8,    40,    -8,    20,    -8,    61,
        -8,    -8,     3,     9,    51,    -8,    -8,    -2,    -2,    -2,
        -2,    -2,    -2,    -8,    -8,    -8,     1,    66,    66,     3,
         3,     3
      };
    }

to

    /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
       STATE-NUM.  */
    private static final byte[] yypact_ =
    {
        25,    -7,    -8,    37,    -8,    40,    -8,    20,    -8,    61,
        -8,    -8,     3,     9,    51,    -8,    -8,    -2,    -2,    -2,
        -2,    -2,    -2,    -8,    -8,    -8,     1,    66,    66,     3,
         3,     3
    };

But it turns out that this was on purpose, to work around the 64KB
limitation in JVM methods.  It was introduced on the 2008-11-10 by
Di-an Jan in 09ccae9b18: "Work around
Java's ``code too large'' problem for parser tables".  See
https://lists.gnu.org/r/help-bison/2008-11/msg00004.html.  A real
test, where we would hit the JVM limitation, would be nice.

To avoid further regressions, add comments.
2020-02-10 07:34:07 +01:00
Akim Demaille
bc74b4b15a skeletons: avoid b4_error_verbose_if, which is confusing
parse.error has more than two possible values.

* data/skeletons/bison.m4 (b4_error_verbose_if, b4_error_verbose_flag):
Remove.
(b4_parse_error_case, b4_parse_error_bmatch): New.
Adjust dependencies.
2020-02-10 07:24:38 +01:00
Akim Demaille
8dd8137c38 skeletons: decorelate %token-table from verbose error messages
Reported by Adrian Vogelsgesang.

* data/skeletons/bison.m4: Here.
* data/skeletons/lalr1.cc: Adjust.
2020-02-10 07:24:38 +01:00
Akim Demaille
1388e5b276 doc: formatting changes
* doc/bison.texi: here.
2020-02-10 07:24:38 +01:00
Akim Demaille
6f5465c917 doc: clearly state that %yacc only makes sense with yacc.c
* doc/bison.texi: here.
* tests/calc.at: Stop testing %yacc with non yacc.c skeletons.
2020-02-09 15:58:55 +01:00
Adrian Vogelsgesang
bb02acc2ed style: stylistic cleanups in the C skeletons
* data/skeletons/glr.c, data/skeletons/yacc.c:
Avoid duplicated declaration of yysymbol_name.
2020-02-09 15:58:27 +01:00
Akim Demaille
80a4389377 java: provide Context with a more OO interface
* data/skeletons/lalr1.java (yyexpectedTokens)
(yysyntaxErrorArguments): Make them methods of Context.
(Context.yysymbolName): New.
* tests/local.at: Adjust.
2020-02-08 16:17:53 +01:00
Akim Demaille
ef097719ea java: add support for parse.error custom
* data/skeletons/lalr1.java: Add support for custom parse errors.
(yyntokens_): Make it public.  Under...
(yyntokens): this name.
(Context): Capture the location too.
* examples/c/bistromathic/parse.y,
* examples/c/bistromathic/bistromathic.test:
Improve error message.
* examples/java/calc/Calc.test, examples/java/calc/Calc.y: Use custom
error messages.
* tests/calc.at, tests/local.at: Check custom error messages.
2020-02-08 16:03:50 +01:00
Akim Demaille
0c90c59795 java: let the Context give access to yyntokens
* data/skeletons/lalr1.java (Context.yytokens): New.
2020-02-08 15:54:16 +01:00
Akim Demaille
18a7cfc7cf java: make the syntax error format string translatable
The error format should be translated, but contrary to the case of
C/C++, we cannot just depend on macros to adapt on the
presence/absence of '_'.  Let's consider that the message format is to
be translated iff there are some internationalized tokens.

* src/output.c (prepare_symbol_names): Define b4_has_translations.
* data/skeletons/java.m4 (b4_trans): New.
* data/skeletons/lalr1.java: Use it to emit translatable or not the
format string.
2020-02-08 11:24:53 +01:00
Akim Demaille
088356cb2f java: introduce yyexpectedTokens
And allow syntax error messages for 'detailed' and 'verbose' to be
translated.

* data/skeletons/lalr1.java (Context, yyexpectedTokens)
(yysyntaxErrorArguments): New.
(yysyntax_error): Use it.
2020-02-08 11:24:53 +01:00
Akim Demaille
52db24b2bc java: add support for parse.error=detailed
In Java there is no need for N_ and yytranslate_.  So instead of
hard-coding the use of N_ in the table of the symbol names, rely on
b4_symbol_translate.

* src/output.c (prepare_symbol_names): Use b4_symbol_translate instead
of N_.
* data/skeletons/c.m4 (b4_symbol_translate): New.
* data/skeletons/lalr1.java (yysymbolName): New.
Use it.
* examples/java/calc/Calc.y: Use parse.error=detailed.
* tests/calc.at: Check parse.error=detailed.
2020-02-08 11:24:53 +01:00
Akim Demaille
650b253843 m4: fix b4_token_format
We used to emit:

    /** Token number,to be returned by the scanner.  */
    static final int NUM = 258;
    /** Token number,to be returned by the scanner.  */
    static final int NEG = 259;

with no space after the comma.  Fix that.

* data/skeletons/bison.m4 (b4_token_format): Quote where appropriate.
2020-02-08 11:24:53 +01:00
Akim Demaille
7781254e01 java: tests: remove now redundant tests
* tests/javapush.at: here.
2020-02-05 13:17:00 +01:00
Akim Demaille
fa226d773c java: tests: check push parsers like the others
Currently in javapush.at.

* tests/calc.at: Here.
2020-02-05 13:17:00 +01:00
Akim Demaille
1cc83505c5 java: tests: remove now redundant tests
* tests/java.at: Calculator tests are now in calc.at.
2020-02-05 13:17:00 +01:00