Commit Graph

1734 Commits

Author SHA1 Message Date
Akim Demaille
9840e5b621 c++: use noexcept where appropriate
Reported by Don Macpherson.
https://github.com/akimd/bison/issues/63
https://github.com/akimd/bison/issues/64

* data/skeletons/c++.m4, data/skeletons/lalr1.cc: here.
2020-12-03 06:19:17 +01:00
Akim Demaille
38cdb2aba2 multistart: also use the api.prefix in the implementation
We were declaring foo_parse_expr but implementing yyparse_expr.

* data/skeletons/yacc.c (_b4_define_sub_yyparse): Use api.prefix for
the parse function name.
2020-11-21 14:57:29 +01:00
Adela Vais
e5854bbddd d: change YYLocation's type from class to struct
This avoids heap allocation and gives minimal costs for the
creation and destruction of the YYParser.Symbol struct if
the location tracking is active.

Suggested by H. S. Teoh.

* data/skeletons/lalr1.d: Here.
* doc/bison.texi: Document it.
* examples/d/calc/calc.y: Adjust.
* tests/calc.at: Test it.
2020-11-20 22:09:31 +01:00
Adela Vais
10305f3e94 d: change the return value of yylex from TokenKind to YYParser.Symbol
The complete symbol approach was deemed to be the right approach for Dlang.
Now, the user can return from yylex() an instance of YYParser.Symbol structure,
which binds together the TokenKind, the semantic value and the location. Before,
the last two were reported separately to the parser.
Only the user API is changed, Bisons's internal structure is kept the same.

* data/skeletons/d.m4 (struct YYParser.Symbol): New.
* data/skeletons/lalr1.d: Change the return value.
* doc/bison.texi: Document it.
* examples/d/calc/calc.y, examples/d/simple/calc.y: Demonstrate it.
* tests/calc.at, tests/scanner.at: Test it.
2020-11-20 22:09:31 +01:00
Adela Vais
593724366f d: add support for lookahead correction
When using lookahead correction, the method YYParser.Context.getExpectedTokens
is not annotated with const, because the method calls yylacCheck, which is not
const. Also, because of yylacStack and yylacEstablished, yylacCheck needs to
be called from the context of the parser class, which is sent as parameter to
the Context's constructor.

* data/skeletons/lalr1.d (yylacCheck, yylacEstablish, yylacDiscard,
yylacStack, yylacEstablished): New.
(Context): Use it.
* doc/bison.texi: Document it.
* tests/calc.at: Check it.
2020-11-18 08:14:43 +01:00
Adela Vais
0e51f6146a d: change the name of the custom error message function to reportSyntaxError
Changed from syntax_error to reportSyntaxError to be similar to the Java parser.

* data/skeletons/lalr1.d: Change the function name.
* doc/bison.texi: Document it.
* tests/local.at: Adjust.
2020-11-18 08:14:21 +01:00
Akim Demaille
b9b13602ed style: prefer b4_symbol(empty, ...) to b4_symbol(-2, ...)
* data/skeletons/c.m4: here.
2020-11-13 07:01:36 +01:00
Akim Demaille
23472033ee Merge branch 'maint'
* maint:
  c++: shorten the assertions that check whether tokens are correct
  c++: don't glue functions together
  lalr1.cc: YY_ASSERT should use api.prefix
  c++: don't use YY_ASSERT at all if parse.assert is disabled
  c++: style: follow the Bison m4 quoting pattern
  yacc.c: provide the Bison version as an integral macro
  regen
  style: make conversion of version string to int public
  %require: accept version numbers with three parts ("3.7.4")
  yacc.c: fix #definition of YYEMPTY
  gnulib: update
  doc: fix incorrect section title
  doc: minor grammar fixes in counterexamples section
2020-11-13 07:01:19 +01:00
Akim Demaille
d8cc6b073e c++: shorten the assertions that check whether tokens are correct
Before:

    YY_ASSERT (tok == token::YYEOF || tok == token::YYerror || tok == token::YYUNDEF || tok == 120 || tok == 49 || tok == 50 || tok == 51 || tok == 52 || tok == 53 || tok == 54 || tok == 55 || tok == 56 || tok == 57 || tok == 97 || tok == 98);

After:

    YY_ASSERT (tok == token::YYEOF
               || (token::YYerror <= tok && tok <= token::YYUNDEF)
               || tok == 120
               || (49 <= tok && tok <= 57)
               || (97 <= tok && tok <= 98));

Clauses are now also wrapped on several lines.  This is nicer to read
and diff, but also avoids pushing Visual C++ to its arbitrary
limits (640K and lines of 16380 bytes ought to be enough for anybody,
otherwise make an C2026 error).

The useless parens are there for the dummy warnings about
precedence (in the future, will we also have to put parens in
`1+2*3`?).

* data/skeletons/variant.hh (_b4_filter_tokens, b4_tok_in, b4_tok_in):
New.
(_b4_token_constructor_define): Use them.
2020-11-13 06:17:52 +01:00
Akim Demaille
0264b4bca0 c++: don't glue functions together
* data/skeletons/bison.m4 (b4_type_foreach): Accept a separator.
* data/skeletons/c++.m4: Use it.
And fix an incorrect comment.
2020-11-13 06:17:52 +01:00
Akim Demaille
8b424b865e lalr1.cc: YY_ASSERT should use api.prefix
Working on the previous commit I realized that YY_ASSERT was used in
the generated headers, so must follow api.prefix to avoid clashes when
multiple C++ parser with variants are used.

Actually many more macros should obey api.prefix (YY_CPLUSPLUS,
YY_COPY, etc.).  There was no complaint so far, so it's not urgent
enough for 3.7.4, but it should be addressed in 3.8.

* data/skeletons/variant.hh (b4_assert): New.
Use it.
* tests/local.at (AT_YYLEX_RETURN): Fix.
* tests/headers.at: Make sure variant-based C++ parsers are checked
too.
This test did find that YY_ASSERT escaped renaming (before the fix in
this commit).
2020-11-13 06:17:52 +01:00
Akim Demaille
f4431ea115 c++: don't use YY_ASSERT at all if parse.assert is disabled
In some extreme situations (about 800 tokens), we generate a
single-line assertion long enough for Visual C++ to discard the end of
the line, thus falling into parse ends for the missing `);`.  On a
shorter example:

    YY_ASSERT (tok == token::TOK_YYEOF || tok == token::TOK_YYerror || tok == token::TOK_YYUNDEF || tok == token::TOK_ASSIGN || tok == token::TOK_MINUS || tok == token::TOK_PLUS || tok == token::TOK_STAR || tok == token::TOK_SLASH || tok == token::TOK_LPAREN || tok == token::TOK_RPAREN);

Whether NDEBUG is used or not is irrelevant, the parser dies anyway.

Reported by Jot Dot <jotdot@shaw.ca>.
https://lists.gnu.org/r/bug-bison/2020-11/msg00002.html

We should avoid emitting lines so long.

We probably should also use a range-based assertion (with extraneous
parens to pacify fascist compilers):

    YY_ASSERT ((token::TOK_YYEOF <= tok && tok <= token::TOK_YYUNDEF)
               || (token::TOK_ASSIGN <= tok && ...)

But anyway, we should simply not emit this assertion at all when not
asked for.

* data/skeletons/variant.hh: Do not define, nor use, YY_ASSERT when it
is not enabled.
2020-11-13 06:17:52 +01:00
Akim Demaille
fe8c36ddca c++: style: follow the Bison m4 quoting pattern
* data/skeletons/variant.hh: here.
2020-11-13 06:17:24 +01:00
Akim Demaille
21c147b6e5 yacc.c: provide the Bison version as an integral macro
Suggested by Balazs Scheidler.
https://github.com/akimd/bison/issues/55

* src/muscle-tab.c (muscle_init): Move/rename `b4_version` to/as...
* src/output.c (prepare): `b4_version_string`.
Also define `b4_version`.
* data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/d.m4,
* data/skeletons/java.m4: Adjust.
* doc/bison.texi: Document it.
2020-11-11 09:08:57 +01:00
Akim Demaille
14c65a35f0 %require: accept version numbers with three parts ("3.7.4")
* src/parse-gram.y (str_to_version): Support three parts.
* data/skeletons/location.cc, data/skeletons/stack.hh:
Adjust.
2020-11-11 08:47:23 +01:00
Todd C. Miller
c47bb87f9f yacc.c: fix #definition of YYEMPTY
When generating a C parser, YYEMPTY is present in enum yytokentype but
there is no corresponding #define like there is for the other values.
There is a special case for YYEMPTY in b4_token_enums but no
corresponding case in b4_token_defines.

* data/skeletons/c.m4 (b4_token_defines): Do define YYEMPTY.
2020-11-11 08:47:21 +01:00
Akim Demaille
3b80811cfa glr2.cc: remove scaffolding for glr.c
* data/skeletons/glr2.cc (b4_glr_cc_setup, b4_glr_cc_cleanup): Remove.
2020-11-07 17:28:25 +01:00
Akim Demaille
10eb13007e d: remove dead comment
* data/skeletons/lalr1.d (reportSyntaxError): here.
2020-11-07 17:12:21 +01:00
Adela Vais
dc15b62a7c d: add the custom error message feature
Parser.Context class returns a const YYLocation, so Lexer's method
yyerror() needs to receive the location as a const parameter.

Internal error reporting flow is changed to be similar to that of
the other skeletons. Before, case YYERRLAB was calling yyerror()
with the result of yysyntax_error() as the string parameter. As the
custom error message lets the user decide if they want to use
yyerror() or not, this flow needed to be changed. Now, case YYERRLAB
calls yyreportSyntaxError(), that builds the error message using
yysyntaxErrorArguments(). Then yyreportSyntaxError() passes the
error message to the user defined syntax_error() in case of a custom
message, or to yyerror() otherwise.

In the tests in tests/calc.at, the order of the tokens needs to be
changed in order of precedence, so that the D program outputs the
expected tokens in the same order as the other parsers.

* data/skeletons/lalr1.d: Add the custom error message feature.
* doc/bison.texi: Document it.
* examples/d/calc/calc.y: Adjust.
* tests/calc.at, tests/local.at: Test it.
2020-11-07 17:03:23 +01:00
Akim Demaille
5a31cda4c3 style: avoid explicit symbol numbers
This should have been part of commit "symbols: stop dealing with YYEMPTY
as b4_symbol(-2, ...)" (cd40ec9526).
Give names to all the special symbols: "eof", "error" and "undef".

* data/skeletons/bison.m4 (b4_symbol): Let `b4_symbol(eof, ...)` mean
`b4_symbol(0, ...)`, `b4_symbol(error, ...)` mean `b4_symbol(1, ...)`,
and , `b4_symbol(undef, ...)` mean `b4_symbol(2, ...)`..

* data/skeletons/c.m4, data/skeletons/glr.c, data/skeletons/glr.cc,
* data/skeletons/glr2.cc, data/skeletons/lalr1.cc,
* data/skeletons/lalr1.d, data/skeletons/lalr1.java,
* data/skeletons/yacc.c:
Prefer symbols to numbers.
2020-11-07 16:58:47 +01:00
Adela Vais
34e6e8815a d: fix Context class
All methods are now declared as const. Method getExpectedTokens() has now the
functionality of reporting only the number of expected tokens.

* data/skeletons/lalr1.d: Fix Context class.
2020-11-07 07:55:12 +01:00
Adela Vais
abf5f7f90e d: add yyerrok
In D's case, yyerrok() is a private method of the Parser class.
It can be called directly as `yyerrok()` from the grammar rules section.

* data/skeletons/lalr1.d: Add yyerrok().
* examples/d/calc/calc.y, examples/d/simple/calc.y: Demonstrate yyerrok().
* tests/calc.at: Update D tests to use yyerrok().
2020-11-07 07:14:52 +01:00
Akim Demaille
d156910453 java: prefer ArrayList to Vector
Vector is synchronized, which is completely useless in our case (and
not even relevant when concurrency matters).  No seasoned Java
programmer would use it.
Reported by Uxio Prego.

* data/skeletons/lalr1.java: Replace Vector with ArrayList.
Unfortunately its API is not as rich, and lacks lastElement and
setSize.
2020-11-03 08:46:54 +01:00
Akim Demaille
c223baee63 java: add support for lookahead correction
Shamelessly stolen from Adrian Vogelsgesang's implementation in
lalr1.cc.

* data/skeletons/lalr1.java (yycdebugNnl, yyLacCheck, yyLacEstablish)
(yyLacDiscard, yylacStack, yylacEstablished): New.
(Context): Use it.
* examples/java/calc/Calc.y: Enable LAC.
2020-11-03 08:46:54 +01:00
Akim Demaille
787052f074 style: java: more style fixes
* data/skeletons/lalr1.java, tests/java.at: Avoid space before paren.
And use braces as is customary in the Java.
2020-11-03 08:46:54 +01:00
Akim Demaille
042b916c0e style: comment changes in the skeletons
* data/skeletons/lalr1.cc: Prepare for Java's LAC.
* data/skeletons/lalr1.java: Style fixes.
2020-11-03 08:46:54 +01:00
Adela Vais
0cd16ae964 d: create the Parser.Context class
This will provide the user an interface for creating custom error messages.

* data/skeletons/lalr1.d: Add the Context class.
* doc/bison.texi: Document it.
2020-10-27 07:39:00 +01:00
Adela Vais
7cd195b30a d: change api.token.raw default value to true
Generate consecutive values for enum TokenKind, as D's yylex()
returns TokenKind and collisions can't happen.

* data/skeletons/d.m4: Change default value.
* tests/scanner.at, tests/d.at: Check it.
2020-10-03 17:17:32 +02:00
Akim Demaille
e66673aa64 m4: have b4_percent_define_if_define apply default values lazily
Currently `b4_percent_define_ifdef([foo])` assigns a default value to
`foo` when invoked.  As a consequence, skeletons such as lalr1.d
cannot specify their specific default values: `foo` was defined in
bison.m4.

Instead, provide `foo` with a default value when `b4_foo_if` is
invoked.

I could not measure a runtime difference between both cases.

* data/skeletons/bison.m4 (_b4_percent_define_define): New.
Helps getting rid of spurious indentation that resulted in spurious
white space in the output.
(b4_percent_define_if_define): Move the definition to...
(_b4_percent_define_if_define): when the defined macros is called.
2020-10-03 09:17:53 +02:00
Adela Vais
3829bd6262 d: don't trigger GC in void toString
* data/skeletons/d.m4 (b4_declare_symbol_enum): Here.
2020-10-02 06:48:11 +02:00
Adela Vais
4bbda69f1e d: remove the default prefix for SymbolKind's enum elements
This is not needed in D, since the kinds are "scoped".

* data/skeletons/d.m4: Remove the default prefix.
* doc/bison.text: Document it.
2020-10-02 06:46:32 +02:00
Adela Vais
4855b98554 d: remove the @property attribute from interface Lexer
D best practices is to not use it.

* data/skeletons/lalr1.d: Remove attribute.
2020-10-02 06:35:17 +02:00
Akim Demaille
cd40ec9526 symbols: stop dealing with YYEMPTY as b4_symbol(-2, ...)
* data/skeletons/bison.m4 (b4_symbol): Redirect `b4_symbol(empty,
...)` to `b4_symbol(-2, ...)`.
Change all uses of the latter to the former.
2020-09-29 06:49:31 +02:00
Adela Vais
2e5592b3ab d: support api.symbol.prefix and api.token.prefix
The D skeleton was not properly supporting them.

* data/skeletons/d.m4, data/skeletons/lalr1.d: Fix it.
* tests/calc.at: Check it.
2020-09-28 19:27:19 +02:00
Akim Demaille
9b18cac96b multistart: start more thorough testing
* tests/local.at (AT_MULTISTART_IF): New.
* tests/calc.at: Adjust to check multiple start symbols.
* data/skeletons/yacc.c (yy_parse_impl): Fix.
2020-09-28 19:26:53 +02:00
Akim Demaille
d441a34791 multistart: also give access to yynerrs
This is something that has always bothered me: with pure parsers (and
they all should be) the user does not have an (easy) access to yynerrs
at the end of the parse.  In the case of error recovery, that's the
only direct means to know if there were errors.  The usual approach
being having the user maintain a counter incremented each time yyerror
is called.

So here, also capture yynerrs in the return value of the start-symbol
parsing functions.

* data/skeletons/yacc.c (yy_parse_impl_t): New.
(yy_parse_impl): Use it.
(b4_accept): Fill it.
* examples/c/lexcalc/parse.y, examples/c/lexcalc/scan.l: No longer
pass nerrs as lex- and parse-param, just use the resulting yynerrs.
bistromathic and reccalc both demonstrate %param.
2020-09-27 11:58:28 +02:00
Akim Demaille
f4d33ff4b4 yacc.c: also count calls to YYERROR in yynerrs
* data/skeletons/yacc.c: here.
2020-09-27 11:58:27 +02:00
Akim Demaille
d9cf99b6a5 multistart: use b4_accept instead of action post-processing
For each start symbol, generate a parsing function with a richer
return value than the usual of yyparse.  Reserve a place for the
returned semantic value, in order to avoid having to pass a pointer as
argument to "return" that value.  This also makes the call to the
parsing function independent of whether a given start-symbol is typed.

For instance, if the grammar file contains:

    %type <int> expression
    %start input expression

(so "input" is valueless) we get

    typedef struct
    {
      int yystatus;
    } yyparse_input_t;

    yyparse_input_t yyparse_input (void);

    typedef struct
    {
      int yyvalue;
      int yystatus;
    } yyparse_expression_t;

    yyparse_expression_t yyparse_expression (void);

This commit also changes the implementation of the parser termination:
when there are multiple start symbols, it is the initial rules that
explicitly YYACCEPT.  They do that after having exported the
start-symbol's value (if it is typed):

  switch (yyn)
    {
  case 1: /* $accept: YY_EXPRESSION expression $end  */
  { ((*yyvalue).TOK_expression) = (yyvsp[-1].TOK_expression); YYACCEPT; }
    break;

  case 2: /* $accept: YY_INPUT input $end  */
  { YYACCEPT; }
    break;

I have tried several ways to deal with termination, and this is the
one that appears the best one to me.  It is also the most natural.

* src/scan-code.h, src/scan-code.l (obstack_for_actions): New.
* src/reader.c (grammar_rule_check_and_complete): Generate the actions
of the rules for each start symbol.

* data/skeletons/bison.m4 (b4_symbol_slot): New, with safer semantics
than type and type_tag.
* data/skeletons/yacc.c (b4_accept): New.
Generates the body of the action of the start rules.
(_b4_declare_sub_yyparse): For each start symbol define a dedicated
return type for its parsing function.
Adjust the declaration of its parsing function.
(_b4_define_sub_yyparse): Adjust the definition of the function.

* examples/c/lexcalc/parse.y: Check the case of valueless symbols.
* examples/c/lexcalc/lexcalc.test: Check start symbols.
2020-09-27 09:44:18 +02:00
Akim Demaille
ed324578a2 multistart: equip yacc.c
* data/skeletons/yacc.c: Add support for multiple start symbols.
2020-09-27 09:23:51 +02:00
Akim Demaille
c08e0863be glr.cc: fix: use symbol_name
* data/skeletons/glr.cc: here.
2020-09-27 09:22:02 +02:00
Akim Demaille
f9b360663b glr2.cc: add an example
Currently this example crashes on input such as "T (x) + y;".
The same example with glr.c works properly.

* examples/c++/glr/Makefile, examples/c++/glr/README.md,
* examples/c++/glr/c++-types.test, examples/c++/glr/c++-types.yy,
* examples/c++/glr/local.mk, examples/c++/local.mk: New.
Based on examples/c/glr/c++-types.y.
2020-09-26 18:33:48 +02:00
Akim Demaille
3add9ffbde glr.cc: fix: use symbol_name
* data/skeletons/glr.cc: here.
2020-09-26 14:33:09 +02:00
Adela Vais
f296669c0f d: change the return value of yylex from int to TokenKind
* data/skeletons/lalr1.d: Change the return value.
* examples/d/calc/calc.y, examples/d/simple/calc.y: Adjust.
* tests/scanner.at: Adjust.
* tests/calc.at (_AT_DATA_CALC_Y(d)): New, extracted from...
(_AT_DATA_CALC_Y(c)): here.
The two grammars have been sufficiently different to be separated.
Still trying to be them together results in a maintenance burden.  For
the same reason, instead of specifying the results for D and for the
rest, compute the expected results with D from the regular case.
2020-09-26 08:08:25 +02:00
Adela Vais
de638df104 d: support api.parser.extends and api.parser.implements
The D skeleton was not properly supporting them.

* data/skeletons/d.m4: Fix it.
* tests/d.at: Check it.
* tests/local.mk, tests/testsuite.at: Adjust.
2020-09-24 09:29:45 +02:00
Akim Demaille
8dc60543c8 glr2.cc: also run all the calculator tests
This revealed issues with yy_symbol_print and yy_reduce_print.
These changes, in turn, reactivated GCC10 warnings:

    559. calc.at:1258: testing Calculator glr2.cc %locations %header parse.error=verbose %debug api.prefix={calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}  ...
    tests/calc.at:1258: COLUMNS=1000; export COLUMNS; NO_TERM_HYPERLINKS=1; export NO_TERM_HYPERLINKS;  bison --color=no -fno-caret -Wno-deprecated -o calc.cc calc.y
    tests/calc.at:1258: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o calc calc.cc calc-lex.cc calc-main.cc $LIBS
    stderr:
    calc.cc: In function 'void glr_stack::yyresolveLocations(glr_state*, int)':
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc:1177:10: error: potential null pointer dereference [-Werror=null-dereference]
     1177 |   return yypred ? &(asItem (this) - yypred)->getState () : YY_NULLPTR;
          |          ^~~~~~
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc: In member function 'YYRESULTTAG glr_stack::yyresolveValue(glr_state*)':
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

* tests/calc.at (AT_CHECK_CALC_GLR_CC): Also check glr2.cc.
* data/skeletons/glr2.cc: Don't pass the user arguments to
yy_symbol_print and yy_reduce_print, since they have it in the parser
object.
(b4_user_formals_no_comma, b4_pure_args, b4_lpure_args)
(b4_locuser_formals, b4_locuser_args): Remove, useless.
(YY_IGNORE_NULL_DEREFERENCE_BEGIN): Enable for GCC >= 10 too.
2020-09-21 06:43:10 +02:00
Akim Demaille
f8cd049ecc tests: check the location of the right-hand side symbols
The D skeleton was not properly supporting @1 etc.
Reported by Adela Vais.
https://lists.gnu.org/r/bison-patches/2020-09/msg00049.html

* data/skeletons/d.m4 (b4_rhs_location): Fix it.
* tests/calc.at: Check the support of @n for all the skeletons.
2020-09-20 17:24:06 +02:00
Akim Demaille
d4ffb69424 glr: support api.header.include
* data/skeletons/glr.c: here.
2020-09-19 17:50:28 +02:00
Akim Demaille
b327f38832 deprecate %defines in favor of %header
This is consistent with --defines being deprecated in favor of
--header.  The directive %defines is also too similar to %define.
And %header matches nicely with api.header.name.

* src/scan-gram.l (%defines): Deprecate to %header.
(%header): Scan it.
* src/parse-gram.y (PERCENT_DEFINES): Replace with...
(PERCENT_HEADER): this.
* data/skeletons/lalr1.java
* doc/bison.texi
* tests/actions.at, tests/c++.at, tests/calc.at, tests/conflicts.at,
* tests/input.at, tests/java.at, tests/local.at, tests/output.at,
* tests/synclines.at, tests/types.at:
Convert most tests to check %header instead of %defines.
2020-09-19 17:49:03 +02:00
Akim Demaille
75c3746ce2 options: rename --defines as --header
The name "defines" is incorrect, the generated file contains far more
than just #defines.

* src/getargs.h, src/getargs.c (-H, --header): New option.
With optional argument, just like --defines, --xml, etc.
(defines_flag): Rename as...
(header_flag): this.
Adjust dependencies.
* data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.c,
* data/skeletons/glr.cc, data/skeletons/glr2.cc, data/skeletons/lalr1.cc,
* data/skeletons/yacc.c:
Adjust.
* examples, doc/bison.texi: Adjust.
* tests/headers.at, tests/local.at, tests/output.at: Convert most
tests from using --defines to using --header.
2020-09-19 08:31:49 +02:00
Valentin Tolmer
12a5cc07e0 glr2.cc: replace refs to parser::symbol_kind_type with yysymbol_kind_t
* data/skeletons/glr2.cc: here.
2020-09-17 19:37:05 +02:00