Commit Graph

259 Commits

Author SHA1 Message Date
Akim Demaille
4e26809ab9 style: rename yysyntax_error_arguments as yy_syntax_error_arguments
It's a private implementation detail.

* NEWS, data/skeletons/glr.c, data/skeletons/lalr1.cc,
* data/skeletons/yacc.c, doc/bison.texi: here.
2020-04-05 08:56:21 +02:00
Akim Demaille
76e11b5a3e c: rename yyparse_context_t as yypcontext_t
The first name is too long.  We already have `yypstate`, so
`yypcontext` is ok.  We are also migrating to using `*_t` for our
types.

* NEWS, data/skeletons/glr.c, data/skeletons/yacc.c, doc/bison.texi,
* examples/c/bistromathic/parse.y, src/parse-gram.y, tests/local.at:
(yyparse_context_t, yyparse_context_location, yyparse_context_token):
Rename as...
(yypcontext_t, yypcontext_location, yypcontext_token): these.
2020-04-04 19:20:29 +02:00
Akim Demaille
e364bcdbc5 doc: c++: promote api.token.raw
* doc/bison.texi (Calc++ Parser): Here.
2020-03-23 07:02:32 +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
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
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
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
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
Akim Demaille
bba2f0a3a0 traces: write the "Reading a token" alone on its line
The Java skeleton displays

    Reading a token:
    Next token is token "number" (1)

while the other display

    Reading a token: Next token is token "number" (1)

When generating logs in the scanner, the first part is separated from
the second, and the end of the scanner logs have the second part
pasted in.  So let's propagate the Java way, but with the colon.

* data/skeletons/glr.c, data/skeletons/lalr1.cc, data/skeletons/lalr1.d,
* data/skeletons/lalr1.java, data/skeletons/yacc.c: Do it.
Adjust test cases and doc.
2020-02-04 07:02:24 +01:00
Akim Demaille
23ba9e5dfa doc: document new features of parse.error
* doc/bison.texi (Error Reporting): Rename as...
(Error Reporting Function): this.
Adjust dependencies.
Make it a subsection of this...
(Error Reporting): new section.
(Syntax Error Reporting Function): New.
(parse.error): Update description.
2020-02-02 09:19:58 +01:00
Akim Demaille
c80cdf2db2 doc: simplify uses of @ref
The PDF output is more consistent: some nodes were not pointed to with
their title.  The HTML output becomes "see section Foo" instead of
"see Foo", but this should be addressed in the next Texinfo release.
Info output is simplified, as it uses only the node name and not its
title.  But it's considered easier to read this way.
See https://lists.gnu.org/r/help-texinfo/2020-01/msg00031.html.

* doc/bison.texi: Set @xrefautomaticsectiontitle on.
Simplify all uses of ref.
2020-01-27 07:22:22 +01:00
Akim Demaille
78e43ce8ff doc: don't pretend trigonometry is part of arithmetics
* doc/bison.texi (arith_funs): Rename as...
(funs): this.
2020-01-27 06:43:19 +01:00
Akim Demaille
8036635251 package: bump copyrights to 2020
Run 'make update-copyright'.
2020-01-05 10:26:35 +01:00
Akim Demaille
da4587fcd7 doc: YYERROR_VERBOSE is no longer supported
* doc/bison.texi (Table of Symbols): Remove last reference to it.
* NEWS: Be clear about that.
2020-01-04 09:14:19 +01:00
Akim Demaille
d29e40a047 doc: clean up the description of YYDEBUG
* doc/bison.texi: Make it clearer that %define parse.trace is the
preferred options.
Fix a typo about api.prefix.
2019-12-29 11:13:00 +01:00
Akim Demaille
0d73c39bb7 doc: formatting changes
* doc/bison.texi: No output changes.
2019-12-14 17:19:53 +01:00
Akim Demaille
20107b77c0 doc: clearly deprecate YYPRINT
* doc/bison.texi (Prologue): Stop using YYPRINT as an example.
(The YYPRINT Macro): Clearly show this macro is deprecated.
2019-12-07 15:29:43 +01:00
Akim Demaille
5e71eef267 doc: formatting changes
* doc/bison.texi: here.
No change in content.
2019-12-07 15:29:43 +01:00
Akim Demaille
357336d254 glr.c: obey the parse.assert %define variable
* data/skeletons/glr.c (YYASSERT): Rename as...
(YY_ASSERT): this, for consistency with yacc.c, and also to emphasize
the fact that this is not for the end user (YY_ prefix).
* tests/glr-regression.at: Define parse.assert.
2019-12-07 13:23:45 +01:00
Akim Demaille
ca796220ec doc: don't promote dangling aliases
String literals as tokens serve two distinct purposes: freeing from
having to implement the keyword matching in the scanner, and improving
error messages.  Most of the time both can be achieved at the same
time, but on occasions, it does not work so well.

We promote their use for error messages.  We will also still support
the former case, but it is _not_ the recommended approach.

* doc/bison.texi (Tokens from Literals): Clearly state that we don't
recommend looking up the token types in the list of token names.
2019-11-18 09:15:35 +01:00
Akim Demaille
8a910107b3 diagnostics: complain about undeclared string tokens
String literals, which allow for better error messages, are (too)
liberally accepted by Bison, which might result in silent errors.  For
instance

    %type <exVal> cond "condition"

does not define “condition” as a string alias to 'cond' (nonterminal
symbols do not have string aliases).  It is rather equivalent to

    %nterm <exVal> cond
    %token <exVal> "condition"

i.e., it gives the type 'exVal' to the "condition" token, which was
clearly not the intention.

Introduce -Wdangling-alias to catch this.

* src/complain.h, src/complain.c: Add support for -Wdangling-alias.
(argmatch_warning_args): Sort.
* src/symtab.c (symbol_check_defined): Complain about dangling
aliases.
* doc/bison.texi: Document it.
* tests/input.at (Dangling aliases): New test.
2019-11-17 18:27:42 +01:00
Akim Demaille
1817b475a6 doc: promote %nterm over %type
As an extension to POSIX Yacc, Bison's %type accepts tokens.
Unfortunately with string literals as implicit tokens, this is
misleading, and led some users to write

    %type <exVal> cond "condition"

believing that "condition" would be associated to the 'cond'
nonterminal (see https://github.com/apache/httpd/pull/72).

* doc/bison.texi: Promote %nterm rather than %type to declare the type
of nonterminals.
2019-11-16 12:54:44 +01:00
Akim Demaille
22ca07defa doc: formatting changes
* doc/bison.texi: No visible changes.
2019-11-16 12:54:44 +01:00
Akim Demaille
dbd6975b5c doc: work around warnings when Flex C output is compiled in C++
* doc/bison.texi (calc++/scanner.ll): here.
While at it, clarify clang vs. warnings.
2019-11-16 12:54:44 +01:00
Akim Demaille
b2347a3c3e doc: formatting changes
* doc/bison.texi: Wrap lines.
No semantical difference.
2019-11-09 07:57:05 +01:00
Akim Demaille
008d927f71 doc: use upper case for tokens
* doc/bison.texi: here.
2019-11-09 07:54:32 +01:00
Akim Demaille
1650c729d9 doc: type-face fixes
* doc/bison.texi: Use @code for types in function definitions.
2019-11-07 07:13:40 +01:00
Akim Demaille
7bdf7246fb c++: expose the type used to store line and column numbers
* data/skeletons/location.cc (position::counter_type)
(location::counter_type): New.
Use them.
* doc/bison.texi (C++ position, C++ location): Adjust.
2019-11-06 18:20:15 +01:00
Akim Demaille
3398b0fa90 c++: fix old cast warnings
We still have a few old C casts in lalr1.cc, let's get rid of them.
Reported by Frank Heckenbach.

Actually, let's monitor all our casts using easy to grep macros.
Let's use these macros to use the C++ standard casts when we are in
C++.

* data/skeletons/c.m4 (b4_cast_define): New.
* data/skeletons/glr.c, data/skeletons/glr.cc,
* data/skeletons/lalr1.cc, data/skeletons/stack.hh,
* data/skeletons/yacc.c:
Use it and/or its casts.

* tests/actions.at, tests/cxx-type.at,
* tests/glr-regression.at, tests/headers.at, tests/torture.at,
* tests/types.at:
Use YY_CAST instead of C casts.

* configure.ac (warn_cxx): Add -Wold-style-cast.
* doc/bison.texi: Disable it.
2019-11-02 16:40:50 +01:00
Akim Demaille
d6ce0521cf doc: spell check
* doc/bison.texi: Remove the index about yyoutput, it is no longer
documented.
Spell check.
2019-10-10 17:53:48 +02:00
Paul Eggert
5463291a91 Use “least” types for integers in Yacc tables
This changes the Yacc skeleton to use “least” integer types to
keep tables smaller on some platforms, which should lessen cache
pressure.  Since Bison uses the Yacc skeleton, it follows suit.
* data/skeletons/yacc.c: Include limits.h and stdint.h if this
seems to be needed.
(yytype_uint8, yytype_int8, yytype_uint16, yytype_int16):
If available, use GCC predefined macros __INT_MAX__ etc. to select
a “least” type, as this avoids namespace hassles.  Otherwise, if
available fall back on selecting a “least” type via the C99 macros
INT_MAX, INT_LEAST8_MAX, etc.  Otherwise, fall further back on one of
the builtin C99 types signed char, short, and int.  Make sure that
any selected type promotes to int.  Ignore any macros YYTYPE_INT16,
YYTYPE_INT8, YYTYPE_UINT16, YYTYPE_UINT8 defined by the user.
(ptrdiff_t, PTRDIFF_MAX): Simplify in the light of the above.
(yytype_uint8, yytype_uint16): Do not assume that unsigned char
and unsigned short promote to int, as this isn’t true on some
platforms (e.g., TI TMS320C55x).
* src/parse-gram.y (YYTYPE_INT16, YYTYPE_INT8, YYTYPE_UINT16)
(YYTYPE_UINT8): Remove, as these are no longer effective.
2019-10-07 00:08:19 -07:00
Paul Eggert
39eb80bdbc * doc/bison.texi (Table of Symbols): Mention memory exhaustion. 2019-10-03 11:17:18 -07:00
Paul Eggert
361004aabe Simplify mfcalc error handling
* doc/bison.texi (Mfcalc Symbol Table, Mfcalc Lexer):
Don’t abort on memory allocation failure or integer overflow.
Instead, comment that these things aren’t checked for.
2019-10-03 11:17:18 -07:00
Paul Eggert
133edcd248 Prefer signed to unsigned integers
This patch contains more fixes to prefer signed to unsigned
integer types, as modern tools like 'gcc -fsanitize=undefined'
can check for signed integer overflow but not unsigned overflow.
* NEWS: Document the API change.
* boostrap.conf (gnulib_modules): Add intprops.
* data/skeletons/glr.c: Include stddef.h and stdint.h,
since this skeleton can assume C99 or later.
(YYSIZEMAX): Now signed, and the minimum of SIZE_MAX and PTRDIFF_MAX.
(yybool) [!__cplusplus]: Now signed (which is how bool behaves).
(YYTRANSLATE): Avoid use of unsigned, and make the macro
safe even for values greater than UINT_MAX.
(yytnamerr, struct yyGLRState, struct yyGLRStateSet, struct yyGLRStack)
(yyaddDeferredAction, yyinitStateSet, yyinitGLRStack)
(yyexpandGLRStack, yymarkStackDeleted, yyremoveDeletes)
(yyglrShift, yyglrShiftDefer, yy_reduce_print, yydoAction)
(yyglrReduce, yysplitStack, yyreportTree, yycompressStack)
(yyprocessOneStack, yyreportSyntaxError, yyrecoverSyntaxError)
(yyparse, yy_yypstack, yypstack, yypdumpstack):
* tests/input.at (Torturing the Scanner):
Prefer ptrdiff_t to size_t.
* data/skeletons/c++.m4 (b4_yytranslate_define):
* src/AnnotationList.c (AnnotationList__computePredecessorAnnotations):
* src/AnnotationList.h (AnnotationIndex):
* src/InadequacyList.h (InadequacyListNodeCount):
* src/closure.c (closure_new):
* src/complain.c (error_message, complains, complain_indent)
(complain_args, duplicate_directive, duplicate_rule_directive):
* src/gram.c (nritems, ritem_print, grammar_dump):
* src/ielr.c (ielr_compute_ritem_sees_lookahead_set)
(ielr_item_has_lookahead, ielr_compute_annotation_lists)
(ielr_compute_lookaheads):
* src/location.c (columns, boundary_print, location_print):
* src/muscle-tab.c (muscle_percent_define_insert)
(muscle_percent_define_check_values):
* src/output.c (prepare_rules, prepare_actions):
* src/parse-gram.y (id, handle_require):
* src/reader.c (record_merge_function_type, packgram):
* src/reduce.c (nuseless_productions, nuseless_nonterminals)
(inaccessable_symbols):
* src/relation.c (relation_print):
* src/scan-code.l (variant, variant_table_size, variant_count)
(variant_add, get_at_spec, show_sub_message, show_sub_messages)
(parse_ref):
* src/scan-gram.l (<SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>)
(scan_integer, convert_ucn_to_byte, handle_syncline):
* src/scan-skel.l (at_complain):
* src/symtab.c (complain_symbol_redeclared)
(complain_semantic_type_redeclared, complain_class_redeclared)
(symbol_class_set, complain_user_token_number_redeclared):
* src/tables.c (conflict_tos, conflrow, conflict_table)
(conflict_list, save_row, pack_vector):
* tests/local.at (AT_YYLEX_DEFINE(c)):
Prefer signed to unsigned integer.
* data/skeletons/lalr1.cc (yy_lac_check_):
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR):
* tests/local.at (AT_YYLEX_DEFINE(c)):
Omit now-unnecessary casts.
* data/skeletons/location.cc (b4_location_define):
* doc/bison.texi (Mfcalc Lexer, C++ position, C++ location):
Prefer int to unsigned for line and column numbers.
Change example to abort explicitly on memory exhaustion,
and fix an off-by-one bug that led to undefined behavior.
* data/skeletons/stack.hh (stack::operator[]):
Also allow ptrdiff_t indexes.
(stack::pop, slice::slice, slice::operator[]):
Index arg is now ptrdiff_t, not int.
(stack::ssize): New method.
(slice::range_): Now ptrdiff_t, not int.
* data/skeletons/yacc.c (b4_state_num_type): Remove.
All uses replaced by b4_int_type.
(YY_CONVERT_INT_BEGIN, YY_CONVERT_INT_END): New macros.
(yylac, yyparse): Use them around conversions that -Wconversion
would give false alarms about. 	Omit unnecessary casts.
(yy_stack_print): Use int rather than unsigned, and omit
a cast that doesn’t seem to be needed here any more.
* examples/c++/variant.yy (yylex):
* examples/c++/variant-11.yy (yylex):
Omit no-longer-needed conversions to unsigned.
* src/InadequacyList.c (InadequacyList__new_conflict):
Don’t assume *node_count is unsigned.
* src/output.c (muscle_insert_unsigned_table):
Remove; no longer used.
2019-10-02 17:11:33 -07:00
Akim Demaille
3ca713abd0 api.token.raw: document it
* doc/bison.texi: here.
2019-09-14 10:09:08 +02:00
Adrian Vogelsgesang
72d4ae5306 lalr1.cc: add LAC support
Implement lookahead correction (LAC) for the C++ skeleton.  LAC is a
mechanism to make sure that we report the correct list of expected
tokens if a syntax error occurs.  So far, LAC was only supported for
the C skeleton "yacc.c".

* data/skeletons/lalr1.cc: Add LAC support.
* doc/bison.texi: Update.
2019-08-09 06:39:59 -05:00
Akim Demaille
d90023af5f doc: fix inaccuracies wrt --define and --force-define
The doc says that -Dfoo=bar is the same as %define foo "bar".  It is
not: the quotes are not added (and it makes a difference).

* doc/bison.texi (Tuning the Parser): Fix the definition of -D/-F
* src/getargs.c (usage): Likewise.
2019-07-07 08:11:35 +02:00
Akim Demaille
964c6508b1 doc: put diagnostics related options together
* doc/bison.texi (Diagnostics): New section.
Move --warning, --color and --style there.
* src/getargs.c (usage): Likewise.
2019-07-07 08:11:35 +02:00
Akim Demaille
4e3c6f59cc doc: move -y's documentation into "Tuning the Parser"
Let's clarify --help: use clearer "section" names, as in the doc.
Move --yacc to where it belongs.

* src/getargs.c (usage): Rename "Parser" as "Tuning the Parser", as in
the doc.
Rename "Output" as "Output Files"
Move --yacc to "Tuning the Parser".
* doc/bison.texi: Likewise.
2019-07-07 08:01:37 +02:00
Akim Demaille
801582b410 doc: document colorized diagnostics
* src/getargs.c (argmatch_color_group): New.
(usage): Document --color and --style.
* doc/bison.texi (Bison Options): Split into three subsections.
Document --color and --style.
2019-07-07 08:01:37 +02:00
Akim Demaille
0428c429a1 remove "experimental" warnings
Sadly enough, AFAIK, there were never answers to the "More user
feedback will help to stabilize it" sentences.  Remove them.

* src/getargs.c: IELR, canonical LR and XML output are here to stay,
and they are no more experimental than some other features.
* doc/bison.texi: Likewise.
Also remove "experimental" warning for Java, LAC, LR tuning options,
and named references.
2019-06-22 08:29:06 +02:00
Akim Demaille
f2b210a901 java: fix support for api.prefix
* data/skeletons/java.m4: here.
* tests/java.at: Check it.
2019-06-19 19:15:31 +02:00
Akim Demaille
dfef525920 tests: remove useless support of '.' in integers
* tests/calc.at: here.
* doc/bison.texi: Avoid uninitialized variables.
2019-06-04 08:36:43 +02:00
Akim Demaille
aa21c457f2 doc: clarify the purpose of symbol_type constructors
Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2019-02/msg00006.html

* doc/bison.texi (Complete Symbols): Here.
2019-05-25 10:28:12 +02:00
Akim Demaille
70c3f3ade5 doc: avoid Texinfo portability issues
Reported by Bruno Haible.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00024.html
Fixed by Karl Berry.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00034.html

* doc/bison.texi: Don't specify the langage, rely on the default.
Avoid blank pages.
2019-05-20 06:12:47 +02:00