summaryrefslogtreecommitdiff
path: root/examples/c++
Commit message (Collapse)AuthorAgeFilesLines
* Prefer signed to unsigned integersPaul Eggert2019-10-022-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* git: update ignoresAkim Demaille2019-09-221-0/+1
|
* package: add missing CLEANFILESAkim Demaille2019-04-282-1/+4
| | | | * examples: here.
* make: regenerate the example parsers when bison changesAkim Demaille2019-02-021-2/+0
| | | | * Makefile.am (dependencies): Also depend on Bison's sources.
* package: bump copyrights to 2019Akim Demaille2019-01-059-10/+10
|
* examples: fix dependenciesAkim Demaille2018-12-262-4/+4
| | | | | | | | Commit 112ccb5ed73ba5c64b0b5300d8b9b686f02f094c moved the skeletons from dist_pkgdata_DATA to dist_skeletons_DATA, hence broke the dependencies. * Makefile.am (dependencies): New. Use it where appropriate.
* examples: add a simple Flex+Bison example in CAkim Demaille2018-12-091-4/+7
| | | | | | | | | | Suggested by Askar Safin. http://lists.gnu.org/archive/html/bug-bison/2018-12/msg00003.html * examples/c/lexcalc/Makefile, examples/c/lexcalc/README.md, * examples/c/lexcalc/lexcalc.test, examples/c/lexcalc/local.mk, * examples/c/lexcalc/parse.y, examples/c/lexcalc/scan.l: New.
* examples: sort them per language and complete themAkim Demaille2018-12-097-9/+278
| | | | | | | | | | | | | | | | | | | | | Convert some of the READMEs to Markdown, which is now more common, and nicely displayed in some git hosting services. Add missing READMEs and Makefiles. Generate XML, HTML and Dot files. Be sure to ship the test files. Complete CLEANFILES to remove all generated files. * examples/calc++: Move into... * examples/c++: here. * examples/mfcalc, examples/rpcalc: Move into... * examples/c: here. * examples/README.md, examples/c++/calc++/Makefile, examples/c/local.mk, * examples/c/mfcalc/Makefile, examples/c/rpcalc/Makefile, * examples/d/README.md, examples/java/README.md: New files. * examples/test (medir): Be robust to deeper directory nesting.
* examples: remove useless includesAkim Demaille2018-11-132-5/+5
| | | | | * examples/c++/variant-11.yy, examples/c++/variant.yy: here. Fix warning when storing a long into an int.
* tests: compile the C++ examples with warningsAkim Demaille2018-11-121-2/+2
| | | | * examples/c++/local.mk: Pass $(WARN_CXXFLAGS_TEST).
* tests: don't fail if the C++ compiler does not workAkim Demaille2018-11-041-8/+13
| | | | | | | | | | | | | | | | Also, make sure that `make dist` generates a correct tarball even if the C++ compiler does not work. Reported by Nelson H. F. Beebe. * m4/cxx.m4 (BISON_CXX_WORKS): Define to true/false instead of true/exit 77. The latter is too dangerous to use (it directly quits). (ENABLE_CXX): New name for the Automake conditional, for consistency with ENABLE_CXX11 etc. * tests/local.at (AT_COMPILE, AT_COMPILE_CXX): Adjust to the new semantics of BISON_CXX_WORKS. * examples/c++/local.mk: Skip the variant test if C++ does not work. * examples/calc++/local.mk: Likewise.
* c++: workaround portability issueAkim Demaille2018-11-041-1/+1
| | | | | | | | | | | | | | | | | | | On some systems (x86_64-pc-solaris2.11), with Developer Studio 12.5's CC, we get: ".../include/CC/Cstd/vector.cc", line 127: Error: Cannot assign const yy::parser::stack_symbol_type to yy::parser::stack_symbol_type without "yy::parser::stack_symbol_type::operator=(const yy::parser::stack_symbol_type&)";. ".../include/CC/Cstd/vector", line 475: Where: While instantiating "std::vector<yy::parser::stack_symbol_type>::__insert_aux(yy::parser::stack_symbol_type*, const yy::parser::stack_symbol_type&)". ".../include/CC/Cstd/vector", line 475: Where: Instantiated from non-template code. 1 Error(s) detected. Don't expect __cplusplus to be always defined. If it's not, consider this is C++98. Reported by Nelson H. F. Beebe. * data/c++.m4, data/lalr1.cc, examples/c++/variant.yy, tests/local.at, * tests/testsuite.h: An undefined __cplusplus means pre C++11.
* doc: spell checkAkim Demaille2018-10-261-2/+3
| | | | * README, doc/bison.texi, examples/README, examples/c++/README: here.
* examples: add a Makefile for C++ short examplesAkim Demaille2018-10-263-2/+31
| | | | | * examples/c++/Makefile: New. * examples/c++/local.mk, examples/c++/README: Adjust.
* configure: quit on trying to get ICC and Flex be friendsAkim Demaille2018-10-241-0/+2
| | | | | | | | | | The CI is using Flex 2.5.35. And ICC is too picky for it. Let's stop making these warnings errors. I wish I could disable them in the source files using the ICC version and the Flex version, but ICC's pragma support is unclear, and I'm tired of fighting it. * configure.ac (FLEX_SCANNER_CXXFLAGS): Make warnings warnings. * examples/c++/local.mk: Comment changes.
* c++: std::to_string is available in C++11Akim Demaille2018-10-241-11/+1
| | | | | | | | Reported by Victor Khomenko. http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00033.html * doc/bison.texi, examples/c++/variant-11.yy: Use std::to_string instead of ours.
* examples: move the variant examples into the C++ directoryAkim Demaille2018-10-246-8/+422
| | | | | | | | | * examples/variant-11.test examples/variant-11.yy, * examples/variant.test examples/variant.yy: Move into examples/c++/. * examples/c++/README: New. * examples/README, examples/c++/local.mk, examples/local.mk: Adjust.
* doc: an introductory example for C++Akim Demaille2018-10-242-0/+49
Suggested by Victor Khomenko. http://lists.gnu.org/archive/html/bug-bison/2018-08/msg00037.html * doc/bison.texi (A Simple C++ Example): New. * examples/c++/local.mk, examples/c++/simple.test: New. Extract, check, and install this new example. * examples/local.mk: Adjust. * examples/test: Adjust to the case where the dirname differs from the test name.