summaryrefslogtreecommitdiff
path: root/src/scan-gram.l
Commit message (Collapse)AuthorAgeFilesLines
* parsers: support translatable token aliasesAkim Demaille2020-01-191-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | In addition to %token NUM "number" accept %token NUM _("number") in which case the token will be translated in error messages. Do not use _() in the output if there are no translatable tokens. * src/symtab.h, src/symtab.c (symbol): Add a 'translatable' member. * src/parse-gram.y (TSTRING): New token. (string_as_id.opt): Replace with... (alias): this. Use it. * src/scan-gram.l (SC_ESCAPED_TSTRING): New start conditions, to match TSTRINGs. * src/output.c (prepare_symbols): Define b4_translatable if there are translatable strings. * data/skeletons/glr.c, data/skeletons/lalr1.cc, * data/skeletons/yacc.c (yytnamerr): Receive b4_translatable, and use it.
* package: bump copyrights to 2020Akim Demaille2020-01-051-1/+1
| | | | Run 'make update-copyright'.
* reader: reduce the "scope" of global variablesAkim Demaille2019-10-261-10/+17
| | | | | | | | | | | | | | | We have too many global variables, adding structure would help. For a start, let's hide some of the variables closer to their usage. * src/getargs.c, src/files.h (current_file): Move to... * src/scan-gram.c: here. * src/scan-gram.h (gram_in, gram__flex_debug): Remove, make them private to the scanner. * src/reader.h, src/reader.c (reader): Take a grammar file as argument. Move the handling of scanner variables to... * src/scan-gram.l (gram_scanner_open, gram_scanner_close): here. (gram_scanner_initialize): Remove, replaced by gram_scanner_open. * src/main.c: Adjust.
* bison: check for int overflow when scanningPaul Eggert2019-10-171-2/+6
| | | | | | * src/scan-gram.l: Include errno.h, for errno. (scan_integer, handle_syncline): Check for integer overflow. * tests/input.at (too-large.y): Adjust to match new diagnostics.
* Prefer signed to unsigned integersPaul Eggert2019-10-021-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* input: stop treating lone CRs as end-of-linesAkim Demaille2019-09-141-65/+15
| | | | | | | | | | | | | | | We used to treat lone CRs (\r, aka ^M) as regular NLs (\n), probably to please Classic MacOS. As of today, it makes more sense to treat \r like a plain white space character. https://lists.gnu.org/archive/html/bison-patches/2019-09/msg00027.html * src/scan-gram.l (no_cr_read): Remove. Instead, use... (eol): this new abbreviation denoting end-of-line. * src/location.c (caret_getc): New. (location_caret): Use it. * tests/diagnostics.at (Carriage return): Adjust expectations. (CR NL): New.
* %fixed-output-files: detach from %yaccAkim Demaille2019-07-071-3/+2
| | | | | | | | | | | | | | The name fixed-output-files is pretty clear: generate y.tab.c, as Yacc does. So let's detach this from %yacc which does more: it requires POSIX Yacc behavior. This directive is obsolete since December 29th 2001 8c9a50bee13474c1491df8f79f075f5214dda0d1. It does not show in the doc. I don't want to spend more time on improving its diagnostics, it could be removed just as well as far as I'm concerned. * src/scan-gram.l, src/parse-gram.y (%fixed-output-files): Detach from %yacc.
* diagnostics: %pure-parser is obsoleteAkim Demaille2019-05-191-2/+4
| | | | | | | | | | | Reported by Uxio Prego. http://lists.gnu.org/archive/html/bug-bison/2018-12/msg00029.html * src/scan-gram.l, src/parse-gram.y (PERCENT_PURE_PARSER) (handle_pure_parser): New. Issue a deprecation/update notice for %pure-parser. * doc/bison.texi (Java Bison Interface): Don't mention %pure-parser. * tests/actions.at, tests/input.at: Adjust.
* style: use consistently *_loc for locationsAkim Demaille2019-05-031-1/+1
| | | | | | | | | | | Some members are called foo_location, others are foo_loc. Stick to the latter. * src/gram.h, src/location.h, src/location.c, src/output.c, * src/parse-gram.y, src/reader.h, src/reader.c, src/reduce.c, * src/scan-gram.l, src/symlist.h, src/symlist.c, src/symtab.h, * src/symtab.c: Use _loc consistently, not _location.
* diagnostics: better rule locationsAkim Demaille2019-04-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "identifier and colon" of a rule is implemented as a single token, but whose location is only that of the identifier (so that messages about the lhs of a rule are accurate). When reducing empty rules, the default location is the single point location on the end of the previous symbol. As a consequence, when Bison parses a grammar, the location of the right-hand side of an empty rule is based on the lhs, *independently of the position of the colon*. And the colon can be way farther, separated by comments, white spaces, including empty lines. As a result, some messages look really bad. For instance: $ cat foo.y %% foo : /* empty */ bar : /* empty */ gives $ bison -Wall foo.y foo.y:2.4: warning: empty rule without %empty [-Wempty-rule] 2 | foo : /* empty */ | ^ foo.y:3.4: warning: empty rule without %empty [-Wempty-rule] 3 | bar | ^ The carets are not at the right column, not even the right line. This commit passes the colon "again" after the "id colon" token, which gives more accurate locations for these messages: $ bison -Wall foo.y foo.y:2.10: warning: empty rule without %empty [-Wempty-rule] 2 | foo : /* empty */ | ^ foo.y:4.2: warning: empty rule without %empty [-Wempty-rule] 4 | : /* empty */ | ^ * src/scan-gram.l (SC_AFTER_IDENTIFIER): Rollback the colon, so that we scan it again afterwards. (INITIAL): Scan colons. * src/parse-gram.y (COLON): New. (rules): Parse the colon after the rule's id_colon (and possible named reference). * tests/actions.at, tests/conflicts.at, tests/diagnostics.at, * tests/existing.at: Adjust.
* diagnostics: fix the handling of multibyte charactersAkim Demaille2019-04-231-3/+13
| | | | | | | | | | | | | | This is a pity: efforts were invested in computing correctly the number of screen columns consumed by multibyte characters, but the routines that do that were fed by single-byte inputs... As a consequence Bison never displayed correctly locations when there are multibyte characters. * src/scan-gram.l (mbchar): New. Use it instead of . in the catch-all clause. * tests/diagnostics.at (Tabulations): Enhance into... (Tabulations and multibyte characters): this.
* diagnostics: fix styling issuesAkim Demaille2019-04-231-1/+4
| | | | | | | | | | | | | | | | | | | Single point locations (equal boundaries) are troublesome, and we were incorrectly ending the style in their case. Which results in an abort in libtextstyle. There is also a confusion between columns as displayed on the screen (which take into account multibyte characters and tabulations), and the number of bytes. Counting the screen-column incrementally (character by character) is uneasy (because of multibyte characters), and I don't want to maintain a buffer of the current line when displaying the diagnostic. So I believe the simplest solution is to track the byte number in addition to the screen column. * src/location.h, src/location.c (boundary): Add the byte-column. Adjust dependencies. * src/getargs.c, src/scan-gram.l: Adjust. * tests/diagnostics.at: Check zero-width locations.
* fixits: handle %file-prefixAkim Demaille2019-01-171-2/+2
| | | | | | | | * src/files.h, src/files.c (spec_file_prefix_loc): New. * src/scan-gram.l (%file-prefix): Delegate diagnostics to... * src/parse-gram.y (handle_file_prefix): here. * src/complain.c (duplicate_directive): Quote the directive. * tests/input.at: Adjust.
* fixits: report duplicate %yacc directivesAkim Demaille2019-01-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We should use -ffixit and --update to clean files with duplicate directives. And we should complain only once about duplicate obsolete directives: keep only the "duplicate" warning. Let's start with %yacc. For instance on: %fixed-output_files %fixed-output-files %yacc %% exp: This run of bison: $ bison /tmp/foo.y -u foo.y:1.1-19: warning: deprecated directive, use '%fixed-output-files' [-Wdeprecated] %fixed-output_files ^~~~~~~~~~~~~~~~~~~ foo.y:2.1-19: warning: duplicate directive [-Wother] %fixed-output-files ^~~~~~~~~~~~~~~~~~~ foo.y:1.1-19: previous declaration %fixed-output_files ^~~~~~~~~~~~~~~~~~~ foo.y:3.1-5: warning: duplicate directive [-Wother] %yacc ^~~~~ foo.y:1.1-19: previous declaration %fixed-output_files ^~~~~~~~~~~~~~~~~~~ bison: file 'foo.y' was updated (backup: 'foo.y~') gives: %fixed-output-files %% exp: * src/location.h, src/location.c (location_empty): New. * src/complain.h, src/complain.c (duplicate_directive): New. * src/getargs.h, src/getargs.c (yacc_flag): Instead of a Boolean, be the location of the definition. Update dependencies. * src/scan-gram.l (%yacc, %fixed-output-files): Move the handling of its warnings to... * src/parse-gram.y (do_yacc): This new function. * tests/input.at (Deprecated Directives): Adjust expectations.
* diagnostics: improve the accuracy for %error-verboseAkim Demaille2019-01-141-2/+2
| | | | | | | | | | | | | | | Avoid duplicate warnings about %error-verbose, once for deprecation, another for duplicate. Keep only the duplicate warning for the second occurrence of %error-verbose. This will help removal fixits. * src/scan-gram.l (%error-verbose): Return as a PERCENT_ERROR_VERBOSE token. * src/parse-gram.y (do_error_verbose): New. Use it. * src/muscle-tab.c (muscle_percent_variable_update): Handle pseudo variables such as %error-verbose.
* diagnostics: improve them for %name-prefixAkim Demaille2019-01-141-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the diagnostics for %name-prefix are not precise enough. In particular, they does not show that braces must be used instead of quotes. Before: foo.y:3.1-14: warning: deprecated directive, use '%define api.prefix' [-Wdeprecated] %name-prefix = "foo" ^^^^^^^^^^^^^^ After: foo.y:3.1-20: warning: deprecated directive, use '%define api.prefix {foo}' [-Wdeprecated] %name-prefix = "foo" ^^^^^^^^^^^^^^^^^^^^ To do this we need the value passed to %name-prefix, so move the warning from the scanner to the parser. Accuracy will be very important for the forthcoming changes. * src/parse-gram.y (do_name_prefix): New. (PERCENT_NAME_PREFIX): Have a semantic value: the raw source, with possibly underscores, equal sign, and spaces. This is used to provide a more accurate message. It does not take comments into account, but... * src/scan-gram.l (%name-prefix): Delegate the warnings to the parser. * tests/headers.at, tests/input.at: Adjust expectations.
* style: minor changesAkim Demaille2019-01-131-4/+3
| | | | | | * src/muscle-tab.c: Sort alphabetically. * src/scan-gram.l: Reduce scopes. Initialize variables.
* package: bump copyrights to 2019Akim Demaille2019-01-051-1/+1
|
* clearly deprecate %name-prefixAkim Demaille2019-01-031-2/+7
| | | | | | | | | | | * src/scan-gram.l (%name-prefix): Issue a deprecation warning. * tests/calc.at, tests/headers.at, tests/input.at, tests/java.at, * tests/javapush.at, tests/local.at: Adjust expectations. Or disable -Wdeprecated. * doc/bison.texi: Document that %name-prefix is replaced by %define api.prefix.
* style: formatting changesAkim Demaille2019-01-021-48/+48
| | | | * src/scan-gram.l: Here.
* style: sort includes in scannersAkim Demaille2019-01-021-12/+11
| | | | * src/scan-code.l, src/scan-gram.l, src/scan-skel.l: Reorder includes.
* parser: warn about string literals in Yacc modeAkim Demaille2018-12-141-0/+2
| | | | | * src/scan-gram.l (scan_integer): Warn. * tests/input.at (Yacc warnings on symbols): Check.
* parser: warn about hexadecimal token numbers in Yacc modeAkim Demaille2018-12-141-0/+4
| | | | | * src/scan-gram.l (scan_integer): Warn. * tests/input.at (Yacc warnings on symbols): Check.
* parser: reprecate %nterm backAkim Demaille2018-12-141-6/+1
| | | | | | | | | | | | | | | | | | | | | | | After having spent quite some time on cleaning the handling of symbol declarations in the grammar files, I believe we should keep it. It looks like it's a duplicate of %type, but it is not. While POSIX Yacc requires %type to apply only to nonterminal symbols, it appears that both byacc and bison accept it for tokens too. And some experienced users do actually expect this feature to group symbols (terminal or not) by type ("On the other hand, it is generally more useful IMHO to group terminals and non-terminals with the same type tag together", http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00000.html). Even Bison's own parser does this today (see CHAR). Basically reverts 7928c3e6fbdf47ff81184966cee937e6aa694b94. * src/scan-gram.l (%nterm): Dedeprecate, but issue a Wyacc warning. * tests/input.at: Adjust expectations. (Yacc warnings on symbols): New. * src/symtab.c (symbol_class_set): Fix error introduced in 20b07467938cf880a1d30eb30d6e191843a21fec.
* diagnostics: complain about Bison directives when -WyaccAkim Demaille2018-11-291-29/+33
| | | | | | * src/complain.h, src/complain.c (bison_directive): New. * src/scan-gram.l (BISON_DIRECTIVE): New. Use it for Bison extensions.
* style: formatting changesAkim Demaille2018-11-131-1/+1
| | | | * src/scan-gram.l: here.
* parser: deprecate %error-verboseAkim Demaille2018-11-121-1/+4
| | | | | | | | | | It is unfortunate that %error_verbose was properly diagnosed as obsoleted by "%define parse.error verbose", but %error-verbose was not. * src/parse-gram.y (%error-verbose): Remove support. * src/scan-gram.l: Do it here instead, with a warning. * tests/input.at (Deprecated directives): Check it.
* parser: deprecate %ntermAkim Demaille2018-11-121-2/+7
| | | | | | | | It has several weaknesses. Reported by Rici Lake. http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00000.html * src/scan-gram.l: here.
* dogfooding: use api.value.type unionAkim Demaille2018-11-101-31/+21
| | | | | | | | * src/parse-gram.y (api.value.type): Set to union. Replace occurrences of %union with explicit %types. * src/scan-gram.l: Adjust yylval's field names. (RETURN_VALUE): No longer needs the Field argument. Use it more.
* scanner: simplify use of gettextAkim Demaille2018-11-101-3/+3
| | | | | * src/scan-gram.l (unexpected_end): Leave the actual call to gettext to the caller.
* style: clean up the scanner and parserAkim Demaille2018-11-101-5/+6
| | | | | | * src/scan-gram.l: Formatting changes. Add "missing" assertion for symmetry. * src/parse-gram.y: Formatting changes.
* spelling: incorrectlyJosh Soref2018-10-051-1/+1
|
* style: src: remove useless reference to 'int' in integral typesAkim Demaille2018-08-141-7/+7
| | | | | | | | * src/AnnotationList.c, src/AnnotationList.h, src/InadequacyList.h, * src/closure.c, src/closure.h, src/gram.c, src/gram.h, src/ielr.c, * src/location.c, src/output.c, src/reader.c, src/relation.c, * src/scan-code.l, src/scan-gram.l, src/tables.c, src/tables.h: Prefer 'unsigned' to 'unsigned int'. Likewise for long and short.
* Update copyright yearsAkim Demaille2018-05-121-1/+1
| | | | Run `make update-copyright`.
* package: bump to 2015Akim Demaille2015-01-041-1/+1
| | | | | | Which also requires: * gnulib: Update.
* flex: don't trust YY_USER_INITAkim Demaille2014-12-311-3/+9
| | | | | | Reported by Bernd Edligner and others. * src/scan-gram.l: here.
* package: bump to 2014Akim Demaille2014-02-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * AUTHORS, ChangeLog-2012, Makefile.am, NEWS, PACKAGING, README, * README-alpha, README-hacking, THANKS, TODO, bootstrap.conf, * build-aux/darwin11.4.0.valgrind, build-aux/local.mk, * build-aux/update-b4-copyright, * build-aux/update-package-copyright-year, cfg.mk, configure.ac, * data/README, data/bison.m4, data/c++-skel.m4, data/c++.m4, * data/c-like.m4, data/c-skel.m4, data/c.m4, data/glr.c, data/glr.cc, * data/java-skel.m4, data/java.m4, data/lalr1.cc, data/lalr1.java, * data/local.mk, data/location.cc, data/stack.hh, data/variant.hh, * data/xslt/bison.xsl, data/xslt/xml2dot.xsl, data/xslt/xml2text.xsl, * data/xslt/xml2xhtml.xsl, data/yacc.c, djgpp/Makefile.maint, * djgpp/README.in, djgpp/config.bat, djgpp/config.sed, * djgpp/config.site, djgpp/config_h.sed, djgpp/djunpack.bat, * djgpp/local.mk, djgpp/subpipe.c, djgpp/subpipe.h, * djgpp/testsuite.sed, doc/bison.texi, doc/local.mk, doc/refcard.tex, * etc/README, etc/bench.pl.in, etc/local.mk, * examples/calc++/calc++.test, examples/calc++/local.mk, * examples/extexi, examples/local.mk, examples/mfcalc/local.mk, * examples/mfcalc/mfcalc.test, examples/rpcalc/local.mk, * examples/rpcalc/rpcalc.test, examples/test, examples/variant.yy, * lib/abitset.c, lib/abitset.h, lib/bbitset.h, lib/bitset.c, * lib/bitset.h, lib/bitset_stats.c, lib/bitset_stats.h, * lib/bitsetv-print.c, lib/bitsetv-print.h, lib/bitsetv.c, * lib/bitsetv.h, lib/ebitset.c, lib/ebitset.h, lib/get-errno.c, * lib/get-errno.h, lib/lbitset.c, lib/lbitset.h, lib/libiberty.h, * lib/local.mk, lib/main.c, lib/timevar.c, lib/timevar.def, * lib/timevar.h, lib/vbitset.c, lib/vbitset.h, lib/yyerror.c, * m4/bison-i18n.m4, m4/c-working.m4, m4/cxx.m4, m4/flex.m4, * m4/timevar.m4, src/AnnotationList.c, src/AnnotationList.h, * src/InadequacyList.c, src/InadequacyList.h, src/LR0.c, src/LR0.h, * src/Sbitset.c, src/Sbitset.h, src/assoc.c, src/assoc.h, * src/closure.c, src/closure.h, src/complain.c, src/complain.h, * src/conflicts.c, src/conflicts.h, src/derives.c, src/derives.h, * src/files.c, src/files.h, src/flex-scanner.h, src/getargs.c, * src/getargs.h, src/gram.c, src/gram.h, src/graphviz.c, * src/graphviz.h, src/ielr.c, src/ielr.h, src/lalr.c, src/lalr.h, * src/local.mk, src/location.c, src/location.h, src/main.c, * src/muscle-tab.c, src/muscle-tab.h, src/named-ref.c, * src/named-ref.h, src/nullable.c, src/nullable.h, src/output.c, * src/output.h, src/parse-gram.c, src/parse-gram.y, src/print-xml.c, * src/print-xml.h, src/print.c, src/print.h, src/print_graph.c, * src/print_graph.h, src/reader.c, src/reader.h, src/reduce.c, * src/reduce.h, src/relation.c, src/relation.h, src/scan-code.h, * src/scan-code.l, src/scan-gram.h, src/scan-gram.l, src/scan-skel.h, * src/scan-skel.l, src/state.c, src/state.h, src/symlist.c, * src/symlist.h, src/symtab.c, src/symtab.h, src/system.h, * src/tables.c, src/tables.h, src/uniqstr.c, src/uniqstr.h, * tests/actions.at, tests/atlocal.in, tests/bison.in, tests/c++.at, * tests/calc.at, tests/conflicts.at, tests/cxx-type.at, * tests/existing.at, tests/glr-regression.at, tests/headers.at, * tests/input.at, tests/java.at, tests/javapush.at, tests/local.at, * tests/local.mk, tests/named-refs.at, tests/output.at, tests/push.at, * tests/reduce.at, tests/regression.at, tests/sets.at, * tests/skeletons.at, tests/synclines.at, tests/testsuite.at, * tests/torture.at, tests/types.at: here.
* glr: allow spaces between "%?" and "{" in predicatesAkim Demaille2013-10-161-1/+1
| | | | | | | | | | Reported by Rici Lake. http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00004.html http://stackoverflow.com/questions/19330171/ * src/scan-gram.l: Do not try to be too smart when diagnosing invalid directives. * tests/glr-regression.at (Predicates): New test.
* parser: no longer use the "braceless" non-terminalAkim Demaille2013-04-181-3/+3
| | | | | | | | | | | | | | | | | | | | The purpose of this symbol was only to factor function calls. As a result the actions were indeed simpler, but the grammar was somewhat uselessly obfuscated. Get rid of this symbol, but introduce functions to simplify dependencies. There is no (intended) changes of behavior here. * src/parse-gram.y (strip_braces, translate_code( (translate_code_braceless): New. (braceless): Remove, use "{...}" instead, and one of the previous functions depending on the context. (STRING, "%{...%}", EPILOGUE): Declare as <code>, instead of <chars>, the difference between both is useless (well, I couldn't make sense of it, even after having read the initial commit that introduced them). (%union): Remove the now useless "chars" type. Adjust the printers. * src/scan-gram.l: Adjust.
* value type: accept "->" in type tagsAkim Demaille2013-04-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide a means to dereference pointers when defining tags. One example could be: %code requires { typedef struct ListElementType { union value { int intVal; float floatVal; char* charptrVal; } value; struct ListElementType* next; } ListElementType; } %union { ListElementType* list; } %token <list->value.charptrVal> STRING %token <list->value.intVal> INTEGER %token <list->value.floatVal> REAL %type <list> ElementList LiteralType * src/scan-code.l, src/scan-gram.l: Accept "->" in tags. * tests/types.at: Add more test cases to cover this case.
* style: simplify the scanning of type tagsAkim Demaille2013-04-091-19/+11
| | | | | | * src/scan-gram.l: Remove the rule for simple tags: the "complex" case subsumes it. It was more efficient, but duplicated the code for a negligible benefit.
* grammar: introduce %emptyAkim Demaille2013-02-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Provide a means to explicitly denote empty right-hand sides of rules: instead of exp: { ... } allow exp: %empty { ... } Make sure that %empty is properly used. With help from Joel E. Denny and Gabriel Rassoul. http://lists.gnu.org/archive/html/bison-patches/2013-01/msg00142.html * src/reader.h, src/reader.c (grammar_current_rule_empty_set): New. * src/parse-gram.y (%empty): New token. Use it. * src/scan-gram.l (%empty): Scan it. * src/reader.c (grammar_rule_check): Check that %empty is properly used. * tests/actions.at (Invalid uses of %empty, Valid uses of %empty): New.
* maint: update copyright yearsAkim Demaille2013-01-121-1/+1
| | | | | Suggested by Stefano Lattarini. Run "make update-copyright".
* scanner: reintroduce unput for missing end tokensTheophile Ranquet2012-12-271-77/+34
| | | | | | | | | | | 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.
* diagnostics: factor the deprecated directive messageAkim Demaille2012-12-231-3/+1
| | | | | * src/complain.h, src/complain.c (deprecated_directive): New. * src/muscle-tab.c: Use it.
* Merge branch 'origin/maint'Akim Demaille2012-12-141-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * origin/maint: maint: credit Wojciech Polak maint: post-release administrivia version 2.7 yacc.c: scope reduction tests: C90 compliance fix C90 compliance glr.c: scope reduction gnulib: update Conflicts: NEWS gnulib src/scan-gram.l src/system.h
| * fix C90 complianceAkim Demaille2012-12-121-1/+1
| | | | | | | | | | | | | | | | * data/glr.c, src/graphviz.h, src/ielr.c, src/scan-gram.l, * src/system.h, tests/actions.at, tests/glr-regression.at: Do not use // comments. Do not introduce variables after statements. Provide "main" with a return value.
* | Merge remote-tracking branch 'origin/maint'Akim Demaille2012-12-031-9/+13
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * origin/maint: parser: accept #line NUM m4: use a safer pattern to enable/disable output tests: beware of gnulib's need for config.h gnulib: update yacc.c, glr.c: check and fix the display of locations formatting changes glr.c: remove stray macro Conflicts: data/c.m4 data/glr.cc data/lalr1.cc data/lalr1.java data/location.cc data/stack.hh data/yacc.c src/scan-gram.l
| * parser: accept #line NUMAkim Demaille2012-12-031-9/+13
| | | | | | | | | | * src/scan-gram.l (scanner): Accept '#line NUM'. (handle_syncline): Adjust to the possible missing file name.
* | Merge remote-tracking branch 'origin/maint'Akim Demaille2012-11-261-8/+13
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | * origin/maint: yacc.c: always initialize yylloc scanner: issue a single error for groups of invalid characters tests: formatting changes doc: one of the fixes for an ambiguous grammar was ambiguous too doc: fix the dangling else with precedence directives doc: prefer "token" to TOKEN doc: formatting changes scanner: use explicit "ignore" statements Conflicts: src/scan-gram.l